[Home] [Help]
PACKAGE BODY: APPS.IGI_IAC_ADJ_EXPENSED_PKG
Source
1 PACKAGE BODY IGI_IAC_ADJ_EXPENSED_PKG AS
2 -- $Header: igiiadxb.pls 120.16.12000000.2 2007/10/16 14:19:23 sharoy noship $
3
4 --===========================FND_LOG.START=====================================
5
6 g_state_level NUMBER;
7 g_proc_level NUMBER;
8 g_event_level NUMBER;
9 g_excep_level NUMBER;
10 g_error_level NUMBER;
11 g_unexp_level NUMBER;
12 g_path VARCHAR2(100);
13
14 --===========================FND_LOG.END=====================================
15
16 PROCEDURE debug_adj_asset(p_asset igi_iac_types.iac_adj_hist_asset_info) IS
17 l_path_name VARCHAR2(150);
18 BEGIN
19 l_path_name := g_path||'debug_adj_asset';
20 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
21 p_full_path => l_path_name,
22 p_string => 'asset_id...............'|| p_asset.asset_id);
23 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
24 p_full_path => l_path_name,
25 p_string => 'book_type_code.........'|| p_asset.book_type_code);
26 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
27 p_full_path => l_path_name,
28 p_string => 'cost...................'|| p_asset.cost );
29 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
30 p_full_path => l_path_name,
31 p_string => 'original_Expensed..........'|| p_asset.original_cost);
32 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
33 p_full_path => l_path_name,
34 p_string => 'adjusted_Expensed..........'|| p_asset.adjusted_cost);
35 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
36 p_full_path => l_path_name,
37 p_string => 'salvage_value..........'|| p_asset.salvage_value );
38 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
39 p_full_path => l_path_name,
40 p_string => 'life_in_months.........'|| p_asset.life_in_months);
41 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
42 p_full_path => l_path_name,
43 p_string => 'rate_adjustment_factor..'||p_asset.rate_adjustment_factor);
44 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
45 p_full_path => l_path_name,
46 p_string => 'period_counter_fully_reserved '|| p_asset.period_counter_fully_reserved);
47 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
48 p_full_path => l_path_name,
49 p_string => 'recoverable_Expensed.......'|| p_asset.recoverable_cost);
50 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
51 p_full_path => l_path_name,
52 p_string => 'date_placed_in_service..'||p_asset.date_placed_in_service);
53 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
54 p_full_path => l_path_name,
55 p_string => 'deprn_start_date........'||p_asset.deprn_start_date);
56 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
57 p_full_path => l_path_name,
58 p_string => 'deprn_periods_elapsed...'||p_asset.deprn_periods_elapsed);
59 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
60 p_full_path => l_path_name,
61 p_string => 'deprn_periods_current_year..'||p_asset.deprn_periods_current_year);
62 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
63 p_full_path => l_path_name,
64 p_string => 'prior year periods..'|| p_asset.deprn_periods_prior_year);
65 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
66 p_full_path => l_path_name,
67 p_string => 'last_period_counter.........'|| p_asset.last_period_counter);
68 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
69 p_full_path => l_path_name,
70 p_string => 'ytd_deprn...................'|| p_asset.ytd_deprn);
71 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
72 p_full_path => l_path_name,
73 p_string => 'deprn_reserve................'|| p_asset.deprn_reserve);
74 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
75 p_full_path => l_path_name,
76 p_string => 'pys_deprn_reserve............'|| p_asset.pys_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 => 'deprn_amount................'|| p_asset.deprn_amount);
80 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
81 p_full_path => l_path_name,
82 p_string => 'depreciate_flag................'|| p_asset.depreciate_flag);
83 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
84 p_full_path => l_path_name,
85 p_string => 'deprn_adjustment_amount................'|| p_asset.deprn_adjustment_amount);
86 END debug_adj_asset;
87
88 FUNCTION Calculate_New_Balances( p_asset_iac_adj_info IN OUT NOCOPY igi_iac_types.iac_adj_hist_asset_info,
89 P_asset_balance IN OUT NOCOPY igi_iac_asset_balances%ROWTYPE,
90 p_adj_hist IN igi_iac_adjustments_history%ROWTYPE)
91 RETURN boolean IS
92
93 CURSOR c_period_num_for_catchup IS
94 SELECT period_num_for_catchup
95 FROM igi_iac_book_controls
96 WHERE book_type_code = p_asset_iac_adj_info.book_type_code;
97
98 CURSOR C_get_curr_reval_rate IS
99 SELECT irr.*
100 FROM igi_iac_revaluation_rates irr
101 WHERE irr.asset_id = p_asset_iac_adj_info.asset_id
102 AND irr.book_type_code = p_asset_iac_adj_info.book_type_code
103 AND irr.latest_record = 'Y'
104 AND irr.revaluation_id = (SELECT max(iar.revaluation_id)
105 FROM igi_iac_revaluation_rates iar ,
106 igi_iac_transaction_headers ith
107 WHERE iar.asset_id = p_asset_iac_adj_info.asset_id
108 AND iar.book_type_code = p_asset_iac_adj_info.book_type_code
109 AND ith.book_type_code = p_asset_iac_adj_info.book_type_code
110 AND ith.asset_id = p_asset_iac_adj_info.asset_id
111 AND iar.adjustment_id = ith.adjustment_id
112 AND ith.adjustment_status IN ('COMPLETE','RUN'));
113
114 l_get_curr_reval_rate igi_iac_revaluation_rates%ROWTYPE;
115 l_cumulative_backlog igi_iac_asset_balances.backlog_deprn_reserve%TYPE;
116 l_current_backlog igi_iac_asset_balances.backlog_deprn_reserve%TYPE;
117 l_Reval_rsv_backlog igi_iac_asset_balances.backlog_deprn_reserve%TYPE;
118 l_operating_acct_backlog igi_iac_asset_balances.backlog_deprn_reserve%TYPE;
119 l_dpis_period_info igi_iac_types.prd_rec;
120 l_period_info igi_iac_types.prd_rec;
121 l_latest_reval_period_info igi_iac_types.prd_rec;
122 l_dpis_price_index Number;
123 l_prev_price_index Number;
124 l_period_num_for_catchup Number;
125 l_curr_price_index Number;
126 l_reval_factor Number;
127 l_prev_reval_factor Number;
128 l_Prev_cumm_reval_factor Number;
129 l_cumm_reval_factor Number;
130 l_period_counter Number;
131 l_fa_asset_info igi_iac_types.fa_hist_asset_info;
132 l_latest_closed_period fa_deprn_periods.period_counter%TYPE;
133 l_last_deprn_period igi_iac_types.prd_rec;
134 l_deprn_periods_elapsed NUMBER;
135 l_deprn_periods_current_year NUMBER;
136
137 l_path_name VARCHAR2(150);
138 BEGIN
139 l_path_name := g_path||'Calculate_New_Balances';
140
141 IF NOT igi_iac_common_utils.get_Period_Info_for_Date(p_asset_iac_adj_info.book_type_code,
142 P_asset_iac_adj_info.date_placed_in_service,
143 l_dpis_period_info) THEN
144 RETURN FALSE;
145 END IF;
146
147 IF NOT igi_iac_common_utils.get_price_index_value(
148 p_asset_iac_adj_info.book_type_code,
149 p_asset_iac_adj_info.asset_id,
150 l_dpis_period_info.period_name,
151 l_dpis_price_index) THEN
152 RETURN FALSE;
153 END IF;
154 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
155 p_full_path => l_path_name,
156 p_string => 'Backlog:Price Index for DPIS :'||TO_CHAR(l_dpis_price_index));
157 l_prev_price_index := l_dpis_price_index;
158
159 -- get revalaution period num
160 OPEN c_period_num_for_catchup;
161 FETCH c_period_num_for_catchup INTO l_period_num_for_catchup;
162 CLOSE c_period_num_for_catchup;
163
164 -- get the latest revaluation of the asset
165 OPEN C_get_curr_reval_rate;
166 FETCH C_get_curr_reval_rate INTO l_get_curr_reval_rate;
167 CLOSE c_get_curr_reval_rate;
168
169 l_fa_asset_info.cost := p_asset_iac_adj_info.cost;
170 l_fa_asset_info.adjusted_cost := p_asset_iac_adj_info.adjusted_cost;
171 l_fa_asset_info.original_cost := p_asset_iac_adj_info.original_cost;
172 l_fa_asset_info.salvage_value := p_asset_iac_adj_info.salvage_value;
173 l_fa_asset_info.life_in_months := p_asset_iac_adj_info.life_in_months;
174 l_fa_asset_info.rate_adjustment_factor := p_asset_iac_adj_info.rate_adjustment_factor;
175 l_fa_asset_info.period_counter_fully_reserved := p_asset_iac_adj_info.period_counter_fully_reserved;
176 l_fa_asset_info.adjusted_recoverable_cost := p_asset_iac_adj_info.adjusted_recoverable_cost;
177 l_fa_asset_info.recoverable_cost := p_asset_iac_adj_info.recoverable_cost;
178 l_fa_asset_info.date_placed_in_service := p_asset_iac_adj_info.date_placed_in_service;
179 l_fa_asset_info.deprn_periods_elapsed := p_asset_iac_adj_info.deprn_periods_elapsed;
180 l_fa_asset_info.deprn_periods_current_year := p_asset_iac_adj_info.deprn_periods_current_year;
181 l_fa_asset_info.deprn_periods_prior_year := p_asset_iac_adj_info.deprn_periods_prior_year;
182 l_fa_asset_info.last_period_counter := p_asset_iac_adj_info.last_period_counter;
183 l_fa_asset_info.gl_posting_allowed_flag := p_asset_iac_adj_info.gl_posting_allowed_flag;
184 l_fa_asset_info.ytd_deprn := p_asset_iac_adj_info.ytd_deprn;
185 l_fa_asset_info.deprn_reserve := p_asset_iac_adj_info.deprn_reserve;
186 l_fa_asset_info.pys_deprn_reserve := p_asset_iac_adj_info.pys_deprn_reserve;
187 l_fa_asset_info.deprn_amount := p_asset_iac_adj_info.deprn_amount;
188 l_fa_asset_info.deprn_start_date := p_asset_iac_adj_info.deprn_start_date;
189 l_fa_asset_info.depreciate_flag := p_asset_iac_adj_info.depreciate_flag;
190
191 l_latest_closed_period := p_adj_hist.period_counter - 1;
192 IF NOT igi_iac_ytd_engine.Calculate_YTD
193 ( p_asset_iac_adj_info.book_type_code,
194 p_asset_iac_adj_info.asset_id,
195 l_fa_asset_info,
196 l_dpis_period_info.period_counter,
197 l_latest_closed_period,
198 'EXPENSED') THEN
199 RETURN FALSE;
200 END IF;
201
202 p_asset_iac_adj_info.last_period_counter := l_fa_asset_info.last_period_counter ;
203 p_asset_iac_adj_info.ytd_deprn := l_fa_asset_info.ytd_deprn ;
204 p_asset_iac_adj_info.deprn_amount := l_fa_asset_info.deprn_amount ;
205
206 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
207 p_full_path => l_path_name,
208 p_string => 'ytd_deprn from YTD engine :'||l_fa_asset_info.ytd_deprn);
209 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
210 p_full_path => l_path_name,
211 p_string => 'deprn_amount from YTD engine :'||l_fa_asset_info.deprn_amount);
212 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
213 p_full_path => l_path_name,
214 p_string => 'Last period counter from YTD engine :'||l_fa_asset_info.last_period_counter);
215 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
216 p_full_path => l_path_name,
217 p_string => 'Last revaluation period for the asset : '|| to_char(l_get_curr_reval_rate.period_counter));
218
219 IF NOT igi_iac_common_utils.get_period_info_for_counter(p_asset_iac_adj_info.book_type_code,
220 l_get_curr_reval_rate.period_counter,
221 l_latest_reval_period_info) THEN
222 igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
223 p_full_path => l_path_name,
224 p_string => 'Backlog:*** Error in fetching period information');
225 RETURN FALSE;
226 END IF;
227
228 l_cumulative_backlog:= 0;
229 l_reval_rsv_backlog := 0;
230 l_operating_acct_backlog := 0;
231 l_Prev_cumm_reval_factor := 1;
232 l_cumm_reval_factor := 1;
233 l_current_backlog:=0;
234
235 FOR l_period_counter IN l_dpis_period_info.period_counter..(l_latest_reval_period_info.period_counter) LOOP
236
237 IF NOT igi_iac_common_utils.get_period_info_for_counter(p_asset_iac_adj_info.book_type_code,
238 l_period_counter,
239 l_period_info) THEN
240 igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
241 p_full_path => l_path_name,
242 p_string => 'Backlog:*** Error in fetching period information');
243 RETURN FALSE;
244 END IF;
245
246 /* if the period in the loop is a catchup period for revaluation
247 then initialize revaluation structures */
248 IF (l_period_num_for_catchup = l_period_info.period_num)
249 OR (l_period_info.period_counter = l_latest_reval_period_info.period_counter) THEN
250
251 IF (l_period_info.period_counter = l_latest_reval_period_info.period_counter) THEN
252 l_cumm_reval_factor := l_get_curr_reval_rate.cumulative_reval_factor;
253 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
254 p_full_path => l_path_name,
255 p_string => 'Cumulative reval factor from last reval : '||l_cumm_reval_factor);
256 ELSE
257 IF NOT (igi_iac_common_utils.get_price_index_value(
258 p_asset_iac_adj_info.book_type_code,
259 p_asset_iac_adj_info.asset_id,
260 l_period_info.period_name,
261 l_curr_price_index)) THEN
262 RETURN FALSE;
263 END IF;
264 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
265 p_full_path => l_path_name,
266 p_string => ' Backlog: Period counter for revaluation :'|| l_period_info.period_counter);
267 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
268 p_full_path => l_path_name,
269 p_string => 'Backlog: Price Index for current revaluation catchup period :'||TO_CHAR(l_curr_price_index));
270
271 IF (l_prev_price_index = 9999.99 OR l_curr_price_index = 9999.99 OR l_prev_price_index = 0) THEN
272 RETURN FALSE;
273 END IF;
274 l_reval_factor := l_curr_price_index / l_prev_price_index ;
275 l_cumm_reval_factor := l_reval_factor * l_Prev_cumm_reval_factor;
276 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
277 p_full_path => l_path_name,
278 p_string => 'Current Price Index value :'||l_curr_price_index);
279 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
280 p_full_path => l_path_name,
281 p_string => 'Cumulative reval factor from catchup : '||l_cumm_reval_factor);
282 END IF;
283
284 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
285 p_full_path => l_path_name,
286 p_string => 'Backlog: Current Reval Factor : '||TO_CHAR(l_reval_factor));
287 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
288 p_full_path => l_path_name,
289 p_string => 'Backlog: Cummulative Reval Factor : '||TO_CHAR(l_cumm_reval_factor));
290 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
291 p_full_path => l_path_name,
292 p_string => 'Backlog: Previous Cummulative Reval Factor : '||TO_CHAR(l_Prev_cumm_reval_factor));
293
294 l_deprn_periods_elapsed := l_period_info.period_counter - l_dpis_period_info.period_counter + 1;
295 l_deprn_periods_current_year := l_period_info.period_num;
296 IF (l_period_info.fiscal_year = l_dpis_period_info.fiscal_year) THEN
297 l_deprn_periods_current_year := l_period_info.period_counter - l_dpis_period_info.period_counter + 1;
298 l_deprn_periods_elapsed := l_deprn_periods_current_year;
299 END IF;
300
301 IF (l_fa_asset_info.last_period_counter < l_period_info.period_counter) THEN
302
303 IF NOT igi_iac_common_utils.get_period_info_for_counter(p_asset_iac_adj_info.book_type_code,
304 l_fa_asset_info.last_period_counter,
305 l_last_deprn_period) THEN
306 RETURN FALSE;
307 END IF;
308
309 l_deprn_periods_elapsed := l_last_deprn_period.period_counter - l_dpis_period_info.period_counter + 1;
310 IF (l_period_info.fiscal_year = l_last_deprn_period.fiscal_year) THEN
311 l_deprn_periods_current_year := l_last_deprn_period.period_num;
312 END IF;
313
314 IF (l_dpis_period_info.fiscal_year = l_last_deprn_period.fiscal_year) THEN
315 l_deprn_periods_current_year := l_last_deprn_period.period_num - l_dpis_period_info.period_num + 1;
316 END IF;
317
318 IF (l_last_deprn_period.fiscal_year < l_period_info.fiscal_year ) THEN
319 l_deprn_periods_current_year := 0;
320 END IF;
321 END IF;
322
323 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
324 p_full_path => l_path_name,
325 p_string => 'periods elapsed..'|| l_deprn_periods_elapsed);
326 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
327 p_full_path => l_path_name,
328 p_string => 'current year periods ...'|| l_deprn_periods_current_year);
329 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
330 p_full_path => l_path_name,
331 p_string => 'FA deprn period..'||l_fa_asset_info.deprn_amount);
332 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
333 p_full_path => l_path_name,
334 p_string => 'previous factor..'|| l_Prev_cumm_reval_factor);
335 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
336 p_full_path => l_path_name,
337 p_string => 'current factor..'|| l_cumm_reval_factor);
338
339 IF (l_cumm_reval_factor >= 1 AND l_Prev_cumm_reval_factor < 1) THEN
340 /* Movement from <1 to 1 */
341 l_current_backlog := ((l_deprn_periods_elapsed - l_deprn_periods_current_year)
342 * l_fa_asset_info.deprn_amount) * (1 - l_prev_cumm_reval_factor);
343 l_operating_acct_backlog := l_Operating_acct_backlog + l_current_backlog;
344 l_cumulative_backlog := l_cumulative_backlog + l_current_backlog;
345 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
346 p_full_path => l_path_name,
347 p_string => 'current backlog1 ..'|| l_current_backlog);
348
349 /* Movement from 1 to >1 */
350 l_current_backlog := ((l_deprn_periods_elapsed - l_deprn_periods_current_year)
351 * l_fa_asset_info.deprn_amount) * (l_cumm_reval_factor - 1);
352 l_Reval_Rsv_Backlog := l_Reval_Rsv_Backlog + l_current_backlog;
353 l_cumulative_backlog := l_cumulative_backlog + l_current_backlog;
354 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
355 p_full_path => l_path_name,
356 p_string => 'current backlog2 ..'|| l_current_backlog);
357
358 ELSIF (l_cumm_reval_factor < 1 AND l_Prev_cumm_reval_factor >= 1) THEN
359 /* Movement from >1 to 1 */
360 l_current_backlog := ((l_deprn_periods_elapsed - l_deprn_periods_current_year)
361 * l_fa_asset_info.deprn_amount) * (1 - l_Prev_cumm_reval_factor);
362 l_Reval_Rsv_Backlog := l_Reval_Rsv_Backlog + l_current_backlog;
363 l_cumulative_backlog := l_cumulative_backlog + l_current_backlog;
364 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
365 p_full_path => l_path_name,
366 p_string => 'current backlog3 ..'|| l_current_backlog);
367
368 /* Movement from 1 to <1 */
369 l_current_backlog := ((l_deprn_periods_elapsed - l_deprn_periods_current_year)
370 * l_fa_asset_info.deprn_amount) * (l_cumm_reval_factor - 1);
371 l_Operating_Acct_Backlog := l_Operating_Acct_Backlog + l_current_backlog;
372 l_cumulative_backlog := l_cumulative_backlog + l_current_backlog;
373 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
374 p_full_path => l_path_name,
375 p_string => 'current backlog4 ..'|| l_current_backlog);
376 ELSE
377 l_current_backlog := ((l_deprn_periods_elapsed - l_deprn_periods_current_year)
378 * l_fa_asset_info.deprn_amount) * (l_cumm_reval_factor - l_Prev_cumm_reval_factor);
379 l_cumulative_backlog := l_cumulative_backlog + l_current_backlog;
380
381 IF (l_cumm_reval_factor >= 1) THEN
382 l_Reval_Rsv_Backlog := l_Reval_Rsv_Backlog + l_current_backlog;
383 ELSE
384 l_Operating_Acct_Backlog := l_Operating_Acct_Backlog + l_current_backlog;
385
386 END IF;
387
388 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
389 p_full_path => l_path_name,
390 p_string => 'current backlog5 ..'|| l_current_backlog);
391 END IF;
392 l_prev_price_index := l_curr_price_index;
393 l_Prev_cumm_reval_factor := l_cumm_reval_factor;
394
395 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
396 p_full_path => l_path_name,
397 p_string => 'Backlog Accumalted...'|| l_cumulative_backlog);
398 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
399 p_full_path => l_path_name,
400 p_string => 'Backlog RR...'|| l_Reval_Rsv_backlog);
401 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
402 p_full_path => l_path_name,
403 p_string => 'Backlog OP...'|| l_Operating_Acct_backlog);
404 END IF;
405
406 END LOOP;
407
408 IF NOT (igi_iac_common_utils.iac_round(l_cumulative_backlog,p_asset_iac_adj_info.book_type_code)) THEN
409 RETURN FALSE;
410 END IF;
411 IF NOT (igi_iac_common_utils.iac_round(l_Reval_Rsv_backlog,p_asset_iac_adj_info.book_type_code)) THEN
412 RETURN FALSE;
413 END IF;
414 IF NOT (igi_iac_common_utils.iac_round(l_Operating_Acct_backlog,p_asset_iac_adj_info.book_type_code)) THEN
415 RETURN FALSE;
416 END IF;
417
418 p_asset_balance.backlog_deprn_reserve := l_cumulative_backlog;
419 p_asset_balance.deprn_reserve := p_asset_iac_adj_info.deprn_reserve * (l_cumm_reval_factor - 1)
420 - l_cumulative_backlog;
421 IF NOT (igi_iac_common_utils.iac_round(p_asset_balance.deprn_reserve,p_asset_iac_adj_info.book_type_code)) THEN
422 RETURN FALSE;
423 END IF;
424
425 p_asset_balance.net_book_value := p_asset_balance.adjusted_cost - p_asset_balance.deprn_reserve
426 - l_cumulative_backlog;
427
428 IF l_cumm_reval_factor >= 1 THEN
429 p_asset_balance.reval_reserve := p_asset_balance.net_book_value;
430 p_asset_balance.Operating_acct := 0 - l_Operating_Acct_backlog;
431 p_asset_balance.General_Fund := p_asset_balance.adjusted_cost - l_Reval_Rsv_backlog - p_asset_balance.reval_reserve;
432 ELSE
433 p_asset_balance.reval_reserve := 0;
434 p_asset_balance.Operating_acct := p_asset_balance.adjusted_cost - l_Operating_Acct_backlog;
435 p_asset_balance.General_Fund := 0 - l_Reval_Rsv_backlog - p_asset_balance.reval_reserve;
436 END IF;
437
438 RETURN TRUE;
439 EXCEPTION
440 WHEN OTHERS THEN
441 igi_iac_debug_pkg.debug_unexpected_msg(p_full_path => l_path_name);
442 RETURN FALSE;
443 END Calculate_New_Balances;
444
445 FUNCTION Do_Expensed_Adj
446 (p_asset_iac_adj_info igi_iac_types.iac_adj_hist_asset_info,
447 P_asset_iac_dist_info igi_iac_types.iac_adj_dist_info_tab,
448 p_adj_hist igi_iac_adjustments_history%ROWTYPE,
449 p_event_id number) --R12 uptake
450 RETURN BOOLEAN
451 IS
452
453 CURSOR c_get_asset_balance (p_asset_id igi_iac_asset_balances.asset_id%TYPE,
454 P_book_type_code igi_iac_asset_balances.book_type_code%TYPE
455 ) IS
456 SELECT *
457 FROM igi_iac_asset_balances
458 WHERE asset_id = p_asset_id
459 AND book_type_code = p_book_type_code
460 AND period_counter = (SELECT MAX(period_counter)
461 FROM igi_iac_asset_balances
462 WHERE asset_id = p_asset_id
463 AND book_type_code = p_book_type_code);
464
465 /* Cursor to get balance information for each distribution of asset */
466 CURSOR c_get_inactive_det_balances(p_asset_id igi_iac_det_balances.asset_id%TYPE,
467 P_book_type_code igi_iac_asset_balances.book_type_code%TYPE,
468 p_prev_adjustment_id igi_iac_det_balances.adjustment_id%TYPE) IS
469 SELECT *
470 FROM igi_iac_det_balances
471 WHERE asset_id = p_asset_id
472 AND book_type_code = p_book_type_code
473 AND adjustment_id = p_prev_adjustment_id
474 AND NVL(active_flag,'Y') = 'N' ;
475
476 CURSOR C_get_iac_fa_deprn(P_book_type_code igi_iac_asset_balances.book_type_code%TYPE,
477 p_asset_id igi_iac_det_balances.asset_id%TYPE ,
478 P_distribution_id igi_iac_det_balances.distribution_id%TYPE
479 , p_prev_adjustment_id igi_iac_det_balances.adjustment_id%TYPE) IS
480
481 SELECT *
482 FROM igi_iac_fa_deprn
483 WHERE book_type_code =P_book_type_code
484 AND asset_id =p_asset_id
485 AND adjustment_id =p_prev_adjustment_id
486 AND distribution_id = P_distribution_id;
487
488 /* Cursor to get total units assigned for the Asset from FA */
489 CURSOR c_get_fa_asset(p_asset_id fa_additions.asset_id%TYPE) IS
490 SELECT asset_category_id,current_units
491 FROM fa_additions
492 WHERE asset_id = p_asset_id;
493
494 CURSOR c_get_active_det_balances (cp_book_type_code in varchar2
495 , cp_asset_id in number
496 , cp_adjustment_id in number
497 ) is
498 SELECT fdh.units_assigned,
499 idb.*
500 FROM fa_distribution_history fdh,
501 igi_iac_det_balances idb
502 WHERE fdh.book_type_code = cp_book_type_code
503 AND fdh.asset_id = cp_asset_id
504 AND fdh.date_ineffective IS NULL
505 AND idb.book_type_code = cp_book_type_code
506 AND idb.asset_id = cp_asset_id
507 AND idb.distribution_id = fdh.distribution_id
508 AND idb.adjustment_id = cp_adjustment_id;
509
510 l_prev_asset_balance igi_iac_asset_balances%ROWTYPE;
511 l_asset_balance_mvmt igi_iac_asset_balances%ROWTYPE;
512 l_curr_asset_balance igi_iac_asset_balances%ROWTYPE;
513 l_det_balances igi_iac_det_balances%ROWTYPE;
514 l_get_iac_fa_deprn C_get_iac_fa_deprn%ROWTYPE;
515 l_adjustment_id igi_iac_adjustments.adjustment_id%TYPE;
516 l_adjustment_id_out igi_iac_adjustments.adjustment_id%TYPE;
517 l_prev_adjustment_id igi_iac_adjustments.adjustment_id%TYPE;
518 l_category_id fa_additions.asset_category_id%TYPE;
519 l_asset_units fa_additions.current_units%TYPE;
520 l_distribution_units fa_distribution_history.units_assigned%TYPE;
521 l_Transaction_Type_Code igi_iac_transaction_headers.transaction_type_code%TYPE;
522 l_Transaction_Id igi_iac_transaction_headers.transaction_header_id%TYPE;
523 l_Mass_Reference_ID igi_iac_transaction_headers.mass_reference_id%TYPE;
524 l_Adjustment_Status igi_iac_transaction_headers.adjustment_status%TYPE;
525 l_backlog Number;
526 l_rowid ROWID;
527 l_sob_id number;
528 l_coa_id number;
529 l_currency varchar2(30);
530 l_precision number;
531 l_revl_rsv_ccid gl_code_combinations.code_combination_id%TYPE;
532 l_blog_rsv_ccid gl_code_combinations.code_combination_id%TYPE;
533 l_op_exp_ccid gl_code_combinations.code_combination_id%TYPE;
534 l_gen_fund_ccid gl_code_combinations.code_combination_id%TYPE;
535 l_asset_cost_ccid gl_code_combinations.code_combination_id%TYPE;
536 l_deprn_rsv_ccid gl_code_combinations.code_combination_id%TYPE;
537 l_deprn_exp_ccid gl_code_combinations.code_combination_id%TYPE;
538 l_asset_iac_adj_info igi_iac_types.Iac_adj_hist_asset_info;
539 l_iac_inactive_dists_ytd NUMBER ;
540 l_iac_current_ytd NUMBER ;
541 l_iac_active_dists_ytd NUMBER ;
542 l_fa_inactive_dists_ytd NUMBER ;
543 l_fa_current_ytd NUMBER ;
544 l_fa_active_dists_ytd NUMBER ;
545 l_total_dist_units NUMBER ;
546 l_dist_prorate_factor NUMBER;
547 l_total_db IGI_IAC_TYPES.iac_det_balances;
548 l_remaining_db IGI_IAC_TYPES.iac_det_balances;
549 l_current_db IGI_IAC_TYPES.iac_det_balances;
550 l_operatg_cost NUMBER ;
551 l_operatg_net NUMBER ;
552 l_operatg_blog NUMBER ;
553 l_reserve_blog NUMBER ;
554 l_deprn_blog NUMBER ;
555 l_reserve_cost NUMBER ;
556 l_operatg_ytd NUMBER ;
557 l_total_db_fa igi_iac_fa_deprn%ROWTYPE;
558 l_remaining_db_fa igi_iac_fa_deprn%ROWTYPE;
559 l_current_db_fa igi_iac_fa_deprn%ROWTYPE;
560 l_ytd_prorate_dists_tab igi_iac_types.prorate_dists_tab;
561 l_ytd_prorate_dists_idx binary_integer;
562 l_path_name VARCHAR2(150);
563 l_dist_ytd_factor NUMBER;
564 idx_YTD BINARY_INTEGER;
565
566
567 BEGIN -- do expensed adj
568 l_Transaction_Type_Code := NULL;
569 l_Transaction_Id := NULL;
570 l_Mass_Reference_ID := NULL;
571 l_Adjustment_Status := NULL;
572
573 l_iac_inactive_dists_ytd := 0;
574 l_iac_current_ytd := 0;
575 l_iac_active_dists_ytd := 0;
576 l_fa_inactive_dists_ytd := 0;
577 l_fa_current_ytd := 0;
578 l_fa_active_dists_ytd := 0;
579 l_total_dist_units := 0;
580 l_operatg_cost := 0;
581 l_operatg_net := 0;
582 l_operatg_blog := 0;
583 l_reserve_blog := 0;
584 l_deprn_blog := 0;
585 l_reserve_cost := 0;
586 l_operatg_ytd := 0;
587 l_path_name := g_path||'do_expensed_adj';
588
589 debug_adj_asset( p_asset_iac_adj_info);
590
591 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
592 p_full_path => l_path_name,
593 p_string => ' IN Process adjustments');
594 l_Transaction_Type_Code := NULL;
595 l_Transaction_Id := NULL;
596 l_Mass_Reference_ID := NULL;
597 l_adjustment_id_out := NULL;
598 l_prev_adjustment_id := NULL;
599 l_Adjustment_Status := NULL;
600
601 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
602 p_full_path => l_path_name,
603 p_string => ' Get previous adjustment');
604 IF NOT igi_iac_common_utils.Get_Latest_Transaction (
605 X_book_type_code => p_asset_iac_adj_info.book_type_code,
606 X_asset_id => p_asset_iac_adj_info.asset_id,
607 X_Transaction_Type_Code => l_Transaction_Type_Code,
608 X_Transaction_Id => l_Transaction_Id,
609 X_Mass_Reference_ID => l_Mass_Reference_ID,
610 X_Adjustment_Id => l_adjustment_id_out,
611 X_Prev_Adjustment_Id => l_prev_adjustment_id,
612 X_Adjustment_Status => l_Adjustment_Status) THEN
613 igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
614 p_full_path => l_path_name,
615 p_string => '*** Error in fetching the latest transaction');
616 RETURN FALSE;
617 END IF;
618 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
619 p_full_path => l_path_name,
620 p_string => ' previous adjustment..is '||l_prev_adjustment_id);
621 l_adjustment_id := NULL;
622 l_rowid := NULL;
623
624 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
625 p_full_path => l_path_name,
626 p_string => ' Create a new adjustment');
627 igi_iac_trans_headers_pkg.insert_row(
628 X_rowid => l_rowid ,
629 X_adjustment_id => l_adjustment_id ,
630 X_transaction_header_id => P_adj_hist.transaction_header_id_in,
631 X_adjustment_id_out => NULL ,
632 X_transaction_type_code => 'DEPRECIATION' ,
633 X_transaction_date_entered => SYSDATE ,
634 X_mass_refrence_id => NULL ,
635 X_transaction_sub_type => 'ADJUSTMENT',
636 X_book_type_code => p_asset_iac_adj_info.book_type_code,
637 X_asset_id => p_asset_iac_adj_info.asset_id,
638 X_category_id => P_adj_hist.category_id, -- p_asset_iac_adj_info.category_id ,
639 X_adj_deprn_start_date => NULL, --p_asset_iac_adj_info.last_period_counter ,
640 X_revaluation_type_flag => NULL,
641 X_adjustment_status => 'COMPLETE' ,
642 X_period_counter => p_adj_hist.period_counter,
643 X_event_id => p_event_id ) ;
644
645 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
646 p_full_path => l_path_name,
647 p_string => ' New adjustment id :'||TO_CHAR(l_adjustment_id));
648
649 -- get the IAC asset balance record;
650 OPEN c_get_asset_balance(p_asset_iac_adj_info.asset_id,
651 p_asset_iac_adj_info.book_type_code);
652 FETCH c_get_asset_balance INTO l_prev_asset_balance;
653 CLOSE c_get_asset_balance;
654
655 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
656 p_full_path => l_path_name,
657 p_string => ' Asset_id:'||l_prev_asset_balance.asset_id);
658 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
659 p_full_path => l_path_name,
660 p_string => ' Period_counter :'||l_prev_asset_balance.period_counter);
661 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
662 p_full_path => l_path_name,
663 p_string => ' Net book value :'||TO_CHAR(l_prev_asset_balance.net_book_value));
664 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
665 p_full_path => l_path_name,
666 p_string => ' Adjusted Cost :'||TO_CHAR(l_prev_asset_balance.adjusted_cost));
667 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
668 p_full_path => l_path_name,
669 p_string => ' Operating Account :'||TO_CHAR(l_prev_asset_balance.operating_acct));
670 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
671 p_full_path => l_path_name,
672 p_string => ' Reval Reserve :'||TO_CHAR(l_prev_asset_balance.reval_reserve));
673 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
674 p_full_path => l_path_name,
675 p_string => ' Deprn Amount :'||TO_CHAR(l_prev_asset_balance.deprn_amount));
676 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
677 p_full_path => l_path_name,
678 p_string => ' Deprn Reserve :'||TO_CHAR(l_prev_asset_balance.deprn_reserve));
679 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
680 p_full_path => l_path_name,
681 p_string => ' Backlog Deprn Reserve :'||TO_CHAR(l_prev_asset_balance.backlog_deprn_reserve));
682 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
683 p_full_path => l_path_name,
684 p_string => ' General Fund :'||TO_CHAR(l_prev_asset_balance.general_fund));
685 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
686 p_full_path => l_path_name,
687 p_string => ' Current Reval Factor :'||TO_CHAR(l_prev_asset_balance.current_reval_factor));
688 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
689 p_full_path => l_path_name,
690 p_string => ' Cumulative Reval Factor :'||TO_CHAR(l_prev_asset_balance.Cumulative_reval_factor));
691
692 -- get the movement of the adjustment amount ;
693 l_curr_asset_balance := l_prev_asset_balance;
694 l_asset_iac_adj_info := p_asset_iac_adj_info;
695
696 IF NOT Calculate_New_Balances( l_asset_iac_adj_info,
697 l_curr_asset_balance,
698 p_adj_hist)THEN
699 igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
700 p_full_path => l_path_name,
701 p_string => ' Error in backlog calculation');
702 RETURN FALSE;
703 END IF;
704
705 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
706 p_full_path => l_path_name,
707 p_string => ' Asset: after new calucation ');
708 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
709 p_full_path => l_path_name,
710 p_string => ' Asset_id:'||l_curr_asset_balance.asset_id);
711 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
712 p_full_path => l_path_name,
713 p_string => ' Period_counter :'||l_curr_asset_balance.period_counter);
714 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
715 p_full_path => l_path_name,
716 p_string => ' Net book value :'||TO_CHAR(l_curr_asset_balance.net_book_value));
717 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
718 p_full_path => l_path_name,
719 p_string => ' Adjusted Cost :'||TO_CHAR(l_curr_asset_balance.adjusted_cost));
720 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
721 p_full_path => l_path_name,
722 p_string => ' Operating Account :'||TO_CHAR(l_curr_asset_balance.operating_acct));
723 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
724 p_full_path => l_path_name,
725 p_string => ' Reval Reserve :'||TO_CHAR(l_curr_asset_balance.reval_reserve));
726 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
727 p_full_path => l_path_name,
728 p_string => ' Deprn Amount :'||TO_CHAR(l_curr_asset_balance.deprn_amount));
729 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
730 p_full_path => l_path_name,
731 p_string => ' Deprn Reserve :'||TO_CHAR(l_curr_asset_balance.deprn_reserve));
732 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
733 p_full_path => l_path_name,
734 p_string => ' Backlog Deprn Reserve :'||TO_CHAR(l_curr_asset_balance.backlog_deprn_reserve));
735 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
736 p_full_path => l_path_name,
737 p_string => ' General Fund :'||TO_CHAR(l_curr_asset_balance.general_fund));
738 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
739 p_full_path => l_path_name,
740 p_string => ' Current Reval Factor :'||TO_CHAR(l_curr_asset_balance.current_reval_factor));
741 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
742 p_full_path => l_path_name,
743 p_string => ' Cumulative Reval Factor :'||TO_CHAR(l_curr_asset_balance.Cumulative_reval_factor));
744 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
745 p_full_path => l_path_name,
746 p_string => ' IAC deprn resrevre..... amount '||P_asset_iac_adj_info.deprn_reserve);
747
748 IF (p_adj_hist.period_counter > l_asset_iac_adj_info.last_period_counter) THEN
749 l_curr_asset_balance.deprn_amount := 0;
750 ELSE
751 l_curr_asset_balance.deprn_amount := l_asset_iac_adj_info.deprn_amount * (l_curr_asset_balance.Cumulative_reval_factor-1);
752 IF NOT (igi_iac_common_utils.iac_round(l_curr_asset_balance.deprn_amount,l_curr_asset_balance.book_type_code)) THEN
753 RETURN FALSE;
754 END IF;
755 END IF;
756 l_iac_current_ytd := l_asset_iac_adj_info.ytd_deprn * (l_curr_asset_balance.Cumulative_reval_factor-1);
757 IF NOT (igi_iac_common_utils.iac_round(l_iac_current_ytd,l_curr_asset_balance.book_type_code)) THEN
758 RETURN FALSE;
759 END IF;
760 l_fa_current_ytd := l_asset_iac_adj_info.ytd_deprn;
761 IF NOT (igi_iac_common_utils.iac_round(l_fa_current_ytd,l_curr_asset_balance.book_type_code)) THEN
762 RETURN FALSE;
763 END IF;
764
765 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
766 p_full_path => l_path_name,
767 p_string => ' Asset: after new calucation ');
768 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
769 p_full_path => l_path_name,
770 p_string => ' Asset_id:'||l_curr_asset_balance.asset_id);
771 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
772 p_full_path => l_path_name,
773 p_string => ' Period_counter :'||l_curr_asset_balance.period_counter);
774 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
775 p_full_path => l_path_name,
776 p_string => ' Net book value :'||TO_CHAR(l_curr_asset_balance.net_book_value));
777 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
778 p_full_path => l_path_name,
779 p_string => ' Adjusted Cost :'||TO_CHAR(l_curr_asset_balance.adjusted_cost));
780 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
781 p_full_path => l_path_name,
782 p_string => ' Operating Account :'||TO_CHAR(l_curr_asset_balance.operating_acct));
783 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
784 p_full_path => l_path_name,
785 p_string => ' Reval Reserve :'||TO_CHAR(l_curr_asset_balance.reval_reserve));
786 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
787 p_full_path => l_path_name,
788 p_string => ' Deprn Amount :'||TO_CHAR(l_curr_asset_balance.deprn_amount));
789 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
790 p_full_path => l_path_name,
791 p_string => ' Deprn Reserve :'||TO_CHAR(l_curr_asset_balance.deprn_reserve));
792 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
793 p_full_path => l_path_name,
794 p_string => ' Backlog Deprn Reserve :'||TO_CHAR(l_curr_asset_balance.backlog_deprn_reserve));
795 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
796 p_full_path => l_path_name,
797 p_string => ' General Fund :'||TO_CHAR(l_curr_asset_balance.general_fund));
798 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
799 p_full_path => l_path_name,
800 p_string => ' Current Reval Factor :'||TO_CHAR(l_curr_asset_balance.current_reval_factor));
801 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
802 p_full_path => l_path_name,
803 p_string => ' Cumulative Reval Factor :'||TO_CHAR(l_curr_asset_balance.Cumulative_reval_factor));
804
805 l_asset_balance_mvmt.asset_id := l_curr_asset_balance.asset_id;
806 l_asset_balance_mvmt.book_type_code := l_curr_asset_balance.book_type_code;
807 l_asset_balance_mvmt.period_counter := p_adj_hist.period_counter;
808 l_asset_balance_mvmt.net_book_value := l_curr_asset_balance.net_book_value - l_prev_asset_balance.net_book_value;
809 l_asset_balance_mvmt.adjusted_cost := l_curr_asset_balance.adjusted_cost - l_prev_asset_balance.adjusted_cost;
810 l_asset_balance_mvmt.operating_acct := l_curr_asset_balance.operating_acct - l_prev_asset_balance.operating_acct;
811 l_asset_balance_mvmt.reval_reserve := l_curr_asset_balance.reval_reserve - l_prev_asset_balance.reval_reserve;
812 l_asset_balance_mvmt.deprn_amount := l_curr_asset_balance.deprn_amount;
813 l_asset_balance_mvmt.deprn_reserve := l_curr_asset_balance.deprn_reserve - l_prev_asset_balance.deprn_reserve;
814 l_asset_balance_mvmt.backlog_deprn_reserve := l_curr_asset_balance.backlog_deprn_reserve - l_prev_asset_balance.backlog_deprn_reserve;
815 l_asset_balance_mvmt.General_Fund := l_curr_asset_balance.General_Fund - l_prev_asset_balance.General_Fund;
816
817 OPEN c_get_fa_asset(l_curr_asset_balance.asset_id);
818 FETCH c_get_fa_asset INTO l_category_id,l_asset_units;
819 CLOSE c_get_fa_asset;
820 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
821 p_full_path => l_path_name,
822 p_string => ' Units assigned for the asset :'||TO_CHAR(l_asset_units));
823
824 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
825 p_full_path => l_path_name,
826 p_string => ' Processing incative distributions ');
827 FOR l_det_balances IN c_get_inactive_det_balances(l_asset_balance_mvmt.asset_id,
828 l_asset_balance_mvmt.book_type_code,
829 l_prev_adjustment_id )
830 LOOP
831 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
832 p_full_path => l_path_name,
833 p_string => ' Inactive distribution' || l_det_balances.distribution_id);
834 l_rowid := NULL;
835 IGI_IAC_DET_BALANCES_PKG.insert_row (
836 x_rowid => l_rowid,
837 x_adjustment_id => l_adjustment_id,
838 x_asset_id => l_det_balances.asset_id,
839 x_distribution_id => l_det_balances.distribution_id,
840 x_book_type_code => l_det_balances.book_type_code,
841 x_period_counter => l_asset_balance_mvmt.period_counter,
842 x_adjustment_cost => l_det_balances.adjustment_cost,
843 x_net_book_value => l_det_balances.net_book_value,
844 x_reval_reserve_cost => l_det_balances.reval_reserve_cost,
845 x_reval_reserve_backlog => l_det_balances.reval_reserve_backlog,
846 x_reval_reserve_gen_fund => l_det_balances.reval_reserve_gen_fund,
847 x_reval_reserve_net => l_det_balances.reval_reserve_net,
848 x_operating_acct_cost => l_det_balances.operating_acct_cost,
849 x_operating_acct_backlog => l_det_balances.operating_acct_backlog,
850 x_operating_acct_net => l_det_balances.operating_acct_net,
851 x_operating_acct_ytd => l_det_balances.operating_acct_ytd,
852 x_deprn_period => l_det_balances.deprn_period,
853 x_deprn_ytd => l_det_balances.deprn_ytd,
854 x_deprn_reserve => l_det_balances.deprn_reserve,
855 x_deprn_reserve_backlog => l_det_balances.deprn_reserve_backlog,
856 x_general_fund_per => l_det_balances.general_fund_per,
857 x_general_fund_acc => l_det_balances.general_fund_acc,
858 x_last_reval_date => l_det_balances.last_reval_date,
859 x_current_reval_factor => l_det_balances.current_reval_factor,
860 x_cumulative_reval_factor => l_det_balances.cumulative_reval_factor,
861 x_active_flag => l_det_balances.active_flag,
862 x_mode => 'R' );
863 l_iac_inactive_dists_ytd := l_iac_inactive_dists_ytd + l_det_balances.deprn_ytd;
864
865 OPEN C_get_iac_fa_deprn(l_det_balances.book_type_code,
866 l_det_balances.asset_id,
867 l_det_balances.distribution_id,
868 l_prev_adjustment_id
869 );
870 FETCH c_get_iac_fa_deprn INTO l_get_iac_fa_deprn;
871 IF C_get_iac_fa_deprn%FOUND THEN
872 l_rowid := NULL;
873 igi_iac_fa_deprn_pkg.insert_row(
874 x_rowid => l_rowid,
875 x_book_type_code => l_det_balances.book_type_code,
876 x_asset_id => l_det_balances.asset_id,
877 x_distribution_id => l_det_balances.distribution_id,
878 x_period_counter => l_asset_balance_mvmt.period_counter,
879 x_adjustment_id => l_adjustment_id,
880 x_deprn_period => l_get_iac_fa_deprn.deprn_period,
881 x_deprn_ytd => l_get_iac_fa_deprn.deprn_ytd ,
882 x_deprn_reserve => l_get_iac_fa_deprn.deprn_reserve,
883 x_active_flag => l_get_iac_fa_deprn.active_flag,
884 x_mode => 'R');
885 END IF;
886 CLOSE c_get_iac_fa_deprn;
887 l_fa_inactive_dists_ytd := l_fa_inactive_dists_ytd + l_get_iac_fa_deprn.deprn_ytd;
888 END LOOP;
889
890 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
891 p_full_path => l_path_name,
892 p_string => ' End of Processing incative distributions ');
893 l_iac_active_dists_ytd := l_iac_current_ytd - l_iac_inactive_dists_ytd;
894 l_fa_active_dists_ytd := l_fa_current_ytd - l_fa_inactive_dists_ytd;
895
896 if l_curr_asset_balance.adjusted_cost >= 0 then
897 l_operatg_cost := 0;
898 l_operatg_net := l_asset_balance_mvmt.Operating_Acct;
899 l_operatg_blog := l_operatg_cost - l_operatg_net;
900
901 l_reserve_blog := l_asset_balance_mvmt.backlog_deprn_reserve + l_asset_balance_mvmt.Operating_acct;
902 l_deprn_blog := l_asset_balance_mvmt.backlog_deprn_reserve;
903 l_reserve_cost := l_asset_balance_mvmt.adjusted_cost;
904 else
905 l_operatg_net := l_asset_balance_mvmt.operating_acct;
906 l_operatg_blog := l_asset_balance_mvmt.backlog_deprn_reserve + l_asset_balance_mvmt.General_Fund;
907 l_operatg_cost := l_asset_balance_mvmt.adjusted_cost;
908 l_deprn_blog := l_asset_balance_mvmt.backlog_deprn_reserve;
909
910 l_reserve_cost := 0;
911 l_reserve_blog := l_reserve_cost - l_asset_balance_mvmt.General_Fund;
912 end if;
913
914 IF p_asset_iac_adj_info.period_counter_fully_reserved IS NOT NULL THEN
915 l_asset_balance_mvmt.deprn_amount := 0;
916 l_asset_iac_adj_info.deprn_amount := 0;
917 l_curr_asset_balance.deprn_amount := 0;
918 END IF;
919
920 l_total_db.adjustment_id := l_adjustment_id;
921 l_total_db.asset_id := l_asset_balance_mvmt.asset_id;
922 l_total_db.distribution_id := -1;
923 l_total_db.book_type_code := l_asset_balance_mvmt.book_type_code;
924 l_total_db.period_counter := l_asset_balance_mvmt.period_counter;
925 l_total_db.adjustment_cost := l_asset_balance_mvmt.adjusted_cost;
926 l_total_db.reval_reserve_cost := l_reserve_cost;
927 l_total_db.reval_reserve_backlog := l_reserve_blog;
928 l_total_db.reval_reserve_gen_fund := l_asset_balance_mvmt.general_fund;
929 l_total_db.reval_reserve_net := l_asset_balance_mvmt.reval_reserve;
930 l_total_db.operating_acct_cost := l_operatg_cost ;
931 l_total_db.operating_acct_backlog := l_operatg_blog;
932 l_total_db.operating_acct_net := l_operatg_net;
933 l_total_db.operating_acct_ytd := l_operatg_ytd;
934 l_total_db.deprn_period := l_asset_balance_mvmt.deprn_amount;
935 l_total_db.deprn_ytd := l_iac_active_dists_ytd;
936
937 l_total_db.deprn_reserve := l_asset_balance_mvmt.deprn_reserve;
938 l_total_db.deprn_reserve_backlog := l_deprn_blog;
939
940 l_total_db.general_fund_per := l_asset_balance_mvmt.deprn_amount;
941 l_total_db.general_fund_acc := l_asset_balance_mvmt.general_fund;
942 l_total_db.last_reval_date := sysdate;
943 l_total_db.current_reval_factor := l_asset_balance_mvmt.current_reval_factor;
944 l_total_db.cumulative_reval_factor := l_asset_balance_mvmt.cumulative_reval_factor;
945 l_total_db.net_book_value := l_total_db.adjustment_cost - l_total_db.deprn_reserve -
946 l_total_db.deprn_reserve_backlog;
947 l_total_db.active_flag := NULL;
948
949 l_total_db_fa.deprn_period := l_asset_iac_adj_info.deprn_amount;
950 l_total_db_fa.deprn_ytd := l_fa_active_dists_ytd;
951 l_total_db_fa.deprn_reserve := l_asset_iac_adj_info.deprn_reserve;
952 l_remaining_db := l_total_db;
953 l_remaining_db_fa := l_total_db_fa;
954
955 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
956 p_full_path => l_path_name,
957 p_string => ' +acctg creation get gl information');
958 IF NOT IGI_IAC_COMMON_UTILS.GET_BOOK_GL_INFO
959 ( X_BOOK_TYPE_CODE => l_asset_balance_mvmt.book_type_code
960 , SET_OF_BOOKS_ID => l_sob_id
961 , CHART_OF_ACCOUNTS_ID => l_coa_id
962 , CURRENCY => l_currency
963 , PRECISION => l_precision
964 )
965 THEN
966 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
967 p_full_path => l_path_name,
968 p_string => ' +acctg creation unable to get gl info');
969 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
970 p_full_path => l_path_name,
971 p_string => ' end create_iac_acctg');
972 RETURN FALSE;
973 END IF;
974
975 IF NOT igi_iac_reval_utilities.prorate_active_dists_YTD ( fp_asset_id => l_asset_balance_mvmt.asset_id
976 , fp_book_type_code => l_asset_balance_mvmt.book_type_code
977 , fp_current_period_counter => l_asset_balance_mvmt.period_counter
978 , fp_prorate_dists_tab => l_ytd_prorate_dists_tab
979 , fp_prorate_dists_idx => l_ytd_prorate_dists_idx
980 ) THEN
981 RETURN FALSE;
982 END IF;
983
984 FOR l_det_balances IN c_get_active_det_balances(l_asset_balance_mvmt.book_type_code,l_asset_balance_mvmt.asset_id,l_prev_adjustment_id)
985 LOOP
986 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
987 p_full_path => l_path_name,
988 p_string => ' +DET BALANCES');
989 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
990 p_full_path => l_path_name,
991 p_string => ' x_adjustment_id => '|| l_det_balances.adjustment_id);
992 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
993 p_full_path => l_path_name,
994 p_string => ' x_asset_id =>'|| l_det_balances.asset_id);
995 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
996 p_full_path => l_path_name,
997 p_string => ' x_distribution_id => '||l_det_balances.distribution_id);
998 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
999 p_full_path => l_path_name,
1000 p_string => ' x_book_type_code => '||l_det_balances.book_type_code);
1001 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1002 p_full_path => l_path_name,
1003 p_string => ' x_period_counter => '||l_det_balances.period_counter);
1004 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1005 p_full_path => l_path_name,
1006 p_string => ' x_adjustment_cost => '||l_det_balances.adjustment_cost);
1007 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1008 p_full_path => l_path_name,
1009 p_string => ' x_net_book_value => '||l_det_balances.net_book_value);
1010 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1011 p_full_path => l_path_name,
1012 p_string => ' x_reval_reserve_cost => '||l_det_balances.reval_reserve_cost);
1013 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1014 p_full_path => l_path_name,
1015 p_string => ' x_reval_reserve_backlog => '||l_det_balances.reval_reserve_backlog);
1016 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1017 p_full_path => l_path_name,
1018 p_string => ' x_reval_reserve_gen_fund => '||l_det_balances.reval_reserve_gen_fund);
1019 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1020 p_full_path => l_path_name,
1021 p_string => ' x_reval_reserve_net => '||l_det_balances.reval_reserve_net);
1022 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1023 p_full_path => l_path_name,
1024 p_string => ' x_operating_acct_cost => '||l_det_balances.operating_acct_cost);
1025 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1026 p_full_path => l_path_name,
1027 p_string => ' x_operating_acct_backlog => '||l_det_balances.operating_acct_backlog);
1028 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1029 p_full_path => l_path_name,
1030 p_string => ' x_operating_acct_net => '||l_det_balances.operating_acct_net);
1031 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1032 p_full_path => l_path_name,
1033 p_string => ' x_operating_acct_ytd => '||l_det_balances.operating_acct_ytd);
1034 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1035 p_full_path => l_path_name,
1036 p_string => ' x_deprn_period => '||l_det_balances.deprn_period);
1037 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1038 p_full_path => l_path_name,
1039 p_string => ' x_deprn_ytd => '||l_det_balances.deprn_ytd);
1040 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1041 p_full_path => l_path_name,
1042 p_string => ' x_deprn_reserve => '||l_det_balances.deprn_reserve);
1043 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1044 p_full_path => l_path_name,
1045 p_string => ' x_deprn_reserve_backlog => '||l_det_balances.deprn_reserve_backlog);
1046 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1047 p_full_path => l_path_name,
1048 p_string => ' x_general_fund_per => '||l_det_balances.general_fund_per);
1049 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1050 p_full_path => l_path_name,
1051 p_string => ' x_general_fund_acc => '||l_det_balances.general_fund_acc);
1052 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1053 p_full_path => l_path_name,
1054 p_string => ' x_last_reval_date => '||l_det_balances.last_reval_date);
1055 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1056 p_full_path => l_path_name,
1057 p_string => ' x_current_reval_factor => '||l_det_balances.current_reval_factor);
1058 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1059 p_full_path => l_path_name,
1060 p_string => ' x_cumulative_reval_factor => '||l_det_balances.cumulative_reval_factor);
1061 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1062 p_full_path => l_path_name,
1063 p_string => ' x_active_flag => '||l_det_balances.active_flag);
1064
1065 l_total_dist_units := l_total_dist_units + l_det_balances.units_assigned;
1066 l_dist_prorate_factor := l_det_balances.units_assigned / l_asset_units;
1067
1068 l_dist_ytd_factor := 0;
1069 idx_YTD := l_YTD_prorate_dists_tab.FIRST;
1070 WHILE idx_YTD <= l_YTD_prorate_dists_tab.LAST LOOP
1071 IF l_YTD_prorate_dists_tab(idx_YTD).distribution_id = l_det_balances.distribution_id THEN
1072 l_dist_ytd_factor := l_YTD_prorate_dists_tab(idx_YTD).ytd_prorate_factor;
1073 EXIT;
1074 END IF;
1075 idx_ytd := l_YTD_prorate_dists_tab.Next(idx_ytd);
1076 END LOOP;
1077
1078 IF l_curr_asset_balance.adjusted_cost >= 0 THEN
1079 l_reserve_cost := l_dist_prorate_factor * l_total_db.adjustment_cost;
1080 l_reserve_blog := l_dist_prorate_factor * l_total_db.reval_reserve_backlog;
1081 l_operatg_cost := 0;
1082 l_operatg_blog := l_dist_prorate_factor * l_total_db.operating_acct_backlog;
1083 l_operatg_net := l_operatg_cost - l_operatg_blog;
1084 l_deprn_blog := l_dist_prorate_factor * l_total_db.deprn_reserve_backlog;
1085 ELSE
1086 l_operatg_blog := l_dist_prorate_factor * l_total_db.operating_acct_backlog;
1087 l_operatg_cost := l_dist_prorate_factor * l_total_db.operating_acct_cost;
1088 l_operatg_net := l_operatg_cost - l_operatg_blog;
1089 l_reserve_cost := 0;
1090 l_reserve_blog := l_dist_prorate_factor * l_total_db.reval_reserve_backlog;
1091 l_deprn_blog := l_dist_prorate_factor * l_total_db.deprn_reserve_backlog;
1092 END IF;
1093
1094 IF (l_total_dist_units < l_asset_units) THEN
1095 l_current_db.adjustment_id := l_adjustment_id;
1096 l_current_db.asset_id := l_det_balances.asset_id;
1097 l_current_db.distribution_id := l_det_balances.distribution_id;
1098 l_current_db.book_type_code := l_det_balances.book_type_code;
1099 l_current_db.period_counter := l_asset_balance_mvmt.period_counter;
1100 l_current_db.adjustment_cost := l_dist_prorate_factor * l_total_db.adjustment_cost;
1101 l_current_db.net_book_value := l_dist_prorate_factor * l_total_db.net_book_value;
1102 l_current_db.reval_reserve_cost := l_reserve_cost;
1103 l_current_db.reval_reserve_backlog := l_reserve_blog;
1104 l_current_db.reval_reserve_gen_fund := l_dist_prorate_factor * l_total_db.reval_reserve_gen_fund;
1105 l_current_db.reval_reserve_net := l_dist_prorate_factor * l_total_db.reval_reserve_net;
1106 l_current_db.operating_acct_cost := l_operatg_cost;
1107 l_current_db.operating_acct_backlog := l_operatg_blog;
1108 l_current_db.operating_acct_net := l_operatg_net;
1109 l_current_db.operating_acct_ytd := l_det_balances.operating_acct_ytd + l_operatg_net;
1110 l_current_db.deprn_period := l_dist_prorate_factor * l_total_db.deprn_period;
1111 l_current_db.deprn_ytd := l_dist_ytd_factor * l_total_db.deprn_ytd;
1112 l_current_db.deprn_reserve := l_dist_prorate_factor * l_total_db.deprn_reserve;
1113 l_current_db.deprn_reserve_backlog := l_deprn_blog;
1114 l_current_db.general_fund_per := l_dist_prorate_factor * l_total_db.general_fund_per;
1115 l_current_db.general_fund_acc := l_dist_prorate_factor * l_total_db.general_fund_acc;
1116 l_current_db.last_reval_date := l_det_balances.last_reval_date;
1117 l_current_db.current_reval_factor := l_det_balances.current_reval_factor;
1118 l_current_db.cumulative_reval_factor := l_det_balances.cumulative_reval_factor;
1119 l_current_db.active_flag := l_det_balances.active_flag;
1120
1121 IF NOT (igi_iac_common_utils.iac_round(l_current_db.adjustment_cost,l_det_balances.book_type_code)) THEN
1122 RETURN FALSE;
1123 END IF;
1124 IF NOT (igi_iac_common_utils.iac_round(l_current_db.net_book_value,l_det_balances.book_type_code)) THEN
1125 RETURN FALSE;
1126 END IF;
1127 IF NOT (igi_iac_common_utils.iac_round(l_current_db.reval_reserve_cost,l_det_balances.book_type_code)) THEN
1128 RETURN FALSE;
1129 END IF;
1130 IF NOT (igi_iac_common_utils.iac_round(l_current_db.reval_reserve_backlog,l_det_balances.book_type_code)) THEN
1131 RETURN FALSE;
1132 END IF;
1133 IF NOT (igi_iac_common_utils.iac_round(l_current_db.reval_reserve_gen_fund,l_det_balances.book_type_code)) THEN
1134 RETURN FALSE;
1135 END IF;
1136 IF NOT (igi_iac_common_utils.iac_round(l_current_db.reval_reserve_net,l_det_balances.book_type_code)) THEN
1137 RETURN FALSE;
1138 END IF;
1139 IF NOT (igi_iac_common_utils.iac_round(l_current_db.operating_acct_cost,l_det_balances.book_type_code)) THEN
1140 RETURN FALSE;
1141 END IF;
1142 IF NOT (igi_iac_common_utils.iac_round(l_current_db.operating_acct_backlog,l_det_balances.book_type_code)) THEN
1143 RETURN FALSE;
1144 END IF;
1145 IF NOT (igi_iac_common_utils.iac_round(l_current_db.operating_acct_net,l_det_balances.book_type_code)) THEN
1146 RETURN FALSE;
1147 END IF;
1148 IF NOT (igi_iac_common_utils.iac_round(l_current_db.operating_acct_ytd,l_det_balances.book_type_code)) THEN
1149 RETURN FALSE;
1150 END IF;
1151 IF NOT (igi_iac_common_utils.iac_round(l_current_db.deprn_period,l_det_balances.book_type_code)) THEN
1152 RETURN FALSE;
1153 END IF;
1154 IF NOT (igi_iac_common_utils.iac_round(l_current_db.deprn_ytd,l_det_balances.book_type_code)) THEN
1155 RETURN FALSE;
1156 END IF;
1157 IF NOT (igi_iac_common_utils.iac_round(l_current_db.deprn_reserve,l_det_balances.book_type_code)) THEN
1158 RETURN FALSE;
1159 END IF;
1160 IF NOT (igi_iac_common_utils.iac_round(l_current_db.deprn_reserve_backlog,l_det_balances.book_type_code)) THEN
1161 RETURN FALSE;
1162 END IF;
1163 IF NOT (igi_iac_common_utils.iac_round(l_current_db.general_fund_per,l_det_balances.book_type_code)) THEN
1164 RETURN FALSE;
1165 END IF;
1166 IF NOT (igi_iac_common_utils.iac_round(l_current_db.general_fund_acc,l_det_balances.book_type_code)) THEN
1167 RETURN FALSE;
1168 END IF;
1169 IF NOT (igi_iac_common_utils.iac_round(l_current_db_fa.deprn_period,l_det_balances.book_type_code)) THEN
1170 RETURN FALSE;
1171 END IF;
1172 IF NOT (igi_iac_common_utils.iac_round(l_current_db_fa.deprn_ytd,l_det_balances.book_type_code)) THEN
1173 RETURN FALSE;
1174 END IF;
1175 IF NOT (igi_iac_common_utils.iac_round(l_current_db_fa.deprn_reserve,l_det_balances.book_type_code)) THEN
1176 RETURN FALSE;
1177 END IF;
1178
1179 l_remaining_db.adjustment_cost := nvl(l_remaining_db.adjustment_cost,0)
1180 - nvl(l_current_db.adjustment_cost,0) ;
1181 l_remaining_db.reval_reserve_cost := nvl(l_remaining_db.reval_reserve_cost,0)
1182 - nvl(l_current_db.reval_reserve_cost,0) ;
1183 l_remaining_db.reval_reserve_backlog := nvl(l_remaining_db.reval_reserve_backlog,0)
1184 - nvl(l_current_db.reval_reserve_backlog,0) ;
1185 l_remaining_db.reval_reserve_gen_fund := nvl(l_remaining_db.reval_reserve_gen_fund,0)
1186 - nvl(l_current_db.reval_reserve_gen_fund,0) ;
1187 l_remaining_db.reval_reserve_net := nvl(l_remaining_db.reval_reserve_cost,0)
1188 - nvl(l_remaining_db.reval_reserve_backlog,0)
1189 - nvl(l_remaining_db.reval_reserve_gen_fund,0) ;
1190 l_remaining_db.operating_acct_cost := nvl(l_remaining_db.operating_acct_cost,0)
1191 - nvl(l_current_db.operating_acct_cost,0) ;
1192 l_remaining_db.operating_acct_backlog := nvl(l_remaining_db.operating_acct_backlog,0)
1193 - nvl(l_current_db.operating_acct_backlog,0) ;
1194 l_remaining_db.operating_acct_net := l_remaining_db.operating_acct_cost
1195 - l_remaining_db.operating_acct_backlog ;
1196 l_remaining_db.operating_acct_ytd := nvl(l_remaining_db.operating_acct_ytd ,0)
1197 - l_current_db.operating_acct_ytd;
1198 l_remaining_db.deprn_period := nvl(l_remaining_db.deprn_period,0)
1199 - nvl(l_current_db.deprn_period,0) ;
1200 l_remaining_db.deprn_ytd := nvl(l_remaining_db.deprn_ytd ,0)
1201 - nvl(l_current_db.deprn_ytd,0) ;
1202 l_remaining_db.deprn_reserve := nvl(l_remaining_db.deprn_reserve ,0)
1203 - nvl(l_current_db.deprn_reserve,0) ;
1204 l_remaining_db.deprn_reserve_backlog := nvl(l_remaining_db.deprn_reserve_backlog ,0)
1205 - nvl(l_current_db.deprn_reserve_backlog,0) ;
1206 l_remaining_db.general_fund_per := nvl(l_remaining_db.general_fund_per ,0)
1207 - nvl(l_current_db.general_fund_per,0) ;
1208 l_remaining_db.general_fund_acc := nvl(l_remaining_db.general_fund_acc ,0)
1209 - nvl(l_current_db.general_fund_acc,0) ;
1210
1211 l_current_db_fa.deprn_period := l_dist_prorate_factor * l_total_db_fa.deprn_period;
1212 l_current_db_fa.deprn_ytd := l_dist_ytd_factor * l_total_db_fa.deprn_ytd;
1213 l_current_db_fa.deprn_reserve := l_dist_prorate_factor * l_total_db_fa.deprn_reserve;
1214
1215 l_remaining_db_fa.deprn_period := l_remaining_db_fa.deprn_period - l_current_db_fa.deprn_period;
1216 l_remaining_db_fa.deprn_ytd := l_remaining_db_fa.deprn_ytd - l_current_db_fa.deprn_ytd;
1217 l_remaining_db_fa.deprn_reserve := l_remaining_db_fa.deprn_reserve - l_current_db_fa.deprn_reserve;
1218
1219 ELSE
1220 l_current_db.adjustment_id := l_adjustment_id;
1221 l_current_db.asset_id := l_det_balances.asset_id;
1222 l_current_db.distribution_id := l_det_balances.distribution_id;
1223 l_current_db.book_type_code := l_det_balances.book_type_code;
1224 l_current_db.period_counter := l_asset_balance_mvmt.period_counter;
1225 l_current_db.adjustment_cost := l_remaining_db.adjustment_cost;
1226 l_current_db.net_book_value := l_remaining_db.net_book_value;
1227 l_current_db.reval_reserve_cost := l_remaining_db.reval_reserve_cost;
1228 l_current_db.reval_reserve_backlog := l_remaining_db.reval_reserve_backlog;
1229 l_current_db.reval_reserve_gen_fund := l_remaining_db.reval_reserve_gen_fund;
1230 l_current_db.reval_reserve_net := l_remaining_db.reval_reserve_net;
1231 l_current_db.operating_acct_cost := l_remaining_db.operating_acct_cost;
1232 l_current_db.operating_acct_backlog := l_remaining_db.operating_acct_backlog;
1233 l_current_db.operating_acct_net := l_remaining_db.operating_acct_net;
1234 l_current_db.operating_acct_ytd := l_det_balances.operating_acct_ytd + l_current_db.operating_acct_net;
1235 l_current_db.deprn_period := l_remaining_db.deprn_period;
1236 l_current_db.deprn_ytd := l_remaining_db.deprn_ytd;
1237 l_current_db.deprn_reserve := l_remaining_db.deprn_reserve;
1238 l_current_db.deprn_reserve_backlog := l_remaining_db.deprn_reserve_backlog;
1239 l_current_db.general_fund_per := l_remaining_db.general_fund_per;
1240 l_current_db.general_fund_acc := l_remaining_db.general_fund_acc;
1241 l_current_db.last_reval_date := l_det_balances.last_reval_date;
1242 l_current_db.current_reval_factor := l_det_balances.current_reval_factor;
1243 l_current_db.cumulative_reval_factor := l_det_balances.cumulative_reval_factor;
1244 l_current_db.active_flag := l_det_balances.active_flag;
1245
1246 l_current_db_fa.deprn_period := l_remaining_db_fa.deprn_period;
1247 l_current_db_fa.deprn_ytd := l_remaining_db_fa.deprn_ytd;
1248 l_current_db_fa.deprn_reserve := l_remaining_db_fa.deprn_reserve;
1249
1250 IF NOT (igi_iac_common_utils.iac_round(l_current_db_fa.deprn_period,l_det_balances.book_type_code)) THEN
1251 RETURN FALSE;
1252 END IF;
1253
1254 END IF;
1255
1256 -- get the account details for adjustments
1257 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1258 p_full_path => l_path_name,
1259 p_string => ' +acctg creation get all accounts');
1260 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1261 p_full_path => l_path_name,
1262 p_string => ' +distribution id '|| l_det_balances.distribution_id );
1263
1264 IF NOT IGI_IAC_COMMON_UTILS.get_account_ccid
1265 ( X_book_type_code => l_det_balances.book_type_code
1266 , X_asset_id => l_det_balances.asset_id
1267 , X_distribution_id => l_det_balances.distribution_id
1268 , X_account_type => 'REVAL_RESERVE_ACCT'
1269 , account_ccid => l_revl_rsv_ccid
1270 )
1271 THEN
1272 igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
1273 p_full_path => l_path_name,
1274 p_string => ' Error in fetching reval reserve');
1275 RETURN FALSE;
1276 END IF;
1277
1278 IF NOT IGI_IAC_COMMON_UTILS.get_account_ccid
1279 ( X_book_type_code => l_det_balances.book_type_code
1280 , X_asset_id => l_det_balances.asset_id
1281 , X_distribution_id => l_det_balances.distribution_id
1282 , X_account_type => 'GENERAL_FUND_ACCT'
1283 , account_ccid => l_gen_fund_ccid
1284 )
1285 THEN
1286 igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
1287 p_full_path => l_path_name,
1288 p_string => ' Error in fetching general fund');
1289 RETURN FALSE;
1290 END IF;
1291
1292 IF NOT IGI_IAC_COMMON_UTILS.get_account_ccid
1293 ( X_book_type_code => l_det_balances.book_type_code
1294 , X_asset_id => l_det_balances.asset_id
1295 , X_distribution_id => l_det_balances.distribution_id
1296 , X_account_type => 'BACKLOG_DEPRN_RSV_ACCT'
1297 , account_ccid => l_blog_rsv_ccid
1298 )
1299 THEN
1300 igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
1301 p_full_path => l_path_name,
1302 p_string => ' Error in fetching backlog deprn rsv acct');
1303 RETURN FALSE;
1304 END IF;
1305
1306 IF NOT IGI_IAC_COMMON_UTILS.get_account_ccid
1307 ( X_book_type_code => l_det_balances.book_type_code
1308 , X_asset_id => l_det_balances.asset_id
1309 , X_distribution_id => l_det_balances.distribution_id
1310 , X_account_type => 'OPERATING_EXPENSE_ACCT'
1311 , account_ccid => l_op_exp_ccid
1312 )
1313 THEN
1314 igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
1315 p_full_path => l_path_name,
1316 p_string => ' Error in fetching operating expense acct');
1317 RETURN FALSE;
1318 END IF;
1319
1320 IF NOT IGI_IAC_COMMON_UTILS.get_account_ccid
1321 ( X_book_type_code => l_det_balances.book_type_code
1322 , X_asset_id => l_det_balances.asset_id
1323 , X_distribution_id => l_det_balances.distribution_id
1324 , X_account_type => 'DEPRN_RESERVE_ACCT'
1325 , account_ccid => l_deprn_rsv_ccid
1326 )
1327 THEN
1328 igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
1329 p_full_path => l_path_name,
1330 p_string => ' Error in fetching deprn reserve');
1331 RETURN FALSE;
1332 END IF;
1333
1334 IF NOT IGI_IAC_COMMON_UTILS.get_account_ccid
1335 ( X_book_type_code => l_det_balances.book_type_code
1336 , X_asset_id => l_det_balances.asset_id
1337 , X_distribution_id => l_det_balances.distribution_id
1338 , X_account_type => 'DEPRN_EXPENSE_ACCT'
1339 , account_ccid => l_deprn_exp_ccid
1340 )
1341 THEN
1342 igi_iac_debug_pkg.debug_other_string(p_level => g_error_level,
1343 p_full_path => l_path_name,
1344 p_string => ' Error in fecthing deprn expense acct');
1345 RETURN FALSE;
1346 END IF;
1347
1348 /* Create accounting entries for non zero values*/
1349 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1350 p_full_path => l_path_name,
1351 p_string => ' Creating accounting entries in igi_iac_adjustments');
1352 IF l_current_db.deprn_reserve <> 0 THEN
1353 l_rowid := NULL ;
1354 igi_iac_adjustments_pkg.insert_row(
1355 X_rowid => l_rowid ,
1356 X_adjustment_id => l_adjustment_id ,
1357 X_book_type_code => l_det_balances.book_type_code ,
1358 X_code_combination_id => l_deprn_exp_ccid,
1359 X_set_of_books_id => l_sob_id ,
1360 X_dr_cr_flag => 'DR' ,
1361 X_amount => l_current_db.deprn_reserve,
1362 X_adjustment_type => 'EXPENSE' ,
1363 X_transfer_to_gl_flag => 'Y' ,
1364 X_units_assigned => l_det_balances.units_assigned ,
1365 X_asset_id => l_det_balances.asset_id ,
1366 X_distribution_id => l_det_balances.distribution_id ,
1367 X_period_counter => l_asset_balance_mvmt.period_counter,
1368 X_adjustment_offset_type => 'RESERVE',
1369 X_report_ccid => Null,
1370 x_mode => 'R',
1371 X_event_id => p_event_id
1372 ) ;
1373
1374 l_rowid := NULL ;
1375 igi_iac_adjustments_pkg.insert_row(
1376 X_rowid => l_rowid ,
1377 X_adjustment_id => l_adjustment_id ,
1378 X_book_type_code => l_det_balances.book_type_code ,
1379 X_code_combination_id => l_deprn_rsv_ccid,
1380 X_set_of_books_id => l_sob_id ,
1381 X_dr_cr_flag => 'CR' ,
1382 X_amount =>l_current_db.deprn_reserve,
1383 X_adjustment_type => 'RESERVE' ,
1384 X_transfer_to_gl_flag => 'Y' ,
1385 X_units_assigned => l_det_balances.units_assigned ,
1386 X_asset_id => l_det_balances.asset_id ,
1387 X_distribution_id => l_det_balances.distribution_id ,
1388 X_period_counter => l_asset_balance_mvmt.period_counter,
1389 X_adjustment_offset_type => 'EXPENSE',
1390 X_report_ccid => Null,
1391 x_mode => 'R',
1392 X_event_id => p_event_id
1393 ) ;
1394 END IF;
1395
1396 IF l_current_db.reval_reserve_gen_fund <> 0 THEN
1397 l_rowid := NULL ;
1398 igi_iac_adjustments_pkg.insert_row(
1399 X_rowid => l_rowid ,
1400 X_adjustment_id => l_adjustment_id ,
1401 X_book_type_code => l_det_balances.book_type_code ,
1402 X_code_combination_id => l_revl_rsv_ccid,
1403 X_set_of_books_id => l_sob_id ,
1404 X_dr_cr_flag => 'DR' ,
1405 X_amount => l_current_db.reval_reserve_gen_fund ,
1406 X_adjustment_type => 'REVAL RESERVE' ,
1407 X_transfer_to_gl_flag => 'Y' ,
1408 X_units_assigned => l_det_balances.units_assigned ,
1409 X_asset_id => l_det_balances.asset_id ,
1410 X_distribution_id => l_det_balances.distribution_id ,
1411 X_period_counter => l_asset_balance_mvmt.period_counter,
1412 X_adjustment_offset_type => 'GENERAL FUND',
1413 X_report_ccid => Null,
1414 x_mode => 'R',
1415 X_event_id => p_event_id
1416 ) ;
1417
1418 l_rowid := NULL ;
1419 igi_iac_adjustments_pkg.insert_row(
1420 X_rowid => l_rowid ,
1421 X_adjustment_id => l_adjustment_id ,
1422 X_book_type_code => l_det_balances.book_type_code ,
1423 X_code_combination_id => l_gen_fund_ccid,
1424 X_set_of_books_id => l_sob_id ,
1425 X_dr_cr_flag => 'CR' ,
1426 X_amount =>l_current_db.reval_reserve_gen_fund ,
1427 X_adjustment_type => 'GENERAL FUND' ,
1428 X_transfer_to_gl_flag => 'Y' ,
1429 X_units_assigned => l_det_balances.units_assigned ,
1430 X_asset_id => l_det_balances.asset_id ,
1431 X_distribution_id => l_det_balances.distribution_id ,
1432 X_period_counter => l_asset_balance_mvmt.period_counter,
1433 X_adjustment_offset_type => 'REVAL RESERVE',
1434 X_report_ccid => l_revl_rsv_ccid,
1435 x_mode => 'R',
1436 X_event_id => p_event_id
1437 ) ;
1438 END IF;
1439
1440 IF l_current_db.reval_reserve_backlog <> 0 THEN
1441 l_rowid := NULL;
1442 igi_iac_adjustments_pkg.insert_row(
1443 X_rowid => l_rowid ,
1444 X_adjustment_id => l_adjustment_id ,
1445 X_book_type_code => l_det_balances.book_type_code ,
1446 X_code_combination_id => l_blog_rsv_ccid,
1447 X_set_of_books_id => l_sob_id ,
1448 X_dr_cr_flag => 'CR' ,
1449 X_amount =>l_current_db.reval_reserve_backlog ,
1450 X_adjustment_type => 'BL RESERVE' ,
1451 X_transfer_to_gl_flag => 'Y' ,
1452 X_units_assigned => l_det_balances.units_assigned ,
1453 X_asset_id => l_det_balances.asset_id ,
1454 X_distribution_id => l_det_balances.distribution_id ,
1455 X_period_counter => l_asset_balance_mvmt.period_counter,
1456 X_adjustment_offset_type => 'REVAL RESERVE',
1457 X_report_ccid => l_revl_rsv_ccid,
1458 x_mode => 'R',
1459 X_event_id => p_event_id
1460 ) ;
1461
1462
1463 l_rowid := NULL;
1464 igi_iac_adjustments_pkg.insert_row(
1465 X_rowid => l_rowid ,
1466 X_adjustment_id => l_adjustment_id ,
1467 X_book_type_code => l_det_balances.book_type_code ,
1468 X_code_combination_id => l_revl_rsv_ccid,
1469 X_set_of_books_id => l_sob_id ,
1470 X_dr_cr_flag => 'DR' ,
1471 X_amount =>l_current_db.reval_reserve_backlog ,
1472 X_adjustment_type => 'REVAL RESERVE' ,
1473 X_transfer_to_gl_flag => 'Y' ,
1474 X_units_assigned => l_det_balances.units_assigned ,
1475 X_asset_id => l_det_balances.asset_id ,
1476 X_distribution_id => l_det_balances.distribution_id ,
1477 X_period_counter => l_asset_balance_mvmt.period_counter,
1478 X_adjustment_offset_type => 'BL RESERVE',
1479 X_report_ccid => Null,
1480 x_mode => 'R',
1481 X_event_id => p_event_id
1482 ) ;
1483
1484 END IF;
1485
1486 IF l_current_db.operating_acct_backlog <> 0 THEN
1487 l_rowid := NULL;
1488 igi_iac_adjustments_pkg.insert_row(
1489 X_rowid => l_rowid ,
1490 X_adjustment_id => l_adjustment_id ,
1491 X_book_type_code => l_det_balances.book_type_code ,
1492 X_code_combination_id => l_blog_rsv_ccid,
1493 X_set_of_books_id => l_sob_id ,
1494 X_dr_cr_flag => 'CR' ,
1495 X_amount =>l_current_db.operating_acct_backlog ,
1496 X_adjustment_type => 'BL RESERVE' ,
1497 X_transfer_to_gl_flag => 'Y' ,
1498 X_units_assigned => l_det_balances.units_assigned ,
1499 X_asset_id => l_det_balances.asset_id ,
1500 X_distribution_id => l_det_balances.distribution_id ,
1501 X_period_counter => l_asset_balance_mvmt.period_counter,
1502 X_adjustment_offset_type => 'OP EXPENSE',
1503 X_report_ccid => l_op_exp_ccid,
1504 x_mode => 'R',
1505 X_event_id => p_event_id
1506 ) ;
1507
1508 l_rowid := NULL;
1509 igi_iac_adjustments_pkg.insert_row(
1510 X_rowid => l_rowid ,
1511 X_adjustment_id => l_adjustment_id ,
1512 X_book_type_code => l_det_balances.book_type_code ,
1513 X_code_combination_id => l_op_exp_ccid,
1514 X_set_of_books_id => l_sob_id ,
1515 X_dr_cr_flag => 'DR' ,
1516 X_amount =>l_current_db.operating_acct_backlog ,
1517 X_adjustment_type => 'OP EXPENSE' ,
1518 X_transfer_to_gl_flag => 'Y' ,
1519 X_units_assigned => l_det_balances.units_assigned ,
1520 X_asset_id => l_det_balances.asset_id ,
1521 X_distribution_id => l_det_balances.distribution_id ,
1522 X_period_counter => l_asset_balance_mvmt.period_counter,
1523 X_adjustment_offset_type => 'BL RESERVE',
1524 X_report_ccid => Null,
1525 x_mode => 'R',
1526 X_event_id => p_event_id
1527 ) ;
1528
1529 END IF;
1530
1531 l_det_balances.adjustment_cost := l_det_balances.adjustment_cost + l_current_db.adjustment_cost;
1532 l_det_balances.net_book_value := l_det_balances.net_book_value + l_current_db.net_book_value;
1533 l_det_balances.reval_reserve_cost := l_det_balances.reval_reserve_cost + l_current_db.reval_reserve_cost;
1534 l_det_balances.reval_reserve_backlog := l_det_balances.reval_reserve_backlog + l_current_db.reval_reserve_backlog;
1535 l_det_balances.reval_reserve_gen_fund := l_det_balances.reval_reserve_gen_fund + l_current_db.reval_reserve_gen_fund;
1536 l_det_balances.reval_reserve_net := l_det_balances.reval_reserve_net + l_current_db.reval_reserve_net;
1537 l_det_balances.operating_acct_cost := l_det_balances.operating_acct_cost + l_current_db.operating_acct_cost;
1538 l_det_balances.operating_acct_backlog := l_det_balances.operating_acct_backlog + l_current_db.operating_acct_backlog;
1539 l_det_balances.operating_acct_net := l_det_balances.operating_acct_net + l_current_db.operating_acct_net;
1540 l_det_balances.deprn_reserve := l_det_balances.deprn_reserve + l_current_db.deprn_reserve;
1541 l_det_balances.deprn_reserve_backlog := l_det_balances.deprn_reserve_backlog + l_current_db.deprn_reserve_backlog;
1542 l_det_balances.general_fund_acc := l_det_balances.general_fund_acc + l_current_db.general_fund_acc;
1543
1544 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1545 p_full_path => l_path_name,
1546 p_string => ' +DET BALANCES..... AFTER');
1547 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1548 p_full_path => l_path_name,
1549 p_string => ' x_adjustment_id => '|| l_current_db.adjustment_id);
1550 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1551 p_full_path => l_path_name,
1552 p_string => ' x_asset_id =>'|| l_current_db.asset_id);
1553 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1554 p_full_path => l_path_name,
1555 p_string => ' x_distribution_id => '||l_current_db.distribution_id);
1556 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1557 p_full_path => l_path_name,
1558 p_string => ' x_book_type_code => '||l_current_db.book_type_code);
1559 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1560 p_full_path => l_path_name,
1561 p_string => ' x_period_counter => '||l_current_db.period_counter);
1562 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1563 p_full_path => l_path_name,
1564 p_string => ' x_adjustment_cost => '||l_det_balances.adjustment_cost);
1565 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1566 p_full_path => l_path_name,
1567 p_string => ' x_net_book_value => '||l_det_balances.net_book_value);
1568 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1569 p_full_path => l_path_name,
1570 p_string => ' x_reval_reserve_cost => '||l_det_balances.reval_reserve_cost);
1571 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1572 p_full_path => l_path_name,
1573 p_string => ' x_reval_reserve_backlog => '||l_det_balances.reval_reserve_backlog);
1574 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1575 p_full_path => l_path_name,
1576 p_string => ' x_reval_reserve_gen_fund => '||l_det_balances.reval_reserve_gen_fund);
1577 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1578 p_full_path => l_path_name,
1579 p_string => ' x_reval_reserve_net => '||l_det_balances.reval_reserve_net);
1580 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1581 p_full_path => l_path_name,
1582 p_string => ' x_operating_acct_cost => '||l_det_balances.operating_acct_cost);
1583 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1584 p_full_path => l_path_name,
1585 p_string => ' x_operating_acct_backlog => '||l_det_balances.operating_acct_backlog);
1586 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1587 p_full_path => l_path_name,
1588 p_string => ' x_operating_acct_net => '||l_det_balances.operating_acct_net);
1589 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1590 p_full_path => l_path_name,
1591 p_string => ' x_operating_acct_ytd => '||l_current_db.operating_acct_ytd);
1592 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1593 p_full_path => l_path_name,
1594 p_string => ' x_deprn_period => '||l_current_db.deprn_period);
1595 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1596 p_full_path => l_path_name,
1597 p_string => ' x_deprn_ytd => '||l_current_db.deprn_ytd);
1598 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1599 p_full_path => l_path_name,
1600 p_string => ' x_deprn_reserve => '||l_det_balances.deprn_reserve);
1601 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1602 p_full_path => l_path_name,
1603 p_string => ' x_deprn_reserve_backlog => '||l_det_balances.deprn_reserve_backlog);
1604 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1605 p_full_path => l_path_name,
1606 p_string => ' x_general_fund_per => '||l_current_db.general_fund_per);
1607 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1608 p_full_path => l_path_name,
1609 p_string => ' x_general_fund_acc => '||l_det_balances.general_fund_acc);
1610 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1611 p_full_path => l_path_name,
1612 p_string => ' x_last_reval_date => '||l_det_balances.last_reval_date);
1613 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1614 p_full_path => l_path_name,
1615 p_string => ' x_current_reval_factor => '||l_det_balances.current_reval_factor);
1616 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1617 p_full_path => l_path_name,
1618 p_string => ' x_cumulative_reval_factor => '||l_det_balances.cumulative_reval_factor);
1619 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1620 p_full_path => l_path_name,
1621 p_string => ' x_active_flag => '||l_det_balances.active_flag);
1622
1623 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1624 p_full_path => l_path_name,
1625 p_string => 'IGI_IAC_DET_BALANCES_PKG.insert_row');
1626 l_rowid := NULL;
1627 IGI_IAC_DET_BALANCES_PKG.insert_row (
1628 x_rowid => l_rowid,
1629 x_adjustment_id => l_current_db.adjustment_id,
1630 x_asset_id => l_current_db.asset_id,
1631 x_distribution_id => l_current_db.distribution_id,
1632 x_book_type_code => l_current_db.book_type_code,
1633 x_period_counter => l_current_db.period_counter,
1634 x_adjustment_cost => l_det_balances.adjustment_cost ,
1635 x_net_book_value => l_det_balances.net_book_value ,
1636 x_reval_reserve_cost => l_det_balances.reval_reserve_cost ,
1637 x_reval_reserve_backlog => l_det_balances.reval_reserve_backlog ,
1638 x_reval_reserve_gen_fund => l_det_balances.reval_reserve_gen_fund ,
1639 x_reval_reserve_net => l_det_balances.reval_reserve_net ,
1640 x_operating_acct_cost => l_det_balances.operating_acct_cost ,
1641 x_operating_acct_backlog => l_det_balances.operating_acct_backlog ,
1642 x_operating_acct_net => l_det_balances.operating_acct_net ,
1643 x_operating_acct_ytd => l_current_db.operating_acct_ytd,
1644 x_deprn_period => l_current_db.deprn_period,
1645 x_deprn_ytd => l_current_db.deprn_ytd,
1646 x_deprn_reserve => l_det_balances.deprn_reserve ,
1647 x_deprn_reserve_backlog => l_det_balances.deprn_reserve_backlog ,
1648 x_general_fund_per => l_current_db.general_fund_per,
1649 x_general_fund_acc => l_det_balances.general_fund_acc ,
1650 x_last_reval_date => l_current_db.last_reval_date,
1651 x_current_reval_factor => l_current_db.current_reval_factor,
1652 x_cumulative_reval_factor => l_current_db.cumulative_reval_factor,
1653 x_active_flag => l_current_db.active_flag,
1654 x_mode => 'R' );
1655
1656 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1657 p_full_path => l_path_name,
1658 p_string => 'Before igi_iac_fa_deprn_pkg.insert_row');
1659 l_rowid := NULL;
1660 igi_iac_fa_deprn_pkg.insert_row(
1661 x_rowid => l_rowid,
1662 x_book_type_code => l_det_balances.book_type_code,
1663 x_asset_id => l_det_balances.asset_id,
1664 x_distribution_id => l_det_balances.distribution_id,
1665 x_period_counter => l_asset_balance_mvmt.period_counter,
1666 x_adjustment_id => l_adjustment_id,
1667 x_deprn_period => l_current_db_fa.deprn_period,
1668 x_deprn_ytd => l_current_db_fa.deprn_ytd ,
1669 x_deprn_reserve => l_current_db_fa.deprn_reserve,
1670 x_active_flag => l_det_balances.active_flag,
1671 x_mode => 'R');
1672 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1673 p_full_path => l_path_name,
1674 p_string => 'After igi_iac_fa_deprn_pkg.insert_row');
1675 END LOOP;
1676
1677 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1678 p_full_path => l_path_name,
1679 p_string => ' Asset_id:'||l_curr_asset_balance.asset_id);
1680 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1681 p_full_path => l_path_name,
1682 p_string => ' Period_counter :'||l_curr_asset_balance.period_counter);
1683 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1684 p_full_path => l_path_name,
1685 p_string => ' Net book value :'||TO_CHAR(l_curr_asset_balance.net_book_value));
1686 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1687 p_full_path => l_path_name,
1688 p_string => ' Adjusted Cost :'||TO_CHAR(l_curr_asset_balance.adjusted_cost));
1689 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1690 p_full_path => l_path_name,
1691 p_string => ' Operating Account :'||TO_CHAR(l_curr_asset_balance.operating_acct));
1692 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1693 p_full_path => l_path_name,
1694 p_string => ' Reval Reserve :'||TO_CHAR(l_curr_asset_balance.reval_reserve));
1695 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1696 p_full_path => l_path_name,
1697 p_string => ' Deprn Amount :'||TO_CHAR(l_curr_asset_balance.deprn_amount));
1698 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1699 p_full_path => l_path_name,
1700 p_string => ' Deprn Reserve :'||TO_CHAR(l_curr_asset_balance.deprn_reserve));
1701 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1702 p_full_path => l_path_name,
1703 p_string => ' Backlog Deprn Reserve :'||TO_CHAR(l_curr_asset_balance.backlog_deprn_reserve));
1704 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1705 p_full_path => l_path_name,
1706 p_string => ' General Fund :'||TO_CHAR(l_curr_asset_balance.general_fund));
1707 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1708 p_full_path => l_path_name,
1709 p_string => ' Current Reval Factor :'||TO_CHAR(l_curr_asset_balance.current_reval_factor));
1710 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1711 p_full_path => l_path_name,
1712 p_string => ' Cumulative Reval Factor :'||TO_CHAR(l_curr_asset_balance.Cumulative_reval_factor));
1713
1714 IGI_IAC_ASSET_BALANCES_PKG.update_row (
1715 x_asset_id => l_curr_asset_balance.asset_id,
1716 x_book_type_code => l_curr_asset_balance.book_type_code,
1717 x_period_counter => l_asset_balance_mvmt.period_counter,
1718 x_net_book_value => l_curr_asset_balance.net_book_value,
1719 x_adjusted_cost => l_curr_asset_balance.adjusted_cost,
1720 x_operating_acct => l_curr_asset_balance.operating_acct,
1721 x_reval_reserve => l_curr_asset_balance.reval_reserve,
1722 x_deprn_amount => l_curr_asset_balance.deprn_amount,
1723 x_deprn_reserve => l_curr_asset_balance.deprn_reserve,
1724 x_backlog_deprn_reserve => l_curr_asset_balance.backlog_deprn_reserve,
1725 x_general_fund => l_curr_asset_balance.general_fund,
1726 x_last_reval_date => l_curr_asset_balance.last_reval_date,
1727 x_current_reval_factor => l_curr_asset_balance.current_reval_factor,
1728 x_cumulative_reval_factor => l_curr_asset_balance.cumulative_reval_factor,
1729 x_mode => 'R'
1730 );
1731
1732 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1733 p_full_path => l_path_name,
1734 p_string => ' Making previous transaction inactive.');
1735 igi_iac_trans_headers_pkg.update_row(
1736 X_prev_adjustment_id => l_adjustment_id_out ,
1737 X_adjustment_id => l_adjustment_id ) ;
1738
1739 igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
1740 p_full_path => l_path_name,
1741 p_string => ' Expensed Adjustment Success.');
1742
1743 Return TRUE;
1744
1745 EXCEPTION
1746 WHEN others THEN
1747 igi_iac_debug_pkg.debug_unexpected_msg(p_full_path => l_path_name);
1748 RETURN FALSE;
1749 END Do_Expensed_Adj;
1750 BEGIN
1751 --===========================FND_LOG.START=====================================
1752 g_state_level := FND_LOG.LEVEL_STATEMENT;
1753 g_proc_level := FND_LOG.LEVEL_PROCEDURE;
1754 g_event_level := FND_LOG.LEVEL_EVENT;
1755 g_excep_level := FND_LOG.LEVEL_EXCEPTION;
1756 g_error_level := FND_LOG.LEVEL_ERROR;
1757 g_unexp_level := FND_LOG.LEVEL_UNEXPECTED;
1758 g_path := 'IGI.PLSQL.igiiadxb.igi_iac_adj_expensed_pkg.';
1759 --===========================FND_LOG.END=====================================
1760
1761 END igi_iac_adj_expensed_pkg;