[Home] [Help]
PACKAGE BODY: APPS.IGI_IAC_ADJ_AMORT_PKG
Source
1 PACKAGE BODY IGI_IAC_ADJ_AMORT_PKG AS
2 -- $Header: igiiadab.pls 120.17.12000000.2 2007/10/16 14:15:46 sharoy noship $
3
4 -- ===================================================================
5 -- Global Variables
6 -- ===================================================================
7
8 l_calling_function varchar2(255);
9
10 l_rowid ROWID;
11 g_calling_fn VARCHAR2(200);
12 g_asset_num fa_additions.asset_number%TYPE;
13
14 -- ===================================================================
15 -- Local functions and procedures
16 -- ===================================================================
17
18 --===========================FND_LOG.START=====================================
19
20 g_state_level NUMBER;
21 g_proc_level NUMBER;
22 g_event_level NUMBER;
23 g_excep_level NUMBER;
24 g_error_level NUMBER;
25 g_unexp_level NUMBER;
26 g_path VARCHAR2(100);
27
28 --===========================FND_LOG.END=====================================
29
30 -- -------------------------------------------------------------------
31 -- PROCEDURE Debug_Adj_Asset : Procedure that will print the historic
32 -- asset information
33 -- -------------------------------------------------------------------
34
35 PROCEDURE debug_adj_asset(p_asset igi_iac_types.iac_adj_hist_asset_info) IS
36 l_path_name VARCHAR2(150);
37 BEGIN
38 l_path_name := g_path||'debug_adj_asset';
39 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
40 p_full_path => l_path_name,
41 p_string => 'asset_id...............'|| p_asset.asset_id);
42 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
43 p_full_path => l_path_name,
44 p_string => 'book_type_code.........'|| p_asset.book_type_code);
45 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
46 p_full_path => l_path_name,
47 p_string => 'cost...................'|| p_asset.cost );
48 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
49 p_full_path => l_path_name,
50 p_string => 'original_Expensed..........'|| p_asset.original_cost);
51 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
52 p_full_path => l_path_name,
53 p_string => 'adjusted_Expensed..........'|| p_asset.adjusted_cost );
54 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
55 p_full_path => l_path_name,
56 p_string => 'salvage_value..........'|| p_asset.salvage_value );
57 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
58 p_full_path => l_path_name,
59 p_string => 'life_in_months.........'|| p_asset.life_in_months);
60 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
61 p_full_path => l_path_name,
62 p_string => 'rate_adjustment_factor..'||p_asset.rate_adjustment_factor);
63 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
64 p_full_path => l_path_name,
65 p_string => 'period_counter_fully_reserved '|| p_asset.period_counter_fully_reserved);
66 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
67 p_full_path => l_path_name,
68 p_string => 'recoverable_Expensed.......'|| p_asset.recoverable_cost);
69 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
70 p_full_path => l_path_name,
71 p_string => 'date_placed_in_service..'||p_asset.date_placed_in_service);
72 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
73 p_full_path => l_path_name,
74 p_string => 'deprn_start_date........'||p_asset.deprn_start_date);
75 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
76 p_full_path => l_path_name,
77 p_string => 'deprn_periods_elapsed...'||p_asset.deprn_periods_elapsed);
78 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
79 p_full_path => l_path_name,
80 p_string => 'deprn_periods_current_year..'||p_asset.deprn_periods_current_year);
81 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
82 p_full_path => l_path_name,
83 p_string => 'prior year periods..'|| p_asset.deprn_periods_prior_year);
84 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
85 p_full_path => l_path_name,
86 p_string => 'last_period_counter.........'|| p_asset.last_period_counter);
87 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
88 p_full_path => l_path_name,
89 p_string => 'ytd_deprn...................'|| p_asset.ytd_deprn);
90 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
91 p_full_path => l_path_name,
92 p_string => 'deprn_reserve................'|| p_asset.deprn_reserve);
93 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
94 p_full_path => l_path_name,
95 p_string => 'pys_deprn_reserve............'|| p_asset.pys_deprn_reserve);
96 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
97 p_full_path => l_path_name,
98 p_string => 'deprn_amount................'|| p_asset.deprn_amount);
99 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
100 p_full_path => l_path_name,
101 p_string => 'depreciate_flag................'|| p_asset.depreciate_flag);
102 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
103 p_full_path => l_path_name,
104 p_string => 'deprn_adjustment_amount................'|| p_asset.deprn_adjustment_amount);
105
106 END debug_adj_asset;
107
108 -- ===================================================================
109 -- Main public functions and procedures
110 -- ===================================================================
111
112 -- -------------------------------------------------------------------
113 -- PROCEDURE Do_Amort_Deprn_Reval: This is the main function that will
114 -- do the Amortization Depreciation revaluation for the asset
115 -- -------------------------------------------------------------------
116 FUNCTION Do_Amort_Deprn_Reval(p_asset_iac_adj_info igi_iac_types.iac_adj_hist_asset_info,
117 p_asset_iac_dist_info igi_iac_types.iac_adj_dist_info_tab,
118 p_adj_hist igi_iac_adjustments_history%ROWTYPE,
119 p_event_id number) --R12 uptake
120 RETURN BOOLEAN
121 IS
122 -- cursors
123 /*-- cursor to check if asset is non depreciating
124 CURSOR c_asset_non_depr(cp_asset_id fa_books.asset_id%TYPE,
125 cp_book_type_code fa_books.book_type_code%TYPE)
126 IS
127 SELECT depreciate_flag
128 FROM fa_books
129 WHERE book_type_code = cp_book_type_code
130 AND asset_id = cp_asset_id
131 AND date_ineffective IS NULL;
132 */
133
134 -- cursor to get iac asset balance information
135 CURSOR c_iac_asset_bal(cp_asset_id igi_iac_asset_balances.asset_id%TYPE,
136 cp_book_type_code igi_iac_asset_balances.book_type_code%TYPE,
137 cp_period_counter igi_iac_asset_balances.period_counter%TYPE)
138 IS
139 SELECT period_counter,
140 net_book_value,
141 adjusted_cost,
142 operating_acct,
143 reval_reserve,
144 deprn_amount,
145 deprn_reserve,
146 backlog_deprn_reserve,
147 general_fund,
148 last_reval_date,
149 current_reval_factor,
150 cumulative_reval_factor
151 FROM igi_iac_asset_balances
152 WHERE asset_id = cp_asset_id
153 AND book_type_code = cp_book_type_code
154 AND period_counter = cp_period_counter;
155
156 -- cursor to get the detail balances for a distribution
157 CURSOR c_det_bal(cp_adjust_id igi_iac_det_balances.adjustment_id%TYPE,
158 cp_asset_id fa_books.asset_id%TYPE,
159 cp_book_type_code fa_books.book_type_code%TYPE,
160 cp_dist_id igi_iac_det_balances.distribution_id%TYPE)
161 IS
162 SELECT iidb.adjustment_id,
163 iidb.distribution_id,
164 iidb.period_counter,
165 iidb.adjustment_cost,
166 iidb.net_book_value,
167 iidb.reval_reserve_cost,
168 iidb.reval_reserve_backlog,
169 iidb.reval_reserve_gen_fund,
170 iidb.reval_reserve_net,
171 iidb.operating_acct_cost,
172 iidb.operating_acct_backlog,
173 iidb.operating_acct_ytd,
174 iidb.operating_acct_net,
175 iidb.deprn_period,
176 iidb.deprn_ytd,
177 iidb.deprn_reserve,
178 iidb.deprn_reserve_backlog,
179 iidb.general_fund_per,
180 iidb.general_fund_acc,
181 iidb.last_reval_date,
182 iidb.current_reval_factor,
183 iidb.cumulative_reval_factor,
184 iidb.active_flag
185 FROM igi_iac_det_balances iidb
186 WHERE iidb.adjustment_id = cp_adjust_id
187 AND iidb.book_type_code = cp_book_type_code
188 AND iidb.asset_id = cp_asset_id
189 AND iidb.distribution_id = cp_dist_id
190 AND iidb.active_flag IS NULL
191 ORDER BY iidb.distribution_id;
192
193 -- cursor to get the latest fa figures from
194 -- igi_iac_fa_deprn
195 CURSOR c_get_fa_iac_deprn(cp_distribution_id igi_iac_fa_deprn.distribution_id%TYPE,
196 cp_adjustment_id igi_iac_fa_deprn.adjustment_id%TYPE)
197 IS
198 SELECT iifd.deprn_ytd,
199 iifd.deprn_period,
200 iifd.deprn_reserve
201 FROM igi_iac_fa_deprn iifd
202 WHERE iifd.adjustment_id = cp_adjustment_id
203 AND iifd.distribution_id = cp_distribution_id
204 AND iifd.active_flag IS NULL;
205
206 -- cursor to get the fa_depreciation adjustment amount
207 CURSOR c_fa_deprn_adjust_amt(cp_asset_id fa_deprn_detail.book_type_code%TYPE,
208 cp_book_type_code fa_deprn_detail.book_type_code%TYPE,
209 cp_period_counter fa_deprn_detail.period_counter%TYPE)
210 IS
211 SELECT SUM(NVL(deprn_amount,0)) deprn_amount,
212 SUM(NVL(deprn_adjustment_amount,0)) deprn_adjustment_amount,
213 SUM(NVL(deprn_reserve,0)) deprn_reserve
214 FROM fa_deprn_detail
215 WHERE book_type_code = cp_book_type_code
216 AND asset_id = cp_asset_id
217 AND period_counter = cp_period_counter;
218
219 CURSOR c_get_period_first_adj(cp_asset_id igi_iac_adjustments_history.asset_id%TYPE,
220 cp_book_type_code igi_iac_adjustments_history.book_type_code%TYPE,
221 cp_period_counter igi_iac_adjustments_history.period_counter%TYPE)
222 IS
223 SELECT ah.pre_adjusted_cost, ah.pre_salvage_value
224 FROM igi_iac_adjustments_history ah
225 WHERE ah.book_type_code = cp_book_type_code
226 AND ah.asset_id = cp_asset_id
227 AND ah.transaction_header_id_in = (SELECT min(iah.transaction_header_id_in)
228 FROM igi_iac_adjustments_history iah
229 WHERE iah.book_type_code = cp_book_type_code
230 AND iah.asset_id = cp_asset_id
231 AND iah.period_counter = cp_period_counter);
232
233
234 -- local variables
235 l_asset_id fa_books.asset_id%TYPE;
236 l_book_type_code fa_books.book_type_code%TYPE;
237 l_last_period_counter igi_iac_transaction_headers.period_counter%TYPE;
238 l_sob_id NUMBER;
239 l_coa_id NUMBER;
240 l_currency VARCHAR2(15);
241 l_precision NUMBER;
242
243 l_latest_trx_type igi_iac_transaction_headers.transaction_type_code%TYPE;
244 l_latest_trx_id igi_iac_transaction_headers.transaction_header_id%TYPE;
245 l_latest_mref_id igi_iac_transaction_headers.mass_reference_id%TYPE;
246 l_latest_adj_id igi_iac_transaction_headers.adjustment_id%TYPE;
247 l_prev_adj_id igi_iac_transaction_headers.adjustment_id%TYPE;
248 l_latest_adj_status igi_iac_transaction_headers.adjustment_status%TYPE;
249 l_adj_id_out igi_iac_transaction_headers.adjustment_id_out%TYPE;
250
251 l_fully_rsvd_pc fa_books.period_counter_fully_reserved%TYPE;
252 -- l_deprn_flag fa_books.depreciate_flag%TYPE;
253
254 l_new_adj_id igi_iac_transaction_headers.adjustment_id%TYPE;
255 l_rsvd_pc igi_iac_transaction_headers.period_counter%TYPE;
256 l_iac_asset_bal c_iac_asset_bal%ROWTYPE;
257
258 l_fa_deprn_adj_amount fa_deprn_detail.deprn_adjustment_amount%TYPE;
259 l_iac_new_deprn_adj_amt igi_iac_asset_balances.deprn_amount%TYPE;
260 l_iac_new_deprn_period igi_iac_asset_balances.deprn_amount%TYPE;
261 l_iac_new_deprn_reserve igi_iac_asset_balances.deprn_reserve%TYPE;
262
263 l_iac_new_nbv igi_iac_asset_balances.net_book_value%TYPE;
264 l_iac_new_rr igi_iac_asset_balances.reval_reserve%TYPE;
265 l_iac_new_gf igi_iac_asset_balances.general_fund%TYPE;
266
267 l_fa_idx NUMBER;
268 l_det_bal c_det_bal%ROWTYPE;
269 l_det_table IGI_IAC_TYPES.dist_amt_tab;
270 l_dist_idx NUMBER;
271 l_dist_id igi_iac_det_balances.distribution_id%TYPE;
272 l_dep_adj_amount igi_iac_det_balances.deprn_period%TYPE;
273 l_units_assigned igi_iac_adjustments.units_assigned%TYPE;
274
275 l_new_dist_dep_prd igi_iac_det_balances.deprn_period%TYPE;
276 l_new_dist_dep_rsv igi_iac_det_balances.deprn_reserve%TYPE;
277 l_new_dist_dep_ytd igi_iac_det_balances.deprn_ytd%TYPE;
278
279 l_new_dist_nbv igi_iac_det_balances.net_book_value%TYPE;
280 l_new_dist_rr_gf igi_iac_det_balances.reval_reserve_gen_fund%TYPE;
281 l_new_dist_rr_net igi_iac_det_balances.reval_reserve_net%TYPE;
282 l_new_dist_gf_per igi_iac_det_balances.general_fund_per%TYPE;
283 l_new_dist_gf_acc igi_iac_det_balances.general_fund_acc%TYPE;
284
285 l_round_diff NUMBER ;
286 l_fa_deprn_period igi_iac_fa_deprn.deprn_period%TYPE;
287 l_fa_deprn_reserve igi_iac_fa_deprn.deprn_reserve%TYPE;
288 l_fa_deprn_ytd igi_iac_fa_deprn.deprn_ytd%TYPE;
289
290 l_ccid igi_iac_adjustments.code_combination_id%TYPE;
291 l_reval_rsv_ccid igi_iac_adjustments.code_combination_id%TYPE;
292 l_exists NUMBER;
293 l_ret BOOLEAN;
294
295 l_deprn_amount fa_deprn_detail.deprn_amount%TYPE;
296 l_deprn_reserve fa_deprn_detail.deprn_reserve%TYPE;
297 l_prev_cost fa_books.cost%TYPE;
298 l_prev_salvage fa_books.salvage_value%TYPE;
299 l_curr_cost fa_books.cost%TYPE;
300 l_curr_Salvage fa_books.salvage_value%TYPE;
301 l_prev_sv_correction NUMBER;
302 l_curr_sv_correction NUMBER;
303 l_diff_sv_correction NUMBER;
304 l_iac_deprn_period_amount NUMBER;
305 l_fa_deprn_period_amount NUMBER;
306
307 -- exceptions
308 e_latest_trx_not_avail EXCEPTION;
309 e_no_period_info_avail EXCEPTION;
310 e_no_ccid_found EXCEPTION;
311 e_no_proration EXCEPTION;
312 e_asset_life_err EXCEPTION;
313 e_no_gl_info EXCEPTION;
314 e_non_dep_asset EXCEPTION;
315 e_curr_period_amort EXCEPTION;
316
317 l_path_name VARCHAR2(150);
318
319 BEGIN -- do amort deprn reval
323 p_full_path => l_path_name,
320 l_path_name := g_path||'do_amort_deprn_reval';
321 l_round_diff := 0;
322 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
324 p_string => 'In Amortized Depreciation Revaluation');
325 debug_adj_asset( p_asset_iac_adj_info);
326
327 -- set local variables
328 l_book_type_code := p_asset_iac_adj_info.book_type_code;
329 l_asset_id := p_asset_iac_adj_info.asset_id;
330 l_last_period_counter := p_asset_iac_adj_info.last_period_counter;
331
332 -- get the asset number for debugging purpose
333 SELECT asset_number
334 INTO g_asset_num
335 FROM fa_additions
336 WHERE asset_id = l_asset_id;
337
338 -- get the GL set of books id
339 IF NOT igi_iac_common_utils.get_book_GL_info(l_book_type_code,
340 l_sob_id,
341 l_coa_id,
342 l_currency,
343 l_precision)
344 THEN
345 RAISE e_no_gl_info;
346 END IF;
347
348 -- Get the latest transaction or adjustment from igi_iac_common_utils.get_latest_transaction
349 -- for the asset and book
350 IF NOT igi_iac_common_utils.get_latest_transaction(l_book_type_code,
351 l_asset_id,
352 l_latest_trx_type,
353 l_latest_trx_id,
354 l_latest_mref_id,
355 l_latest_adj_id,
356 l_prev_adj_id,
357 l_latest_adj_status)
358 THEN
359 RAISE e_latest_trx_not_avail;
360 END IF;
361
362 -- set the adjustment_id_out
363 l_adj_id_out := l_latest_adj_id;
364
365 -- check if latest adjustment is a REVALUATION in PREVIEW status
366 IF (l_latest_trx_type = 'REVALUATION' AND l_latest_adj_status IN ('PREVIEW', 'OBSOLETE')) THEN
367 l_latest_adj_id := l_prev_adj_id;
368 END IF;
369
370 -- check if the asset is fully reserved
371 IF NOT igi_iac_adj_cost_reval_pkg.chk_asset_life(p_book_code => l_book_type_code,
372 p_period_counter => l_last_period_counter,
373 p_asset_id => l_asset_id,
374 l_last_period_counter => l_fully_rsvd_pc)
375 THEN
376 RAISE e_asset_life_err;
377 END IF;
378 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
379 p_full_path => l_path_name,
380 p_string => 'Fully reserved period counter: '||l_fully_rsvd_pc);
381
382 -- check if asset is non depreciating asset
383 /* OPEN c_asset_non_depr(l_asset_id,
384 l_book_type_code);
385 FETCH c_asset_non_depr INTO l_deprn_flag;
386 IF (c_asset_non_depr%NOTFOUND) THEN
387 RAISE NO_DATA_FOUND;
388 END IF;
389 CLOSE c_asset_non_depr;
390
391 Debug('Asset depreciation flag: '||l_deprn_flag);
392 */
393 -- if asset is non depreciating do not process any further
394 IF (p_asset_iac_adj_info.depreciate_flag = 'NO') THEN
395 RAISE e_non_dep_asset;
396 END IF;
397
398 OPEN c_get_period_first_adj(l_asset_id,
399 l_book_type_code,
400 l_last_period_counter);
401 FETCH c_get_period_first_adj INTO l_prev_cost, l_prev_salvage;
402 CLOSE c_get_period_first_adj;
403
404 l_curr_cost := p_adj_hist.adjusted_cost;
405 l_curr_salvage := p_adj_hist.salvage_value;
406
407 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
408 p_full_path => l_path_name,
409 p_string => 'Before adjustment Cost: '||l_prev_cost);
410 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
411 p_full_path => l_path_name,
412 p_string => 'Before adjustment Salvage Value: '||l_prev_salvage);
413 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
414 p_full_path => l_path_name,
415 p_string => 'After adjustment Cost: '||l_curr_cost);
416 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
417 p_full_path => l_path_name,
418 p_string => 'After adjustment Salvage Value: '||l_curr_salvage);
419
420 -- check if asset is amortized in current period, if yes then
421 -- do not process any further
422 IF (p_adj_hist.current_period_amortization = 'Y' AND
423 (l_prev_cost = l_curr_cost OR
424 (l_prev_cost <> l_curr_cost AND l_prev_salvage = 0 AND l_curr_salvage = 0)) AND
425 l_prev_salvage = l_curr_salvage) THEN
426 RAISE e_curr_period_amort;
427 END IF;
428
429 IF (l_last_period_counter >= l_fully_rsvd_pc) THEN
430 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
431 p_full_path => l_path_name,
432 p_string => 'Asset is fully reserved or non depreciable');
436 INTO l_rsvd_pc
433 -- get the period counter associated with the latest adjustment
434 -- for the asset
435 SELECT period_counter
437 FROM igi_iac_transaction_headers
438 WHERE adjustment_id = l_latest_adj_id;
439
440 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
441 p_full_path => l_path_name,
442 p_string => 'Last period counter for fully reserved or non deprn asset: '||l_rsvd_pc);
443 ELSE
444 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
445 p_full_path => l_path_name,
446 p_string => 'asset is depreciable with life');
447 l_rsvd_pc := l_last_period_counter;
448 END IF;
449
450 -- Fetch the latest IGI_IAC_ASSET_BALANCES for the asset regardless of type
451 -- bug 3391000, start 1
452 /* OPEN c_iac_asset_bal(l_asset_id,
453 l_book_type_code,
454 l_rsvd_pc);
455 FETCH c_iac_asset_bal INTO l_iac_asset_bal;
456 IF c_iac_asset_bal%NOTFOUND THEN
457 RAISE NO_DATA_FOUND ;
458 END IF ;
459 CLOSE c_iac_asset_bal; */
460
461 -- Fetch the latest IGI_IAC_ASSET_BALANCES for the asset regardless of type
462 -- if a balance row exists for the latest open period counter then retrieve
463 -- that else, retrieve the last active row
464 OPEN c_iac_asset_bal(l_asset_id,
465 l_book_type_code,
466 l_last_period_counter);
467 FETCH c_iac_asset_bal INTO l_iac_asset_bal;
468 IF c_iac_asset_bal%NOTFOUND THEN
469 CLOSE c_iac_asset_bal;
470 OPEN c_iac_asset_bal(l_asset_id,
471 l_book_type_code,
472 l_rsvd_pc);
473 FETCH c_iac_asset_bal INTO l_iac_asset_bal;
474 IF c_iac_asset_bal%NOTFOUND THEN
475 RAISE NO_DATA_FOUND ;
476 END IF ;
477 END IF;
478 CLOSE c_iac_asset_bal;
479
480 -- bug 3391000, end 1
481
482 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
483 p_full_path => l_path_name,
484 p_string => 'Latest period counter: '||l_last_period_counter);
485
486 -- Calculate the new revalued FA depreciation amount
487 IF (p_asset_iac_adj_info.deprn_adjustment_amount = 0) THEN
488 -- fetch from fa_deprn_detail
489 OPEN c_fa_deprn_adjust_amt(l_asset_id,
490 l_book_type_code,
491 l_last_period_counter);
492 FETCH c_fa_deprn_adjust_amt INTO l_deprn_amount,
493 l_fa_deprn_adj_amount,
494 l_deprn_reserve;
495 IF c_fa_deprn_adjust_amt%NOTFOUND THEN
496 RAISE NO_DATA_FOUND;
497 END IF;
498 CLOSE c_fa_deprn_adjust_amt;
499 ELSE
500 l_deprn_amount := p_asset_iac_adj_info.deprn_amount;
501 l_fa_deprn_adj_amount := p_asset_iac_adj_info.deprn_adjustment_amount;
502 l_deprn_reserve := p_asset_iac_adj_info.deprn_reserve;
503 END IF;
504
505 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
506 p_full_path => l_path_name,
507 p_string => 'FA depreciation adjustment amount: '||l_fa_deprn_adj_amount);
508
509 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
510 p_full_path => l_path_name,
511 p_string => 'FA depreciation amount: '||l_deprn_amount);
512 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
513 p_full_path => l_path_name,
514 p_string => 'FA depreciation reserve: '||l_deprn_reserve);
515
516 IF ((l_prev_cost <> l_curr_cost OR l_prev_salvage <> l_curr_salvage) AND
517 (l_prev_salvage <> 0 OR l_curr_salvage <> 0)) THEN
518 l_prev_sv_correction := (l_deprn_reserve - l_deprn_amount) * (l_prev_salvage/(l_prev_cost-l_prev_salvage));
519 l_curr_sv_correction := (l_deprn_reserve - l_deprn_amount) * (l_curr_salvage/(l_curr_cost-l_curr_salvage));
520 l_diff_sv_correction := l_curr_sv_correction - l_prev_sv_correction;
521 ELSE
522 l_diff_sv_correction := 0;
523 END IF;
524 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
525 p_full_path => l_path_name,
526 p_string => 'Prev Salvage Value Correction: '||l_prev_sv_correction);
527 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
528 p_full_path => l_path_name,
529 p_string => 'Curr Salvage Value Correction: '||l_curr_sv_correction);
530
531 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
532 p_full_path => l_path_name,
533 p_string => 'Salvage Value Correction: '||l_diff_sv_correction);
534
535 l_fa_deprn_adj_amount := l_fa_deprn_adj_amount + l_diff_sv_correction;
536
537 IF (l_fa_deprn_adj_amount = 0) THEN
538 RAISE e_curr_period_amort;
539 END IF;
540
541 -- create a new row in igi_iac_transaction_headers with transaction type code
542 -- ADJUSTMENT and transaction sub type as COST
543 l_new_adj_id := null;
544
548 x_transaction_header_id => p_adj_hist.transaction_header_id_in, -- bug 3391000 null,
545 IGI_IAC_TRANS_HEADERS_PKG.Insert_Row(
546 x_rowid => l_rowid,
547 x_adjustment_id => l_new_adj_id, -- out NOCOPY parameter
549 x_adjustment_id_out => null,
550 x_transaction_type_code => 'DEPRECIATION',
551 x_transaction_date_entered => sysdate,
552 x_mass_refrence_id => null,
553 x_transaction_sub_type => 'ADJUSTMENT',
554 x_book_type_code => l_book_type_code,
555 x_asset_id => l_asset_id,
556 x_category_id => p_adj_hist.category_id,
557 x_adj_deprn_start_date => null,
558 x_revaluation_type_flag => null,
559 x_adjustment_status => 'COMPLETE',
560 x_period_counter => l_last_period_counter,
561 x_event_id => p_event_id
562 );
563
564 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
565 p_full_path => l_path_name,
566 p_string => 'New adjustment id: '||l_new_adj_id);
567
568 -- update the previous active row for the asset in igi_iac_transaction_headers
569 -- in order to make it inactive by setting adjustment_id_out= adjustment_id of
570 -- the active row in igi_iac_transaction_headers
571 IGI_IAC_TRANS_HEADERS_PKG.Update_Row(
572 x_prev_adjustment_id => l_adj_id_out,
573 x_adjustment_id => l_new_adj_id
574 );
575
576 -- calculate the new revlaued deprn adjustment amount
577 l_iac_new_deprn_adj_amt := l_fa_deprn_adj_amount*(l_iac_asset_bal.cumulative_reval_factor - 1);
578
579 -- round the depreciation adjustment amount
580 l_ret := igi_iac_common_utils.iac_round(l_iac_new_deprn_adj_amt,
581 l_book_type_code) ;
582
583 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
584 p_full_path => l_path_name,
585 p_string => 'New IAC revalued depreciation adjustment amount: '||l_iac_new_deprn_adj_amt);
586
587 -- calculate the new deprn_amount, deprn_ytd and deprn_reserve
588 l_iac_new_deprn_period := l_iac_new_deprn_adj_amt;
589 l_iac_new_deprn_reserve:= l_iac_asset_bal.deprn_reserve + l_iac_new_deprn_adj_amt;
590
591 -- calculate net book value
592 -- l_iac_new_nbv := l_iac_asset_bal.net_book_value - l_iac_new_deprn_adj_amt;
593 l_iac_new_nbv := l_iac_asset_bal.adjusted_cost -
594 (l_iac_new_deprn_reserve + l_iac_asset_bal.backlog_deprn_reserve);
595 -- added 2: 16/12/2003
596 -- add gen fun and change IF condition
597 -- IF (l_iac_asset_bal.adjusted_cost > 0) THEN
598 IF (l_iac_asset_bal.cumulative_reval_factor >= 1) THEN
599 l_iac_new_gf := l_iac_asset_bal.general_fund + l_iac_new_deprn_adj_amt;
600 l_iac_new_rr := l_iac_asset_bal.reval_reserve -l_iac_new_deprn_adj_amt;
601 ELSE
602 l_iac_new_gf := l_iac_asset_bal.general_fund;
603 l_iac_new_rr := l_iac_asset_bal.reval_reserve;
604 END IF;
605 -- end 1: 12/12/2003
606
607 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
608 p_full_path => l_path_name,
609 p_string => 'new deprn period: '||l_iac_new_deprn_period);
610 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
611 p_full_path => l_path_name,
612 p_string => 'new deprn reserve: '||l_iac_new_deprn_reserve);
613
614 -- Prorate th depreciation ajustment amount for the active distributions in the
615 -- ratio of the units assigned to them
616 IF NOT igi_iac_common_utils.prorate_amt_to_active_dists(l_book_type_code,
617 l_asset_id,
618 l_iac_new_deprn_adj_amt,
619 l_det_table)
620 THEN
621 RAISE e_no_proration;
622 END IF;
623
624 l_round_diff := 0;
625
626 -- create a new row in igi_iac_det_balances for each active distribution
627 FOR l_dist_idx IN l_det_table.FIRST..l_det_table.LAST LOOP
628 l_dist_id := l_det_table(l_dist_idx).distribution_id;
629 l_dep_adj_amount := l_det_table(l_dist_idx).amount;
630 l_units_assigned := l_det_table(l_dist_idx).units;
631
632 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
633 p_full_path => l_path_name,
634 p_string => ' Dist ID: '||l_dist_id||' Units: '||l_units_assigned
635 ||' adjusted amount: '||l_dep_adj_amount);
636
637 -- get the detail balances for the distribution for l_latest_adj_id
638 OPEN c_det_bal(l_latest_adj_id,
639 l_asset_id,
640 l_book_type_code,
641 l_dist_id);
642 FETCH c_det_bal INTO l_det_bal;
643 IF c_det_bal%NOTFOUND THEN
644 RAISE NO_DATA_FOUND ;
645 END IF ;
646 CLOSE c_det_bal;
647 -- round dep_adj_amount
651 l_round_diff := l_round_diff + l_dep_adj_amount;
648 l_ret := igi_iac_common_utils.iac_round(l_dep_adj_amount,
649 l_book_type_code);
650 -- maintain the diff due to rounding
652
653 IF (l_dist_idx = l_det_table.LAST) THEN
654 -- add rounding diff to the last distribution
655 l_dep_adj_amount := l_dep_adj_amount + (l_iac_new_deprn_adj_amt - l_round_diff);
656 END IF;
657
658 -- calcluate the new depreciation figures
659 l_new_dist_dep_prd := l_dep_adj_amount;
660 l_new_dist_dep_rsv := l_det_bal.deprn_reserve + l_dep_adj_amount;
661 l_new_dist_dep_ytd := l_det_bal.deprn_ytd + l_dep_adj_amount;
662
663 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
664 p_full_path => l_path_name,
665 p_string => 'new dist deprn period: '||l_new_dist_dep_prd);
666 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
667 p_full_path => l_path_name,
668 p_string => 'new dist deprn reserve: '||l_new_dist_dep_rsv);
669 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
670 p_full_path => l_path_name,
671 p_string => 'new dist deprn ytd: '||l_new_dist_dep_ytd);
672
673 -- added 2, 16/12/2003
674 -- added gen fund, and change IF condition
675 -- IF (l_det_bal.adjustment_cost > 0) THEN
676 IF (l_iac_asset_bal.cumulative_reval_factor >= 1) THEN
677 l_new_dist_rr_gf := l_det_bal.reval_reserve_gen_fund + l_dep_adj_amount;
678 -- l_new_dist_rr_net := l_det_bal.reval_reserve_net + l_dep_adj_amount;
679 l_new_dist_rr_net := l_det_bal.reval_reserve_cost -
680 ( l_det_bal.reval_reserve_backlog + l_new_dist_rr_gf);
681
682 l_new_dist_gf_per := l_new_dist_dep_prd;
683 l_new_dist_gf_acc := l_det_bal.general_fund_acc + l_dep_adj_amount;
684 ELSE
685 l_new_dist_rr_gf := l_det_bal.reval_reserve_gen_fund;
686 l_new_dist_rr_net := l_det_bal.reval_reserve_net;
687 l_new_dist_gf_per := l_det_bal.general_fund_per;
688 l_new_dist_gf_acc := l_det_bal.general_fund_acc;
689 END IF;
690 -- calculate the nbv
691 -- l_new_dist_nbv := l_det_bal.net_book_value - l_dep_adj_amount;
692 l_new_dist_nbv := l_det_bal.adjustment_cost -
693 (l_new_dist_dep_rsv + l_det_bal.deprn_reserve_backlog);
694 -- insert the row into igi_iac_det_balances
695 IF p_asset_iac_adj_info.period_counter_fully_reserved IS NOT NULL THEN
696 l_iac_deprn_period_amount := 0;
697 ELSE
698 l_iac_deprn_period_amount := l_new_dist_dep_prd;
699 END IF;
700
701 IGI_IAC_DET_BALANCES_PKG.Insert_Row(
702 x_rowid => l_rowid,
703 x_adjustment_id => l_new_adj_id,
704 x_asset_id => l_asset_id,
705 x_book_type_code => l_book_type_code,
706 x_distribution_id => l_dist_id,
707 x_period_counter => l_last_period_counter,
708 x_adjustment_cost => l_det_bal.adjustment_cost,
709 x_net_book_value => l_new_dist_nbv, -- l_det_bal.net_book_value,
710 x_reval_reserve_cost => l_det_bal.reval_reserve_cost,
711 x_reval_reserve_backlog => l_det_bal.reval_reserve_backlog,
712 x_reval_reserve_gen_fund => l_new_dist_rr_gf, -- l_det_bal.reval_reserve_gen_fund,
713 x_reval_reserve_net => l_new_dist_rr_net, -- l_det_bal.reval_reserve_net,
714 x_operating_acct_cost => l_det_bal.operating_acct_cost,
715 x_operating_acct_backlog => l_det_bal.operating_acct_backlog,
716 x_operating_acct_net => l_det_bal.operating_acct_net,
717 x_operating_acct_ytd => l_det_bal.operating_acct_ytd,
718 x_deprn_period => l_iac_deprn_period_amount,
719 x_deprn_ytd => l_new_dist_dep_ytd,
720 x_deprn_reserve => l_new_dist_dep_rsv,
721 x_deprn_reserve_backlog => l_det_bal.deprn_reserve_backlog,
722 x_general_fund_per => l_new_dist_gf_per, -- l_det_bal.general_fund_per,
723 x_general_fund_acc => l_new_dist_gf_acc, -- l_det_bal.general_fund_acc,
724 x_last_reval_date => l_det_bal.last_reval_date,
725 x_current_reval_factor => l_det_bal.current_reval_factor,
726 x_cumulative_reval_factor => l_det_bal.cumulative_reval_factor,
727 x_active_flag => null,
728 x_mode => 'R'
729 );
730
731 -- create accounting entries only if iac adjustment is not equal to zero
732 IF (l_dep_adj_amount <> 0) THEN
733 -- find the ccid for EXPENSE
734 IF NOT igi_iac_common_utils.get_account_ccid(l_book_type_code,
735 l_asset_id,
739 THEN
736 l_det_bal.distribution_id,
737 'DEPRN_EXPENSE_ACCT',
738 l_ccid)
740 RAISE e_no_ccid_found;
741 END IF;
742
743 -- insert into igi_iac_adjustments for EXPENSE
744 IGI_IAC_ADJUSTMENTS_PKG.Insert_Row(
745 x_rowid => l_rowid,
746 x_adjustment_id => l_new_adj_id,
747 x_book_type_code => l_book_type_code,
748 x_code_combination_id => l_ccid,
749 x_set_of_books_id => l_sob_id,
750 x_dr_cr_flag => 'DR',
751 x_amount => l_new_dist_dep_prd,
752 x_adjustment_type => 'EXPENSE',
753 x_transfer_to_gl_flag => 'Y',
754 x_units_assigned => l_units_assigned,
755 x_asset_id => l_asset_id,
756 x_distribution_id => l_det_bal.distribution_id,
757 x_period_counter => l_last_period_counter,
758 x_adjustment_offset_type => 'RESERVE',
759 x_report_ccid => Null,
760 x_mode => 'R',
761 x_event_id => p_event_id
762 );
763
764 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
765 p_full_path => l_path_name,
766 p_string => 'EXPENSE ccid: '||l_ccid);
767
768 -- find the ccid for RESERVE
769 IF NOT igi_iac_common_utils.get_account_ccid(l_book_type_code,
770 l_asset_id,
771 l_det_bal.distribution_id,
772 'DEPRN_RESERVE_ACCT',
773 l_ccid)
774 THEN
775 RAISE e_no_ccid_found;
776 END IF;
777
778 -- insert into igi_iac_adjustments for RESERVE
779 IGI_IAC_ADJUSTMENTS_PKG.Insert_Row(
780 x_rowid => l_rowid,
781 x_adjustment_id => l_new_adj_id,
782 x_book_type_code => l_book_type_code,
783 x_code_combination_id => l_ccid,
784 x_set_of_books_id => l_sob_id,
785 x_dr_cr_flag => 'CR',
786 x_amount => l_new_dist_dep_prd,
787 x_adjustment_type => 'RESERVE',
788 x_transfer_to_gl_flag => 'Y',
789 x_units_assigned => l_units_assigned,
790 x_asset_id => l_asset_id,
791 x_distribution_id => l_det_bal.distribution_id,
792 x_period_counter => l_last_period_counter,
793 x_adjustment_offset_type => 'EXPENSE',
794 x_report_ccid => Null,
795 x_mode => 'R',
796 x_event_id => p_event_id
797 );
798
799 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
800 p_full_path => l_path_name,
801 p_string => 'RESERVE ccid: '||l_ccid);
802
803 IF (l_iac_asset_bal.cumulative_reval_factor >= 1) THEN
804 -- find the ccid for REVAL RESERVE
805 IF NOT igi_iac_common_utils.get_account_ccid(l_book_type_code,
806 l_asset_id,
807 l_det_bal.distribution_id,
808 'REVAL_RESERVE_ACCT',
809 l_reval_rsv_ccid)
810 THEN
811 RAISE e_no_ccid_found;
812 END IF;
813
814 -- insert into igi_iac_adjustments for EXPENSE
815 IGI_IAC_ADJUSTMENTS_PKG.Insert_Row(
816 x_rowid => l_rowid,
817 x_adjustment_id => l_new_adj_id,
818 x_book_type_code => l_book_type_code,
819 x_code_combination_id => l_reval_rsv_ccid,
820 x_set_of_books_id => l_sob_id,
821 x_dr_cr_flag => 'DR',
822 x_amount => l_new_dist_dep_prd,
823 x_adjustment_type => 'REVAL RESERVE',
824 x_transfer_to_gl_flag => 'Y',
825 x_units_assigned => l_units_assigned,
826 x_asset_id => l_asset_id,
827 x_distribution_id => l_det_bal.distribution_id,
828 x_period_counter => l_last_period_counter,
829 x_adjustment_offset_type => 'GENERAL FUND',
830 x_report_ccid => Null ,
831 x_mode => 'R',
835 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
832 x_event_id => p_event_id
833 );
834
836 p_full_path => l_path_name,
837 p_string => 'EXPENSE ccid: '||l_ccid);
838
839 -- find the ccid for GENERAL FUND
840 IF NOT igi_iac_common_utils.get_account_ccid(l_book_type_code,
841 l_asset_id,
842 l_det_bal.distribution_id,
843 'GENERAL_FUND_ACCT',
844 l_ccid)
845 THEN
846 RAISE e_no_ccid_found;
847 END IF;
848
849 -- insert into igi_iac_adjustments for EXPENSE
850 IGI_IAC_ADJUSTMENTS_PKG.Insert_Row(
851 x_rowid => l_rowid,
852 x_adjustment_id => l_new_adj_id,
853 x_book_type_code => l_book_type_code,
854 x_code_combination_id => l_ccid,
855 x_set_of_books_id => l_sob_id,
856 x_dr_cr_flag => 'CR',
857 x_amount => l_new_dist_dep_prd,
858 x_adjustment_type => 'GENERAL FUND',
859 x_transfer_to_gl_flag => 'Y',
860 x_units_assigned => l_units_assigned,
861 x_asset_id => l_asset_id,
862 x_distribution_id => l_det_bal.distribution_id,
863 x_period_counter => l_last_period_counter,
864 x_adjustment_offset_type => 'REVAL RESERVE',
865 x_report_ccid => l_reval_rsv_ccid ,
866 x_mode => 'R',
867 x_event_id => p_event_id
868 );
869
870 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
871 p_full_path => l_path_name,
872 p_string => 'RESERVE ccid: '||l_ccid);
873
874 END IF; -- reval factor >= 1
875 END IF; -- if iac deprn adjustment amount <> 0
876 END LOOP;
877
878 -- do the igi_iac_fa_deprn active distributions
879 FOR l_fa_idx IN p_asset_iac_dist_info.FIRST.. p_asset_iac_dist_info.LAST LOOP
880 l_fa_deprn_adj_amount := p_asset_iac_dist_info(l_fa_idx).deprn_adjustment_amount;
881
882 -- calculate the IAC maintained YTD figures
883 OPEN c_get_fa_iac_deprn(p_asset_iac_dist_info(l_fa_idx).distribution_id,
884 l_latest_adj_id);
885
886 FETCH c_get_fa_iac_deprn INTO l_fa_deprn_ytd, l_fa_deprn_period, l_fa_deprn_reserve;
887 IF c_get_fa_iac_deprn%NOTFOUND THEN
888 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
889 p_full_path => l_path_name,
890 p_string => 'Fetching FA deprn detail values for IGI_IAC_FA_DEPRN');
891 l_fa_deprn_period := p_asset_iac_dist_info(l_fa_idx).deprn_adjustment_amount;
892 l_fa_deprn_ytd := p_asset_iac_dist_info(l_fa_idx).ytd_deprn;
893 l_fa_deprn_reserve := p_asset_iac_dist_info(l_fa_idx).deprn_reserve;
894 ELSE
895 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
896 p_full_path => l_path_name,
897 p_string => 'Fetching IAC FA deprn detail values for IGI_IAC_FA_DEPRN');
898 l_fa_deprn_period := l_fa_deprn_adj_amount;
899 l_fa_deprn_ytd := l_fa_deprn_ytd + l_fa_deprn_adj_amount;
900 l_fa_deprn_reserve := l_fa_deprn_reserve + l_fa_deprn_adj_amount;
901 END IF;
902 CLOSE c_get_fa_iac_deprn;
903
904 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
905 p_full_path => l_path_name,
906 p_string => 'new FA dist deprn period: '||l_fa_deprn_period);
907 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
908 p_full_path => l_path_name,
909 p_string => 'new FA dist deprn reserve: '||l_fa_deprn_reserve);
910 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
911 p_full_path => l_path_name,
912 p_string => 'new FA dist deprn ytd: '||l_fa_deprn_ytd);
913
914 IF p_asset_iac_adj_info.period_counter_fully_reserved IS NOT NULL THEN
915 l_fa_deprn_period_amount := 0;
916 ELSE
917 l_fa_deprn_period_amount := l_fa_deprn_period;
918 END IF;
919 -- insert into igi_iac_fa_deprn
920 IGI_IAC_FA_DEPRN_PKG.Insert_Row(
921 x_rowid => l_rowid,
922 x_book_type_code => l_book_type_code,
923 x_asset_id => l_asset_id,
924 x_period_counter => l_last_period_counter,
925 x_adjustment_id => l_new_adj_id,
926 x_distribution_id => p_asset_iac_dist_info(l_fa_idx).distribution_id,
927 x_deprn_period => l_fa_deprn_period_amount,
928 x_deprn_ytd => l_fa_deprn_ytd,
932 );
929 x_deprn_reserve => l_fa_deprn_reserve,
930 x_active_flag => null,
931 x_mode => 'R'
933
934 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
935 p_full_path => l_path_name,
936 p_string => 'IAC FA Deprn row inserted: '||l_new_adj_id);
937
938 END LOOP;
939
940 -- Roll YTD rows forward
941 -- Carry forward any inactive distributions from the previous adjustment to the new adjustment
942 igi_iac_adj_cost_reval_pkg.Roll_YTD_Forward(l_asset_id,
943 l_book_type_code,
944 l_latest_adj_id,
945 l_new_adj_id,
946 l_last_period_counter);
947
948 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
949 p_full_path => l_path_name,
950 p_string => 'YTD rows rolled forward');
951
952 -- check if a row exists in igi_iac_asset_balances for l_last_period_counter
953 -- if it does then update it else insert a new row
954 SELECT count(*)
955 INTO l_exists
956 FROM igi_iac_asset_balances
957 WHERE asset_id = l_asset_id
958 AND book_type_code = l_book_type_code
959 AND period_counter = l_last_period_counter;
960
961 -- Update row in IGI_IAC_ASSET_BALANCES for the asset for the new revalued iac cost using
962 -- IGI_IAC_ASSET_BALANCES.Update_Row
963
964 IF p_asset_iac_adj_info.period_counter_fully_reserved IS NOT NULL THEN
965 l_iac_deprn_period_amount := 0;
966 ELSE
967 l_iac_deprn_period_amount := l_iac_new_deprn_period;
968 END IF;
969
970 IF (l_exists > 0) THEN
971 IGI_IAC_ASSET_BALANCES_PKG.Update_Row(
972 X_asset_id => l_asset_id,
973 X_book_type_code => l_book_type_code,
974 X_period_counter => l_iac_asset_bal.period_counter,
975 X_net_book_value => l_iac_new_nbv, -- l_iac_asset_bal.net_book_value,
976 X_adjusted_cost => l_iac_asset_bal.adjusted_cost,
977 X_operating_acct => l_iac_asset_bal.operating_acct,
978 X_reval_reserve => l_iac_new_rr, -- l_iac_asset_bal.reval_reserve,
979 X_deprn_amount => l_iac_deprn_period_amount,
980 X_deprn_reserve => l_iac_new_deprn_reserve,
981 X_backlog_deprn_reserve => l_iac_asset_bal.backlog_deprn_reserve,
982 X_general_fund => l_iac_new_gf, -- l_iac_asset_bal.general_fund,
983 X_last_reval_date => l_iac_asset_bal.last_reval_date,
984 X_current_reval_factor => l_iac_asset_bal.current_reval_factor,
985 X_cumulative_reval_factor => l_iac_asset_bal.cumulative_reval_factor
986 ) ;
987 ELSE
988 -- insert a row for the last period counter
989 IGI_IAC_ASSET_BALANCES_PKG.Insert_Row(
990 X_rowid => l_rowid,
991 X_asset_id => l_asset_id,
992 X_book_type_code => l_book_type_code,
993 X_period_counter => l_last_period_counter,
994 X_net_book_value => l_iac_new_nbv, -- l_iac_asset_bal.net_book_value,
995 X_adjusted_cost => l_iac_asset_bal.adjusted_cost,
996 X_operating_acct => l_iac_asset_bal.operating_acct,
997 X_reval_reserve => l_iac_new_rr, -- l_iac_asset_bal.reval_reserve,
998 X_deprn_amount => l_iac_deprn_period_amount,
999 X_deprn_reserve => l_iac_new_deprn_reserve,
1000 X_backlog_deprn_reserve => l_iac_asset_bal.backlog_deprn_reserve,
1001 X_general_fund => l_iac_new_gf, -- l_iac_asset_bal.general_fund,
1002 X_last_reval_date => l_iac_asset_bal.last_reval_date,
1003 X_current_reval_factor => l_iac_asset_bal.current_reval_factor,
1004 X_cumulative_reval_factor => l_iac_asset_bal.cumulative_reval_factor
1005 ) ;
1006 END IF;
1007
1008 -- successful completion
1009 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1010 p_full_path => l_path_name,
1011 p_string => 'Adjustment Amortized Depreciation Reval completed successfully!!!');
1012 -- rollback;
1013 RETURN TRUE;
1014
1015 EXCEPTION
1016 WHEN e_latest_trx_not_avail THEN
1017 igi_iac_debug_pkg.debug_other_string(p_level => g_excep_level,
1018 p_full_path => l_path_name,
1019 p_string => 'Latest transaction for the asset could not be retrieved');
1020 FA_SRVR_MSG.add_message(
1021 Calling_Fn => g_calling_fn,
1022 Name => 'IGI_IAC_NO_LATEST_TRX');
1023 RETURN FALSE;
1024
1025 WHEN e_no_period_info_avail THEN
1026 igi_iac_debug_pkg.debug_other_string(p_level => g_excep_level,
1027 p_full_path => l_path_name,
1028 p_string => 'No open period information available for the book');
1029 FA_SRVR_MSG.add_message(
1030 Calling_Fn => g_calling_fn,
1031 Name => 'IGI_IAC_NO_PERIOD_INFO');
1032 RETURN FALSE;
1033
1034 WHEN e_no_gl_info THEN
1035 igi_iac_debug_pkg.debug_other_string(p_level => g_excep_level,
1036 p_full_path => l_path_name,
1037 p_string => 'Could not retrive GL information for Book');
1038 FA_SRVR_MSG.add_message(
1039 Calling_Fn => g_calling_fn,
1040 Name => 'IGI_IAC_NO_GL_INFO');
1041 RETURN FALSE;
1042
1043 WHEN e_no_ccid_found THEN
1044 igi_iac_debug_pkg.debug_other_string(p_level => g_excep_level,
1045 p_full_path => l_path_name,
1046 p_string => 'CCID could not be found');
1047 FA_SRVR_MSG.add_message(
1048 Calling_Fn => g_calling_fn,
1049 Name => 'IGI_IAC_WF_FAILED_CCID');
1050 RETURN FALSE;
1051
1052 WHEN e_no_proration THEN
1053 igi_iac_debug_pkg.debug_other_string(p_level => g_excep_level,
1054 p_full_path => l_path_name,
1055 p_string => 'Amount could not be prorated among the distributions');
1056 FA_SRVR_MSG.add_message(
1057 Calling_Fn => g_calling_fn,
1058 Name => 'IGI_IAC_NO_PRORATION');
1059 RETURN FALSE;
1060
1061 WHEN e_asset_life_err THEN
1062 igi_iac_debug_pkg.debug_other_string(p_level => g_excep_level,
1063 p_full_path => l_path_name,
1064 p_string => 'Asset life could not be checked');
1065 FA_SRVR_MSG.add_message(
1066 Calling_Fn => g_calling_fn,
1067 Name => 'IGI_IAC_ASSET_LIFE_ERR');
1068 RETURN FALSE;
1069
1070 WHEN e_non_dep_asset THEN
1071 igi_iac_debug_pkg.debug_other_string(p_level => g_excep_level,
1072 p_full_path => l_path_name,
1073 p_string => 'No further processing for non-depreciating asset');
1074 FA_SRVR_MSG.add_message(
1075 Calling_Fn => g_calling_fn,
1076 Name => 'IGI_IAC_NON_DEP_ASSET',
1077 Token1 => 'ASSET_NUM',
1078 Value1 => g_asset_num);
1079 RETURN TRUE;
1080
1081 WHEN e_curr_period_amort THEN
1082 igi_iac_debug_pkg.debug_other_string(p_level => g_excep_level,
1083 p_full_path => l_path_name,
1084 p_string => 'No further processing for current period amortized asset');
1085 FA_SRVR_MSG.add_message(
1086 Calling_Fn => g_calling_fn,
1087 Name => 'IGI_IAC_CURR_PRD_AMORT',
1088 Token1 => 'ASSET_NUM',
1089 Value1 => g_asset_num);
1090 RETURN TRUE;
1091
1092 WHEN others THEN
1093 igi_iac_debug_pkg.debug_unexpected_msg(p_full_path => l_path_name);
1094 FA_SRVR_MSG.add_sql_error(Calling_Fn => g_calling_fn);
1095 RETURN FALSE;
1096
1097 END Do_Amort_Deprn_Reval;
1098
1099 BEGIN
1100 l_calling_function := '***Amort***';
1101 g_calling_fn := 'IGI_IAC_ADJ_AMORT_PKG.Do_Amort_Deprn_Reval';
1102
1103 --===========================FND_LOG.START=====================================
1104 g_state_level := FND_LOG.LEVEL_STATEMENT;
1105 g_proc_level := FND_LOG.LEVEL_PROCEDURE;
1106 g_event_level := FND_LOG.LEVEL_EVENT;
1107 g_excep_level := FND_LOG.LEVEL_EXCEPTION;
1108 g_error_level := FND_LOG.LEVEL_ERROR;
1109 g_unexp_level := FND_LOG.LEVEL_UNEXPECTED;
1110 g_path := 'IGI.PLSQL.igiiadab.igi_iac_adj_amort_pkg.';
1111 --===========================FND_LOG.END=====================================
1112
1113 END IGI_IAC_ADJ_AMORT_PKG;