DBA Data[Home] [Help]

PACKAGE BODY: APPS.IGI_IAC_CATCHUP_PKG

Source


1 PACKAGE BODY IGI_IAC_CATCHUP_PKG AS
2 -- $Header: igiiactb.pls 120.22.12010000.2 2010/06/25 05:29:15 schakkin ship $
3 
4      g_debug BOOLEAN ;
5 
6     --===========================FND_LOG.START=====================================
7 
8     g_state_level NUMBER	    ;
9     g_proc_level  NUMBER	    ;
10     g_event_level NUMBER	    ;
11     g_excep_level NUMBER	    ;
12     g_error_level NUMBER	    ;
13     g_unexp_level NUMBER	    ;
14     g_path        VARCHAR2(100) ;
15 
16     --===========================FND_LOG.END=====================================
17 
18     PROCEDURE Debug_Period(p_period igi_iac_types.prd_rec) IS
19   	l_path_name VARCHAR2(150) ;
20     BEGIN
21   	    l_path_name := g_path||'debug_period';
22 
23   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
24 		     p_full_path => l_path_name,
25 		     p_string => '         Period counter :'||to_char(p_period.period_counter));
26   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
27 		     p_full_path => l_path_name,
28 		     p_string => '         Period Num :'||to_char(p_period.period_num));
29   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
30 		     p_full_path => l_path_name,
31 		     p_string => '         Fiscal Year :'||to_char(p_period.fiscal_year));
32   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
33 		     p_full_path => l_path_name,
34 		     p_string => '         Period Name :'||p_period.period_name);
35     END Debug_Period;
36 
37     procedure do_round ( p_amount in out NOCOPY number, p_book_type_code in varchar2) is
38         l_amount number     := p_amount;
39         l_amount_old number := p_amount;
40         l_path varchar2(150) := g_path||'do_round';
41     begin
42        IF IGI_IAC_COMMON_UTILS.Iac_Round(X_Amount => l_amount, X_Book => p_book_type_code)
43        THEN
44           p_amount := l_amount;
45        ELSE
46           p_amount := round( l_amount, 2);
47        END IF;
48     exception when others then
49       p_amount := l_amount_old;
50       igi_iac_debug_pkg.debug_unexpected_msg(l_path);
51       Raise;
52     end;
53 
54     PROCEDURE Debug_Asset(p_asset igi_iac_types.iac_reval_input_asset) IS
55   	l_path_name VARCHAR2(150);
56     BEGIN
57   	    l_path_name := g_path||'debug_asset';
58 
59      	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
60 	     		p_full_path => l_path_name,
61 	     		p_string => '         Net book value :'||to_char(p_asset.net_book_value));
62      	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
63 	     		p_full_path => l_path_name,
64 	     		p_string => '         Adjusted Cost :'||to_char(p_asset.adjusted_cost));
65      	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
66 	     		p_full_path => l_path_name,
67 	     		p_string => '         Operating Account :'||to_char(p_asset.operating_acct));
68      	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
69 	     		p_full_path => l_path_name,
70 	     		p_string => '         Reval Reserve :'||to_char(p_asset.reval_reserve));
71      	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
72 	     		p_full_path => l_path_name,
73 	     		p_string => '         Deprn Amount :'||to_char(p_asset.deprn_amount));
74      	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
75 	     		p_full_path => l_path_name,
76 	     		p_string => '         Deprn Reserve :'||to_char(p_asset.deprn_reserve));
77      	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
78 	     		p_full_path => l_path_name,
79 	     		p_string => '         Backlog Deprn Reserve :'||to_char(p_asset.backlog_deprn_reserve));
80      	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
81 	     		p_full_path => l_path_name,
82 	     		p_string => '         General Fund :'||to_char(p_asset.general_fund));
83      	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
84 	     		p_full_path => l_path_name,
85 	     		p_string => '         Current Reval Factor :'||to_char(p_asset.current_reval_factor));
86      	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
87 	     		p_full_path => l_path_name,
88 	     		p_string => '         Cumulative Reval Factor :'||to_char(p_asset.Cumulative_reval_factor));
89     END Debug_Asset;
90 
91     FUNCTION get_FA_Deprn_Expense(
92                     p_asset_id          IN NUMBER,
93                     p_book_type_code    IN VARCHAR2,
94                     p_period_counter    IN NUMBER,
95                     p_calling_function  IN VARCHAR2,
96                     p_deprn_reserve     IN NUMBER,
97                     p_deprn_YTD         IN NUMBER,
98                     p_deprn_expense_py  OUT NOCOPY NUMBER,
99                     p_deprn_expense_cy  OUT NOCOPY NUMBER,
100                     p_last_asset_period OUT NOCOPY NUMBER
101                     ) return BOOLEAN IS
102 
103         CURSOR c_get_fa_asset_info IS
104         SELECT cost,
105                salvage_value,
106                date_placed_in_service,
107                depreciate_flag,
108                period_counter_fully_reserved,
109                period_counter_fully_retired,
110                transaction_header_id_in,
111                life_in_months,
112                add_months(date_placed_in_service,life_in_months) last_date
113         FROM   fa_books
114         WHERE  book_type_code = p_book_type_code
115         AND    asset_id  = p_asset_id
116         AND    transaction_header_id_out IS NULL;
117 
118 	/* Bug 2961656 vgadde 08-jul-03 Start(1) */
119         CURSOR c_get_user_deprn IS
120         SELECT period_counter,deprn_reserve,YTD_deprn
121         FROM fa_deprn_summary
122         WHERE book_type_code = p_book_type_code
123         AND asset_id = p_asset_id
124         AND deprn_source_code = 'BOOKS';
125 	/* Bug 2961656 vgadde 08-jul-03 End(1) */
126 
127         /* Cursor for fetching latest deprn_reserve for RECLASS */
128 	CURSOR c_get_deprn_reserve IS
129         SELECT period_counter, deprn_reserve
130         FROM fa_deprn_summary
131         WHERE book_type_code = p_book_type_code
132         AND asset_id = p_asset_id
133         AND period_counter = (SELECT max(period_counter)
134                               FROM fa_deprn_summary
135                               WHERE book_type_code = p_book_type_code
136                               AND asset_id = p_asset_id);
137 
138         CURSOR c_get_deprn_calendar IS
139         SELECT deprn_calendar
140         FROM fa_book_controls
141         WHERE book_type_code like p_book_type_code;
142 
143         CURSOR c_get_periods_in_year(p_calendar_type fa_calendar_types.calendar_type%TYPE) IS
144         SELECT number_per_fiscal_year
145         FROM fa_calendar_types
146         WHERE calendar_type = p_calendar_type;
147 
148         l_fa_deprn_acc      fa_adjustments.adjustment_amount%TYPE;
149         l_dpis_period       igi_iac_types.prd_rec;
150         l_current_period    igi_iac_types.prd_rec;
151         l_last_period        igi_iac_types.prd_rec;
152         l_booksrow_period_rec igi_iac_types.prd_rec;
153         l_deprn_calendar    fa_calendar_types.calendar_type%TYPE;
154         l_periods_in_year   fa_calendar_types.number_per_fiscal_year%TYPE;
155         l_booksrow_period   NUMBER;	-- added for bug 2961656
156         l_booksrow_reserve  NUMBER;	-- added for bug 2961656
157         l_deprn_reserve     NUMBER;
158         l_reclass_period    fa_deprn_periods.period_counter%TYPE;
159         l_total_periods     NUMBER;
160         l_last_period_counter fa_deprn_periods.period_counter%TYPE;    -- added for bug 2411599
161       	l_path_name VARCHAR2(150);
162         l_booksrow_ytd_deprn  NUMBER;
163 
164     BEGIN
165       	l_path_name := g_path||'get_fa_deprn_expense';
166   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
167 		     p_full_path => l_path_name,
168 		     p_string => '     Start of processing in get_FA_Deprn_Expense function');
169   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
170 		     p_full_path => l_path_name,
171 		     p_string => '     ---------Input Parameter Values---------');
172   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
173 		     p_full_path => l_path_name,
174 		     p_string => '     Asset Id :'||to_char(p_asset_id));
175   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
176 		     p_full_path => l_path_name,
177 		     p_string => '     Book Type Code :'||p_book_type_code);
178   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
179 		     p_full_path => l_path_name,
180 		     p_string => '     Period Counter :'||to_char(p_period_counter));
181   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
182 		     p_full_path => l_path_name,
183 		     p_string => '     Calling function :'||p_calling_function);
184   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
185 		     p_full_path => l_path_name,
186 		     p_string => '     ----------------------------------');
187 
188 	/* Bug 2961656 vgadde 08-jul-03 Start(2) */
189         IF (p_calling_function = 'UPGRADE') THEN
190 
191             OPEN c_get_deprn_calendar;
192     	    FETCH c_get_deprn_calendar INTO l_deprn_calendar;
193     	    CLOSE c_get_deprn_calendar;
194 
195     	    OPEN c_get_periods_in_year(l_deprn_calendar);
196     	    FETCH c_get_periods_in_year INTO l_periods_in_year;
197     	    CLOSE c_get_periods_in_year;
198       	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
199 		     p_full_path => l_path_name,
200 		     p_string => '     Periods in Year for the calendar :'||to_char(l_periods_in_year));
201 
202             FOR l_asset_info IN c_get_fa_asset_info LOOP
203 
204                 IF (l_asset_info.depreciate_flag = 'NO') THEN
205           		    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
206 		     		p_full_path => l_path_name,
207 		     		p_string => '     Depreciate Flag is off. No depreciation required');
208                     p_deprn_expense_py := 0;
209                     p_deprn_expense_cy := 0;
210                     p_last_asset_period := NULL;
211                     return TRUE;
212                 END IF;
213 
214                 IF NOT igi_iac_common_utils.get_period_info_for_date(p_book_type_code,
215                                                                      l_asset_info.date_placed_in_service,
216                                                                      l_dpis_period) THEN
217           		    igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
218 		     		p_full_path => l_path_name,
219 		     		p_string => '     Error in fetching dpis period information');
220                     return FALSE;
221                 END IF;
222 
223                 l_total_periods := ceil((l_asset_info.life_in_months*l_periods_in_year)/12);
224                 igi_iac_debug_pkg.debug_other_string(g_state_level,l_path_name,'l_total_periods =' || l_total_periods);
225                 l_last_period_counter := (l_dpis_period.period_counter + l_total_periods - 1);
226 
227                 IF nvl(l_asset_info.period_counter_fully_reserved,l_last_period_counter) < l_last_period_counter THEN
228                     l_last_period_counter := l_asset_info.period_counter_fully_reserved;
229                 END IF;
230 
231                 IF l_last_period_counter > p_period_counter THEN
232                     l_last_period_counter := NULL;
233                 END IF;
234                 igi_iac_debug_pkg.debug_other_string(g_state_level,l_path_name,'l_last_period_counter =' || l_last_period_counter);
235 
236                 IF NOT igi_iac_common_utils.get_period_info_for_counter(p_book_type_code,
237                                                                      p_period_counter,
238                                                                      l_current_period) THEN
239           		    igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
240 		                                                 p_full_path => l_path_name,
241                                                          p_string => '     Error in fetching open period information');
242                     return FALSE;
243                 END IF;
244 
245                 IF (l_last_period_counter IS NULL) THEN
246   	            	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
247     		                                                 p_full_path => l_path_name,
248                                              	     		 p_string => '     Asset is not fully reserved.');
249                     IF p_deprn_ytd IS NULL THEN
250                         p_deprn_expense_py := p_deprn_reserve /  (p_period_counter - l_dpis_period.period_counter);
251                         do_round(p_deprn_expense_py,p_book_type_code);
252                         p_deprn_expense_cy := p_deprn_expense_py;
253                         p_last_asset_period := NULL;
254                     ELSE
255                          p_last_asset_period := NULL;
256                         p_deprn_expense_py := (p_deprn_reserve - p_deprn_ytd)/(p_period_counter - l_dpis_period.period_counter - l_current_period.period_num + 1);
257                         do_round(p_deprn_expense_py,p_book_type_code);
258                         p_deprn_expense_cy := p_deprn_ytd / (l_current_period.period_num - 1);
259                         do_round(p_deprn_expense_cy,p_book_type_code);
260                     END IF;
261                     igi_iac_debug_pkg.debug_other_string(g_state_level,l_path_name,'p_deprn_expense_py =' || p_deprn_expense_py);
262                     igi_iac_debug_pkg.debug_other_string(g_state_level,l_path_name,'p_deprn_expense_cy =' || p_deprn_expense_cy);
263                 ELSE
264           		    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
265 		                                          		p_full_path => l_path_name,
266                                                 		p_string => '     Asset is fully reserved');
267                     IF NOT igi_iac_common_utils.get_period_info_for_counter(p_book_type_code,
268                                                                          l_last_period_counter,
269                                                                          l_last_period) THEN
270                         return FALSE;
271                     END IF;
272 
273                     IF p_deprn_ytd IS NULL THEN
274                         p_deprn_expense_py := p_deprn_reserve / (l_last_period.period_counter - l_dpis_period.period_counter + 1);
275                         do_round(p_deprn_expense_py,p_book_type_code);
276                         p_deprn_expense_cy := p_deprn_expense_py;
277                         p_last_asset_period := l_last_period_counter;
278                     ELSE
279                         IF l_last_period.fiscal_year = l_current_period.fiscal_year THEN
280                             p_deprn_expense_py := (p_deprn_reserve - p_deprn_ytd)/(l_last_period_counter - l_dpis_period.period_counter - l_last_period.period_num + 1);
281                             do_round(p_deprn_expense_py,p_book_type_code);
282                             p_deprn_expense_cy := p_deprn_ytd / (l_last_period.period_counter);
283                             do_round(p_deprn_expense_cy,p_book_type_code);
284                             p_last_asset_period := l_last_period_counter;
285                         ELSE
286                             p_deprn_expense_py := p_deprn_reserve / (l_last_period_counter - l_dpis_period.period_counter + 1);
287                             do_round(p_deprn_expense_py,p_book_type_code);
288                             p_deprn_expense_cy := p_deprn_expense_py;
289                             p_last_asset_period := l_last_period_counter;
290                         END IF;
291                         IF l_last_period.fiscal_year < l_current_period.fiscal_year THEN
292                             p_deprn_expense_cy := 0;
293                         END IF;
294                     END IF;
295                     igi_iac_debug_pkg.debug_other_string(g_state_level,l_path_name,'p_deprn_expense_py =' || p_deprn_expense_py);
296                     igi_iac_debug_pkg.debug_other_string(g_state_level,l_path_name,'p_deprn_expense_cy =' || p_deprn_expense_cy);
297                 END IF;
298             END LOOP;
299         END IF;
300 
301 	    IF ((p_calling_function = 'RECLASS') OR (p_calling_function = 'ADDITION') ) THEN
302 
303             OPEN c_get_user_deprn;
304             FETCH c_get_user_deprn INTO l_booksrow_period, l_booksrow_reserve,l_booksrow_ytd_deprn;
305             CLOSE c_get_user_deprn;
306 
307     	    OPEN c_get_deprn_calendar;
308 	        FETCH c_get_deprn_calendar INTO l_deprn_calendar;
309 	        CLOSE c_get_deprn_calendar;
310 
311     	    OPEN c_get_periods_in_year(l_deprn_calendar);
312 	        FETCH c_get_periods_in_year INTO l_periods_in_year;
313 	        CLOSE c_get_periods_in_year;
314       	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
315 	                                	     	p_full_path => l_path_name,
316                                  		     	p_string => '     Periods in Year for the calendar :'||to_char(l_periods_in_year));
317 
318     	    FOR l_asset_info IN c_get_fa_asset_info LOOP
319 
320               		igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
321 		                                                 p_full_path => l_path_name,
322                                                   		p_string => '         cost :'||to_char(l_asset_info.cost));
323               		igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
324 		                                         		p_full_path => l_path_name,
325                                     		     		p_string => '         salvage value :'||to_char(l_asset_info.salvage_value));
326               		igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
327 		                                         		p_full_path => l_path_name,
328                                     		     		p_string => '         date placed in service :'||to_char(l_asset_info.date_placed_in_service));
329               		igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
330 		                                         		p_full_path => l_path_name,
331                                     		     		p_string => '         depreciate flag :'||l_asset_info.depreciate_flag);
332               		igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
333 		                                             		p_full_path => l_path_name,
334                                         		     		p_string => '         period counter fully reserved :'||to_char(l_asset_info.period_counter_fully_reserved));
335               		igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
336 		                                             		p_full_path => l_path_name,
337                                         		     		p_string => '         transaction header id in :'||to_char(l_asset_info.transaction_header_id_in));
338               		igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
339 		                                             		p_full_path => l_path_name,
340                                         		     		p_string => '         life in months :'||to_char(l_asset_info.life_in_months));
341 
342                 IF (l_asset_info.depreciate_flag = 'NO') THEN
343                   		    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
344 		     	                                            	p_full_path => l_path_name,
345                                             		     		p_string => '     Depreciate Flag is off. No depreciation calculation required');
346                     p_deprn_expense_py := 0;
347                     p_deprn_expense_cy := 0;
348                     p_last_asset_period := NULL;
349                     return TRUE;
350                END IF;
351 
352                 l_total_periods := ceil((l_asset_info.life_in_months*l_periods_in_year)/12);
353               		igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
354 		                                         		p_full_path => l_path_name,
355                                         	     		p_string => '     Total Periods in Asset life :'||to_char(l_total_periods));
356 
357             		/* Added for bug 2411599 vgadde 12/06/2002 Start(1)*/
358             		/* Modified logic for getting last period in asset life */
359                 IF NOT igi_iac_common_utils.get_period_info_for_date(p_book_type_code,
360                                                                      l_asset_info.date_placed_in_service,
361                                                                      l_dpis_period) THEN
362                     return FALSE;
363                 END IF;
364 
365                 l_last_period_counter := (l_dpis_period.period_counter + l_total_periods - 1);
366           		igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
367 		                                     		p_full_path => l_path_name,
368                                 		     		p_string => '     Last Period counter :'||to_char(l_last_period_counter));
369 
370                 IF nvl(l_asset_info.period_counter_fully_reserved,l_last_period_counter) < l_last_period_counter THEN
371                     l_last_period_counter := l_asset_info.period_counter_fully_reserved;
372                 END IF;
373 
374                 IF (l_last_period_counter < p_period_counter) THEN
375                     p_last_asset_period := l_last_period_counter;
376                 ELSE
377                     p_last_asset_period := NULL;
378                 END IF;
379         		/* Added for bug 2411599 vgadde 12/06/2002 End(1) */
380 
381                 IF ((p_calling_function = 'ADDITION') AND (nvl(l_booksrow_reserve,0) <> 0) and p_last_asset_period IS NULL) THEN
382 
383               		    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
384 		             		p_full_path => l_path_name,
385         		     		p_string => '     Depreciation amount entered by user');
386 
387                         ------------- supplied YTD -----------------
388                         IF Nvl(l_booksrow_ytd_deprn,0) <> 0 Then
389 
390                                  IF NOT igi_iac_common_utils.get_period_info_for_counter(p_book_type_code,
391                                                                      p_period_counter-1,
392                                                                      l_current_period) THEN
393                                                    return FALSE;
394                                  END IF;
395 
396                                     p_deprn_expense_py := (l_booksrow_reserve - l_booksrow_ytd_deprn)/(p_period_counter - l_dpis_period.period_counter - l_current_period.period_num );
397                                     do_round(p_deprn_expense_py,p_book_type_code);
398                                     p_deprn_expense_cy := l_booksrow_ytd_deprn/l_current_period.period_num;
399                                     do_round(p_deprn_expense_cy,p_book_type_code);
400                         Else
401                                 p_deprn_expense_py := l_booksrow_reserve/ (p_period_counter - l_dpis_period.period_counter);
402                                 do_round(p_deprn_expense_py,p_book_type_code);
403                                 p_deprn_expense_cy := p_deprn_expense_py;
404                        END IF;
405                        igi_iac_debug_pkg.debug_other_string(g_state_level,l_path_name,'p_deprn_expense_py =' || p_deprn_expense_py);
406                        igi_iac_debug_pkg.debug_other_string(g_state_level,l_path_name,'p_deprn_expense_cy =' || p_deprn_expense_cy);
407 
408                 ELSIF (p_calling_function = 'RECLASS') THEN
409                          OPEN c_get_deprn_reserve;
410                          FETCH c_get_deprn_reserve INTO l_reclass_period,l_deprn_reserve;
411                          CLOSE c_get_deprn_reserve;
412 
413                           --Code added by Venkat Gadde
414 			  IF l_reclass_period <> l_booksrow_period THEN
415                             IF l_last_period_counter is not null and l_last_period_counter < l_reclass_period Then
416                               l_reclass_period := l_last_period_counter;
417                             end if;
418                             p_deprn_expense_py := l_deprn_reserve /(l_reclass_period - l_dpis_period.period_counter + 1);
419                             do_round(p_deprn_expense_py,p_book_type_code);
420                             p_deprn_expense_cy := p_deprn_expense_py;
421                           ELSIF (nvl(l_booksrow_reserve,0) <> 0) THEN
422                             p_deprn_expense_py := l_booksrow_reserve/ (p_period_counter - l_dpis_period.period_counter);
423                             do_round(p_deprn_expense_py,p_book_type_code);
424                             p_deprn_expense_cy := p_deprn_expense_py;
425                           ELSE
426                             p_deprn_expense_py := (l_asset_info.cost-l_asset_info.salvage_value)/l_total_periods;
427                             do_round(p_deprn_expense_py,p_book_type_code);
428                             p_deprn_expense_cy := p_deprn_expense_py;
429                           END IF;
430 
431                           igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
432 		             		p_full_path => l_path_name,
433         		     		p_string => '     Calculated the deprn expense for '||l_reclass_period);
434                           -- End of code added by Venkat Gadde
435                     ELSE
436                 		    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
437 		             	                            	p_full_path => l_path_name,
438                             		     	        	p_string => '     Depreciation amount calculated by FA');
439                           p_deprn_expense_py := (l_asset_info.cost-l_asset_info.salvage_value)/l_total_periods;
440                           do_round(p_deprn_expense_py,p_book_type_code);
441                           p_deprn_expense_cy := p_deprn_expense_py;
442               END IF;
443               igi_iac_debug_pkg.debug_other_string(g_state_level,l_path_name,'p_deprn_expense_py =' || p_deprn_expense_py);
444               igi_iac_debug_pkg.debug_other_string(g_state_level,l_path_name,'p_deprn_expense_cy =' || p_deprn_expense_cy);
445             END LOOP;
446 
447         END IF;
448 	/* Bug 2961656 vgadde 08-jul-03 End(2) */
449 	do_round(p_deprn_expense_py,p_book_type_code);
450 	do_round(p_deprn_expense_cy,p_book_type_code);
451   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
452 		     p_full_path => l_path_name,
453 		     p_string => '-----Output from get_fa_deprn_expense function');
454   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
455 		     p_full_path => l_path_name,
456 		     p_string => '     FA pys Depreciation Expense per period :'||to_char(p_deprn_expense_py));
457   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
458 		     p_full_path => l_path_name,
459 		     p_string => '     FA cys Depreciation Expense per period :'||to_char(p_deprn_expense_cy));
460   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
461 		     p_full_path => l_path_name,
462 		     p_string => '     Last period for the asset :'||to_char(p_last_asset_period));
463   	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
464 		     p_full_path => l_path_name,
465 		     p_string => '----------------------------------------------');
466         return TRUE;
467 
468         EXCEPTION
469             WHEN OTHERS THEN
470   		igi_iac_debug_pkg.debug_unexpected_msg(p_full_path => l_path_name);
471                 return FALSE;
472     END get_FA_Deprn_Expense;
473 
474    FUNCTION Do_Deprn_Catchup(
475                 p_period_counter_from   IN  NUMBER,
476                 p_period_counter_to     IN  NUMBER,
477                 p_period_counter        IN  NUMBER,
478                 p_crud_iac_tables       IN  BOOLEAN,
479                 p_calling_function      IN  VARCHAR2,
480                 p_fa_deprn_expense_py   IN  NUMBER,
481                 p_fa_deprn_expense_cy   IN  NUMBER,
482                 p_asset_last_period     IN  NUMBER,
483                 p_fa_deprn_reserve      IN  NUMBER,
484                 p_fa_deprn_ytd          IN  NUMBER,
485                 p_asset_balance         IN OUT NOCOPY igi_iac_types.iac_reval_input_asset,
486                 p_event_id              IN  NUMBER    --R12 uptake
487                 ) return BOOLEAN IS
488 
489         l_deprn_catchup_amount      NUMBER;
490         l_rowid                     VARCHAR2(25) ;
491         l_adjustment_id             igi_iac_transaction_headers.adjustment_id%TYPE;
492         l_transaction_sub_type      igi_iac_transaction_headers.transaction_sub_type%TYPE;
493         l_distributions_tab         igi_iac_types.dist_amt_tab;
494         l_fa_dist_catchup_tab	    igi_iac_types.dist_amt_tab;
495         l_account_ccid	            NUMBER(15) ;
496     	l_set_of_books_id           NUMBER(15) ;
497     	l_chart_of_accts_id         NUMBER(15) ;
498     	l_currency_code	            VARCHAR2(15) ;
499     	l_precision                 VARCHAR2(1) ;
500         l_idx                       NUMBER;
501         l_detail_balance            igi_iac_det_balances%ROWTYPE;
502         l_distribution_amount       NUMBER;
503         l_dist_period_amount        NUMBER;
504         l_last_catchup_prd_rec      igi_iac_types.prd_rec;
505         l_last_reval_prd_rec        igi_iac_types.prd_rec;
506         l_deprn_ytd                 NUMBER;
507         l_reval_reserve_net         igi_iac_det_balances.reval_reserve_net%TYPE;
508         l_reval_general_fund	    igi_iac_det_balances.reval_reserve_gen_fund%TYPE;
509         l_general_fund_acc          igi_iac_det_balances.general_fund_acc%TYPE;
510         l_fa_deprn_acc	    	    NUMBER;
511         l_fa_deprn_catchup_amount   NUMBER;
512         l_iac_fa_deprn_rec          igi_iac_fa_deprn%ROWTYPE;
513         l_last_deprn_catchup_period NUMBER;
514         l_periods_in_year           NUMBER;
515         l_deprn_calendar            fa_calendar_types.calendar_type%TYPE;
516         /* Bug 2961656 vgadde 08-jul-2003 Start(3) */
517         l_iac_deprn_amount_py       NUMBER;
518         l_iac_deprn_amount_cy       NUMBER;
519         l_period_from               igi_iac_types.prd_rec;
520         l_period_to                 igi_iac_types.prd_rec;
521         l_period_open               igi_iac_types.prd_rec;
522         l_period_reserved           igi_iac_types.prd_rec;
523         /* Bug 2961656 vgadde 08-jul-2003 End(3) */
524         l_path_name                 VARCHAR2(150);
525         l_iac_deprn_period_amount   NUMBER;
526         l_fa_deprn_period_amount    NUMBER;
527         l_booksrow_period           NUMBER;
528         l_booksrow_reserve          NUMBER;
529         l_booksrow_YTD              NUMBER;
530         l_reval_rsv_ccid            NUMBER;
531         l_iac_active_dists_YTD      NUMBER;
532         l_fa_active_dists_YTD       NUMBER;
533         l_iac_inactive_dists_YTD    NUMBER;
534         l_fa_inactive_dists_YTD     NUMBER;
535         l_iac_all_dists_YTD         NUMBER;
536         l_fa_all_dists_YTD          NUMBER;
537 
538         CURSOR c_get_transaction IS
539         SELECT *
540         FROM igi_iac_transaction_headers
541         WHERE period_counter = p_period_counter
542         AND book_type_code = p_asset_balance.book_type_code
543         AND asset_id = p_asset_balance.asset_id
544         AND transaction_type_code = p_calling_function
545         AND transaction_sub_type = 'REVALUATION'
546         AND adjustment_id_out is NULL;
547 
548         CURSOR c_get_detail_balances(p_adjustment_id NUMBER,p_distribution_id NUMBER) IS
549         SELECT *
550         FROM igi_iac_det_balances
551         WHERE book_type_code = p_asset_balance.book_type_code
552         AND asset_id = p_asset_balance.asset_id
553         AND adjustment_id = p_adjustment_id
554         AND distribution_id = p_distribution_id;
555 
556         CURSOR c_get_inactive_dists(p_adjustment_id NUMBER) IS
557         SELECT *
558         FROM igi_iac_det_balances
559         WHERE adjustment_id = p_adjustment_id
560         AND book_type_code = p_asset_balance.book_type_code
561         AND asset_id = p_asset_balance.asset_id
562         AND nvl(active_flag,'Y') = 'N';
563 
564         CURSOR c_get_upgrade_rec IS
565         SELECT *
566         FROM igi_imp_iac_interface_py_add
567         WHERE book_type_code = p_asset_balance.book_type_code
568         AND asset_id = p_asset_balance.asset_id
569         AND period_counter = p_period_counter;
570 
571         CURSOR c_get_iac_fa_deprn_rec(cp_adjustment_id	igi_iac_fa_deprn.adjustment_id%TYPE
572         			     ,cp_distribution_id igi_iac_fa_deprn.distribution_id%TYPE) IS
573         SELECT *
574         FROM igi_iac_fa_deprn
575         WHERE book_type_code = p_asset_balance.book_type_code
576         AND asset_id = p_asset_balance.asset_id
577         AND adjustment_id = cp_adjustment_id
578         AND distribution_id = cp_distribution_id;
579 
580         CURSOR c_get_iac_fa_inactive_dists(cp_adjustment_id igi_iac_fa_deprn.adjustment_id%TYPE) IS
581         SELECT *
582         FROM igi_iac_fa_deprn
583         WHERE adjustment_id = cp_adjustment_id
584         AND book_type_code = p_asset_balance.book_type_code
585         AND asset_id = p_asset_balance.asset_id
586         AND nvl(active_flag,'Y') = 'N';
587 
588         cursor c_asset_details_salvage is
589         SELECT 	life_in_months,salvage_value,rate_adjustment_factor
590  	    FROM fa_books
591    	    WHERE book_type_code = p_asset_balance.book_type_code
592    	    AND   asset_id = p_asset_balance.asset_id
593    	    AND   date_ineffective is NULL ;
594 
595         l_asset_details_salvage c_asset_details_salvage%rowtype;
596         l_salvage_value_correction number ;
597 
598         CURSOR c_get_deprn_calendar IS
599         SELECT deprn_calendar
600         FROM fa_book_controls
601         WHERE book_type_code = p_asset_balance.book_type_code;
602 
603         CURSOR c_get_periods_in_year(p_calendar_type fa_calendar_types.calendar_type%TYPE) IS
604         SELECT number_per_fiscal_year
605         FROM fa_calendar_types
606         WHERE calendar_type = p_calendar_type;
607 
608         CURSOR c_get_user_deprn IS
609         SELECT period_counter,deprn_reserve,YTD_deprn
610         FROM fa_deprn_summary
611         WHERE book_type_code = p_asset_balance.book_type_code
612         AND asset_id = p_asset_balance.asset_id
613         AND deprn_source_code = 'BOOKS';
614 
615 
616     BEGIN
617         IF FND_PROFILE.VALUE('IGI_DEBUG_OPTION') = 'Y'  THEN
618             g_debug := TRUE;
619         END IF;
620         l_path_name := g_path||'do_deprn_catchup';
621         l_salvage_value_correction :=0;
622 
623   	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
624 		     	                             p_full_path => l_path_name,
625                                            	 p_string => '----------Start of processing by function Do_Deprn_Catchup....');
626       	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
627 	                             	     	 p_full_path => l_path_name,
628                              		         p_string => '---- Input Parameters for the function ---------');
629       	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
630 	                            	         p_full_path => l_path_name,
631 		     	                             p_string => '     Period Counter From :'||to_char(p_period_counter_from));
632       	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
633 	                             	     	 p_full_path => l_path_name,
634                                  	     	 p_string => '     Period Counter To :'||to_char(p_period_counter_to));
635       	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
636 	                                      	 p_full_path => l_path_name,
637                              		     	 p_string => '     Current Open Period Counter :'||to_char(p_period_counter));
638         If p_crud_iac_tables then
639   	            igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
640 		                                             p_full_path => l_path_name,
641                                      		     	 p_string => '     CRUD IAC tables is TRUE');
642         Else
643           	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
644 		                                          	 p_full_path => l_path_name,
645                                          	     	 p_string => '     CRUD IAC tables is FALSE');
646         End If;
647         igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
648 		  	                                 p_full_path => l_path_name,
649                             		     	 p_string => '     Calling Function :'||p_calling_function);
650     	Debug_Asset(p_asset_balance);
651   	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
652 		                                   	 p_full_path => l_path_name,
653                                          	 p_string => '--------------------------------------------------');
654         IF (p_period_counter_from >= p_period_counter_to) THEN
655   	                igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
656 		                                            	p_full_path => l_path_name,
657                                       		     		p_string => '     Returning from do_deprn_catchup as no catchup is required');
658             return TRUE;
659         END IF;
660 
661         /* Bug 2961656 vgadde 08-jul-2003 Start(4) */
662         /*IF NOT get_FA_Deprn_Expense(p_asset_balance.asset_id,
663                                  p_asset_balance.book_type_code,
664                                  p_period_counter,
665                                  p_calling_function,
666                                  l_fa_deprn_amount,
667                                  l_last_asset_period) THEN
668                 Debug('*** Error in get_FA_Deprn_Expense function');
669                 return FALSE;
670         END IF;*/
671         /* Bug 2961656 vgadde 08-jul-2003 End(4) */
672 
673         /* Bug 2961656 vgadde 08-jul-2003 Start(5) */
674         IF (nvl(p_fa_deprn_expense_py,0) = 0 AND nvl(p_fa_deprn_expense_cy,0) = 0) THEN
675             igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
676 		     	p_full_path => l_path_name,
677 		     	p_string => '     Returning from do_deprn_catchup since no depreciation catchup is required');
678             return TRUE;
679         END IF;
680 
681         l_iac_deprn_amount_py := (p_fa_deprn_expense_py * p_asset_balance.cumulative_reval_factor)-p_fa_deprn_expense_py;
682         do_round(l_iac_deprn_amount_py,p_asset_balance.book_type_code);
683         l_iac_deprn_amount_cy := (p_fa_deprn_expense_cy * p_asset_balance.cumulative_reval_factor)-p_fa_deprn_expense_cy;
684         do_round(l_iac_deprn_amount_cy,p_asset_balance.book_type_code);
685 
686       	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
687 		     	                             p_full_path => l_path_name,
688                              		     	 p_string => '     IAC pys Depreciation amount per period :'||to_char(l_iac_deprn_amount_py));
689   	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
690                                  	     	 p_full_path => l_path_name,
691                                  	     	 p_string => '     IAC cys Depreciation amount per period :'||to_char(l_iac_deprn_amount_cy));
692         Open  c_get_deprn_calendar;
693         Fetch c_get_deprn_calendar into l_deprn_calendar;
694         Close c_get_deprn_calendar;
695 
696         Open  c_get_periods_in_year(l_deprn_calendar);
697         Fetch c_get_periods_in_year into l_periods_in_year;
698         Close c_get_periods_in_year;
699 
700         IF (p_calling_function = 'ADDITION' OR p_calling_function = 'RECLASS') THEN
701 
702             -- Supplied  YTD
703             OPEN c_get_user_deprn;
704             FETCH c_get_user_deprn INTO l_booksrow_period, l_booksrow_reserve,l_booksrow_ytd;
705             CLOSE c_get_user_deprn;
706 
707             IF  ((p_calling_function = 'ADDITION') AND (nvl(l_booksrow_YTD,0) <> 0) AND (p_asset_last_period IS NULL)) THEN
708 
709                 IF NOT igi_iac_common_utils.get_period_info_for_counter(p_asset_balance.book_type_code,
710                                                                         p_period_counter_from,l_period_from) THEN
711                     return FALSE;
712                 END IF;
713 
714                 IF NOT igi_iac_common_utils.get_period_info_for_counter(p_asset_balance.book_type_code,
715                                                                  p_period_counter_to-1,l_period_to) THEN
716                     return FALSE;
717                 END IF;
718 
719                 IF NOT igi_iac_common_utils.get_period_info_for_counter(p_asset_balance.book_type_code,
720                                                                  p_period_counter-1,
721                                                                  l_period_open) THEN
722                     return FALSE;
723                 END IF;
724                 -- get the deprn amt per period ---
725 
726                     IF (l_period_from.fiscal_year < l_period_open.fiscal_year) AND (l_period_to.fiscal_year < l_period_open.fiscal_year) THEN
727                           igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
728                                  	     	 p_full_path => l_path_name,
729                                  	     	 p_string => 'Depreciation catch up in previous years :');
730                           l_deprn_catchup_amount := l_iac_deprn_amount_py * (p_period_counter_to - p_period_counter_from );
731                           do_round(l_deprn_catchup_amount,p_asset_balance.book_type_code);
732                           l_fa_deprn_catchup_amount := p_fa_deprn_expense_py * (p_period_counter_to - p_period_counter_from);
733                           do_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code);
734 
735                     ELSIF (l_period_from.fiscal_year < l_period_open.fiscal_year) AND (l_period_to.fiscal_year = l_period_open.fiscal_year) THEN
736                             igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
737                                  	     	 p_full_path => l_path_name,
738                                  	     	 p_string => 'Depreciation catch up in previous year and current year :');
739 
740 
741                         l_deprn_catchup_amount := (l_iac_deprn_amount_cy * l_period_to.period_num ) +
742                             (l_iac_deprn_amount_py * (p_period_counter_to - p_period_counter_from - l_period_to.period_num ));
743                         do_round(l_deprn_catchup_amount,p_asset_balance.book_type_code);
744                         l_fa_deprn_catchup_amount := (p_fa_deprn_expense_cy * l_period_to.period_num ) +
745                             (p_fa_deprn_expense_py * (p_period_counter_to - p_period_counter_from - l_period_to.period_num ));
746                         do_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code);
747 
748                     ELSIF (l_period_from.fiscal_year = l_period_open.fiscal_year) AND (l_period_to.fiscal_year = l_period_open.fiscal_year) THEN
749                            igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
750                                  	     	 p_full_path => l_path_name,
751                                  	     	 p_string => 'Depreciation catch up in current year :');
752 
753                           l_deprn_catchup_amount := l_iac_deprn_amount_cy *  (p_period_counter_to - p_period_counter_from );
754                           do_round(l_deprn_catchup_amount,p_asset_balance.book_type_code);
755                           l_fa_deprn_catchup_amount := p_fa_deprn_expense_cy * (p_period_counter_to - p_period_counter_from );
756                           do_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code);
757                     END IF;
758 
759             ELSE -- not supplied YTD
760 
761                 IF (p_asset_last_period IS NULL) THEN
762                     l_deprn_catchup_amount := l_iac_deprn_amount_py * ( p_period_counter_to - p_period_counter_from);
763                     do_round(l_deprn_catchup_amount,p_asset_balance.book_type_code);
764                     l_fa_deprn_catchup_amount := p_fa_deprn_expense_py * (p_period_counter_to - p_period_counter_from);
765                     do_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code);
766                 ELSE
767                     IF(p_asset_last_period < p_period_counter_from) THEN
768                         return TRUE;
769                     ELSIF (p_asset_last_period < p_period_counter_to) THEN
770                         l_deprn_catchup_amount := l_iac_deprn_amount_py * (p_asset_last_period - p_period_counter_from + 1);
771                         do_round(l_deprn_catchup_amount,p_asset_balance.book_type_code);
772                         l_fa_deprn_catchup_amount := p_fa_deprn_expense_py * (p_asset_last_period - p_period_counter_from + 1);
773                         do_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code);
774                     ELSE
775                         l_deprn_catchup_amount := l_iac_deprn_amount_py * ( p_period_counter_to - p_period_counter_from);
776                         do_round(l_deprn_catchup_amount,p_asset_balance.book_type_code);
777                         l_fa_deprn_catchup_amount := p_fa_deprn_expense_py * (p_period_counter_to - p_period_counter_from);
778                         do_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code);
779                     END IF;
780                 END IF;
781             END IF;
782         END IF; -- Addition and reclass
783 
784         IF (p_calling_function = 'UPGRADE') THEN
785             IF NOT igi_iac_common_utils.get_period_info_for_counter(p_asset_balance.book_type_code,
786                                                                  p_period_counter_from,
787                                                                  l_period_from) THEN
788                 return FALSE;
789             END IF;
790 
791             IF NOT igi_iac_common_utils.get_period_info_for_counter(p_asset_balance.book_type_code,
792                                                                  p_period_counter_to-1,
793                                                                  l_period_to) THEN
794                 return FALSE;
795             END IF;
796             IF NOT igi_iac_common_utils.get_period_info_for_counter(p_asset_balance.book_type_code,
797                                                                  p_period_counter,
798                                                                  l_period_open) THEN
799                 return FALSE;
800             END IF;
801             IF nvl(p_asset_last_period, l_period_to.period_counter) >= l_period_to.period_counter THEN
802                 IF l_period_to.fiscal_year < l_period_open.fiscal_year THEN
803                     l_deprn_catchup_amount := l_iac_deprn_amount_py * (p_period_counter_to - p_period_counter_from);
804                     do_round(l_deprn_catchup_amount,p_asset_balance.book_type_code);
805                     l_fa_deprn_catchup_amount := p_fa_deprn_expense_py * (p_period_counter_to - p_period_counter_from);
806                     do_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code);
807                 ELSE
808                     IF l_period_from.fiscal_year < l_period_open.fiscal_year THEN
809                         l_deprn_catchup_amount := (l_iac_deprn_amount_cy * l_period_to.period_num) +
810                             (l_iac_deprn_amount_py * (p_period_counter_to - p_period_counter_from - l_period_to.period_num ));
811                         do_round(l_deprn_catchup_amount,p_asset_balance.book_type_code);
812                         l_fa_deprn_catchup_amount := (p_fa_deprn_expense_cy * l_period_to.period_num) +
813                             (p_fa_deprn_expense_py * (p_period_counter_to - p_period_counter_from - l_period_to.period_num ));
814                         do_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code);
815                     ELSE
816                         l_deprn_catchup_amount := l_iac_deprn_amount_cy * (p_period_counter_to - p_period_counter_from);
817                         do_round(l_deprn_catchup_amount,p_asset_balance.book_type_code);
818                         l_fa_deprn_catchup_amount := p_fa_deprn_expense_cy * (p_period_counter_to - p_period_counter_from);
819                         do_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code);
820                     END IF;
821                 END IF;
822             ELSIF p_asset_last_period < p_period_counter_from THEN
823                 return TRUE;
824             ELSE
825                 IF NOT igi_iac_common_utils.get_period_info_for_counter(p_asset_balance.book_type_code,
826                                                                         p_asset_last_period,
827                                                                         l_period_reserved) THEN
828                     return FALSE;
829                 END IF;
830 
831                 IF l_period_to.fiscal_year < l_period_open.fiscal_year THEN
832                     l_deprn_catchup_amount := l_iac_deprn_amount_py * (p_asset_last_period - l_period_from.period_counter + 1);
833                     do_round(l_deprn_catchup_amount,p_asset_balance.book_type_code);
834                     l_fa_deprn_catchup_amount := p_fa_deprn_expense_py * (p_asset_last_period - l_period_from.period_counter + 1);
835                     do_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code);
836                 ELSIF l_period_to.fiscal_year = l_period_open.fiscal_year THEN
837                     IF l_period_from.fiscal_year < l_period_open.fiscal_year THEN
838                         IF l_period_reserved.fiscal_year < l_period_open.fiscal_year THEN
839                             l_deprn_catchup_amount := l_iac_deprn_amount_py * (p_asset_last_period - p_period_counter_from + 1);
840                             do_round(l_deprn_catchup_amount,p_asset_balance.book_type_code);
841                             l_fa_deprn_catchup_amount := p_fa_deprn_expense_py * (p_asset_last_period - p_period_counter_from + 1);
842                             do_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code);
843                         ELSIF l_period_reserved.fiscal_year = l_period_open.fiscal_year THEN
844                             l_deprn_catchup_amount := (l_iac_deprn_amount_cy * l_period_reserved.period_num) +
845                                 (l_iac_deprn_amount_py * (l_period_reserved.period_counter - l_period_from.period_counter - l_period_reserved.period_num));
846                             do_round(l_deprn_catchup_amount,p_asset_balance.book_type_code);
847                             l_fa_deprn_catchup_amount := (p_fa_deprn_expense_cy * l_period_reserved.period_num) +
848                                 (p_fa_deprn_expense_py * (l_period_reserved.period_counter - l_period_from.period_counter - l_period_reserved.period_num));
849                             do_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code);
850                         END IF;
851                     ELSIF l_period_from.fiscal_year = l_period_open.fiscal_year THEN
852                         l_deprn_catchup_amount := l_iac_deprn_amount_cy * (p_asset_last_period - p_period_counter_from + 1);
853                         do_round(l_deprn_catchup_amount,p_asset_balance.book_type_code);
854                         l_fa_deprn_catchup_amount := p_fa_deprn_expense_cy * (p_asset_last_period - p_period_counter_from + 1);
855                         do_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code);
856                     END IF;
857                 END IF;
858             END IF;
859 
860         END IF;
861         /* Bug 2961656 vgadde 08-jul-2003 End(5) */
862 
863         IF NOT (igi_iac_common_utils.iac_round(l_deprn_catchup_amount,p_asset_balance.book_type_code)) THEN
864             return FALSE;
865         END IF;
866 
867          IF NOT (igi_iac_common_utils.iac_round(l_fa_deprn_catchup_amount,p_asset_balance.book_type_code)) THEN
868             return FALSE;
869         END IF;
870 
871         /* Bug 2961656 vgadde 08-jul-2003 Start(6) */
872         IF NOT (igi_iac_common_utils.iac_round(l_iac_deprn_amount_py,p_asset_balance.book_type_code)) THEN
873             return FALSE;
874         END IF;
875 
876         IF NOT (igi_iac_common_utils.iac_round(l_iac_deprn_amount_cy,p_asset_balance.book_type_code)) THEN
877             return FALSE;
878         END IF;
879         /* Bug 2961656 vgadde 08-jul-2003 End(6) */
880 
881         igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
882 		     	p_full_path => l_path_name,
883 		     	p_string => '     Total Depreciation catchup amount :'||to_char(l_deprn_catchup_amount));
884         igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
885 		     	p_full_path => l_path_name,
886 		     	p_string => '	    FA Depreciation catchup amount :'||to_char(l_fa_deprn_catchup_amount));
887 
888         p_asset_balance.deprn_amount := l_iac_deprn_amount_cy;
889         p_asset_balance.net_book_value := nvl(p_asset_balance.net_book_value,0) - l_deprn_catchup_amount;
890         p_asset_balance.deprn_reserve  := nvl(p_asset_balance.deprn_reserve,0) + l_deprn_catchup_amount;
891 
892         /* Bug 2423710 vgadde 19/06/2002 Start(1) */
893         IF (p_asset_balance.adjusted_cost > 0) THEN
894 	        p_asset_balance.reval_reserve  := nvl(p_asset_balance.reval_reserve,0) - l_deprn_catchup_amount;
895 	        p_asset_balance.general_fund   := nvl(p_asset_balance.general_fund,0) + l_deprn_catchup_amount;
896         END IF;
897         /* Bug 2423710 vgadde 19/06/2002 End(1) */
898 
899         igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
900 		     	p_full_path => l_path_name,
901 		     	p_string => '------ Output Asset Record from do_deprn_catchup-----------');
902         Debug_Asset(p_asset_balance);
903 
904         IF (p_crud_iac_tables) THEN
905 
906             IF (nvl(p_asset_last_period,p_period_counter) < (p_period_counter - 1)) THEN
907                 l_last_deprn_catchup_period := p_asset_last_period;
908             ELSE
909                 l_last_deprn_catchup_period := p_period_counter - 1;
910             END IF;
911 
912             IF NOT igi_iac_common_utils.get_period_info_for_counter(p_asset_balance.book_type_code,
913                                                                         l_last_deprn_catchup_period,
914                                                                         l_last_catchup_prd_rec) THEN
915                    return FALSE;
916             END IF;
917 
918             IF NOT igi_iac_common_utils.get_period_info_for_counter(p_asset_balance.book_type_code,
919                                                                         p_period_counter_from-1,
920                                                                         l_last_reval_prd_rec) THEN
921                     return FALSE;
922             END IF;
923 
924             IF (p_calling_function <> 'UPGRADE') THEN
925 
926                 /* Accounting entries to be created */
927                 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
928 		     		p_full_path => l_path_name,
929 		     		p_string => '     Inserting records into IAC tables');
930                 IF NOT (igi_iac_common_utils.get_book_gl_info(p_asset_balance.book_type_code ,
931     		    				  l_set_of_books_id ,
932 			    				  l_chart_of_accts_id ,
933 			    				  l_currency_code ,
934 			    				  l_precision )) THEN
935                     igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
936                         p_full_path => l_path_name,
937                         p_string => '*** Error in getting book GL info - do_deprn_catchup');
938                     RETURN false;
939                 END IF;
940 
941                 l_rowid := NULL;
942                 l_adjustment_id := NULL;
943 
944                 FOR l_transaction IN c_get_transaction LOOP
945                     igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
946                         p_full_path => l_path_name,
947                         p_string => '     Transaction ID created by revaluation :'||to_char(l_transaction.adjustment_id));
948                     igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
949                         p_full_path => l_path_name,
950                         p_string => '     Inserting record into igi_iac_transaction_headers');
951                     igi_iac_trans_headers_pkg.insert_row(
952 	                       	    X_rowid		            => l_rowid ,
953                         		X_adjustment_id	        => l_adjustment_id ,
954                         		X_transaction_header_id => NULL ,
955                         		X_adjustment_id_out	    => NULL ,
956                         		X_transaction_type_code => p_calling_function ,
957                         		X_transaction_date_entered => sysdate ,
958                         		X_mass_refrence_id	    => NULL ,
959                         		X_transaction_sub_type	=> 'CATCHUP' ,
960                         		X_book_type_code	    => l_transaction.book_type_code ,
961                         		X_asset_id		        => l_transaction.asset_id ,
962                         		X_category_id		    => l_transaction.category_id ,
963                         		X_adj_deprn_start_date	=> l_transaction.adj_deprn_start_date ,
964                         		X_revaluation_type_flag => NULL,
965                         		X_adjustment_status	    => 'COMPLETE' ,
966                         		X_period_counter	    => l_transaction.period_counter,
967                                 X_event_id              =>  p_event_id) ;
968 
969                     igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
970                         p_full_path => l_path_name,
971                         p_string => '     New Adjustment Id for deprn catchup :'||to_char(l_adjustment_id));
972 
973                     igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
974                         p_full_path => l_path_name,
975                         p_string => '	    Processing Inactive distributions');
976 
977                     l_iac_inactive_dists_YTD := 0;
978                     l_fa_inactive_dists_YTD := 0;
979                     l_iac_active_dists_YTD := 0;
980                     l_fa_active_dists_YTD := 0;
981                     l_iac_all_dists_YTD := 0;
982                     l_fa_all_dists_YTD := 0;
983 
984                     FOR l_inactive_dist IN c_get_inactive_dists(l_transaction.adjustment_id) LOOP
985                         igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
986                             p_full_path => l_path_name,
987                             p_string => '	    Distribution Id :'||to_char(l_inactive_dist.distribution_id));
988 
989                         l_rowid := NULL;
990                         igi_iac_det_balances_pkg.insert_row(
991                             X_rowid                     => l_rowid ,
992                             X_adjustment_id             => l_adjustment_id ,
993                             X_asset_id                  => l_inactive_dist.asset_id ,
994                             X_distribution_id           => l_inactive_dist.distribution_id ,
995                             X_book_type_code            => l_inactive_dist.book_type_code ,
996                             X_period_counter            => p_period_counter ,
997                             X_adjustment_cost           => l_inactive_dist.adjustment_cost ,
998                             X_net_book_value            => l_inactive_dist.net_book_value ,
999                             X_reval_reserve_cost        => l_inactive_dist.reval_reserve_cost ,
1000                             X_reval_reserve_backlog     => l_inactive_dist.reval_reserve_backlog ,
1001                             X_reval_reserve_gen_fund    => l_inactive_dist.reval_reserve_gen_fund ,
1002                             X_reval_reserve_net         => l_inactive_dist.reval_reserve_net,
1003                             X_operating_acct_cost	    => l_inactive_dist.operating_acct_cost ,
1004                             X_operating_acct_backlog    => l_inactive_dist.operating_acct_backlog ,
1005                             X_operating_acct_net	    => l_inactive_dist.operating_acct_net ,
1006                             X_operating_acct_ytd	    => l_inactive_dist.operating_acct_ytd ,
1007                             X_deprn_period              => l_inactive_dist.deprn_period ,
1008                             X_deprn_ytd                 => l_inactive_dist.deprn_ytd ,
1009                             X_deprn_reserve             => l_inactive_dist.deprn_reserve ,
1010                             X_deprn_reserve_backlog	    => l_inactive_dist.deprn_reserve_backlog ,
1011                             X_general_fund_per          => l_inactive_dist.general_fund_per ,
1012                             X_general_fund_acc          => l_inactive_dist.general_fund_acc ,
1013                             X_last_reval_date           => l_inactive_dist.last_reval_date ,
1014                             X_current_reval_factor	    => l_inactive_dist.current_reval_factor ,
1015                             X_cumulative_reval_factor   => l_inactive_dist.cumulative_reval_factor ,
1016                             X_active_flag               => l_inactive_dist.active_flag ) ;
1017 
1018                             l_iac_inactive_dists_YTD := l_iac_inactive_dists_YTD + l_inactive_dist.deprn_ytd;
1019                     END LOOP; /* inactive distributions of igi_iac_det_balances */
1020 
1021                     FOR l_iac_fa_inactive_dist IN c_get_iac_fa_inactive_dists(l_transaction.adjustment_id) LOOP
1022                         l_rowid := NULL;
1023                         igi_iac_fa_deprn_pkg.insert_row(
1024                             x_rowid                     => l_rowid,
1025                             x_book_type_code            => l_iac_fa_inactive_dist.book_type_code,
1026                             x_asset_id                  => l_iac_fa_inactive_dist.asset_id,
1027                             x_distribution_id           => l_iac_fa_inactive_dist.distribution_id,
1028                             x_period_counter            => p_period_counter,
1029                             x_adjustment_id             => l_adjustment_id,
1030                             x_deprn_period              => l_iac_fa_inactive_dist.deprn_period,
1031                             x_deprn_ytd                 => l_iac_fa_inactive_dist.deprn_ytd ,
1032                             x_deprn_reserve             => l_iac_fa_inactive_dist.deprn_reserve ,
1033                             x_active_flag               => l_iac_fa_inactive_dist.active_flag,
1034                             x_mode                      => 'R');
1035                             l_fa_inactive_dists_YTD := l_fa_inactive_dists_YTD + l_iac_fa_inactive_dist.deprn_ytd;
1036                     END LOOP;
1037 
1038                     IF (l_last_catchup_prd_rec.period_num > l_last_reval_prd_rec.period_num) THEN
1039                         l_iac_all_dists_YTD := l_iac_deprn_amount_cy *
1040                                         (l_last_catchup_prd_rec.period_num - l_last_reval_prd_rec.period_num );
1041                         do_round(l_iac_all_dists_YTD,p_asset_balance.book_type_code);
1042                         l_fa_all_dists_YTD := p_fa_deprn_expense_cy *
1043                                         (l_last_catchup_prd_rec.period_num - l_last_reval_prd_rec.period_num );
1044                         do_round(l_fa_all_dists_YTD,p_asset_balance.book_type_code);
1045 
1046                         l_iac_active_dists_YTD := l_iac_all_dists_YTD ;
1047                         l_fa_active_dists_YTD := l_fa_all_dists_YTD ;
1048                     ELSE
1049                         l_iac_all_dists_YTD := l_iac_deprn_amount_cy * l_last_catchup_prd_rec.period_num;
1050                         do_round(l_iac_all_dists_YTD,p_asset_balance.book_type_code);
1051                         l_fa_all_dists_YTD := p_fa_deprn_expense_cy * l_last_catchup_prd_rec.period_num;
1052                         do_round(l_fa_all_dists_YTD,p_asset_balance.book_type_code);
1053                         l_iac_active_dists_YTD := l_iac_all_dists_YTD - l_iac_inactive_dists_YTD;
1054                         l_fa_active_dists_YTD := l_fa_all_dists_YTD - l_fa_inactive_dists_YTD;
1055                     END IF;
1056 
1057 
1058                     IF NOT igi_iac_common_utils.Prorate_Amt_to_Active_Dists( l_transaction.book_type_Code ,
1059                                                      l_transaction.Asset_id ,
1060                                                      l_deprn_catchup_amount ,
1061                                                      l_distributions_tab ) THEN
1062                         igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
1063                             p_full_path => l_path_name,
1064                             p_string => '*** Error in prorating catchup amount to active distributions');
1065                         return FALSE;
1066                     END IF;
1067 
1068                     IF NOT igi_iac_common_utils.Prorate_Amt_to_Active_Dists( l_transaction.book_type_Code ,
1069                                                      l_transaction.Asset_id ,
1070                                                      l_fa_deprn_catchup_amount ,
1071                                                      l_fa_dist_catchup_tab ) THEN
1072                         igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
1073                             p_full_path => l_path_name,
1074                             p_string => '*** Error in prorating period amount to active distributions');
1075                         return FALSE;
1076                     END IF;
1077 
1078                     igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1079                         p_full_path => l_path_name,
1080                         p_string => '     Total Number of Distributions For Asset:'||to_char(l_distributions_tab.LAST));
1081                     FOR l_idx IN l_distributions_tab.FIRST..l_distributions_tab.LAST LOOP
1082                         igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1083                             p_full_path => l_path_name,
1084                             p_string => '     Distribution id :'||to_char(l_distributions_tab(l_idx).distribution_id));
1085                         igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1086                             p_full_path => l_path_name,
1087                             p_string => '     Prorated Catchup Amount for the distribution :'||to_char(l_distributions_tab(l_idx).amount));
1088                         igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1089                             p_full_path => l_path_name,
1090                             p_string => '     Units for the distribution :'||to_char(l_distributions_tab(l_idx).units));
1091                         OPEN c_get_detail_balances(l_transaction.adjustment_id,
1092                                                 l_distributions_tab(l_idx).distribution_id);
1093                         FETCH c_get_detail_balances INTO l_detail_balance;
1094                         CLOSE c_get_detail_balances;
1095 
1096                         l_distribution_amount := l_distributions_tab(l_idx).amount;
1097                         do_round(l_distribution_amount,p_asset_balance.book_type_code);
1098                         l_dist_period_amount := l_iac_deprn_amount_cy * l_distributions_tab(l_idx).prorate_factor;
1099                         do_round(l_dist_period_amount,p_asset_balance.book_type_code);
1100 
1101                         IF NOT igi_iac_common_utils.iac_round(l_distribution_amount,
1102                                                         l_transaction.book_type_code) THEN
1103                             return FALSE;
1104                         END IF;
1105 
1106                         IF NOT igi_iac_common_utils.iac_round(l_dist_period_amount,
1107                                                         l_transaction.book_type_code) THEN
1108                             return FALSE;
1109                         END IF;
1110 
1111                         IF (l_distribution_amount <> 0) THEN
1112             		    /* Do not create accounting entries if the amount is zero */
1113 
1114                             l_rowid := NULL;
1115                             l_account_ccid := NULL ;
1116                             igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1117                                 p_full_path => l_path_name,
1118                                 p_string => '     Inserting records into igi_iac_adjustments');
1119                             IF NOT (igi_iac_common_utils.get_account_ccid(l_transaction.book_type_code ,
1120 			    						  l_transaction.asset_id ,
1121 			    						  l_distributions_tab(l_idx).distribution_id ,
1122 			    						  'DEPRN_EXPENSE_ACCT' ,
1123 			    						  l_account_ccid )) THEN
1124 
1125                                 RETURN false;
1126                             END IF;
1127                             igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1128                                 p_full_path => l_path_name,
1129                                 p_string => '     Deprn expense ccid :'||to_char(l_account_ccid));
1130                             igi_iac_adjustments_pkg.insert_row(
1131 		     		    	    X_rowid                 => l_rowid ,
1132                                 X_adjustment_id         => l_adjustment_id ,
1133                                 X_book_type_code		=> l_transaction.book_type_code ,
1134                                 X_code_combination_id	=> l_account_ccid,
1135                                 X_set_of_books_id		=> l_set_of_books_id ,
1136                                 X_dr_cr_flag            => 'DR' ,
1137                                 X_amount               	=> l_distribution_amount ,
1138                                 X_adjustment_type      	=> 'EXPENSE' ,
1139                                 X_transfer_to_gl_flag  	=> 'Y' ,
1140                                 X_units_assigned		=> l_distributions_tab(l_idx).units ,
1141                                 X_asset_id		        => l_transaction.asset_id ,
1142                                 X_distribution_id      	=> l_distributions_tab(l_idx).distribution_id ,
1143                                 X_period_counter       	=> l_transaction.period_counter,
1144                                 X_adjustment_offset_type => 'RESERVE' ,
1145                                 X_report_ccid        	=> Null,
1146                                 x_mode                  => 'R',
1147                                 X_event_id              =>  p_event_id ) ;
1148 
1149                             l_rowid := NULL;
1150                             l_account_ccid := NULL ;
1151                             IF NOT (igi_iac_common_utils.get_account_ccid(l_transaction.book_type_code ,
1152 			    						  l_transaction.asset_id ,
1153 			    						  l_distributions_tab(l_idx).distribution_id ,
1154 			    						  'DEPRN_RESERVE_ACCT' ,
1155 			    						  l_account_ccid )) THEN
1156 
1157                                 RETURN false;
1158                             END IF;
1159                             igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1160                                 p_full_path => l_path_name,
1161                                 p_string    => '     Deprn reserve ccid :'||to_char(l_account_ccid));
1162                             igi_iac_adjustments_pkg.insert_row(
1163                                 X_rowid                 => l_rowid ,
1164                                 X_adjustment_id         => l_adjustment_id ,
1165                                 X_book_type_code		=> l_transaction.book_type_code ,
1166                                 X_code_combination_id	=> l_account_ccid,
1167                                 X_set_of_books_id		=> l_set_of_books_id ,
1168                                 X_dr_cr_flag            => 'CR' ,
1169                                 X_amount               	=> l_distribution_amount ,
1170                                 X_adjustment_type      	=> 'RESERVE' ,
1171                                 X_transfer_to_gl_flag  	=> 'Y' ,
1172                                 X_units_assigned		=> l_distributions_tab(l_idx).units ,
1173                                 X_asset_id		        => l_transaction.asset_id ,
1174                                 X_distribution_id      	=> l_distributions_tab(l_idx).distribution_id ,
1175                                 X_period_counter       	=> l_transaction.period_counter,
1176                                 X_adjustment_offset_type => 'EXPENSE' ,
1177                                 X_report_ccid        	=> Null,
1178                                 x_mode                  => 'R',
1179                                 X_event_id              =>  p_event_id ) ;
1180 
1181                             IF (p_asset_balance.adjusted_cost > 0) THEN
1182 
1183                                 l_rowid := NULL;
1184                                 l_account_ccid := NULL ;
1185                                 l_reval_rsv_ccid := Null;
1186 
1187                                 IF NOT (igi_iac_common_utils.get_account_ccid(l_transaction.book_type_code ,
1188 			    						  l_transaction.asset_id ,
1189 			    						  l_distributions_tab(l_idx).distribution_id ,
1190 			    						  'REVAL_RESERVE_ACCT' ,
1191 			    						  l_account_ccid )) THEN
1192 
1193                                     RETURN false;
1194                                 END IF;
1195                                 l_reval_rsv_ccid :=l_account_ccid;
1196                                 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1197                                     p_full_path => l_path_name,
1198                                     p_string => '     Reval reserve ccid :'||to_char(l_account_ccid));
1199                                 igi_iac_adjustments_pkg.insert_row(
1200                                     X_rowid                 => l_rowid ,
1201                                     X_adjustment_id         => l_adjustment_id ,
1202                                     X_book_type_code        => l_transaction.book_type_code ,
1203                                     X_code_combination_id	=> l_account_ccid,
1204                                     X_set_of_books_id       => l_set_of_books_id ,
1205                                     X_dr_cr_flag            => 'DR' ,
1206                                     X_amount               	=> l_distribution_amount ,
1207                                     X_adjustment_type      	=> 'REVAL RESERVE' ,
1208                                     X_transfer_to_gl_flag  	=> 'Y' ,
1209                                     X_units_assigned        => l_distributions_tab(l_idx).units ,
1210                                     X_asset_id		        => l_transaction.asset_id ,
1211                                     X_distribution_id      	=> l_distributions_tab(l_idx).distribution_id ,
1212                                     X_period_counter       	=> l_transaction.period_counter,
1213                                     X_adjustment_offset_type => 'GENERAL FUND' ,
1214                                     X_report_ccid        	=> Null ,
1215                                     x_mode                  => 'R',
1216                                     X_event_id              =>  p_event_id ) ;
1217 
1218                                 l_rowid := NULL;
1219                                 l_account_ccid := NULL ;
1220                                 IF NOT (igi_iac_common_utils.get_account_ccid(l_transaction.book_type_code ,
1221 			    						  l_transaction.asset_id ,
1222 			    						  l_distributions_tab(l_idx).distribution_id ,
1223 			    						  'GENERAL_FUND_ACCT' ,
1224 			    						  l_account_ccid )) THEN
1225 
1226                                     RETURN false;
1227                                 END IF;
1228                                 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1229                                     p_full_path => l_path_name,
1230                                     p_string => '     General Fund ccid :'||to_char(l_account_ccid));
1231                                 igi_iac_adjustments_pkg.insert_row(
1232                                     X_rowid                 => l_rowid ,
1233                                     X_adjustment_id         => l_adjustment_id ,
1234                                     X_book_type_code		=> l_transaction.book_type_code ,
1235                                     X_code_combination_id	=> l_account_ccid,
1236                                     X_set_of_books_id       => l_set_of_books_id ,
1237                                     X_dr_cr_flag            => 'CR' ,
1238                                     X_amount               	=> l_distribution_amount ,
1239                                     X_adjustment_type      	=> 'GENERAL FUND' ,
1240                                     X_transfer_to_gl_flag  	=> 'Y' ,
1241                                     X_units_assigned		=> l_distributions_tab(l_idx).units ,
1242                                     X_asset_id		        => l_transaction.asset_id ,
1243                                     X_distribution_id      	=> l_distributions_tab(l_idx).distribution_id ,
1244                                     X_period_counter       	=> l_transaction.period_counter,
1245                                     X_adjustment_offset_type => 'REVAL RESERVE' ,
1246                                     X_report_ccid        	=> l_reval_rsv_ccid ,
1247                                     x_mode                  => 'R',
1248                                     X_event_id              =>  p_event_id ) ;
1249 
1250                             END IF; /* End of checking adjusted_cost > 0 */
1251                         END IF; /* End of distribution amount is not zero */
1252 
1253                         /* Bug 2423710 vgadde 19/06/2002 Start(2) */
1254                         IF (p_asset_balance.adjusted_cost > 0) THEN
1255                             l_reval_reserve_net := nvl(l_detail_balance.reval_reserve_net,0) - l_distribution_amount;
1256                             l_reval_general_fund := nvl(l_detail_balance.reval_reserve_gen_fund,0) + l_distribution_amount;
1257                             l_general_fund_acc := nvl(l_detail_balance.general_fund_acc,0) + l_distribution_amount;
1258                         ELSE
1259                             l_reval_reserve_net := nvl(l_detail_balance.reval_reserve_net,0) ;
1260                             l_reval_general_fund := nvl(l_detail_balance.reval_reserve_gen_fund,0) ;
1261                             l_general_fund_acc := nvl(l_detail_balance.general_fund_acc,0) ;
1262                         END IF;
1263                         /* Bug 2423710 vgadde 19/06/2002 End(2) */
1264 
1265                         IF (l_last_catchup_prd_rec.period_counter < p_period_counter - 1) THEN
1266                             l_iac_deprn_period_amount := 0;
1267                         ELSE
1268                             l_iac_deprn_period_amount := l_dist_period_amount;
1269                         END IF;
1270 
1271                         IF (l_last_catchup_prd_rec.period_num > l_last_reval_prd_rec.period_num) THEN
1272                             l_deprn_ytd := l_detail_balance.deprn_ytd + (l_iac_active_dists_YTD * l_distributions_tab(l_idx).prorate_factor);
1273                             do_round(l_deprn_ytd,p_asset_balance.book_type_code);
1274                         ELSE
1275                             l_deprn_ytd := (l_iac_active_dists_YTD * l_distributions_tab(l_idx).prorate_factor);
1276                             do_round(l_deprn_ytd,p_asset_balance.book_type_code);
1277                         END IF;
1278 
1279                         IF NOT igi_iac_common_utils.iac_round(l_deprn_ytd,
1280                                                         l_transaction.book_type_code) THEN
1281                             return FALSE;
1282                         END IF;
1283 
1284                         igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1285                             p_full_path => l_path_name,
1286                             p_string => '     Inserting into igi_iac_det_balances ');
1287                         l_rowid := NULL;
1288                         igi_iac_det_balances_pkg.insert_row(
1289                         		X_rowid                     => l_rowid ,
1290 			     		    X_adjustment_id		    => l_adjustment_id ,
1291     					    X_asset_id		    => l_detail_balance.asset_id ,
1292 	    				    X_distribution_id	    => l_detail_balance.distribution_id ,
1293 		    			    X_book_type_code	    => l_detail_balance.book_type_code ,
1294 			    		    X_period_counter	    => l_detail_balance.period_counter ,
1295 				    	    X_adjustment_cost	    => l_detail_balance.adjustment_cost ,
1296                             X_net_book_value	    => l_detail_balance.net_book_value - l_distribution_amount ,
1297         				    X_reval_reserve_cost	    => l_detail_balance.reval_reserve_cost ,
1298 		    			    X_reval_reserve_backlog     => l_detail_balance.reval_reserve_backlog ,
1299 			    		    X_reval_reserve_gen_fund    => l_reval_general_fund ,
1300 				    	    X_reval_reserve_net	    => l_reval_reserve_net,
1301                             X_operating_acct_cost	    => l_detail_balance.operating_acct_cost ,
1302     					    X_operating_acct_backlog    => l_detail_balance.operating_acct_backlog ,
1303 	    				    X_operating_acct_net	    => l_detail_balance.operating_acct_net ,
1304  		    			    X_operating_acct_ytd	    => l_detail_balance.operating_acct_ytd ,
1305 			    		    X_deprn_period		    => l_iac_deprn_period_amount ,
1306  				    	    X_deprn_ytd		    => l_deprn_ytd ,
1307                             X_deprn_reserve		    => l_detail_balance.deprn_reserve + l_distribution_amount ,
1308     					    X_deprn_reserve_backlog	    => l_detail_balance.deprn_reserve_backlog ,
1309 	    				    X_general_fund_per	    => l_distribution_amount ,
1310 		    			    X_general_fund_acc	    => l_general_fund_acc ,
1311  			    		    X_last_reval_date	    => l_detail_balance.last_reval_date ,
1312 				    	    X_current_reval_factor	    => l_detail_balance.current_reval_factor ,
1313                             X_cumulative_reval_factor   =>l_detail_balance.cumulative_reval_factor ,
1314      					    X_active_flag		    => l_detail_balance.active_flag ) ;
1315 
1316                         igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1317                             p_full_path => l_path_name,
1318                             p_string => '     distribution YTD:'||to_char(l_deprn_ytd));
1319 
1320                     END LOOP; /* End of Processing each distribution */
1321 
1322                     IF (l_last_catchup_prd_rec.period_counter < p_period_counter - 1) THEN
1323                         l_iac_deprn_period_amount := 0;
1324                     ELSE
1325                         l_iac_deprn_period_amount := p_asset_balance.deprn_amount;
1326                     END IF;
1327 
1328                     igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1329                         p_full_path => l_path_name,
1330                         p_string => '     Updating asset balances record for the current period');
1331                     igi_iac_asset_balances_pkg.update_row(
1332 		    			X_asset_id		=> p_asset_balance.asset_id ,
1333 				    	X_book_type_code	=> p_asset_balance.book_type_code ,
1334     					X_period_counter	=> p_period_counter ,
1335 	    				X_net_book_value	=> p_asset_balance.net_book_value ,
1336 		    			X_adjusted_cost		=> p_asset_balance.adjusted_cost ,
1337 			    		X_operating_acct	=> p_asset_balance.operating_acct ,
1338 				    	X_reval_reserve		=> p_asset_balance.reval_reserve ,
1339                         X_deprn_amount		=> l_iac_deprn_period_amount ,
1340     					X_deprn_reserve		=> p_asset_balance.deprn_reserve ,
1341 	    				X_backlog_deprn_reserve => p_asset_balance.backlog_deprn_reserve ,
1342 		    			X_general_fund		=> p_asset_balance.general_fund ,
1343 			    		X_last_reval_date	=> p_asset_balance.last_reval_date ,
1344 				    	X_current_reval_factor	=> p_asset_balance.current_reval_factor ,
1345                         X_cumulative_reval_factor => p_asset_balance.cumulative_reval_factor ) ;
1346 
1347                     igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1348                         p_full_path => l_path_name,
1349                         p_string => '	    Updating asset balances record for the next period');
1350                     igi_iac_asset_balances_pkg.update_row(
1351 		    			X_asset_id		=> p_asset_balance.asset_id ,
1352 				    	X_book_type_code	=> p_asset_balance.book_type_code ,
1353     					X_period_counter	=> p_period_counter + 1 ,
1354 	    				X_net_book_value	=> p_asset_balance.net_book_value ,
1355 		    			X_adjusted_cost		=> p_asset_balance.adjusted_cost ,
1356 			    		X_operating_acct	=> p_asset_balance.operating_acct ,
1357 				    	X_reval_reserve		=> p_asset_balance.reval_reserve ,
1358                         X_deprn_amount		=> l_iac_deprn_period_amount ,
1359     					X_deprn_reserve		=> p_asset_balance.deprn_reserve ,
1360 	    				X_backlog_deprn_reserve => p_asset_balance.backlog_deprn_reserve ,
1361 		    			X_general_fund		=> p_asset_balance.general_fund ,
1362 			    		X_last_reval_date	=> p_asset_balance.last_reval_date ,
1363 				    	X_current_reval_factor	=> p_asset_balance.current_reval_factor ,
1364                         X_cumulative_reval_factor => p_asset_balance.cumulative_reval_factor ) ;
1365 
1366 
1367                     FOR l_idx IN l_fa_dist_catchup_tab.FIRST..l_fa_dist_catchup_tab.LAST LOOP
1368 
1369                         OPEN c_get_iac_fa_deprn_rec(l_transaction.adjustment_id, l_fa_dist_catchup_tab(l_idx).distribution_id);
1370                         FETCH c_get_iac_fa_deprn_rec INTO l_iac_fa_deprn_rec;
1371                         CLOSE c_get_iac_fa_deprn_rec;
1372 
1373                         IF (l_last_catchup_prd_rec.period_num > l_last_reval_prd_rec.period_num) THEN
1374                     		l_deprn_ytd := l_iac_fa_deprn_rec.deprn_ytd + (l_fa_active_dists_YTD * l_fa_dist_catchup_tab(l_idx).prorate_factor);
1375                         do_round(l_deprn_ytd,p_asset_balance.book_type_code);
1376                         ELSE
1377                     		l_deprn_ytd := (l_fa_active_dists_YTD * l_fa_dist_catchup_tab(l_idx).prorate_factor);
1378                         do_round(l_deprn_ytd,p_asset_balance.book_type_code);
1379                         END IF;
1380 
1381                         IF (l_last_catchup_prd_rec.period_counter < p_period_counter - 1) THEN
1382                     		l_fa_deprn_period_amount := 0;
1383                         ELSE
1384                     		l_fa_deprn_period_amount := p_fa_deprn_expense_cy * l_fa_dist_catchup_tab(l_idx).prorate_factor;
1385                         do_round(l_fa_deprn_period_amount,p_asset_balance.book_type_code);
1386                         END IF;
1387 
1388                         IF NOT igi_iac_common_utils.iac_round(l_fa_deprn_period_amount,
1389                                                         l_iac_fa_deprn_rec.book_type_code) THEN
1390                        		return FALSE;
1391                         END IF;
1392 
1393                         IF NOT igi_iac_common_utils.iac_round(l_deprn_ytd,
1394                                                         l_iac_fa_deprn_rec.book_type_code) THEN
1395                        		return FALSE;
1396                         END IF;
1397 
1398                         IF NOT igi_iac_common_utils.iac_round(l_fa_dist_catchup_tab(l_idx).amount,
1399                                                         l_iac_fa_deprn_rec.book_type_code) THEN
1400                        		return FALSE;
1401                         END IF;
1402 
1403                         l_rowid := NULL;
1404                         igi_iac_fa_deprn_pkg.insert_row(
1405                             x_rowid			=> l_rowid,
1406                             x_book_type_code	=> l_iac_fa_deprn_rec.book_type_code,
1407                             x_asset_id		=> l_iac_fa_deprn_rec.asset_id,
1408                             x_distribution_id	=> l_iac_fa_deprn_rec.distribution_id,
1409                             x_period_counter	=> p_period_counter,
1410                             x_adjustment_id		=> l_adjustment_id,
1411                             x_deprn_period		=> l_fa_deprn_period_amount,
1412                             x_deprn_ytd		=> l_deprn_ytd ,
1413                             x_deprn_reserve		=> l_iac_fa_deprn_rec.deprn_reserve + l_fa_dist_catchup_tab(l_idx).amount,
1414                             x_active_flag		=> l_iac_fa_deprn_rec.active_flag,
1415                             x_mode			=> 'R');
1416                         igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1417                             p_full_path => l_path_name,
1418                             p_string => '     distribution FA YTD:'||to_char(l_deprn_ytd));
1419 
1420                     END LOOP; /* processing distributions for igi_iac_fa_deprn */
1421 
1422 
1423                     igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1424                         p_full_path => l_path_name,
1425                         p_string => '     Closing the previous transaction created by IAC revaluation');
1426                     igi_iac_trans_headers_pkg.update_row(
1427 		    			X_prev_adjustment_id	=> l_transaction.adjustment_id ,
1428 					    X_adjustment_id		    => l_adjustment_id ) ;
1429 
1430                 END LOOP; /* End of Processing the transaction */
1431             ELSE /* calling function is UPGRADE */
1432 
1433                 FOR l_upgrade_rec IN c_get_upgrade_rec LOOP
1434                     igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1435                         p_full_path => l_path_name,
1436                         p_string => '     Processing for upgrade. Updating the record');
1437 
1438                     /* Bug 2961656 vgadde 08-Jul-2003 Start(7) */
1439             	    IF p_fa_deprn_ytd IS NOT NULL THEN
1440                         l_deprn_ytd := p_fa_deprn_ytd;
1441             	    ELSE
1442                         l_deprn_ytd := p_fa_deprn_expense_cy * l_last_catchup_prd_rec.period_num;
1443                         do_round(l_deprn_ytd,p_asset_balance.book_type_code);
1444             	    END IF;
1445                     l_fa_deprn_acc := p_fa_deprn_reserve;
1446                     /* Bug 2961656 vgadde 08-Jul-2003 End(7) */
1447 
1448                     IF (l_last_catchup_prd_rec.period_counter < p_period_counter - 1) THEN
1449                         l_iac_deprn_period_amount := 0;
1450                         l_fa_deprn_period_amount := 0;
1451                     ELSE
1452                         l_fa_deprn_period_amount := p_fa_deprn_expense_cy;
1453                         l_iac_deprn_period_amount := p_asset_balance.deprn_amount;
1454                     END IF;
1455 
1456                     UPDATE igi_imp_iac_interface_py_add
1457                     SET net_book_value  	= p_asset_balance.net_book_value,
1458                         adjusted_cost   	= p_asset_balance.adjusted_cost,
1459                         operating_acct  	= p_asset_balance.operating_acct,
1460                         reval_reserve   	= p_asset_balance.reval_reserve,
1461                         deprn_amount    	= l_iac_deprn_period_amount,
1462                         deprn_reserve   	= p_asset_balance.deprn_reserve,
1463                         backlog_deprn_reserve 	= p_asset_balance.backlog_deprn_reserve,
1464                         general_fund    	= p_asset_balance.general_fund,
1465                         hist_deprn_expense      = l_fa_deprn_period_amount,
1466                         hist_accum_deprn 	= l_fa_deprn_acc,
1467                         hist_ytd		= l_deprn_ytd,
1468                         hist_nbv		= l_upgrade_rec.hist_cost - l_fa_deprn_acc,
1469                         general_fund_periodic   = p_asset_balance.deprn_amount
1470                     WHERE   asset_id = l_upgrade_rec.asset_id
1471                     AND     book_type_code = l_upgrade_rec.book_type_code
1472                     AND     period_counter = l_upgrade_rec.period_counter;
1473 
1474                 END LOOP;
1475             END IF; /* End of check for calling function */
1476         END IF; /* End of check for CRUD allowed */
1477         igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1478             p_full_path => l_path_name,
1479             p_string => ' End of Processing by Do_Deprn_Catchup');
1480         return TRUE;
1481 
1482         EXCEPTION
1483             WHEN OTHERS THEN
1484   		        igi_iac_debug_pkg.debug_unexpected_msg(p_full_path => l_path_name);
1485                 return FALSE;
1486     END Do_Deprn_Catchup;
1487 
1488     FUNCTION do_reval_init_struct(
1489                     p_period_counter        IN NUMBER,
1490                     p_reval_control         IN OUT NOCOPY igi_iac_types.iac_reval_control_tab,
1491                     p_reval_asset_params    IN OUT NOCOPY igi_iac_types.iac_reval_asset_params_tab,
1492                     p_reval_input_asset     IN OUT NOCOPY igi_iac_types.iac_reval_asset_tab,
1493                     p_reval_output_asset    IN OUT NOCOPY igi_iac_types.iac_reval_asset_tab,
1494                     p_reval_output_asset_mvmt IN OUT NOCOPY igi_iac_types.iac_reval_asset_tab,
1495                     p_reval_asset_rules     IN OUT NOCOPY igi_iac_types.iac_reval_asset_rules_tab,
1496                     p_prev_rate_info        IN OUT NOCOPY igi_iac_types.iac_reval_rates_tab,
1497                     p_curr_rate_info_first  IN OUT NOCOPY igi_iac_types.iac_reval_rates_tab,
1498                     p_curr_rate_info_next   IN OUT NOCOPY igi_iac_types.iac_reval_rates_tab,
1499                     p_curr_rate_info        IN OUT NOCOPY igi_iac_types.iac_reval_rates_tab,
1500                     p_reval_exceptions      IN OUT NOCOPY igi_iac_types.iac_reval_exceptions_tab,
1501                     p_fa_asset_info         IN OUT NOCOPY igi_iac_types.iac_reval_fa_asset_info_tab,
1502                     p_fa_deprn_expense_py   IN NUMBER,
1503                     p_fa_deprn_expense_cy   IN NUMBER,
1504                     p_asset_last_period     IN NUMBER,
1505                     p_calling_function      IN VARCHAR2
1506                     ) return BOOLEAN IS
1507 
1508         CURSOR c_fa_asset_info IS
1509         SELECT cost,
1510                 adjusted_cost,
1511                 original_cost,
1512                 salvage_value,
1513                 life_in_months,
1514                 rate_adjustment_factor,
1515                 period_counter_fully_reserved,
1516                 adjusted_recoverable_cost,
1517                 recoverable_cost,
1518                 date_placed_in_service,
1519                 0 deprn_periods_elapsed,
1520                 0 deprn_periods_current_year,
1521                 0 deprn_periods_prior_year,
1522                 last_period_counter,
1523                 gl_posting_allowed_flag,
1524                 0 ytd_deprn,
1525                 0 deprn_reserve,
1526                 0 pys_deprn_reserve,
1527                 0 deprn_amount,
1528                 deprn_start_date,
1529                 depreciate_flag
1530         FROM    fa_books b, fa_book_controls c
1531         WHERE   b.book_type_code = p_reval_asset_params(1).book_type_code
1532         AND     c.book_type_code = p_reval_asset_params(1).book_type_code
1533         AND     b.asset_id = p_reval_asset_params(1).asset_id
1534         AND     b.transaction_header_id_out IS NULL;
1535 
1536 
1537         CURSOR c_get_user_deprn IS
1538         SELECT period_counter,deprn_reserve,YTD_deprn
1539         FROM fa_deprn_summary
1540         WHERE book_type_code = p_reval_asset_params(1).book_type_code
1541         AND asset_id = p_reval_asset_params(1).asset_id
1542         AND deprn_source_code = 'BOOKS';
1543 
1544 
1545         l_user_id           NUMBER ;
1546         l_login_id          NUMBER ;
1547         l_prev_price_index  NUMBER;
1548         l_dpis_price_index  NUMBER;
1549         l_curr_price_index  NUMBER;
1550         l_curr_period       igi_iac_types.prd_rec;
1551         l_dpis_period       igi_iac_types.prd_rec;
1552 	/* Bug 2961656 vgadde 08-jul-2003 Start(8) */
1553         l_open_period       igi_iac_types.prd_rec;
1554         l_last_catchup_period igi_iac_types.prd_rec;
1555         l_last_deprn_period igi_iac_types.prd_rec;
1556         l_fa_asset_info     igi_iac_types.fa_hist_asset_info;
1557         l_reval_factor      NUMBER;
1558         l_last_deprn_date   DATE;
1559 	/* Bug 2961656 vgadde 08-jul-2003 End(8) */
1560         l_path_name VARCHAR2(150);
1561         l_booksrow_period_rec igi_iac_types.prd_rec;
1562         l_deprn_calendar    fa_calendar_types.calendar_type%TYPE;
1563         l_periods_in_year   fa_calendar_types.number_per_fiscal_year%TYPE;
1564         l_booksrow_period   NUMBER;
1565         l_booksrow_reserve  NUMBER;
1566         l_booksrow_YTD  NUMBER;
1567         l_fa_deprn_expense_py   NUMBER;
1568         l_fa_deprn_expense_cy   NUMBER;
1569 
1570     BEGIN
1571          IF FND_PROFILE.VALUE('IGI_DEBUG_OPTION') = 'Y'  THEN
1572                 g_debug := TRUE;
1573          END IF;
1574         l_path_name := g_path||'do_reval_init_struct';
1575         l_user_id            := fnd_global.user_id;
1576         l_login_id           := fnd_global.login_id;
1577 
1578         	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1579 		                                         p_full_path => l_path_name,
1580 		                                         p_string => '-----------Start of processing by do_reval_init_struct');
1581         OPEN c_fa_asset_info;
1582         FETCH c_fa_asset_info INTO l_fa_asset_info;
1583         CLOSE c_fa_asset_info;
1584 
1585         IF NOT igi_iac_common_utils.get_period_info_for_date(
1586                                          p_reval_asset_params(1).book_type_code,
1587                                          l_fa_asset_info.date_placed_in_service,
1588                                          l_dpis_period) THEN
1589              return FALSE;
1590         END IF;
1591   	        igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1592 		                                         p_full_path => l_path_name,
1593                                                  p_string => '    DPIS Period Info');
1594         	Debug_Period(l_dpis_period);
1595 
1596         IF NOT igi_iac_common_utils.get_price_index_value(
1597                                         p_reval_asset_params(1).book_type_code,
1598                                         p_reval_asset_params(1).asset_id,
1599                                         l_dpis_period.period_name,
1600                                         l_dpis_price_index) THEN
1601             return FALSE;
1602         END IF;
1603       	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1604 	                                	     p_full_path => l_path_name,
1605                                 		     p_string => '     Price Index for DPIS :'||to_char(l_dpis_price_index));
1606         l_prev_price_index := l_dpis_price_index;
1607 
1608 	/* Bug 2961656 vgadde 08-jul-2003 Start(9) */
1609         /*IF NOT get_FA_Deprn_Expense(p_reval_asset_params(1).asset_id,
1610                                  p_reval_asset_params(1).book_type_code,
1611                                  p_period_counter,
1612                                  p_calling_function,
1613                                  l_fa_deprn_amount,
1614                                  l_last_asset_period) THEN
1615                 return FALSE;
1616         END IF;*/
1617 	/* Bug 2961656 vgadde 08-jul-2003 End(9) */
1618 
1619        ---Get the details for supplied depreciation and YTD --------
1620        IF (p_calling_function = 'ADDITION' OR p_calling_function = 'RECLASS') THEN
1621 
1622             OPEN c_get_user_deprn;
1623             FETCH c_get_user_deprn INTO l_booksrow_period, l_booksrow_reserve,l_booksrow_ytd;
1624             CLOSE c_get_user_deprn;
1625 
1626     	   /* OPEN c_get_deprn_calendar;
1627 	        FETCH c_get_deprn_calendar INTO l_deprn_calendar;
1628 	        CLOSE c_get_deprn_calendar;
1629 
1630     	    OPEN c_get_periods_in_year(l_deprn_calendar);
1631 	        FETCH c_get_periods_in_year INTO l_periods_in_year;
1632 	        CLOSE c_get_periods_in_year;*/
1633 
1634        END IF;
1635        ---Get the details for supplied depreciation and YTD --------
1636 
1637 
1638         FOR idx IN p_reval_control.FIRST..p_reval_control.LAST LOOP
1639 
1640             IF NOT (igi_iac_common_utils.get_period_info_for_counter(
1641                                         p_reval_asset_params(idx).book_type_code,
1642                                         p_reval_asset_params(idx).period_counter,
1643                                         l_curr_period)) THEN
1644                 return FALSE;
1645             END IF;
1646 
1647             IF NOT (igi_iac_common_utils.get_price_index_value(
1648                                         p_reval_asset_params(idx).book_type_code,
1649                                         p_reval_asset_params(idx).asset_id,
1650                                         l_curr_period.period_name,
1651                                         l_curr_price_index)) THEN
1652                 return FALSE;
1653             END IF;
1654   	             igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1655 		     p_full_path => l_path_name,
1656 		     p_string => '     Price Index for current revaluation catchup period :'||to_char(l_curr_price_index));
1657 
1658             l_reval_factor := l_curr_price_index / l_prev_price_index ;
1659   	         igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1660 		     p_full_path => l_path_name,
1661 		     p_string => '     Current Reval Factor : '||to_char(l_reval_factor));
1662             IF (idx = p_reval_control.FIRST) THEN
1663   		            igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1664 		     	p_full_path => l_path_name,
1665 		     	p_string => '     Initialization for First revaluation ');
1666                 p_reval_control(idx).first_time_flag := TRUE;
1667 
1668   		                igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1669 		     	p_full_path => l_path_name,
1670 		     	p_string => '     Initializing reval input asset');
1671                 p_reval_input_asset(idx).asset_id := p_reval_asset_params(idx).asset_id;
1672                 p_reval_input_asset(idx).book_type_code := p_reval_asset_params(idx).book_type_code;
1673                 p_reval_input_asset(idx).period_counter := p_reval_asset_params(idx).period_counter;
1674                 p_reval_input_asset(idx).net_book_value := 0;
1675                 p_reval_input_asset(idx).adjusted_cost := 0;
1676                 p_reval_input_asset(idx).operating_acct := 0;
1677                 p_reval_input_asset(idx).reval_reserve := 0;
1678                 p_reval_input_asset(idx).deprn_amount := 0;
1679                 p_reval_input_asset(idx).deprn_reserve := 0;
1680                 p_reval_input_asset(idx).backlog_deprn_reserve := 0;
1681                 p_reval_input_asset(idx).general_fund := 0;
1682                 p_reval_input_asset(idx).last_reval_date := sysdate;
1683                 p_reval_input_asset(idx).current_reval_factor := l_reval_factor;
1684                 p_reval_input_asset(idx).cumulative_reval_factor := l_reval_factor;
1685                 p_reval_input_asset(idx).created_by := l_user_id;
1686                 p_reval_input_asset(idx).creation_date := sysdate;
1687                 p_reval_input_asset(idx).last_update_login := l_login_id;
1688                 p_reval_input_asset(idx).last_update_date := sysdate;
1689                 p_reval_input_asset(idx).last_updated_by := l_user_id;
1690 
1691   	        	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1692 		     	p_full_path => l_path_name,
1693 		     	p_string => '     Initializing previous rate info');
1694                 p_prev_rate_info(idx).asset_id := p_reval_asset_params(idx).asset_id;
1695                 p_prev_rate_info(idx).book_type_code := p_reval_asset_params(idx).book_type_code;
1696                 p_prev_rate_info(idx).period_counter := p_reval_asset_params(idx).period_counter;
1697                 p_prev_rate_info(idx).revaluation_id := 0;
1698                 p_prev_rate_info(idx).current_reval_factor := 1;
1699                 p_prev_rate_info(idx).cumulative_reval_factor := 1;
1700                 p_prev_rate_info(idx).processed_flag := 'Y';
1701                 p_prev_rate_info(idx).latest_record := 'Y';
1702                 p_prev_rate_info(idx).created_by := l_user_id;
1703                 p_prev_rate_info(idx).creation_date := sysdate;
1704                 p_prev_rate_info(idx).last_update_login := l_login_id;
1705                 p_prev_rate_info(idx).last_update_date := sysdate;
1706                 p_prev_rate_info(idx).last_updated_by := l_user_id;
1707                 p_prev_rate_info(idx).adjustment_id := 0;
1708 
1709                 p_curr_rate_info(idx).cumulative_reval_factor := l_reval_factor;
1710 
1711             ELSE
1712 
1713                 p_reval_control(idx).first_time_flag := FALSE;
1714                 p_prev_rate_info(idx) := p_curr_rate_info(idx-1);
1715                 p_curr_rate_info(idx).current_reval_factor := l_reval_factor;
1716                 p_curr_rate_info(idx).cumulative_reval_factor :=
1717                                 l_reval_factor * p_curr_rate_info(idx-1).cumulative_reval_factor;
1718                 p_reval_input_asset(idx).current_reval_factor := l_reval_factor;
1719                 p_reval_input_asset(idx).cumulative_reval_factor :=
1720                                 p_curr_rate_info(idx).cumulative_reval_factor;
1721             END IF;
1722 
1723             IF (idx = p_reval_control.LAST) THEN
1724   		        igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1725 		     	p_full_path => l_path_name,
1726 		     	p_string => '     Last revaluation - setting CRUD flags to TRUE');
1727                 p_reval_control(idx).create_acctg_entries := TRUE;
1728                 p_reval_control(idx).crud_allowed := TRUE;
1729                 p_reval_control(idx).modify_balances := TRUE;
1730             ELSE
1731                 p_reval_control(idx).create_acctg_entries := FALSE;
1732                 p_reval_control(idx).crud_allowed := FALSE;
1733                 p_reval_control(idx).modify_balances := FALSE;
1734             END IF;
1735 
1736   	             igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1737 		     p_full_path => l_path_name,
1738 		     p_string => '     Initializing reval control structure');
1739             p_reval_control(idx).transaction_type_code := p_calling_function;
1740             p_reval_control(idx).transaction_sub_type := 'REVALUATION';
1741             p_reval_control(idx).adjustment_status := 'COMPLETE';
1742             p_reval_control(idx).validate_business_rules := FALSE;
1743             p_reval_control(idx).message_level := 3;
1744             p_reval_control(idx).commit_flag := FALSE;
1745             p_reval_control(idx).print_report := FALSE;
1746             p_reval_control(idx).mixed_scenario := FALSE;
1747             p_reval_control(idx).show_exceptions := FALSE;
1748 
1749   	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1750 		     p_full_path => l_path_name,
1751 		     p_string => '     Initializing reval asset params');
1752             p_reval_asset_params(idx).revaluation_rate := l_reval_factor;
1753             p_reval_asset_params(idx).revaluation_date := sysdate;
1754             p_reval_asset_params(idx).first_set_adjustment_id := 0;
1755             p_reval_asset_params(idx).second_set_adjustment_id := 0;
1756 
1757   	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1758 		     p_full_path => l_path_name,
1759 		     p_string => '     Initializing reval out NOCOPY put asset');
1760             p_reval_output_asset(idx) := p_reval_input_asset(idx);
1761 
1762   	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1763 		     p_full_path => l_path_name,
1764 		     p_string => '     Initializing reval output asset mvmt ');
1765             p_reval_output_asset_mvmt(idx) := p_reval_input_asset(idx);
1766             p_reval_output_asset_mvmt(idx).net_book_value := 0;
1767             p_reval_output_asset_mvmt(idx).adjusted_cost := 0;
1768             p_reval_output_asset_mvmt(idx).operating_acct := 0;
1769             p_reval_output_asset_mvmt(idx).reval_reserve := 0;
1770             p_reval_output_asset_mvmt(idx).deprn_amount := 0;
1771             p_reval_output_asset_mvmt(idx).deprn_reserve := 0;
1772             p_reval_output_asset_mvmt(idx).backlog_deprn_reserve := 0;
1773             p_reval_output_asset_mvmt(idx).general_fund := 0;
1774 
1775   	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1776 		     p_full_path => l_path_name,
1777 		     p_string => '     Initializing current rate info');
1778             p_curr_rate_info(idx).asset_id := p_reval_asset_params(idx).asset_id;
1779             p_curr_rate_info(idx).book_type_code := p_reval_asset_params(idx).book_type_code;
1780             p_curr_rate_info(idx).period_counter := p_reval_asset_params(idx).period_counter;
1781             p_curr_rate_info(idx).revaluation_id := 0;
1782             p_curr_rate_info(idx).reval_type := p_reval_asset_rules(idx).revaluation_type;
1783             p_curr_rate_info(idx).current_reval_factor := l_reval_factor;
1784             p_curr_rate_info(idx).processed_flag := 'Y';
1785             p_curr_rate_info(idx).latest_record := 'Y';
1786             p_curr_rate_info(idx).created_by := l_user_id;
1787             p_curr_rate_info(idx).creation_date := sysdate;
1788             p_curr_rate_info(idx).last_update_login := l_login_id;
1789             p_curr_rate_info(idx).last_update_date := sysdate;
1790             p_curr_rate_info(idx).last_updated_by := l_user_id;
1791             p_curr_rate_info(idx).adjustment_id := 0;
1792 
1793   	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1794 		     p_full_path => l_path_name,
1795 		     p_string => '     Initializing current rate info first and current rate info next');
1796             p_curr_rate_info_first(idx) := p_curr_rate_info(idx);
1797             p_curr_rate_info_next(idx) := p_curr_rate_info(idx);
1798 
1799   	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1800 		     p_full_path => l_path_name,
1801 		     p_string => '     Initializing reval asset rules');
1802             p_reval_asset_rules(idx).book_type_code := p_reval_asset_params(idx).book_type_code;
1803             p_reval_asset_rules(idx).asset_id := p_reval_asset_params(idx).asset_id;
1804             p_reval_asset_rules(idx).revaluation_factor := l_reval_factor;
1805             p_reval_asset_rules(idx).category_id := p_reval_asset_params(idx).category_id;
1806             p_reval_asset_rules(idx).revaluation_id := 0;
1807 
1808   	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1809 		     p_full_path => l_path_name,
1810 		     p_string => '     Initializing fa asset info');
1811             p_fa_asset_info(idx) := l_fa_asset_info;
1812 
1813 	    /* Bug 2961656 vgadde 08-jul-2003 Start(10) */
1814             IF (p_calling_function = 'ADDITION' OR p_calling_function = 'RECLASS') THEN
1815 
1816                  ---Get the details for supplied depreciation and YTD --------
1817                  IF ((p_calling_function = 'ADDITION') AND (NVL(l_booksrow_YTD,0) <> 0) AND (p_asset_last_period IS NuLL))  THEN -- supplied YYD
1818 
1819                         IF NOT (igi_iac_common_utils.get_period_info_for_counter(
1820                                         p_reval_asset_params(idx).book_type_code,
1821                                         p_period_counter-1,
1822                                         l_open_period)) THEN
1823                       		    igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
1824 		                                                             p_full_path => l_path_name,
1825                                            		     		         p_string => '     Error in getting open period information');
1826                             return FALSE;
1827                         END IF;
1828 
1829                         IF (l_open_period.fiscal_year <> l_curr_period.fiscal_year) THEN -- If not addition year
1830 
1831                                     p_fa_asset_info(idx).deprn_amount := p_fa_deprn_expense_py;
1832                                     p_fa_asset_info(idx).deprn_periods_elapsed :=l_curr_period.period_counter - l_dpis_period.period_counter + 1;
1833                                     --p_fa_asset_info(idx).deprn_amount := (l_booksrow_reserve-l_booksrow_YTD)/p_fa_asset_info(idx).deprn_periods_elapsed;
1834                                     IF (l_dpis_period.fiscal_year = l_curr_period.fiscal_year AND l_dpis_period.period_num <= l_curr_period.period_num) THEN
1835                                 	    p_fa_asset_info(idx).deprn_periods_current_year := l_curr_period.period_num - l_dpis_period.period_num + 1;
1836     		                        ELSE
1837                     	                p_fa_asset_info(idx).deprn_periods_current_year := l_curr_period.period_num ;
1838                             		END IF;
1839                                     p_fa_asset_info(idx).deprn_periods_prior_year :=
1840                                     p_fa_asset_info(idx).deprn_periods_elapsed - p_fa_asset_info(idx).deprn_periods_current_year;
1841                                     p_fa_asset_info(idx).deprn_reserve :=
1842                                     p_fa_asset_info(idx).deprn_periods_elapsed * p_fa_deprn_expense_py;
1843                                     do_round(p_fa_asset_info(idx).deprn_reserve,p_reval_asset_params(1).book_type_code);
1844 
1845                                     p_fa_asset_info(idx).ytd_deprn :=
1846                                     p_fa_asset_info(idx).deprn_periods_current_year * p_fa_deprn_expense_py;
1847                                     do_round(p_fa_asset_info(idx).ytd_deprn,p_reval_asset_params(1).book_type_code);
1848                                     p_fa_asset_info(idx).pys_deprn_reserve :=
1849                                     p_fa_asset_info(idx).deprn_reserve - p_fa_asset_info(idx).ytd_deprn;
1850                          ELSE /* Revaluation in the latest fiscal year */
1851                                         p_fa_asset_info(idx).deprn_periods_elapsed :=
1852                                         l_curr_period.period_counter - l_dpis_period.period_counter + 1;
1853 
1854                                         IF (l_dpis_period.fiscal_year = l_curr_period.fiscal_year AND l_dpis_period.period_num <= l_curr_period.period_num) THEN
1855                                                p_fa_asset_info(idx).deprn_periods_current_year := l_curr_period.period_num - l_dpis_period.period_num + 1;
1856                         		        ELSE
1857                                     	    p_fa_asset_info(idx).deprn_periods_current_year := l_curr_period.period_num ;
1858                                 		END IF;
1859     		                            p_fa_asset_info(idx).deprn_periods_prior_year :=
1860                                         p_fa_asset_info(idx).deprn_periods_elapsed - p_fa_asset_info(idx).deprn_periods_current_year;
1861                                         p_fa_asset_info(idx).pys_deprn_reserve := p_fa_asset_info(idx).deprn_periods_prior_year*p_fa_deprn_expense_py;
1862                                         do_round(p_fa_asset_info(idx).pys_deprn_reserve,p_reval_asset_params(1).book_type_code);
1863                                         p_fa_asset_info(idx).ytd_deprn :=  p_fa_asset_info(idx).deprn_periods_current_year * p_fa_deprn_expense_cy;
1864                                         do_round(p_fa_asset_info(idx).ytd_deprn,p_reval_asset_params(1).book_type_code);
1865                                         p_fa_asset_info(idx).deprn_reserve :=p_fa_asset_info(idx).pys_deprn_reserve+p_fa_asset_info(idx).ytd_deprn;
1866                                         p_fa_asset_info(idx).deprn_amount :=p_fa_deprn_expense_cy;
1867 
1868                      END IF;
1869             ELSE      -- If no supplied YTD
1870 
1871                     IF (nvl(p_asset_last_period,l_curr_period.period_counter+1) >= l_curr_period.period_counter) THEN
1872                             p_fa_asset_info(idx).deprn_periods_elapsed :=
1873                                          l_curr_period.period_counter - l_dpis_period.period_counter + 1 ;
1874                     ELSE
1875                             p_fa_asset_info(idx).deprn_periods_elapsed :=
1876                                         p_asset_last_period - l_dpis_period.period_counter + 1;
1877                     END IF;
1878                     p_fa_asset_info(idx).deprn_reserve :=
1879                                 p_fa_asset_info(idx).deprn_periods_elapsed * p_fa_deprn_expense_py;
1880                     do_round(p_fa_asset_info(idx).deprn_reserve,p_reval_asset_params(1).book_type_code);
1881 
1882                     IF NOT igi_iac_ytd_engine.Calculate_YTD
1883                                     ( p_reval_asset_params(1).book_type_code,
1884                                       p_reval_asset_params(1).asset_id,
1885                                       p_fa_asset_info(idx),
1886                                      l_dpis_period.period_counter,
1887                                      l_curr_period.period_counter,
1888                                     p_calling_function) THEN
1889                         RETURN FALSE;
1890                     END IF;
1891 
1892                 END IF; -- supplied YTd
1893 
1894             ELSIF p_calling_function = 'UPGRADE' THEN
1895 
1896             IF (p_fa_deprn_expense_py = p_fa_deprn_expense_cy) THEN
1897                 IF (nvl(p_asset_last_period,l_curr_period.period_counter+1) >= l_curr_period.period_counter) THEN
1898                     p_fa_asset_info(idx).deprn_periods_elapsed :=
1899                         l_curr_period.period_counter - l_dpis_period.period_counter + 1 ;
1900                 ELSE
1901                     p_fa_asset_info(idx).deprn_periods_elapsed :=
1902                             p_asset_last_period - l_dpis_period.period_counter + 1;
1903                 END IF;
1904                 p_fa_asset_info(idx).deprn_reserve :=
1905                             p_fa_asset_info(idx).deprn_periods_elapsed * p_fa_deprn_expense_py;
1906                 do_round(p_fa_asset_info(idx).deprn_reserve,p_reval_asset_params(1).book_type_code);
1907 
1908                 igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
1909                   p_full_path => l_path_name,
1910                   p_string => 'p_fa_asset_info(idx).deprn_periods_elapsed = ' || p_fa_asset_info(idx).deprn_periods_elapsed);
1911 
1912                 igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
1913                   p_full_path => l_path_name,
1914                   p_string => 'p_fa_asset_info(idx).deprn_reserve = ' || p_fa_asset_info(idx).deprn_reserve);
1915 
1916                 IF NOT igi_iac_ytd_engine.Calculate_YTD
1917                                 ( p_reval_asset_params(1).book_type_code,
1918                                 p_reval_asset_params(1).asset_id,
1919                                 p_fa_asset_info(idx),
1920                                 l_dpis_period.period_counter,
1921                                 l_curr_period.period_counter,
1922                                 p_calling_function) THEN
1923                     RETURN FALSE;
1924                 END IF;
1925             ELSE
1926 
1927                 IF NOT (igi_iac_common_utils.get_period_info_for_counter(
1928                                         p_reval_asset_params(idx).book_type_code,
1929                                         p_period_counter,
1930                                         l_open_period)) THEN
1931           		    igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
1932 		     		p_full_path => l_path_name,
1933 		     		p_string => '     Error in getting open period information');
1934                     return FALSE;
1935                 END IF;
1936 
1937                 IF p_asset_last_period IS NOT NULL THEN
1938                     IF NOT igi_iac_common_utils.get_period_info_for_counter(
1939                                                     p_reval_asset_params(idx).book_type_code,
1940                                                     p_asset_last_period,
1941                                                     l_last_deprn_period) THEN
1942                       			igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
1943 		         	                                 	p_full_path => l_path_name,
1944                             		             		p_string => '     Error in getting last depreciation period information');
1945                             return FALSE;
1946                     END IF;
1947                 END IF;
1948 
1949                 IF (l_open_period.fiscal_year <> l_curr_period.fiscal_year) THEN
1950                     IF (nvl(p_asset_last_period,l_curr_period.period_counter+1) >= l_curr_period.period_counter) THEN
1951                         p_fa_asset_info(idx).deprn_amount := p_fa_deprn_expense_py;
1952                         p_fa_asset_info(idx).deprn_periods_elapsed :=
1953                             l_curr_period.period_counter - l_dpis_period.period_counter + 1;
1954                         IF (l_dpis_period.fiscal_year = l_curr_period.fiscal_year AND l_dpis_period.period_num <= l_curr_period.period_num) THEN
1955                     	    p_fa_asset_info(idx).deprn_periods_current_year := l_curr_period.period_num - l_dpis_period.period_num + 1;
1956     		        ELSE
1957                     	    p_fa_asset_info(idx).deprn_periods_current_year := l_curr_period.period_num ;
1958             		END IF;
1959                         p_fa_asset_info(idx).deprn_periods_prior_year :=
1960                                 p_fa_asset_info(idx).deprn_periods_elapsed - p_fa_asset_info(idx).deprn_periods_current_year;
1961                         p_fa_asset_info(idx).deprn_reserve :=
1962                                 p_fa_asset_info(idx).deprn_periods_elapsed * p_fa_asset_info(idx).deprn_amount;
1963                         do_round(p_fa_asset_info(idx).deprn_reserve,p_reval_asset_params(1).book_type_code);
1964                         p_fa_asset_info(idx).ytd_deprn :=
1965                                 p_fa_asset_info(idx).deprn_periods_current_year * p_fa_asset_info(idx).deprn_amount;
1966                         do_round(p_fa_asset_info(idx).ytd_deprn,p_reval_asset_params(1).book_type_code);
1967                         p_fa_asset_info(idx).pys_deprn_reserve :=
1968                                 p_fa_asset_info(idx).deprn_reserve - p_fa_asset_info(idx).ytd_deprn;
1969                     ELSE
1970                         IF l_last_deprn_period.fiscal_year = l_curr_period.fiscal_year THEN
1971                             p_fa_asset_info(idx).deprn_amount := 0;
1972                             p_fa_asset_info(idx).deprn_periods_elapsed :=
1973                                 l_last_deprn_period.period_counter - l_dpis_period.period_counter + 1;
1974                             IF (l_dpis_period.fiscal_year = l_last_deprn_period.fiscal_year AND l_dpis_period.period_num <= l_last_deprn_period.period_num) THEN
1975                     	        p_fa_asset_info(idx).deprn_periods_current_year := l_last_deprn_period.period_num - l_dpis_period.period_num + 1;
1976     		            ELSE
1977                     	        p_fa_asset_info(idx).deprn_periods_current_year := l_last_deprn_period.period_num ;
1978             		    END IF;
1979     		            p_fa_asset_info(idx).deprn_periods_prior_year :=
1980                                 p_fa_asset_info(idx).deprn_periods_elapsed - p_fa_asset_info(idx).deprn_periods_current_year;
1981                             p_fa_asset_info(idx).deprn_reserve :=
1982                                 p_fa_asset_info(idx).deprn_periods_elapsed * p_fa_deprn_expense_py;
1983                             do_round(p_fa_asset_info(idx).deprn_reserve,p_reval_asset_params(1).book_type_code);
1984                             p_fa_asset_info(idx).ytd_deprn :=
1985                                 p_fa_asset_info(idx).deprn_periods_current_year * p_fa_deprn_expense_py;
1986                             do_round(p_fa_asset_info(idx).ytd_deprn,p_reval_asset_params(1).book_type_code);
1987                             p_fa_asset_info(idx).pys_deprn_reserve :=
1988                                 p_fa_asset_info(idx).deprn_reserve - p_fa_asset_info(idx).ytd_deprn;
1989                         ELSE /* fully reserved in a year prior to current revaluation */
1990                             p_fa_asset_info(idx).deprn_amount := 0;
1991                             p_fa_asset_info(idx).deprn_periods_elapsed :=
1992                                 l_last_deprn_period.period_counter - l_dpis_period.period_counter + 1;
1993                             p_fa_asset_info(idx).deprn_periods_current_year := 0;
1994     		            p_fa_asset_info(idx).deprn_periods_prior_year :=
1995                                 p_fa_asset_info(idx).deprn_periods_elapsed - p_fa_asset_info(idx).deprn_periods_current_year;
1996                             p_fa_asset_info(idx).deprn_reserve :=
1997                                 p_fa_asset_info(idx).deprn_periods_elapsed * p_fa_deprn_expense_py;
1998                             do_round(p_fa_asset_info(idx).deprn_reserve,p_reval_asset_params(1).book_type_code);
1999                             p_fa_asset_info(idx).ytd_deprn :=
2000                                 p_fa_asset_info(idx).deprn_periods_current_year * p_fa_deprn_expense_py;
2001                             do_round(p_fa_asset_info(idx).ytd_deprn,p_reval_asset_params(1).book_type_code);
2002                             p_fa_asset_info(idx).pys_deprn_reserve :=
2003                                 p_fa_asset_info(idx).deprn_reserve - p_fa_asset_info(idx).ytd_deprn;
2004                         END IF;
2005                     END IF;
2006                 ELSE /* Revaluation in the latest fiscal year */
2007                     IF (nvl(p_asset_last_period,l_curr_period.period_counter+1) >= l_curr_period.period_counter) THEN
2008                         p_fa_asset_info(idx).deprn_amount := p_fa_deprn_expense_cy;
2009                         p_fa_asset_info(idx).deprn_periods_elapsed :=
2010                             l_curr_period.period_counter - l_dpis_period.period_counter + 1;
2011                         IF (l_dpis_period.fiscal_year = l_curr_period.fiscal_year AND l_dpis_period.period_num <= l_curr_period.period_num) THEN
2012                     	    p_fa_asset_info(idx).deprn_periods_current_year := l_curr_period.period_num - l_dpis_period.period_num + 1;
2013     		        ELSE
2014                     	    p_fa_asset_info(idx).deprn_periods_current_year := l_curr_period.period_num ;
2015             		END IF;
2016     		        p_fa_asset_info(idx).deprn_periods_prior_year :=
2017                                 p_fa_asset_info(idx).deprn_periods_elapsed - p_fa_asset_info(idx).deprn_periods_current_year;
2018                         p_fa_asset_info(idx).deprn_reserve :=
2019                                 p_fa_asset_info(idx).deprn_periods_prior_year * p_fa_deprn_expense_py +
2020                                 p_fa_asset_info(idx).deprn_periods_current_year * p_fa_deprn_expense_cy;
2021                         do_round(p_fa_asset_info(idx).deprn_reserve,p_reval_asset_params(1).book_type_code);
2022                         p_fa_asset_info(idx).ytd_deprn :=
2023                                 p_fa_asset_info(idx).deprn_periods_current_year * p_fa_deprn_expense_cy;
2024                         do_round(p_fa_asset_info(idx).ytd_deprn,p_reval_asset_params(1).book_type_code);
2025                         p_fa_asset_info(idx).pys_deprn_reserve :=
2026                                 p_fa_asset_info(idx).deprn_reserve - p_fa_asset_info(idx).ytd_deprn;
2027                     ELSE
2028                         IF l_last_deprn_period.fiscal_year = l_curr_period.fiscal_year THEN
2029                             p_fa_asset_info(idx).deprn_amount := 0;
2030                             p_fa_asset_info(idx).deprn_periods_elapsed :=
2031                                 l_last_deprn_period.period_counter - l_dpis_period.period_counter + 1;
2032                             IF (l_dpis_period.fiscal_year = l_last_deprn_period.fiscal_year AND l_dpis_period.period_num <= l_last_deprn_period.period_num) THEN
2033                     	        p_fa_asset_info(idx).deprn_periods_current_year := l_last_deprn_period.period_num - l_dpis_period.period_num + 1;
2034     		            ELSE
2035                     	        p_fa_asset_info(idx).deprn_periods_current_year := l_last_deprn_period.period_num ;
2036             		    END IF;
2037     		            p_fa_asset_info(idx).deprn_periods_prior_year :=
2038                                 p_fa_asset_info(idx).deprn_periods_elapsed - p_fa_asset_info(idx).deprn_periods_current_year;
2039                             p_fa_asset_info(idx).deprn_reserve :=
2040                                 p_fa_asset_info(idx).deprn_periods_prior_year * p_fa_deprn_expense_py +
2041                                 p_fa_asset_info(idx).deprn_periods_current_year * p_fa_deprn_expense_cy;
2042                             do_round(p_fa_asset_info(idx).deprn_reserve,p_reval_asset_params(1).book_type_code);
2043                             p_fa_asset_info(idx).ytd_deprn :=
2044                                 p_fa_asset_info(idx).deprn_periods_current_year * p_fa_deprn_expense_cy;
2045                             do_round(p_fa_asset_info(idx).ytd_deprn,p_reval_asset_params(1).book_type_code);
2046                             p_fa_asset_info(idx).pys_deprn_reserve :=
2047                                 p_fa_asset_info(idx).deprn_reserve - p_fa_asset_info(idx).ytd_deprn;
2048                         ELSE /* fully reserved in a year prior to current revaluation */
2049                             p_fa_asset_info(idx).deprn_amount := 0;
2050                             p_fa_asset_info(idx).deprn_periods_elapsed :=
2051                                 l_last_deprn_period.period_counter - l_dpis_period.period_counter + 1;
2052                             p_fa_asset_info(idx).deprn_periods_current_year := 0;
2053     		                p_fa_asset_info(idx).deprn_periods_prior_year :=
2054                                 p_fa_asset_info(idx).deprn_periods_elapsed - p_fa_asset_info(idx).deprn_periods_current_year;
2055                             p_fa_asset_info(idx).deprn_reserve :=
2056                                 p_fa_asset_info(idx).deprn_periods_prior_year * p_fa_deprn_expense_py;
2057                             do_round(p_fa_asset_info(idx).deprn_reserve,p_reval_asset_params(1).book_type_code);
2058                             p_fa_asset_info(idx).ytd_deprn := 0;
2059                             p_fa_asset_info(idx).pys_deprn_reserve := p_fa_asset_info(idx).deprn_reserve;
2060                         END IF;
2061                     END IF;
2062                 END IF;
2063             END IF;
2064             END IF;
2065 	        /* Bug 2961656 vgadde 08-jul-2003 End(10) */
2066       	     igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
2067 		                                     p_full_path => l_path_name,
2068                                 		     p_string => '         Deprn amount :'||to_char(p_fa_asset_info(idx).deprn_amount));
2069   	        igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
2070 		                                     p_full_path => l_path_name,
2071                                 		     p_string => '         Deprn periods elapsed :'||to_char(p_fa_asset_info(idx).deprn_periods_elapsed));
2072       	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
2073 	                                    	     p_full_path => l_path_name,
2074                                     		     p_string => '         Deprn periods current year :'||to_char(p_fa_asset_info(idx).deprn_periods_current_year));
2075       	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
2076 	                                             p_full_path => l_path_name,
2077                                     		     p_string => '         Deprn periods prior year :'||to_char(p_fa_asset_info(idx).deprn_periods_prior_year));
2078             igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
2079 		                                         p_full_path => l_path_name,
2080                                     		     p_string => '         Deprn YTD :'||to_char(p_fa_asset_info(idx).ytd_deprn));
2081       	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
2082 		                                         p_full_path => l_path_name,
2083                                 	    	     p_string => '         Prior years deprn reserve :'||to_char(p_fa_asset_info(idx).pys_deprn_reserve));
2084       	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
2085 	                                    	     p_full_path => l_path_name,
2086                                     		     p_string => '         Deprn Reserve :'||to_char(p_fa_asset_info(idx).deprn_reserve));
2087       	    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
2088 	                                    	     p_full_path => l_path_name,
2089                                     		     p_string => '     Initializing reval exceptions');
2090                                                  p_reval_exceptions(idx).asset_id := p_reval_asset_params(idx).asset_id;
2091                                                     p_reval_exceptions(idx).book_type_code := p_reval_asset_params(idx).book_type_code;
2092 
2093             l_prev_price_index := l_curr_price_index;
2094 
2095         END LOOP;
2096 
2097       	igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
2098 	                                	     p_full_path => l_path_name,
2099                                             p_string => ' End of initialization for revaluation in catchup pkg');
2100         return TRUE;
2101 
2102         EXCEPTION
2103             WHEN OTHERS THEN
2104           		igi_iac_debug_pkg.debug_unexpected_msg(p_full_path => l_path_name);
2105                 return FALSE;
2106     END do_reval_init_struct;
2107 
2108  BEGIN
2109 
2110     g_debug := FALSE;
2111 
2112     --===========================FND_LOG.START=====================================
2113 
2114     g_state_level :=	FND_LOG.LEVEL_STATEMENT;
2115     g_proc_level  :=	FND_LOG.LEVEL_PROCEDURE;
2116     g_event_level :=	FND_LOG.LEVEL_EVENT;
2117     g_excep_level :=	FND_LOG.LEVEL_EXCEPTION;
2118     g_error_level :=	FND_LOG.LEVEL_ERROR;
2119     g_unexp_level :=	FND_LOG.LEVEL_UNEXPECTED;
2120     g_path        := 'IGI.PLSQL.igiiactb.igi_iac_catchup_pkg.';
2121 
2122     --===========================FND_LOG.END=====================================
2123 
2124 
2125 
2126 END igi_iac_catchup_pkg;