[Home] [Help]
PACKAGE BODY: APPS.FA_TAX_RSV_ADJ_PVT
Source
1 PACKAGE BODY FA_TAX_RSV_ADJ_PVT as
2 /* $Header: FAVTRSVB.pls 120.5.12010000.2 2008/12/18 23:58:03 tkawamur ship $ */
3
4 /* Bug 4597471 -- added one more parameter p_mrc_sob_type_code for passing the type of reporting flag whether 'P' = Primary
5 or 'R'= Reporting */
6
7 FUNCTION do_tax_rsv_adj
8 (px_trans_rec IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
9 px_asset_hdr_rec IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
10 p_asset_desc_rec IN FA_API_TYPES.asset_desc_rec_type,
11 p_asset_type_rec IN FA_API_TYPES.asset_type_rec_type,
12 p_asset_cat_rec IN FA_API_TYPES.asset_cat_rec_type,
13 px_asset_fin_rec IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
14 p_asset_tax_rsv_adj_rec IN FA_API_TYPES.asset_tax_rsv_adj_rec_type,
15 p_mrc_sob_type_code IN VARCHAR2,
16 p_calling_fn IN VARCHAR2,
17 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
18 ) RETURN BOOLEAN
19 IS
20
21 l_asset_fin_rec FA_API_TYPES.asset_fin_rec_type; -- This is the original / old asset_fin_rec.
22 l_asset_fin_rec_adj FA_API_TYPES.asset_fin_rec_type := NULL;
23 l_asset_fin_rec_new FA_API_TYPES.asset_fin_rec_type;
24
25
26 l_fin_info fa_std_types.fin_info_struct;
27 l_asset_tax_rsv_adj_rec FA_API_TYPES.asset_tax_rsv_adj_rec_type;
28
29 l_asset_deprn_rec_old FA_API_TYPES.asset_deprn_rec_type;
30 l_asset_deprn_rec_new FA_API_TYPES.asset_deprn_rec_type;
31 l_asset_deprn_rec FA_API_TYPES.asset_deprn_rec_type;
32
33 l_cur_period_rec FA_API_TYPES.period_rec_type;
34 l_period_rec FA_API_TYPES.period_rec_type;
35
36
37 l_reporting_flag VARCHAR2(1);
38 l_pers_per_yr Number;
39
40 l_adj_acct Number;
41 l_exp_acct Number;
42 l_rsv_acct Number;
43 l_cost_acct Number;
44
45 l_cur_dpr_rsv Number;
46 l_old_dpr_rsv Number;
47 l_new_dpr_rsv Number;
48 l_new_adj_cost Number;
49 l_old_adj_cost Number;
50 l_last_year_old_dpr_rsv Number;
51 l_cur_bonus_deprn_rsv Number;
52 l_new_rate_adj_factor Number;
53 l_new_ann_adj_exp Number;
54 l_signed_adj_amount Number;
55
56 l_adj_amount Number;
57 l_total_adjs Number;
58 L_SIGNED_ADJ_AMT Number;
59
60 l_exchange_rate Number;
61 l_avg_rate Number;
62 l_old_ytd_deprn Number;
63
64 l_deprn_basis_rule VARCHAR2(10);
65 l_annual_deprn_rounding_flag FA_BOOKS.ANNUAL_DEPRN_ROUNDING_FLAG%Type;
66
67 l_dummy_varch varchar2(124);
68 l_dummy_bool Boolean;
69 l_dummy_dpr_arr fa_std_types.dpr_arr_type;
70
71
72 l_adj FA_ADJUST_TYPE_PKG.fa_adj_row_struct;
73
74 dpr fa_std_types.dpr_struct;
75 dpr_row fa_std_types.fa_deprn_row_struct;
76 dpr_out fa_std_types.dpr_out_struct;
77
78 l_bks_rowid varchar2(30);
79 l_th_rowid varchar2(30);
80
81 l_status BOOLEAN;
82 l_rsv_flag BOOLEAN := FALSE;
83 l_calling_fn VARCHAR2(40) := 'FA_TAX_RSV_ADJ_PVT.do_tax_rsv_adj';
84
85
86 TAX_RSV_ADJ_ERR EXCEPTION;
87
88 CURSOR fiscal_year_cr (p_book_type_code FA_BOOKS.book_type_code%TYPE, p_fiscal_year Number) is
89 SELECT DP.FISCAL_YEAR, MAX(DP.PERIOD_NUM),MAX(DP.PERIOD_COUNTER)
90 FROM FA_DEPRN_PERIODS DP
91 WHERE DP.BOOK_TYPE_CODE = p_book_type_code
92 AND DP.FISCAL_YEAR > p_fiscal_year
93 AND DP.PERIOD_CLOSE_DATE IS NOT NULL
94 GROUP BY DP.FISCAL_YEAR
95 ORDER BY MIN(DP.PERIOD_OPEN_DATE);
96 BEGIN
97
98 SAVEPOINT do_tax_rsv_adj;
99 -- Get the book type code P,R or N
100
101 if not fa_cache_pkg.fazcsob
102 (X_set_of_books_id => px_asset_hdr_rec.set_of_books_id,
103 X_mrc_sob_type_code => l_reporting_flag,
104 p_log_level_rec => p_log_level_rec
105 ) then
106 raise tax_rsv_adj_err;
107 end if;
108
109 /* Bug 4597471 -- loading the reporting falg which denoted the type of book Primary or Reporting */
110 l_reporting_flag := p_mrc_sob_type_code;
111
112 -- Make a local copy of the asset_fin_rec, asset_tax_rsv_adj_rec.
113
114 l_asset_fin_rec := px_asset_fin_rec;
115 l_asset_tax_rsv_adj_rec := p_asset_tax_rsv_adj_rec;
116
117 -- Load l_fin_info for non-financial info.
118
119 -- substitute values at asset level.
120
121 l_fin_info.current_time := px_trans_rec.who_info.creation_date;
122 l_fin_info.asset_number := p_asset_desc_rec.asset_number;
123 l_fin_info.asset_id := PX_ASSET_HDR_REC.asset_id;
124
125
126 if not FA_UTIL_PVT.get_current_units
127 (l_calling_fn,
128 px_asset_hdr_rec.asset_id,
129 l_fin_info.units,
130 p_log_level_rec => p_log_level_rec
131 ) then
132 raise tax_rsv_adj_err;
133 end if;
134
135 -- l_fin_info.units := p_asset_desc_rec.current_units;
136 l_fin_info.category_id := p_asset_cat_rec.category_id;
137 l_fin_info.asset_type := p_asset_type_rec.asset_type;
138
139 -- substitute values at book level.
140
141 l_fin_info.adj_rate := l_asset_fin_rec.adjusted_rate;
142 l_fin_info.ceiling_name := l_asset_fin_rec.ceiling_name;
143 l_fin_info.bonus_rule := l_asset_fin_rec.bonus_rule;
144 l_fin_info.book := PX_ASSET_HDR_REC.book_type_code;
145 l_fin_info.transaction_id := px_trans_rec.transaction_header_id;
146 l_fin_info.method_code := l_asset_fin_rec.deprn_method_code;
147 l_fin_info.life := l_asset_fin_rec.life_in_months;
148 l_fin_info.date_placed_in_svc := l_asset_fin_rec.date_placed_in_service;
149 l_fin_info.jdate_in_svc := to_number(to_char(l_asset_fin_rec.date_placed_in_service,'J'));
150 l_fin_info.prorate_date := l_asset_fin_rec.prorate_date;
151 l_fin_info.deprn_start_date := l_asset_fin_rec.deprn_start_date;
152 l_fin_info.capacity := l_asset_fin_rec.production_capacity;
153 l_fin_info.adj_capacity := l_fin_info.capacity;
154 l_fin_info.deprn_rounding_flag := fa_std_types.FA_DPR_ROUND_ADJ;
155
156 if (px_asset_fin_rec.depreciate_flag = 'YES') then
157 l_fin_info.dep_flag := TRUE;
158 else
159 l_fin_info.dep_flag := FALSE;
160 end if;
161
162 if not fa_cache_pkg.fazcbc(l_fin_info.book) then
163 fa_srvr_msg.add_message (calling_fn => 'fa_tax_rsv_adj_pkg.do_tax_rsv_adj_pub',
164 p_log_level_rec => p_log_level_rec);
165 return (FALSE);
166 end if;
167
168 l_fin_info.period_ctr := fa_cache_pkg.fazcbc_record.last_period_counter + 1;
169
170 -- End of non financial loading of l_fin_info.
171
172 l_asset_fin_rec_new := l_asset_fin_rec;
173 if l_reporting_flag <> 'R' then
174
175
176 -- (3) Fin_info : Calculate / Populate amts. based on Primary SOB.
177
178 l_fin_info.cost := px_asset_fin_rec.cost;
179 l_fin_info.salvage_value := px_asset_fin_rec.salvage_value;
180
181
182 if not fa_asset_calc_pvt.calc_deprn_limit_adj_rec_cost
183 (p_asset_hdr_rec => px_asset_hdr_rec,
184 p_asset_type_rec => p_asset_type_rec,
185 p_asset_fin_rec_old => l_asset_fin_rec,
186 p_asset_fin_rec_adj => l_asset_fin_rec_adj,
187 px_asset_fin_rec_new => l_asset_fin_rec_new,
188 p_mrc_sob_type_code => l_reporting_flag,
189 p_log_level_rec => p_log_level_rec
190 ) then
191 raise tax_rsv_adj_err;
192 end if;
193
194 if (l_asset_fin_rec_new.adjusted_recoverable_cost is not null) then
195 l_fin_info.rec_cost := l_asset_fin_rec_new.adjusted_recoverable_cost;
196 else
197 l_fin_info.rec_cost := l_asset_fin_rec_new.recoverable_cost;
198 end if;
199
200 l_fin_info.adj_cost := l_fin_info.rec_cost;
201 l_fin_info.rate_adj_factor := px_asset_fin_rec.rate_adjustment_factor;
202 l_fin_info.reval_amo_basis := px_asset_fin_rec.reval_amortization_basis;
203 l_asset_tax_rsv_adj_rec.adjusted_ytd_deprn := p_asset_tax_rsv_adj_rec.adjusted_ytd_deprn;
204
205 -- (3) Fin_info : End of loading l_fin_info.
206
207 -- Bug 4597471 -- Insert into fa_transaction_headers. only when the mode is 'RUN'
208
209 if (l_asset_tax_rsv_adj_rec.run_mode = 'RUN') then
210
211 -- Generate Thid nextval sequence for PSOB.
212
213 select fa_transaction_headers_s.nextval
214 into px_trans_rec.transaction_header_id
215 from dual;
216
217 l_fin_info.transaction_id := px_trans_rec.transaction_header_id;--vmarella
218
219 -- SLA UPTAKE
220 -- assign an event for the transaction
221 -- at this point key info asset/book/trx info is known from above code
222
223 if not fa_xla_events_pvt.create_transaction_event
224 (p_asset_hdr_rec => px_asset_hdr_rec,
225 p_asset_type_rec=> p_asset_type_rec,
226 px_trans_rec => px_trans_rec,
227 p_event_status => NULL,
228 p_calling_fn => l_calling_fn,
229 p_log_level_rec => p_log_level_rec
230 ) then
231 raise tax_rsv_adj_err;
232 end if;
233
234
235 FA_TRANSACTION_HEADERS_PKG.Insert_Row
236 (X_Rowid => l_th_rowid,
237 X_Transaction_Header_Id => px_trans_rec.transaction_header_id,
238 X_Book_Type_Code => px_asset_hdr_rec.book_type_code,
239 X_Asset_Id => px_asset_hdr_rec.asset_id,
240 X_Transaction_Type_Code => px_trans_rec.transaction_type_code,
241 X_Transaction_Date_Entered => px_trans_rec.transaction_date_entered,
242 X_Date_Effective => px_trans_rec.who_info.creation_date,
243 X_Last_Update_Date => px_trans_rec.who_info.last_update_date,
244 X_Last_Updated_By => px_trans_rec.who_info.last_updated_by,
245 X_Transaction_Name => px_trans_rec.transaction_name,
246 X_Invoice_Transaction_Id => NULL,
247 X_Source_Transaction_Header_Id => px_trans_rec.Source_Transaction_Header_Id,
248 X_Mass_Reference_Id => px_trans_rec.mass_reference_id,
249 X_Last_Update_Login => px_trans_rec.who_info.last_update_login,
250 X_Transaction_Subtype => px_trans_rec.transaction_subtype,
251 X_Attribute1 => px_trans_rec.desc_flex.attribute1,
252 X_Attribute2 => px_trans_rec.desc_flex.attribute2,
253 X_Attribute3 => px_trans_rec.desc_flex.attribute3,
254 X_Attribute4 => px_trans_rec.desc_flex.attribute4,
255 X_Attribute5 => px_trans_rec.desc_flex.attribute5,
256 X_Attribute6 => px_trans_rec.desc_flex.attribute6,
257 X_Attribute7 => px_trans_rec.desc_flex.attribute7,
258 X_Attribute8 => px_trans_rec.desc_flex.attribute8,
259 X_Attribute9 => px_trans_rec.desc_flex.attribute9,
260 X_Attribute10 => px_trans_rec.desc_flex.attribute10,
261 X_Attribute11 => px_trans_rec.desc_flex.attribute11,
262 X_Attribute12 => px_trans_rec.desc_flex.attribute12,
263 X_Attribute13 => px_trans_rec.desc_flex.attribute13,
264 X_Attribute14 => px_trans_rec.desc_flex.attribute14,
265 X_Attribute15 => px_trans_rec.desc_flex.attribute15,
266 X_Attribute_Category_Code => px_trans_rec.desc_flex.attribute_category_code,
267 X_Transaction_Key => px_trans_rec.transaction_key,
268 X_Amortization_Start_Date => px_trans_rec.amortization_start_date,
269 X_Calling_Interface => px_trans_rec.calling_interface,
270 X_Mass_Transaction_ID => px_trans_rec.mass_transaction_id,
271 X_Member_Transaction_Header_Id => px_trans_rec.member_transaction_header_id,
272 X_Trx_Reference_Id => px_trans_rec.trx_reference_id,
273 X_event_Id => px_trans_rec.event_id,
274 X_Return_Status => l_status,
275 X_Calling_Fn => l_calling_fn,
276 p_log_level_rec => p_log_level_rec
277 );
278
279 if not l_status then
280 raise tax_rsv_adj_err;
281 end if;
282
283 end if; -- Run_mode checking
284
285 else -- for reporting = 'R'.
286
287 -- get the latest average rate (used conditionally in some cases below)
288
289 if not fa_mc_util_pvt.get_latest_rate
290 (p_asset_id => px_asset_hdr_rec.asset_id,
291 p_book_type_code => px_asset_hdr_rec.book_type_code,
292 p_set_of_books_id => px_asset_hdr_rec.set_of_books_id,
293 px_rate => l_exchange_rate,
294 px_avg_exchange_rate => l_avg_rate,
295 p_log_level_rec => p_log_level_rec
296 ) then
297 raise tax_rsv_adj_err;
298 end if;
299
300 -- (4) Fin_info : Calculate / Populate amts. based on Reporting SOB.
301
302 l_fin_info.cost := l_asset_fin_rec.cost * l_avg_rate;
303 l_fin_info.salvage_value := l_asset_fin_rec.salvage_value * l_avg_rate;
304
305 if not fa_asset_calc_pvt.calc_deprn_limit_adj_rec_cost
306 (p_asset_hdr_rec => px_asset_hdr_rec,
307 p_asset_type_rec => p_asset_type_rec,
308 p_asset_fin_rec_old => l_asset_fin_rec,
309 p_asset_fin_rec_adj => l_asset_fin_rec_adj, -- NULL;
310 px_asset_fin_rec_new => l_asset_fin_rec_new,
311 p_mrc_sob_type_code => l_reporting_flag,
312 p_log_level_rec => p_log_level_rec
313 ) then
314 raise tax_rsv_adj_err;
315 end if;
316
317 if (l_asset_fin_rec_new.adjusted_recoverable_cost is not null) then
318 l_fin_info.rec_cost := l_asset_fin_rec_new.adjusted_recoverable_cost * l_avg_rate;
319 else
320 l_fin_info.rec_cost := l_asset_fin_rec_new.recoverable_cost * l_avg_rate;
321 end if;
322
323 l_fin_info.adj_cost := l_fin_info.rec_cost * l_avg_rate;
324 l_fin_info.rate_adj_factor := px_asset_fin_rec.rate_adjustment_factor * l_avg_rate;
325 l_fin_info.reval_amo_basis := px_asset_fin_rec.reval_amortization_basis * l_avg_rate;
326 l_asset_tax_rsv_adj_rec.adjusted_ytd_deprn := p_asset_tax_rsv_adj_rec.adjusted_ytd_deprn * l_avg_rate;
327
328 -- (4) Fin_info : End of loading l_fin_info.
329
330 -- for reporting currency round to correct precision.
331
332 if not fa_utils_pkg.faxrnd
333 (x_amount => l_fin_info.cost,
334 x_book => px_asset_hdr_rec.book_type_code,
335 p_log_level_rec => p_log_level_rec
336 ) then
337 raise tax_rsv_adj_err;
338 end if;
339
340 if not fa_utils_pkg.faxrnd
341 (x_amount => l_fin_info.salvage_value,
342 x_book => px_asset_hdr_rec.book_type_code,
343 p_log_level_rec => p_log_level_rec
344 ) then
345 raise tax_rsv_adj_err;
346 end if;
347
348 if not fa_utils_pkg.faxrnd
349 (x_amount => l_fin_info.rec_cost,
350 x_book => px_asset_hdr_rec.book_type_code,
351 p_log_level_rec => p_log_level_rec
352 ) then
353 raise tax_rsv_adj_err;
354 end if;
355
356 if not fa_utils_pkg.faxrnd
357 (x_amount => l_fin_info.adj_cost,
358 x_book => px_asset_hdr_rec.book_type_code,
359 p_log_level_rec => p_log_level_rec
360 ) then
361 raise tax_rsv_adj_err;
362 end if;
363
364 if not fa_utils_pkg.faxrnd
365 (x_amount => l_fin_info.rate_adj_factor,
366 x_book => px_asset_hdr_rec.book_type_code,
367 p_log_level_rec => p_log_level_rec
368 ) then
369 raise tax_rsv_adj_err;
370 end if;
371
372 if not fa_utils_pkg.faxrnd
373 (x_amount => l_fin_info.reval_amo_basis,
374 x_book => px_asset_hdr_rec.book_type_code,
375 p_log_level_rec => p_log_level_rec
376 ) then
377 raise tax_rsv_adj_err;
378 end if;
379
380 if not fa_utils_pkg.faxrnd
381 (x_amount => l_asset_tax_rsv_adj_rec.adjusted_ytd_deprn,
382 x_book => px_asset_hdr_rec.book_type_code,
383 p_log_level_rec => p_log_level_rec
384 ) then
385 raise tax_rsv_adj_err;
386 end if;
387
388 -- Get asset_fin_rec for mrc
389
390 if not FA_UTIL_PVT.get_asset_fin_rec
391 (P_ASSET_HDR_REC => px_asset_hdr_rec,
392 px_asset_fin_rec => l_asset_fin_rec,
393 p_transaction_header_id => NULL,
394 p_mrc_sob_type_code => l_reporting_flag,
395 p_log_level_rec => p_log_level_rec
396 ) then
397 raise tax_rsv_adj_err;
398 end if;
399
400
401 end if; --l_reporting_flag
402
403
404 -- Initialize variables
405
406 l_cur_dpr_rsv := 0;
407 l_old_dpr_rsv := 0;
408 l_new_dpr_rsv := 0;
409 l_new_adj_cost := 0;
410 l_adj_amount := 0;
411 l_total_adjs := 0;
412 l_signed_adj_amt := 0;
413 l_last_year_old_dpr_rsv := 0;
414 l_asset_deprn_rec_old.deprn_reserve := 0;
415 l_asset_deprn_rec_new.deprn_reserve := 0;
416 l_fin_info.adj_capacity := 0; -- MVK : Just why we doing this.
417
418 -- Build the depreciation structure
419
420 -- MVK fa_exp_pvt.faxbds ???? refer FAVAMRTB.pls for its usage.
421 /*
422 if not FA_EXP_PVT.faxbds
423 (PX_ASSET_HDR_REC => px_asset_hdr_rec,
424 px_asset_fin_rec_new => l_asset_fin_rec,
425 p_asset_deprn_rec => l_asset_deprn_rec,
426 p_asset_desc_rec => p_asset_desc_rec,
427 X_dpr_ptr => dpr,
428 X_deprn_rsv => l_cur_deprn_rsv,
429 X_bonus_deprn_rsv => l_cur_bonus_deprn_rsv,
430 p_amortized_flag => FALSE,
431 p_mrc_sob_type_code => p_mrc_sob_type_code) then
432 fa_srvr_msg.add_message (calling_fn => l_calling_fn);
433 return (FALSE);
434 end if;
435 */
436
437 if not fa_exp_pkg.faxbds
438 (l_fin_info,
439 dpr,
440 l_dummy_varch,
441 l_asset_deprn_rec_new.deprn_reserve,
442 FALSE,
443 l_reporting_flag,
444 p_log_level_rec => p_log_level_rec
445 ) then
446 raise TAX_RSV_ADJ_ERR;
447 end if;
448
449 -- Get calendar period information from cache
450
451 if not fa_cache_pkg.fazcct (dpr.calendar_type,
452 p_log_level_rec => p_log_level_rec) then
453 raise TAX_RSV_ADJ_ERR;
454 end if;
455
456 l_pers_per_yr := fa_cache_pkg.fazcct_record.NUMBER_PER_FISCAL_YEAR;
457
458 -- Get current fiscal year and Deprn_Adjustment_Acct from FA_BOOK_CONTROLS
459
460 if not fa_cache_pkg.fazcbc(l_fin_info.book,
461 p_log_level_rec => p_log_level_rec) then
462 raise TAX_RSV_ADJ_ERR;
463 end if;
464
465 l_cur_period_rec.fiscal_year := fa_cache_pkg.fazcbc_record.CURRENT_FISCAL_YEAR;
466
467 l_adj_acct := fa_cache_pkg.fazcbc_record.DEPRN_ADJUSTMENT_ACCT;
468
469 -- Get the Deprn Accounts for insertion into FA_ADJ.
470
471 if not fa_cache_pkg.fazccb
472 (l_fin_info.book,
473 l_fin_info.category_id,
474 p_log_level_rec => p_log_level_rec )then
475 raise TAX_RSV_ADJ_ERR;
476 end if;
477
478 l_rsv_acct := fa_cache_pkg.fazccb_record.DEPRN_RESERVE_ACCT;
479 l_exp_acct := fa_cache_pkg.fazccb_record.DEPRN_EXPENSE_ACCT;
480
481 -- Bug 4597471 -- cost Account for inserting into interface table when run_mode is 'PREVIEW'
482 l_cost_acct := fa_cache_pkg.fazccb_record.ASSET_COST_ACCT;
483
484 -- Get the deprn basis rule
485
486 if not fa_cache_pkg.fazccmt
487 ( dpr.method_code,
488 dpr.life,
489 p_log_level_rec => p_log_level_rec) then
490 raise TAX_RSV_ADJ_ERR;
491 end if;
492
493 l_deprn_basis_rule := fa_cache_pkg.fazccmt_record.deprn_basis_rule;
494
495
496 -- Calculate the LTD deprn_rsv.
497 -- Initialize...
498
499 dpr_row.asset_id := l_fin_info.asset_id;
500 dpr_row.book := l_fin_info.book;
501 dpr_row.dist_id := 0;
502 dpr_row.mrc_sob_type_code := l_reporting_flag;
503
504
505 -- MVK : i guess I can avoid this call ... since we are passing the delta rsv.
506 -- Can move this logic into the FAPAPIB.pls
507
508 dpr_row.period_ctr := 0;
509
510 FA_QUERY_BALANCES_PKG.QUERY_BALANCES_INT (
511 dpr_row,
512 'ADJUSTED',
513 FALSE,
514 l_dummy_bool,
515 'fa_tax_rsv_adj_pvt.do_tax_rsv_adj',
516 -1,
517 p_log_level_rec => p_log_level_rec);
518
519
520 if not (l_dummy_bool) then
521 raise TAX_RSV_ADJ_ERR;
522 elsif (dpr_row.period_ctr <> 0) then
523 l_cur_dpr_rsv := dpr_row.deprn_rsv;
524 else
525 raise TAX_RSV_ADJ_ERR;
526 end if;
527
528 -- MVK. Upto here.
529
530 -- Old Deprn Reserve for the FY where Tax rsv. adjusted.
531
532 dpr_row.period_ctr := l_asset_tax_rsv_adj_rec.max_period_ctr_adjusted;
533
534 FA_QUERY_BALANCES_PKG.QUERY_BALANCES_INT (
535 dpr_row,
536 'ADJUSTED',
537 FALSE,
538 l_dummy_bool,
539 'fa_tax_rsv_adj_pvt.do_tax_rsv_adj',
540 -1,
541 p_log_level_rec => p_log_level_rec);
542
543 if not (l_dummy_bool) then
544 raise TAX_RSV_ADJ_ERR;
545 elsif (dpr_row.period_ctr <> 0) then
546 l_old_dpr_rsv := dpr_row.deprn_rsv;
547 else
548 raise TAX_RSV_ADJ_ERR;
549 end if;
550
551 -- Bug 4597471 -- variable used for PREVIEW mode
552 l_old_ytd_deprn := dpr_row.ytd_deprn;
553
554 -- Initialize variables for loop
555
556 --Bug7630553: fa_tax_rsv_adj_pub.do_tax_rsv_adj is expecting delta reserve between current one and user specified reserve
557 l_adj_amount := l_asset_tax_rsv_adj_rec.adjusted_ytd_deprn;
558 l_new_dpr_rsv := l_old_dpr_rsv + l_adj_amount;
559 l_new_rate_adj_factor := l_fin_info.rate_adj_factor;
560 l_new_adj_cost := l_fin_info.rec_cost - l_new_dpr_rsv;
561 l_total_adjs := l_adj_amount;
562
563
564
565
566 -- Make sure the reserve doesn't exceed recoverable cost
567 -- For NBV check for current open period. Also check end of fy since
568 -- following fy's will be checked by deprn engine calls
569
570 if (l_deprn_basis_rule = fa_std_types.FAD_DBR_COST) then
571
572 if (l_fin_info.rec_cost > 0 and
573 l_fin_info.rec_cost < (l_cur_dpr_rsv + l_adj_amount)) or
574 (l_fin_info.rec_cost < 0 and
575 l_fin_info.rec_cost > (l_cur_dpr_rsv + l_adj_amount)) then
576
577 l_adj_amount := l_fin_info.rec_cost;
578
579 end if;
580
581 else -- NBV
582
583 if (l_fin_info.rec_cost > 0 and
584 l_fin_info.rec_cost < l_new_dpr_rsv) or
585 (l_fin_info.rec_cost < 0 and
586 l_fin_info.rec_cost > l_new_dpr_rsv) then
587
588 l_adj_amount := l_fin_info.rec_cost;
589
590 end if;
591
592 end if;
593
594 /*
595 * Insert the adjustment row for the first fiscal year adjusted
596 * using the Insert into FA_ADJUSTMENTS function*/
597 /*
598 * Bug 4597471 -- only when the run_mode is 'RUN' we need to insert into FA_ADJUSTMENTS
599 *
600 */
601 if (l_asset_tax_rsv_adj_rec.run_mode = 'RUN') then
602
603 l_adj.transaction_header_id := l_fin_info.transaction_id;
604 l_adj.source_type_code := 'TAX';
605 l_adj.code_combination_id := 0; -- ??
606 l_adj.book_type_code := l_fin_info.book;
607 l_adj.period_counter_created := l_fin_info.period_ctr;
608 l_adj.asset_id := l_fin_info.asset_id;
609 l_adj.adjustment_amount := abs(l_adj_amount);
610 l_adj.annualized_adjustment := 0;
611 l_adj.period_counter_adjusted := l_asset_tax_rsv_adj_rec.max_period_ctr_adjusted;
612 l_adj.distribution_id := 0;
613 l_adj.last_update_date := l_fin_info.current_time;
614 l_adj.current_units := l_fin_info.units;
615 l_adj.selection_mode := fa_std_types.FA_AJ_ACTIVE;
616
617 -- l_adj.flush_adj_flag := TRUE; -- ** ** ** MVK ??
618
619 l_adj.flush_adj_flag := FALSE;
620
621 l_adj.gen_ccid_flag := TRUE;
622 l_adj.leveling_flag := TRUE;
623 l_adj.asset_invoice_id := 0;
624
625 l_adj.account_type := 'DEPRN_RESERVE_ACCT';
626 l_adj.adjustment_type := 'RESERVE';
627 l_adj.account := l_rsv_acct;
628
629 if (l_adj_amount < 0) then
630 l_adj.debit_credit_flag := 'DR';
631 else
632 l_adj.debit_credit_flag := 'CR';
633 end if;
634
635 l_adj.mrc_sob_type_code := l_reporting_flag;
636
637 if not FA_INS_ADJUST_PKG.faxinaj
638 (adj_ptr_passed => l_adj,
639 p_log_level_rec => p_log_level_rec
640 ) then
641 raise TAX_RSV_ADJ_ERR;
642 end if;
643
644 l_adj.account_type := 'DEPRN_ADJUSTMENT_ACCT';
645 l_adj.adjustment_type := 'DEPRN ADJUST';
646 l_adj.account := l_adj_acct;
647
648 if (l_adj_amount < 0) then
649 l_adj.debit_credit_flag := 'CR';
650 else
651 l_adj.debit_credit_flag := 'DR';
652 end if;
653
654 l_adj.flush_adj_flag := TRUE;
655
656 if (not FA_INS_ADJUST_PKG.faxinaj
657 (adj_ptr_passed => l_adj,
658 p_log_level_rec => p_log_level_rec)) then
659 raise TAX_RSV_ADJ_ERR;
660 end if;
661
662
663 /*
664 * We're done if deprn method is not based on the net book value;
665 * (We don't want to insert any more FA_ADJUSTMENTS rows, and
666 * don't want to terminate and insert FA_BOOKS rows, for non NBV-based
667 * assets unless asset is no longer fully reserved.
668 */
669
670 if l_deprn_basis_rule = fa_std_types.FAD_DBR_COST then
671
672 If (( l_asset_fin_rec.period_counter_fully_reserved > 0 ) and
673 ( l_new_dpr_rsv < l_fin_info.rec_cost ))then
674
675 If (l_asset_tax_rsv_adj_rec.deprn_basis_formula = 'STRICT_FLAT' ) then
676 l_annual_deprn_rounding_flag := l_asset_fin_rec.annual_deprn_rounding_flag;
677 else
678 l_annual_deprn_rounding_flag := 'ADJ';
679 end if;
680
681
682 -- terminate/insert fa_books rows
683 -- terminate the active row
684
685 fa_books_pkg.deactivate_row
686 (X_asset_id => px_asset_hdr_rec.asset_id,
687 X_book_type_code => px_asset_hdr_rec.book_type_code,
688 X_transaction_header_id_out => px_trans_rec.transaction_header_id,
689 X_date_ineffective => px_trans_rec.who_info.last_update_date,
690 X_mrc_sob_type_code => l_reporting_flag,
691 X_Calling_Fn => l_calling_fn,
692 p_log_level_rec => p_log_level_rec
693 );
694
695 -- fa books
696 fa_books_pkg.insert_row
697 (X_Rowid => l_bks_rowid,
698 X_Book_Type_Code => px_asset_hdr_rec.book_type_code,
699 X_Asset_Id => px_asset_hdr_rec.asset_id,
700 X_Date_Placed_In_Service => l_asset_fin_rec.date_placed_in_service,
701 X_Date_Effective => px_trans_rec.who_info.last_update_date,
702 X_Deprn_Start_Date => l_asset_fin_rec.deprn_start_date,
703 X_Deprn_Method_Code => l_asset_fin_rec.deprn_method_code,
704 X_Life_In_Months => l_asset_fin_rec.life_in_months,
705 X_Rate_Adjustment_Factor => l_fin_info.rate_adj_factor, -- MVK will change.
706 X_Adjusted_Cost => l_fin_info.adj_cost, -- MVK will change.
707 X_Cost => l_asset_fin_rec.cost,
708 X_Original_Cost => l_asset_fin_rec.original_cost,
709 X_Salvage_Value => l_asset_fin_rec.salvage_value,
710 X_Prorate_Convention_Code => l_asset_fin_rec.prorate_convention_code,
711 X_Prorate_Date => l_asset_fin_rec.prorate_date,
712 X_Cost_Change_Flag => l_asset_fin_rec.cost_change_flag,
713 X_Adjustment_Required_Status => l_asset_fin_rec.adjustment_required_status,
714 X_Capitalize_Flag => l_asset_fin_rec.capitalize_flag,
715 X_Retirement_Pending_Flag => l_asset_fin_rec.retirement_pending_flag,
716 X_Depreciate_Flag => l_asset_fin_rec.depreciate_flag,
717 X_Disabled_Flag => l_asset_fin_rec.disabled_flag,--HH
718 X_Last_Update_Date => px_trans_rec.who_info.last_update_date,
719 X_Last_Updated_By => px_trans_rec.who_info.last_updated_by,
720 X_Date_Ineffective => NULL, -- MVK will change.
721 X_Transaction_Header_Id_In => l_fin_info.transaction_id, -- MVK will change.
722 X_Transaction_Header_Id_Out => NULL, -- MVK will change.
723 X_Itc_Amount_Id => l_asset_fin_rec.itc_amount_id,
724 X_Itc_Amount => l_asset_fin_rec.itc_amount,
725 X_Retirement_Id => l_asset_fin_rec.retirement_id,
726 X_Tax_Request_Id => l_asset_fin_rec.tax_request_id,
727 X_Itc_Basis => l_asset_fin_rec.itc_basis,
728 X_Basic_Rate => l_asset_fin_rec.basic_rate,
729 X_Adjusted_Rate => l_asset_fin_rec.adjusted_rate,
730 X_Bonus_Rule => l_asset_fin_rec.bonus_rule,
731 X_Ceiling_Name => l_asset_fin_rec.ceiling_name,
732 X_Recoverable_Cost => l_asset_fin_rec.recoverable_cost,
733 X_Last_Update_Login => px_trans_rec.who_info.last_update_login,
734 X_Adjusted_Capacity => l_asset_fin_rec.adjusted_capacity,
735 X_Fully_Rsvd_Revals_Counter => l_asset_fin_rec.fully_rsvd_revals_counter,
736 X_Idled_Flag => l_asset_fin_rec.idled_flag,
737 X_Period_Counter_Capitalized => l_asset_fin_rec.period_counter_capitalized,
738 X_PC_Fully_Reserved => l_asset_fin_rec.period_counter_fully_reserved, -- MVK will change
739 X_Period_Counter_Fully_Retired => l_asset_fin_rec.period_counter_fully_retired,
740 X_Production_Capacity => l_asset_fin_rec.production_capacity,
741 X_Reval_Amortization_Basis => l_asset_fin_rec.reval_amortization_basis,
742 X_Reval_Ceiling => l_asset_fin_rec.reval_ceiling,
743 X_Unit_Of_Measure => l_asset_fin_rec.unit_of_measure,
744 X_Unrevalued_Cost => l_asset_fin_rec.unrevalued_cost,
745 X_Annual_Deprn_Rounding_Flag => l_annual_deprn_rounding_flag, -- MVK will change
746 X_Percent_Salvage_Value => l_asset_fin_rec.percent_salvage_value,
747 X_Allowed_Deprn_Limit => l_asset_fin_rec.allowed_deprn_limit,
748 X_Allowed_Deprn_Limit_Amount => l_asset_fin_rec.allowed_deprn_limit_amount,
749 X_Period_Counter_Life_Complete => l_asset_fin_rec.period_counter_life_complete,
750 X_Adjusted_Recoverable_Cost => l_asset_fin_rec.adjusted_recoverable_cost,
751 X_Short_Fiscal_Year_Flag => l_asset_fin_rec.short_fiscal_year_flag,
752 X_Conversion_Date => l_asset_fin_rec.conversion_date,
753 X_Orig_Deprn_Start_Date => l_asset_fin_rec.orig_deprn_start_date,
754 X_Remaining_Life1 => l_asset_fin_rec.remaining_life1,
755 X_Remaining_Life2 => l_asset_fin_rec.remaining_life2,
756 X_Old_Adj_Cost => l_asset_fin_rec.old_adjusted_cost,
757 X_Formula_Factor => l_asset_fin_rec.formula_factor,
758 X_gf_Attribute1 => l_asset_fin_rec.global_attribute1,
759 X_gf_Attribute2 => l_asset_fin_rec.global_attribute2,
760 X_gf_Attribute3 => l_asset_fin_rec.global_attribute3,
761 X_gf_Attribute4 => l_asset_fin_rec.global_attribute4,
762 X_gf_Attribute5 => l_asset_fin_rec.global_attribute5,
763 X_gf_Attribute6 => l_asset_fin_rec.global_attribute6,
764 X_gf_Attribute7 => l_asset_fin_rec.global_attribute7,
765 X_gf_Attribute8 => l_asset_fin_rec.global_attribute8,
766 X_gf_Attribute9 => l_asset_fin_rec.global_attribute9,
767 X_gf_Attribute10 => l_asset_fin_rec.global_attribute10,
768 X_gf_Attribute11 => l_asset_fin_rec.global_attribute11,
769 X_gf_Attribute12 => l_asset_fin_rec.global_attribute12,
770 X_gf_Attribute13 => l_asset_fin_rec.global_attribute13,
771 X_gf_Attribute14 => l_asset_fin_rec.global_attribute14,
772 X_gf_Attribute15 => l_asset_fin_rec.global_attribute15,
773 X_gf_Attribute16 => l_asset_fin_rec.global_attribute16,
774 X_gf_Attribute17 => l_asset_fin_rec.global_attribute17,
775 X_gf_Attribute18 => l_asset_fin_rec.global_attribute18,
776 X_gf_Attribute19 => l_asset_fin_rec.global_attribute19,
777 X_gf_Attribute20 => l_asset_fin_rec.global_attribute20,
778 X_global_attribute_category => l_asset_fin_rec.global_attribute_category,
779 X_group_asset_id => l_asset_fin_rec.group_asset_id,
780 X_salvage_type => l_asset_fin_rec.salvage_type,
781 X_deprn_limit_type => l_asset_fin_rec.deprn_limit_type,
782 X_over_depreciate_option => l_asset_fin_rec.over_depreciate_option,
783 X_super_group_id => l_asset_fin_rec.super_group_id,
784 X_reduction_rate => l_asset_fin_rec.reduction_rate,
785 X_reduce_addition_flag => l_asset_fin_rec.reduce_addition_flag,
786 X_reduce_adjustment_flag => l_asset_fin_rec.reduce_adjustment_flag,
787 X_reduce_retirement_flag => l_asset_fin_rec.reduce_retirement_flag,
788 X_recognize_gain_loss => l_asset_fin_rec.recognize_gain_loss,
789 X_recapture_reserve_flag => l_asset_fin_rec.recapture_reserve_flag,
790 X_limit_proceeds_flag => l_asset_fin_rec.limit_proceeds_flag,
791 X_terminal_gain_loss => l_asset_fin_rec.terminal_gain_loss,
792 X_exclude_proceeds_from_basis => l_asset_fin_rec.exclude_proceeds_from_basis,
793 X_retirement_deprn_option => l_asset_fin_rec.retirement_deprn_option,
794 X_tracking_method => l_asset_fin_rec.tracking_method,
795 X_allocate_to_fully_rsv_flag => l_asset_fin_rec.allocate_to_fully_rsv_flag,
796 X_allocate_to_fully_ret_flag => l_asset_fin_rec.allocate_to_fully_ret_flag,
797 X_exclude_fully_rsv_flag => l_asset_fin_rec.exclude_fully_rsv_flag,
798 X_excess_allocation_option => l_asset_fin_rec.excess_allocation_option,
799 X_depreciation_option => l_asset_fin_rec.depreciation_option,
800 X_member_rollup_flag => l_asset_fin_rec.member_rollup_flag,
801 X_ytd_proceeds => nvl(l_asset_fin_rec.ytd_proceeds, 0),
802 X_ltd_proceeds => nvl(l_asset_fin_rec.ltd_proceeds, 0),
803 X_eofy_reserve => l_asset_fin_rec.eofy_reserve,
804 X_terminal_gain_loss_amount => l_asset_fin_rec.terminal_gain_loss_amount,
805 X_ltd_cost_of_removal => nvl(l_asset_fin_rec.ltd_cost_of_removal, 0),
806 X_mrc_sob_type_code => l_reporting_flag,
807 X_Return_Status => l_status,
808 X_Calling_Fn => l_calling_fn,
809 p_log_level_rec => p_log_level_rec
810 );
811
812 if not l_status then
813 raise tax_rsv_adj_err;
814 else
815 return (TRUE);
816 end if;
817 end if;
818 end if;
819 end if; /* run_mode checking */
820
821
822 -- For NBV basis ... and strict_ flat.. Will go with the existing logic for now ??
823 /*
824 * Main driving loop for this program. Loop for each fiscal year after
825 * the adjustment; recalculate reserve up until the last closed period
826 */
827
828 open fiscal_year_cr(l_fin_info.book,l_cur_period_rec.fiscal_year);
829
830 loop
831
832 fetch fiscal_year_cr into l_period_rec.fiscal_year,l_period_rec.period_num, l_period_rec.period_counter;
833 exit when fiscal_year_cr%notfound;
834
835
836 -- Set the deprn struct parms to calculate deprn reserve
837 dpr.y_begin := l_period_rec.fiscal_year;
838 dpr.y_end := l_period_rec.fiscal_year;
839 dpr.p_cl_begin := 1;
840 dpr.p_cl_end := l_period_rec.period_num;
841 dpr.deprn_rsv := l_new_dpr_rsv;
842 dpr.adj_cost := l_new_adj_cost;
843 dpr.mrc_sob_type_code := l_reporting_flag;
844
845 --
846
847 -- Call deprn engine to calc new reserve.
848 if not fa_cde_pkg.faxcde (
849 dpr,
850 l_dummy_dpr_arr,
851 dpr_out,
852 fa_std_types.FA_DPR_NORMAL,
853 p_log_level_rec => p_log_level_rec
854 ) then
855 raise tax_rsv_adj_err;
856 end if;
857
858
859 -- Set the new_adj_cost and new_deprn_rsv to the value
860 -- recalculated by deprn
861 l_new_adj_cost := dpr_out.new_adj_cost;
862 l_new_dpr_rsv := dpr_out.new_deprn_rsv;
863
864 -- Get the adjusted cost and the reserve previously taken as of
865 -- the end of the fiscal year, or the last closed deprn period
866
867 l_last_year_old_dpr_rsv := l_old_dpr_rsv;
868
869
870 -- MVK
871 dpr_row.asset_id := l_fin_info.asset_id;
872 dpr_row.book := l_fin_info.book;
873 dpr_row.dist_id := 0;
874 dpr_row.period_ctr := l_period_rec.period_counter;
875 dpr_row.mrc_sob_type_code := l_reporting_flag;
876
877 /*
878 * Use the Query Fin Info function to get the reserve as of
879 * this period.
880 */
881
882 FA_QUERY_BALANCES_PKG.QUERY_BALANCES_INT (
883 dpr_row,
884 'STANDARD',
885 FALSE,
886 l_dummy_bool,
887 l_calling_fn,
888 -1,
889 p_log_level_rec => p_log_level_rec);
890
891 if not (l_dummy_bool) then
892 fa_srvr_msg.add_message (calling_fn => l_calling_fn,
893 p_log_level_rec => p_log_level_rec);
894 return (FALSE);
895 end if;
896
897 l_asset_deprn_rec_old.deprn_reserve := dpr_row.deprn_rsv;
898 l_old_adj_cost := dpr_row.adj_cost;
899
900
901 -- UPTO here
902
903 -- Calculate the adjustment amount , new_adjusted_cost, total adjustments
904
905 l_adj_amount := l_new_dpr_rsv - (l_asset_deprn_rec_old.deprn_reserve + l_total_adjs);
906 l_new_adj_cost := l_fin_info.rec_cost - l_new_dpr_rsv;
907 l_total_adjs := l_total_adjs + l_adj_amount;
908
909 -- Process the adjustment rows for this fiscal year
910
911 /*
912 * Call the Insert into FA_ADJUSTMENTS function
913 * for EXPENSE adjustment; use the CCID from FA_DISTRIBUTION_HISTORY,
914 * so set adj.ccid = 0 and gen_ccid_flag = FALSE
915 */
916
917 l_adj.transaction_header_id := l_fin_info.transaction_id;
918 l_adj.source_type_code := 'TAX';
919 l_adj.adjustment_type := 'EXPENSE';
920 l_adj.code_combination_id := 0;
921 l_adj.book_type_code := l_fin_info.book;
922 l_adj.period_counter_created := l_fin_info.period_ctr;
923 l_adj.asset_id := l_fin_info.asset_id;
924 l_adj.adjustment_amount := abs(l_adj_amount);
925 l_adj.period_counter_adjusted := l_period_rec.period_counter;
926 l_adj.distribution_id := 0;
927
928
929 /*
930 * If this is the current fiscal year, then annualized adjustment
931 * is the difference between the new annualized expense and
932 * the extrapolated pre-tax-adjustment annualized expense amounts.
933 */
934
935
936 if l_cur_period_rec.fiscal_year = l_period_rec.fiscal_year then
937
938 l_new_ann_adj_exp := dpr_out.ann_adj_exp;
939
940 -- reset deprn struct parms to calculate what the
941 -- annulalized expense would have been
942
943 dpr.p_cl_end := l_pers_per_yr;
944 dpr.deprn_rsv := l_last_year_old_dpr_rsv;
945 dpr.adj_cost := l_old_adj_cost;
946 dpr.mrc_sob_type_code := l_reporting_flag;
947
948 -- Call deprn engine to calc expense
949
950 if not fa_cde_pkg.faxcde
951 (dpr,
952 l_dummy_dpr_arr,
953 dpr_out,
954 fa_std_types.FA_DPR_NORMAL,
955 p_log_level_rec => p_log_level_rec
956 ) then
957 raise tax_rsv_adj_err;
958 end if;
959
960 l_adj.annualized_adjustment := l_new_ann_adj_exp - dpr_out.ann_adj_exp;
961
962 else
963
964 l_adj.annualized_adjustment := 0;
965
966 end if;
967
968 /* Bug 4597471 -- insert into FA_ADJUSTMENTS only if the run_mode is 'RUN' */
969
970 if (l_asset_tax_rsv_adj_rec.run_mode = 'RUN') then
971
972 l_adj.last_update_date := l_fin_info.current_time;
973 l_adj.current_units := l_fin_info.units;
974 l_adj.selection_mode := fa_std_types.FA_AJ_ACTIVE;
975 l_adj.flush_adj_flag := TRUE; -- MVK ??
976 l_adj.gen_ccid_flag := TRUE;
977 l_adj.asset_invoice_id := 0;
978 l_adj.leveling_flag := TRUE;
979 l_adj.account_type := 'DEPRN_EXPENSE_ACCT';
980 l_adj.account := l_exp_acct;
981
982 if (l_adj_amount < 0) then
983 l_adj.debit_credit_flag := 'CR';
984 else
985 l_adj.debit_credit_flag := 'DR';
986 end if;
987
988 l_adj.mrc_sob_type_code := l_reporting_flag;
989
990 if not FA_INS_ADJUST_PKG.faxinaj
991 (adj_ptr_passed => l_adj,
992 p_log_level_rec => p_log_level_rec) then
993 raise tax_rsv_adj_err;
994 end if;
995 end if;
996 end loop;
997
998 close fiscal_year_cr;
999
1000 /*
1001 * This is like Strict Calculation Basis
1002 * If user choose to do this, then reset adjusted cost to
1003 * the adjusted cost as of beggining of current fiscal year
1004 */
1005 -- Bug 3045324 : Added the if ..else stmt.
1006
1007 if (l_adj.debit_credit_flag = 'DR') then
1008 l_signed_adj_amount := -1 * nvl(l_adj.adjustment_amount, 0);
1009 else
1010 l_signed_adj_amount := nvl(l_adj.adjustment_amount, 0);
1011 end if;
1012
1013 if ( (l_asset_tax_rsv_adj_rec.deprn_basis_formula = 'STRICT_FLAT') and
1014 (nvl(dpr.ytd_deprn, 0) <> 0) ) then
1015 l_new_adj_cost := l_new_adj_cost + nvl(dpr.ytd_deprn, 0) - nvl(l_signed_adj_amount, 0);
1016 end if;
1017
1018
1019 /*
1020 * terminate the current FA_BOOKS row; and insert a new one, with
1021 * the updated adjusted cost and rate adjustment factor
1022 * we only do this for assets with an NBV-based deprn method
1023 * and if this is not the year of adjustment
1024 */
1025
1026 if l_new_dpr_rsv < l_fin_info.rec_cost then
1027 l_rsv_flag := TRUE;
1028 end if;
1029
1030 If (l_asset_tax_rsv_adj_rec.deprn_basis_formula = 'STRICT_FLAT' ) then
1031 l_annual_deprn_rounding_flag := l_asset_fin_rec.annual_deprn_rounding_flag;
1032 else
1033 l_annual_deprn_rounding_flag := 'ADJ';
1034 end if;
1035
1036 -- terminate/insert fa_books rows
1037 -- terminate the active row
1038 -- Bug 4597471 -- only if the run_mode is 'RUN'
1039
1040 if (l_asset_tax_rsv_adj_rec.run_mode = 'RUN') then
1041
1042 fa_books_pkg.deactivate_row
1043 (X_asset_id => px_asset_hdr_rec.asset_id,
1044 X_book_type_code => px_asset_hdr_rec.book_type_code,
1045 X_transaction_header_id_out => px_trans_rec.transaction_header_id,
1046 X_date_ineffective => px_trans_rec.who_info.last_update_date,
1047 X_mrc_sob_type_code => l_reporting_flag,
1048 X_Calling_Fn => l_calling_fn,
1049 p_log_level_rec => p_log_level_rec
1050 );
1051
1052 -- fa books
1053
1054 fa_books_pkg.insert_row
1055 (X_Rowid => l_bks_rowid,
1056 X_Book_Type_Code => px_asset_hdr_rec.book_type_code,
1057 X_Asset_Id => px_asset_hdr_rec.asset_id,
1058 X_Date_Placed_In_Service => l_asset_fin_rec.date_placed_in_service,
1059 X_Date_Effective => px_trans_rec.who_info.last_update_date,
1060 X_Deprn_Start_Date => l_asset_fin_rec.deprn_start_date,
1061 X_Deprn_Method_Code => l_asset_fin_rec.deprn_method_code,
1062 X_Life_In_Months => l_asset_fin_rec.life_in_months,
1063 X_Rate_Adjustment_Factor => l_fin_info.rate_adj_factor, -- MVK will change.
1064 X_Adjusted_Cost => l_fin_info.adj_cost, -- MVK will change.
1065 X_Cost => l_asset_fin_rec.cost,
1066 X_Original_Cost => l_asset_fin_rec.original_cost,
1067 X_Salvage_Value => l_asset_fin_rec.salvage_value,
1068 X_Prorate_Convention_Code => l_asset_fin_rec.prorate_convention_code,
1069 X_Prorate_Date => l_asset_fin_rec.prorate_date,
1070 X_Cost_Change_Flag => l_asset_fin_rec.cost_change_flag,
1071 X_Adjustment_Required_Status => l_asset_fin_rec.adjustment_required_status,
1072 X_Capitalize_Flag => l_asset_fin_rec.capitalize_flag,
1073 X_Retirement_Pending_Flag => l_asset_fin_rec.retirement_pending_flag,
1074 X_Depreciate_Flag => l_asset_fin_rec.depreciate_flag,
1075 X_Disabled_Flag => l_asset_fin_rec.disabled_flag,--HH
1076 X_Last_Update_Date => px_trans_rec.who_info.last_update_date,
1077 X_Last_Updated_By => px_trans_rec.who_info.last_updated_by,
1078 X_Date_Ineffective => NULL, -- MVK will change.
1079 X_Transaction_Header_Id_In => px_trans_rec.transaction_header_id, -- MVK will change.
1080 X_Transaction_Header_Id_Out => NULL, -- MVK will change.
1081 X_Itc_Amount_Id => l_asset_fin_rec.itc_amount_id,
1082 X_Itc_Amount => l_asset_fin_rec.itc_amount,
1083 X_Retirement_Id => l_asset_fin_rec.retirement_id,
1084 X_Tax_Request_Id => l_asset_fin_rec.tax_request_id,
1085 X_Itc_Basis => l_asset_fin_rec.itc_basis,
1086 X_Basic_Rate => l_asset_fin_rec.basic_rate,
1087 X_Adjusted_Rate => l_asset_fin_rec.adjusted_rate,
1088 X_Bonus_Rule => l_asset_fin_rec.bonus_rule,
1089 X_Ceiling_Name => l_asset_fin_rec.ceiling_name,
1090 X_Recoverable_Cost => l_asset_fin_rec.recoverable_cost,
1091 X_Last_Update_Login => px_trans_rec.who_info.last_update_login,
1092 X_Adjusted_Capacity => l_asset_fin_rec.adjusted_capacity,
1093 X_Fully_Rsvd_Revals_Counter => l_asset_fin_rec.fully_rsvd_revals_counter,
1094 X_Idled_Flag => l_asset_fin_rec.idled_flag,
1095 X_Period_Counter_Capitalized => l_asset_fin_rec.period_counter_capitalized,
1096 X_PC_Fully_Reserved => l_asset_fin_rec.period_counter_fully_reserved, -- MVK will change
1097 X_Period_Counter_Fully_Retired => l_asset_fin_rec.period_counter_fully_retired,
1098 X_Production_Capacity => l_asset_fin_rec.production_capacity,
1099 X_Reval_Amortization_Basis => l_asset_fin_rec.reval_amortization_basis,
1100 X_Reval_Ceiling => l_asset_fin_rec.reval_ceiling,
1101 X_Unit_Of_Measure => l_asset_fin_rec.unit_of_measure,
1102 X_Unrevalued_Cost => l_asset_fin_rec.unrevalued_cost,
1103 X_Annual_Deprn_Rounding_Flag => l_annual_deprn_rounding_flag, -- MVK will change
1104 X_Percent_Salvage_Value => l_asset_fin_rec.percent_salvage_value,
1105 X_Allowed_Deprn_Limit => l_asset_fin_rec.allowed_deprn_limit,
1106 X_Allowed_Deprn_Limit_Amount => l_asset_fin_rec.allowed_deprn_limit_amount,
1107 X_Period_Counter_Life_Complete => l_asset_fin_rec.period_counter_life_complete,
1108 X_Adjusted_Recoverable_Cost => l_asset_fin_rec.adjusted_recoverable_cost,
1109 X_Short_Fiscal_Year_Flag => l_asset_fin_rec.short_fiscal_year_flag,
1110 X_Conversion_Date => l_asset_fin_rec.conversion_date,
1111 X_Orig_Deprn_Start_Date => l_asset_fin_rec.orig_deprn_start_date,
1112 X_Remaining_Life1 => l_asset_fin_rec.remaining_life1,
1113 X_Remaining_Life2 => l_asset_fin_rec.remaining_life2,
1114 X_Old_Adj_Cost => l_asset_fin_rec.old_adjusted_cost,
1115 X_Formula_Factor => l_asset_fin_rec.formula_factor,
1116 X_gf_Attribute1 => l_asset_fin_rec.global_attribute1,
1117 X_gf_Attribute2 => l_asset_fin_rec.global_attribute2,
1118 X_gf_Attribute3 => l_asset_fin_rec.global_attribute3,
1119 X_gf_Attribute4 => l_asset_fin_rec.global_attribute4,
1120 X_gf_Attribute5 => l_asset_fin_rec.global_attribute5,
1121 X_gf_Attribute6 => l_asset_fin_rec.global_attribute6,
1122 X_gf_Attribute7 => l_asset_fin_rec.global_attribute7,
1123 X_gf_Attribute8 => l_asset_fin_rec.global_attribute8,
1124 X_gf_Attribute9 => l_asset_fin_rec.global_attribute9,
1125 X_gf_Attribute10 => l_asset_fin_rec.global_attribute10,
1126 X_gf_Attribute11 => l_asset_fin_rec.global_attribute11,
1127 X_gf_Attribute12 => l_asset_fin_rec.global_attribute12,
1128 X_gf_Attribute13 => l_asset_fin_rec.global_attribute13,
1129 X_gf_Attribute14 => l_asset_fin_rec.global_attribute14,
1130 X_gf_Attribute15 => l_asset_fin_rec.global_attribute15,
1131 X_gf_Attribute16 => l_asset_fin_rec.global_attribute16,
1132 X_gf_Attribute17 => l_asset_fin_rec.global_attribute17,
1133 X_gf_Attribute18 => l_asset_fin_rec.global_attribute18,
1134 X_gf_Attribute19 => l_asset_fin_rec.global_attribute19,
1135 X_gf_Attribute20 => l_asset_fin_rec.global_attribute20,
1136 X_global_attribute_category => l_asset_fin_rec.global_attribute_category,
1137 X_group_asset_id => l_asset_fin_rec.group_asset_id,
1138 X_salvage_type => l_asset_fin_rec.salvage_type,
1139 X_deprn_limit_type => l_asset_fin_rec.deprn_limit_type,
1140 X_over_depreciate_option => l_asset_fin_rec.over_depreciate_option,
1141 X_super_group_id => l_asset_fin_rec.super_group_id,
1142 X_reduction_rate => l_asset_fin_rec.reduction_rate,
1143 X_reduce_addition_flag => l_asset_fin_rec.reduce_addition_flag,
1144 X_reduce_adjustment_flag => l_asset_fin_rec.reduce_adjustment_flag,
1145 X_reduce_retirement_flag => l_asset_fin_rec.reduce_retirement_flag,
1146 X_recognize_gain_loss => l_asset_fin_rec.recognize_gain_loss,
1147 X_recapture_reserve_flag => l_asset_fin_rec.recapture_reserve_flag,
1148 X_limit_proceeds_flag => l_asset_fin_rec.limit_proceeds_flag,
1149 X_terminal_gain_loss => l_asset_fin_rec.terminal_gain_loss,
1150 X_exclude_proceeds_from_basis => l_asset_fin_rec.exclude_proceeds_from_basis,
1151 X_retirement_deprn_option => l_asset_fin_rec.retirement_deprn_option,
1152 X_tracking_method => l_asset_fin_rec.tracking_method,
1153 X_allocate_to_fully_rsv_flag => l_asset_fin_rec.allocate_to_fully_rsv_flag,
1154 X_allocate_to_fully_ret_flag => l_asset_fin_rec.allocate_to_fully_ret_flag,
1155 X_exclude_fully_rsv_flag => l_asset_fin_rec.exclude_fully_rsv_flag,
1156 X_excess_allocation_option => l_asset_fin_rec.excess_allocation_option,
1157 X_depreciation_option => l_asset_fin_rec.depreciation_option,
1158 X_member_rollup_flag => l_asset_fin_rec.member_rollup_flag,
1159 X_ytd_proceeds => nvl(l_asset_fin_rec.ytd_proceeds, 0),
1160 X_ltd_proceeds => nvl(l_asset_fin_rec.ltd_proceeds, 0),
1161 X_eofy_reserve => l_asset_fin_rec.eofy_reserve,
1162 X_terminal_gain_loss_amount => l_asset_fin_rec.terminal_gain_loss_amount,
1163 X_ltd_cost_of_removal => nvl(l_asset_fin_rec.ltd_cost_of_removal, 0),
1164 X_mrc_sob_type_code => l_reporting_flag,
1165 X_Return_Status => l_status,
1166 X_Calling_Fn => l_calling_fn,
1167 p_log_level_rec => p_log_level_rec
1168 );
1169
1170 if not l_status then
1171 raise tax_rsv_adj_err;
1172 else
1173 return (TRUE);
1174 end if;
1175 end if; /* run_mode checking */
1176
1177 /* Bug 4597471 -- for PREVIEW mode insert into interface table so that the preview report can just pick the
1178 values from the interface table */
1179
1180 if not fa_utils_pkg.faxrnd
1181 (x_amount => l_asset_tax_rsv_adj_rec.adjusted_ytd_deprn,
1182 x_book => px_asset_hdr_rec.book_type_code,
1183 p_log_level_rec => p_log_level_rec
1184 ) then
1185 raise tax_rsv_adj_err;
1186 end if;
1187
1188
1189
1190 if (l_asset_tax_rsv_adj_rec.run_mode = 'PREVIEW') then
1191 insert into fa_mass_tax_adj_rep_t
1192 (MASS_TAX_ADJ_ID ,
1193 REQUEST_ID ,
1194 ADJUSTED_BOOK_TYPE_CODE ,
1195 ASSET_ID ,
1196 ASSET_NUMBER ,
1197 DESCRIPTION ,
1198 DEPRN_RESERVE_ACCT ,
1199 ASSET_COST_ACCT ,
1200 COST ,
1201 OLD_YTD_DEPRN ,
1202 ADJ_YTD_DEPRN ,
1203 NEW_YTD_DEPRN ,
1204 LAST_UPDATE_DATE ,
1205 LAST_UPDATED_BY ,
1206 CREATED_BY ,
1207 CREATION_DATE ,
1208 LAST_UPDATE_LOGIN )
1209 values
1210 (px_trans_rec.mass_transaction_id ,
1211 px_trans_rec.mass_reference_id ,
1212 px_asset_hdr_rec.book_type_code ,
1213 px_asset_hdr_rec.asset_id ,
1214 p_asset_desc_rec.asset_number ,
1215 p_asset_desc_rec.description ,
1216 l_rsv_acct ,
1217 l_cost_acct ,
1218 l_asset_fin_rec.cost ,
1219 l_old_ytd_deprn ,--old_ytd
1220 l_asset_tax_rsv_adj_rec.adjusted_ytd_deprn - l_old_ytd_deprn,--adj_ytd
1221 l_asset_tax_rsv_adj_rec.adjusted_ytd_deprn,--new_ytd_deprn
1222 px_trans_rec.who_info.last_update_date ,
1223 px_trans_rec.who_info.last_updated_by ,
1224 px_trans_rec.who_info.last_updated_by ,
1225 px_trans_rec.who_info.last_update_date ,
1226 px_trans_rec.who_info.last_update_login );
1227 end if; /* run mode is PREVIEW */
1228
1229 return TRUE;
1230
1231 exception
1232 when tax_rsv_adj_err then
1233 fa_srvr_msg.add_message(calling_fn => l_calling_fn,
1234 p_log_level_rec => p_log_level_rec);
1235 if (p_log_level_rec.statement_level) then
1236 fa_debug_pkg.add(l_calling_fn, 'EXCEPTION', 'tax_rsv_adj_err',
1237 p_log_level_rec => p_log_level_rec);
1238 end if;
1239 return(FALSE);
1240
1241 when others then
1242 fa_srvr_msg.add_message(calling_fn => l_calling_fn,
1243 p_log_level_rec => p_log_level_rec);
1244 if (p_log_level_rec.statement_level) then
1245 fa_debug_pkg.add(l_calling_fn, 'EXCEPTION', 'others',
1246 p_log_level_rec => p_log_level_rec);
1247
1248 end if;
1249 return(FALSE);
1250 END do_tax_rsv_adj;
1251
1252 END FA_TAX_RSV_ADJ_PVT;