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