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