[Home] [Help]
PACKAGE BODY: APPS.FA_CDE_PKG
Source
1 PACKAGE BODY FA_CDE_PKG as
2 /* $Header: FACDEB.pls 120.90.12010000.4 2008/10/15 11:52:05 gigupta ship $ */
3
4 ROUND_WITH_RESTRICTIONS constant integer:= 0;
5 ROUND_ALWAYS constant integer:= 1;
6 g_tested_use_annual_round boolean:= FALSE;
7 g_use_annual_round integer:= ROUND_WITH_RESTRICTIONS;
8 primary_cost NUMBER;
9 g_pre_period_name fa_calendar_periods.period_name%TYPE;
10 g_pre_period_ctr fa_calendar_periods.period_num%TYPE;
11 g_pre_fyctr fa_fiscal_year.fiscal_year%TYPE;
12
13
14
15 Function faxgpr (
16 X_dpr_ptr fa_std_types.dpr_struct
17 ,X_period fa_std_types.fa_cp_struct
18 ,X_projecting_flag BOOLEAN
19 ,X_prodn in out nocopy NUMBER,
20 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null)
21
22 return boolean is
23 h_dist_book varchar2(18);
24
25 CURSOR PROD IS
26 SELECT rowid,
27 used_flag used,
28 production *
29 (least (to_date (X_period.end_jdate, 'J'), end_date) -
30 greatest (to_date (X_period.start_jdate, 'J'), start_date) + 1)
31 / (end_date - start_date + 1) prod
32 FROM FA_PERIODIC_PRODUCTION
33 WHERE asset_id = X_dpr_ptr.asset_id
34 AND book_type_code = h_dist_book
35 AND start_date <= to_date (X_period.end_jdate, 'J')
36 AND end_date >= to_date (X_period.start_jdate, 'J')
37 FOR UPDATE OF
38 used_flag
39 NOWAIT;
40
41 begin <<FAXGPR>>
42
43 -- Get fa_book_controls.distribution_source_book since
44 -- production is only stored in the corporate book.
45
46 -- fazcbc cache should have already been called don't call again -bmr
47
48 h_dist_book := fa_cache_pkg.fazcbc_record.distribution_source_book;
49 X_prodn := 0;
50
51 For h in PROD loop
52 X_prodn := X_prodn + h.prod;
53
54 if not X_projecting_flag and h.used <> 'YES' then
55 UPDATE FA_PERIODIC_PRODUCTION
56 SET Used_Flag = 'YES'
57 WHERE RowID = h.rowid;
58
59 If SQL%NOTFOUND then
60 fa_srvr_msg.add_message (
61 calling_fn => 'fa_cde_pkg.faxgpr',
62 name => 'FA_DEPRN_FETCH_PROD',
63 p_log_level_rec => p_log_level_rec);
64 raise NO_DATA_FOUND;
65 end if;
66 end if;
67 end loop;
68
69 return (true);
70
71 exception
72 when others then
73 fa_srvr_msg.add_sql_error (
74 calling_fn => 'fa_cde_pkg.faxgpr'
75 ,p_log_level_rec => p_log_level_rec);
76 return (FALSE);
77 end FAXGPR;
78
79
80 Function faxgtr (
81 X_method_id number
82 ,X_year_of_life number
83 ,X_prorate_period number
84 ,X_rate out nocopy number
85 ,p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null)
86 return boolean is
87 begin <<FAZGTR>>
88
89 SELECT rate
90 INTO X_rate
91 FROM fa_rates
92 WHERE method_id = X_method_id
93 AND year = X_year_of_life
94 AND period_placed_in_service = X_prorate_period;
95
96 return (TRUE);
97
98 exception
99 when no_data_found then
100 X_rate := 0;
101 return (TRUE);
102 when others then
103 fa_srvr_msg.add_sql_error (
104 calling_fn => 'fa_cde_pkg.faxgtr'
105 ,p_log_level_rec => p_log_level_rec);
106 return (FALSE);
107 end FAXGTR;
108
109 /* syoung: Take out remaining life calculation */
110
111 /* this can be called from Pro*C during deprn or when mass change is
112 run */
113
114 procedure faxgfr (X_Book_Type_Code IN VARCHAR2,
115 X_Asset_Id IN NUMBER,
116 X_Short_Fiscal_Year_Flag IN VARCHAR2,
117 X_Conversion_Date IN DATE := NULL,
118 X_Prorate_Date IN DATE := NULL,
119 X_Orig_Deprn_Start_Date IN DATE := NULL,
120 C_Prorate_Date IN VARCHAR2 := NULL,
121 C_Conversion_Date IN VARCHAR2 := NULL,
122 C_Orig_Deprn_Start_Date IN VARCHAR2 := NULL,
123 X_Method_Code IN VARCHAR2,
124 X_Life_In_Months IN INTEGER,
125 X_Fiscal_Year IN NUMBER,
126 X_Current_Period IN NUMBER,
127
128 -- Bug 6665510: FP: Japan Tax Reform Project
129 X_calling_interface IN VARCHAR2 DEFAULT NULL,
130 X_new_cost IN NUMBER DEFAULT NULL,
131 X_adjusted_cost IN NUMBER DEFAULT NULL,
132
133 X_Rate OUT NOCOPY NUMBER,
134 X_Method_Type OUT NOCOPY NUMBER,
135 X_Success OUT NOCOPY INTEGER,
136 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
137
138 h_method_id number;
139 h_formula varchar2(4000);
140 h_formula_parsed varchar2(4000);
141 h_cursor number;
142 h_return_code number;
143 h_count1 number;
144 h_count2 number;
145 h_prod_method number := 0;
146 h_rem_life1 number;
147 h_rem_life2 number;
148 h_conversion_date DATE := X_Conversion_Date;
149 h_prorate_date DATE := X_Prorate_Date;
150 h_orig_deprn_start_date DATE := X_Orig_Deprn_Start_Date;
151 h_deprn_basis_rule VARCHAR2(4);
152 cache_exception EXCEPTION;
153 rem_life_exception EXCEPTION;
154 rate_null_exception EXCEPTION;
155 rate_neg_exception EXCEPTION;
156
157 h_msg_count NUMBER := 0;
158 h_msg_data VARCHAR2(512);
159
160 begin <<FAXGFR>>
161
162 -- Fix for Bug #2629724. Call the fazccmt cache to improve perf.
163 if (not fa_cache_pkg.fazccmt (
164 X_Method => X_Method_Code,
165 X_Life => X_Life_In_Months
166 ,p_log_level_rec => p_log_level_rec)) then
167 RAISE cache_exception;
168 end if;
169
170 h_method_id := fa_cache_pkg.fazccmt_record.method_id;
171 h_deprn_basis_rule := fa_cache_pkg.fazccmt_record.deprn_basis_rule;
172 h_formula_parsed := fa_cache_pkg.fazcfor_record.formula_parsed;
173
174 h_count1 := instr (h_formula_parsed, 'REMAINING_LIFE1');
175 h_count2 := instr (h_formula_parsed, 'REMAINING_LIFE2');
176 h_prod_method := instr (fa_cache_pkg.fazcfor_record.formula_actual,
177 'CAPACITY');
178
179 X_Method_Type := 0;
180
181 -- Method Type values:
182 -- 0: Life Based
183 -- 1: Production Based
184 /* if (h_prod_method > 0) then
185 X_Method_Type := 1;
186 else
187 X_Method_Type := 0;
188 end if; */ -- commented this for bug 3357903
189
190 -- Bug 6665510: FP: Japan Tax Reform Project (Start)
191 if fa_cache_pkg.fazccmt_record.guarantee_rate_method_flag = 'YES' then
192 if (p_log_level_rec.statement_level) then
193 fa_debug_pkg.add('FAXGFR','+++ in', fa_cache_pkg.fazccmt_record.guarantee_rate_method_flag, p_log_level_rec);
194 end if;
195
196 if X_calling_interface in ('FAXCDE') and (X_new_cost is not null and X_adjusted_cost is not null) then
197 h_formula_parsed := replace(h_formula_parsed, 'ADJUSTED_COST', to_char(X_adjusted_cost));
198 h_formula_parsed := replace(h_formula_parsed, 'COST', to_char(X_new_cost));
199
200 if (p_log_level_rec.statement_level) then
201 fa_debug_pkg.add('FAXGFR','+++ faxcde Cost', X_new_cost, p_log_level_rec);
202 fa_debug_pkg.add('FAXGFR','+++ faxcde NBV', X_adjusted_cost, p_log_level_rec);
203 end if; -- p_log_level_rec.statement_level
204 end if; -- calling interface
205 end if; -- guarantee_rate method
206 -- Bug 6665510: FP: Japan Tax Reform Project (End)
207
208 if (h_count1 > 0 OR h_count2 > 0) then
209
210 if (h_conversion_date is NULL) then
211 if (C_Conversion_Date = 'DD/MM/YYYY') then
212 h_conversion_date := NULL;
213 else
214 h_conversion_date := to_date(C_Conversion_Date, 'DD/MM/YYYY');
215 end if;
216 end if;
217 if (h_prorate_date is NULL) then
218 h_prorate_date := to_date(C_Prorate_Date, 'DD/MM/YYYY');
219 end if;
220
221 if (h_orig_deprn_start_date is NULL) then
222 if (C_Orig_Deprn_Start_Date = 'DD/MM/YYYY') then
223 h_orig_deprn_start_date := NULL;
224 else
225 h_orig_deprn_start_date := to_date(C_Orig_Deprn_Start_Date,
226 'DD/MM/YYYY');
227 end if;
228 end if;
229
230 if (not faxgrl(
231 X_Asset_Id => X_Asset_Id,
232 X_Book_Type_Code => X_Book_Type_Code,
233 X_Short_Fiscal_Year_Flag => X_Short_Fiscal_Year_Flag,
234 X_Prorate_Date => h_prorate_date,
235 X_Conversion_Date => h_conversion_Date,
236 X_Orig_Deprn_Start_Date => h_orig_deprn_start_date,
237 X_Fiscal_Year => X_Fiscal_Year,
238 X_Life_In_Months => X_Life_In_Months,
239 X_Method_Code => X_Method_Code,
240 X_Current_Period => X_Current_Period,
241 X_rem_life1 => h_rem_life1,
242 X_rem_life2 => h_rem_life2
243 ,p_log_level_rec => p_log_level_rec)) then
244 RAISE rem_life_exception;
245 end if;
246
247 h_formula_parsed := replace(h_formula_parsed, 'REMAINING_LIFE1',
248 to_char(h_rem_life1));
249 h_formula_parsed := replace(h_formula_parsed, 'REMAINING_LIFE2',
250 to_char(h_rem_life2));
251
252 end if;
253
254 -- fix for 4685808
255 h_formula_parsed := replace(h_formula_parsed, 'LIFE_IN_MONTHS',
256 to_char(X_Life_In_Months));
257
258 -- Fix for Bug #2939771. Use bind variables.
259 h_formula := 'SELECT ' || h_formula_parsed ||
260 ' rate FROM fa_books fabk, fa_deprn_periods fadp ' ||
261 ' WHERE (fabk.asset_id = :v1) ' ||
262 ' AND (fabk.book_type_code = :v2' ||
263 ' ) AND (fabk.book_type_code = fadp.book_type_code) ' ||
264 ' AND (fabk.date_ineffective is null) ' ||
265 ' AND (fadp.period_close_date is null)';
266
267 if (p_log_level_rec.statement_level) then
268 fa_debug_pkg.add('FAXGFR','+++ stmt:', h_formula, p_log_level_rec);
269 end if;
270
271 -- Open the cursor for processing.
272 h_cursor := dbms_sql.open_cursor;
273
274 -- Parse the query.
275 dbms_sql.parse(h_cursor,h_formula,1);
276
277 -- Bind X_asset_id to the placeholder.
278 dbms_sql.bind_variable (h_cursor, ':v1', X_Asset_ID);
279 dbms_sql.bind_variable (h_cursor, ':v2', X_Book_Type_Code);
280
281 -- Define the output variable, rate.
282 dbms_sql.define_column (h_cursor, 1, X_Rate);
283
284 -- Execute the statement. We don't care about the
285 -- return value, but we do need to declare a variable
286 -- for it.
287 h_return_code := dbms_sql.execute(h_cursor);
288
289 -- This is the fetch loop.
290 loop
291 if dbms_sql.fetch_rows (h_cursor) = 0 then
292 exit;
293 end if;
294
295 dbms_sql.column_value (h_cursor, 1, X_rate);
296 end loop;
297
298 -- Close the cursor.
299 dbms_sql.close_cursor (h_cursor);
300
301 -- Fix for Bug #2421998. For a formula that uses remaining life, we
302 -- need to take this into account so that the depreciation is allocated
303 -- correctly in the last year of its life. For example, if there are
304 -- only 3 months left in the life, the rate per month should be
305 -- four times what is calculated since the asset needs to be fully
306 -- reserved at the end of the third month. We only want to do this
307 -- with assets that use remaining life 1 in the formula method and
308 -- not remaining life 2 and the deprn basis rule is COST. For NBV
309 -- methods, we just use 1 / (h_rem_life1 / 12) as the rate.
310 if ((h_rem_life1 > 0) and (h_rem_life1 < 12) and
311 (NVL(X_Short_Fiscal_Year_Flag, 'NO') <> 'YES') and
312 (h_count1 > 0) and (h_count2 = 0)) then
313
314 if (h_deprn_basis_rule = 'COST') then
315 X_Rate := X_Rate * (12 / h_rem_life1);
316 elsif (h_deprn_basis_rule = 'NBV') then
317 X_Rate := greatest (X_Rate, 1 / (h_rem_life1 / 12));
318 end if;
319 end if;
320
321 -- Bug 6665510: FP: Japan Tax Reform Project (Start)
322 if (p_log_level_rec.statement_level) then
323 fa_debug_pkg.add('FAXGFR','+++ guarantee_flag', fa_cache_pkg.fazccmt_record.guarantee_rate_method_flag, p_log_level_rec);
324 fa_debug_pkg.add('FAXGFR','+++ X_calling_interface', X_calling_interface, p_log_level_rec);
325 end if;
326
327 if fa_cache_pkg.fazccmt_record.guarantee_rate_method_flag = 'YES' then
328 if X_calling_interface is null then
329 if (p_log_level_rec.statement_level) then
330 fa_debug_pkg.add('FAXGFR','+++ Fetching current rate from fa_books', 'YES', p_log_level_rec);
331 end if; -- p_log_level_rec.statement_level
332
333 SELECT rate_in_use
334 INTO X_Rate
335 FROM fa_books
336 WHERE book_type_code = X_Book_Type_Code
337 AND asset_id = X_Asset_Id
338 AND date_ineffective is null;
339 end if; -- X_calling_interface is null
340 end if; -- guarantee rate flag
341 -- Bug 6665510: FP: Japan Tax Reform Project (End)
342
343 if (X_Rate is null) then
344 RAISE rate_null_exception;
345 end if;
346
347 if (X_Rate < 0) then
348 RAISE rate_neg_exception;
349 end if;
350
351 X_Success := 1;
352 exception
353 when no_data_found then
354 fa_srvr_msg.add_message (
355 calling_fn => 'fa_cde_pkg.faxgfr',
356 name => 'FA_FORMULA_RATE_NO_DATA_FOUND',
357 token1 => 'ASSET_ID',
358 value1 => to_char(X_Asset_Id),
359 p_log_level_rec => p_log_level_rec);
360 X_rate := 0;
361 X_Success := -2;
362 when zero_divide then
363 fa_srvr_msg.add_message (
364 calling_fn => 'fa_cde_pkg.faxgfr',
365 name => 'FA_FORMULA_RATE_ZERO_DIVIDE',
366 token1 => 'ASSET_ID',
367 value1 => to_char(X_Asset_Id),
368 p_log_level_rec => p_log_level_rec);
369 X_rate := 0;
370 X_Success := 1;
371 when cache_exception then
372 fa_srvr_msg.add_message (
373 calling_fn => 'fa_cde_pkg.faxgfr',
374 name => 'FA_SHARED_INVALID_METHOD_RATE',
375 p_log_level_rec => p_log_level_rec);
376 X_rate := 0;
377 X_Success := -7;
378 when rate_null_exception then
379 fa_srvr_msg.add_message (
380 calling_fn => 'fa_cde_pkg.faxgfr',
381 name => 'FA_FORMULA_RATE_NULL',
382 token1 => 'ASSET_ID',
383 value1 => to_char(X_Asset_Id),
384 p_log_level_rec => p_log_level_rec);
385 X_rate := 0;
386 X_Success := -4;
387 when rem_life_exception then
388 fa_srvr_msg.add_message (
389 calling_fn => 'fa_cde_pkg.faxgfr',
390 name => 'FA_FORMULA_RATE_LIFE',
391 token1 => 'ASSET_ID',
392 value1 => to_char(X_Asset_Id),
393 p_log_level_rec => p_log_level_rec);
394 X_rate := 0;
395 X_Success := -5;
396 when rate_neg_exception then
397 fa_srvr_msg.add_message (
398 calling_fn => 'fa_cde_pkg.faxgfr',
399 name => 'FA_FORMULA_RATE_NEGATIVE',
400 token1 => 'ASSET_ID',
401 value1 => to_char(round(X_Rate, 5)),
402 p_log_level_rec => p_log_level_rec);
403 X_rate := 0;
404 X_Success := 1;
405 when others then
406 fa_srvr_msg.add_sql_error (
407 calling_fn => 'fa_cde_pkg.faxgfr'
408 ,p_log_level_rec => p_log_level_rec);
409 X_rate := 0;
410 X_Success := 0;
411 end FAXGFR;
412
413 FUNCTION faxgrl(
414 X_Asset_Id IN NUMBER,
415 X_Book_Type_Code IN VARCHAR2,
416 X_Short_Fiscal_Year_Flag IN VARCHAR2,
417 X_Prorate_Date IN DATE,
418 X_Conversion_Date IN DATE,
419 X_Orig_Deprn_Start_Date IN DATE,
420 X_Fiscal_Year IN NUMBER,
421 X_Life_In_Months IN NUMBER,
422 X_Method_Code IN VARCHAR2,
423 X_Current_Period IN NUMBER,
424 X_rem_life1 OUT NOCOPY NUMBER,
425 X_rem_life2 OUT NOCOPY NUMBER,
426 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null)
427 RETURN BOOLEAN IS
428
429 X_curr_fy_start_date DATE;
430 X_curr_fy_end_date DATE;
431 X_Success VARCHAR2(3);
432 X_Rate_Source_Rule varchar2(10) := 'FORMULA';
433 h_curr_fy number;
434 h_short_fiscal_year_flag varchar2(3);
435 h_conversion_year number;
436 h_dpis DATE;
437 -- added h_deprn_start_date for fix to Bug 1095275
438 h_deprn_start_date DATE;
439
440 BEGIN
441 select fy.start_date,
442 fy.end_date,
443 bc2.current_fiscal_year,
444 bk.date_placed_in_service,
445 bk.deprn_start_date
446 into X_curr_fy_start_date,
447 X_curr_fy_end_date,
448 h_curr_fy,
449 h_dpis,
450 h_deprn_start_date
451 from fa_books bk,
452 fa_fiscal_year fy,
453 fa_book_controls bc,
454 fa_book_controls bc2
455 where bc.book_type_code = X_Book_Type_Code
456 and fy.fiscal_year_name = bc.fiscal_year_name
457 and fy.fiscal_year = X_Fiscal_Year
458 and bc2.book_type_code = X_Book_Type_Code
459 and bk.book_type_code = X_Book_Type_Code
460 and bk.asset_id = X_Asset_Id
461 and bk.date_ineffective is null;
462
463 if (X_Short_Fiscal_Year_Flag = 'YES' and
464 h_curr_fy <> X_Fiscal_Year) then
465 h_short_fiscal_year_flag := 'NO';
466 elsif (X_Short_Fiscal_Year_Flag = 'NO' and
467 X_Conversion_Date is not NULL) then
468 select count(*)
469 into h_conversion_year
470 from fa_fiscal_year fy,
471 fa_book_controls bc
472 where bc.book_type_code = X_Book_Type_Code
473 and bc.fiscal_year_name = fy.fiscal_year_name
474 and X_Conversion_Date between fy.start_date and
475 fy.end_date;
476 if (h_conversion_year > 0) then
477 h_short_fiscal_year_flag := 'YES';
478 end if;
479 else h_short_fiscal_year_flag := X_Short_Fiscal_Year_Flag;
480 end if;
481
482 -- pass h_deprn_start_date instead of prorate date for
483 -- calculating remaing life. Fix for Bug 1095275
484
485 FA_SHORT_TAX_YEARS_PKG.Calculate_Short_Tax_Vals(
486 X_Asset_Id,
487 X_Book_Type_Code,
488 h_short_fiscal_year_flag,
489 h_dpis,
490 h_deprn_start_date,
491 X_prorate_date,
492 X_Conversion_Date,
493 X_Orig_Deprn_Start_Date,
494 X_Curr_Fy_Start_Date,
495 X_Curr_Fy_End_Date,
496 NULL, NULL, NULL, NULL, NULL,
497 NULL, NULL,
498 X_Life_In_Months,
499 X_Rate_Source_Rule,
500 X_Fiscal_Year,
501 X_Method_Code,
502 X_Current_Period,
503 X_rem_life1,
504 X_rem_life2,
505 X_Success
506 ,p_log_level_rec => p_log_level_rec);
507 if (X_success = 'YES') then
508 return (TRUE);
509 else return (FALSE);
510 end if;
511
512 EXCEPTION
513 WHEN OTHERS THEN
514 return (FALSE);
515 END faxgrl;
516
517 Function faxcfyf (
518 X_dpr in out nocopy fa_std_types.dpr_struct
519 ,X_d_pers_per_yr number
520 ,X_rate_source_rule varchar2
521 ,X_y_begin number
522 ,X_y_dead number
523 ,X_y_ret number
524 ,X_dp_begin number
525 ,X_dpp_begin number
526 ,X_dp_d_ptr in out nocopy number
527 ,X_dp_r_ptr number
528 ,X_dpp_r_ptr number
529 ,X_pp_begin number
530 ,X_pp_dead number
531 ,X_pp_ret number
532 ,X_by_factor in out nocopy number
533 ,X_bp_frac in out nocopy number
534 ,X_dp_frac in out nocopy number
535 ,X_rp_frac in out nocopy number
536 ,X_by_frac in out nocopy number
537 ,X_dy_frac in out nocopy number
538 ,X_ry_frac in out nocopy number
539 ,X_prd_flag varchar2,
540 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null)
541 return boolean is
542 h_by_dfrac number;
543 h_dy_dfrac number;
544 h_p_period_fracs fa_std_types.table_fa_cp_struct;
545 h_d_period_fracs fa_std_types.table_fa_cp_struct;
546 h_ctr number;
547 h_b_temp number;
548 h_d_temp number;
549 h_r_temp number;
550 h_cur_fy number;
551
552 begin <<FAXCFYF>>
553
554 /* If different (or new) book, get book information */
555 if last_book = X_dpr.book then
556 null;
557 else
558 -- fazcbc cache should have already been called, dont'd call it again
559 last_book := X_dpr.book;
560 last_pro_cal := fa_cache_pkg.fazcbc_record.PRORATE_CALENDAR;
561 last_divide_evenly_flag :=
562 substr (fa_cache_pkg.fazcbc_record.DEPRN_ALLOCATION_CODE,1,1) = 'E';
563
564 if not fa_cache_pkg.fazcct (last_pro_cal) then
565 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.faxcfyf',
566 p_log_level_rec => p_log_level_rec);
567 return (FALSE);
568 end if;
569 p_pers_per_yr := fa_cache_pkg.fazcct_record.NUMBER_PER_FISCAL_YEAR;
570
571 if not fa_cache_pkg.fazcct (X_dpr.calendar_type, p_log_level_rec) then
572 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.faxcfyf',
573 p_log_level_rec => p_log_level_rec);
574 return (FALSE);
575 end if;
576 end if;
577
578 if last_divide_evenly_flag then
579
580 X_by_frac := (p_pers_per_yr + 1 - X_pp_begin) / p_pers_per_yr;
581
582 /* Fix for Bug# 4304260, 4621761 */
583 if (p_pers_per_yr >= X_d_pers_per_yr) then
584 h_by_dfrac := (p_pers_per_yr + 1 - X_dpp_begin) / p_pers_per_yr;
585 else
586 -- Bug# 5085669
587 h_by_dfrac := (X_d_pers_per_yr + 1 - X_dp_begin) / X_d_pers_per_yr;
588 end if;
589
590 h_b_temp := (X_d_pers_per_yr - X_dp_begin) / X_d_pers_per_yr;
591
592 else
593 if not fa_cache_pkg.fazcff (last_pro_cal, X_dpr.book, X_y_begin,h_p_period_fracs, p_log_level_rec) then
594 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.faxcfyf',
595 p_log_level_rec => p_log_level_rec);
596 return (FALSE);
597 end if;
598
599 if not fa_cache_pkg.fazcff (X_dpr.calendar_type,X_dpr.book,X_y_begin,h_d_period_fracs, p_log_level_rec) then
600 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.faxcfyf',
601 p_log_level_rec => p_log_level_rec);
602 return (FALSE);
603 end if;
604
605 X_by_frac := 0;
606 for i in X_pp_begin..p_pers_per_yr loop
607 X_by_frac := X_by_frac + h_p_period_fracs(i-1).frac;
608 end loop;
609
610 h_by_dfrac := 0;
611 for i in X_dpp_begin..p_pers_per_yr loop
612 h_by_dfrac := h_by_dfrac + h_p_period_fracs(i-1).frac;
613 end loop;
614
615 h_b_temp := 0;
616 for i in X_dp_begin+1..X_d_pers_per_yr loop
617 h_b_temp := h_b_temp + h_d_period_fracs(i-1).frac;
618 end loop;
619 end if;
620
621 X_bp_frac := h_by_dfrac - h_b_temp;
622
623 if X_rate_source_rule = 'TABLE' then
624 if h_by_dfrac <= 0 then
625 fa_srvr_msg.add_message (
626 calling_fn => 'fa_cde_pkg.faxcfyf',
627 name => 'FA_DEPRN_ILLEGAL_VALUE',
628 token1 => 'VARIABLE',
629 value1 => 'BY_DFRAC',
630 token2 => 'VALUE',
631 value2 => h_by_dfrac,
632 translate => FALSE,
633 p_log_level_rec => p_log_level_rec);
634
635 return (FALSE);
636 end if;
637
638 X_by_factor := 1/h_by_dfrac;
639 elsif X_rate_source_rule = 'FLAT' then
640 if h_by_dfrac <= 0 then
641 fa_srvr_msg.add_message (
642 calling_fn => 'fa_cde_pkg.faxcfyf',
643 name => 'FA_DEPRN_ILLEGAL_VALUE',
644 token1 => 'VARIABLE',
645 value1 => 'BY_DFRAC',
646 token2 => 'VALUE',
647 value2 => h_by_dfrac,
648 translate => FALSE,
649 p_log_level_rec => p_log_level_rec);
650 return (FALSE);
651 end if;
652
653 X_by_factor := X_by_frac / h_by_dfrac;
654
655 elsif X_rate_source_rule in ('PRODUCTION','CALCULATED', 'FORMULA') then
656 X_by_factor := 1;
657 else
658 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.faxcfyf.switch',
659 p_log_level_rec => p_log_level_rec);
660 return(FALSE);
661 end if;
662
663 if X_y_ret <> 0 then
664 h_cur_fy := fa_cache_pkg.fazcbc_record.CURRENT_FISCAL_YEAR;
665
666 if last_divide_evenly_flag then
667 --Bug6187408
668 --Added the conditon to check for daily prorate and first period.
669
670 if p_pers_per_yr = 365 and X_prd_flag = 'Y' then
671 X_ry_frac :=(X_pp_ret - X_pp_begin) / p_pers_per_yr;
672 h_r_temp := 0;
673 else
674 X_ry_frac :=(X_pp_ret - 1) / p_pers_per_yr;
675 h_r_temp := (X_dp_r_ptr - 1) / X_d_pers_per_yr;
676 end if;
677
678 else
679 if not fa_cache_pkg.fazcff (last_pro_cal, X_dpr.book, X_y_ret,
680 h_p_period_fracs
681 ,p_log_level_rec => p_log_level_rec) then
682 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.faxcfyf',
683 p_log_level_rec => p_log_level_rec);
684 return (FALSE);
685 end if;
686
687 -- Bug#4953366: if not fa_cache_pkg.fazcff (X_dpr.calendar_type, X_dpr.book, X_y_ret,
688 if not fa_cache_pkg.fazcff (X_dpr.calendar_type, X_dpr.book, h_cur_fy,
689 h_d_period_fracs
690 ,p_log_level_rec => p_log_level_rec) then
691 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.faxcfyf',
692 p_log_level_rec => p_log_level_rec);
693 return (FALSE);
694 end if;
695
696 --Bug# 7313407 - Added the conditon to check for daily prorate and first period.
697 if p_pers_per_yr = 365 and X_prd_flag = 'Y' then
698 X_ry_frac := 0;
699 for i in X_pp_begin .. X_pp_ret-1 loop
700 X_ry_frac := X_ry_frac + h_p_period_fracs(i-1).frac;
701 end loop;
702 h_r_temp := 0;
703 else
704 /*
705 * Note condition 'i < X_pp_ret'; this is because no
706 * depreciation should be taken in the prorate
707 * period retired
708 */
709 X_ry_frac := 0;
710 for i in 1 .. X_pp_ret-1 loop
711 X_ry_frac := X_ry_frac + h_p_period_fracs(i-1).frac;
712 end loop;
713
714 /* Note condition 'i < *X_dp_r_ptr'; see above */
715 h_r_temp := 0;
716 for i in 1 .. X_dp_r_ptr-1 loop
717 h_r_temp := h_r_temp + h_d_period_fracs(i-1).frac;
718 end loop;
719 end if;
720 end if;
721
722 X_rp_frac := (X_y_ret - h_cur_fy)+ (X_ry_frac - h_r_temp);
723
724 if X_y_ret = X_y_begin then
725 if X_by_frac <= 0 then
726 fa_srvr_msg.add_message (
727 calling_fn => 'fa_cde_pkg.faxcfyf',
728 name => 'FA_DEPRN_ILLEGAL_VALUE',
729 token1 => 'VARIABLE',
730 value1 => 'BY_FRAC',
731 token2 => 'VALUE',
732 value2 => X_by_frac,
733 translate => FALSE,
734 p_log_level_rec => p_log_level_rec);
735
736 return (FALSE);
737 end if;
738
739 X_rp_frac := (h_by_dfrac/X_by_frac) * (X_ry_frac+X_by_frac-1) -
740 (X_bp_frac+h_r_temp+h_b_temp-1);
741
742 if X_dp_r_ptr = X_dp_begin then
743 X_bp_frac := X_rp_frac;
744 end if;
745 end if;
746
747 if X_ry_frac < 0 then
748 X_ry_frac := 0 ;
749 X_rp_frac := 0 ;
750 end if;
751
752 else
753 X_ry_frac := 1;
754 X_rp_frac := 0;
755 end if;
756
757 if X_y_dead <> 0 then
758 if last_divide_evenly_flag then
759 X_dy_frac := X_pp_dead / p_pers_per_yr;
760 h_dy_dfrac := X_dy_frac;
761
762 if p_pers_per_yr = X_d_pers_per_yr then
763 X_dp_d_ptr := X_pp_dead;
764 else
765 X_dp_d_ptr := ceil ( round (
766 X_dy_frac * X_d_pers_per_yr,fa_std_types.FA_ROUND_DECIMAL));
767 end if;
768
769 h_d_temp := (X_dp_d_ptr - 1) / X_d_pers_per_yr;
770 else
771 if not fa_cache_pkg.fazcff (last_pro_cal, X_dpr.book, X_y_dead,
772 h_p_period_fracs, p_log_level_rec) then
773 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.faxcfyf',
774 p_log_level_rec => p_log_level_rec);
775 return (FALSE);
776 end if;
777
778 if not fa_cache_pkg.fazcff (X_dpr.calendar_type, X_dpr.book, X_y_dead,
779 h_d_period_fracs, p_log_level_rec) then
780 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.faxcfyf',
781 p_log_level_rec => p_log_level_rec);
782 return (FALSE);
783 end if;
784
785 -- Fixed loop ctr usage here - changed i to i-1
786 X_dy_frac := 0;
787 for i in 1.. X_pp_dead loop
788 X_dy_frac := X_dy_frac + h_p_period_fracs(i-1).frac;
789 end loop;
790
791 h_dy_dfrac := X_dy_frac;
792 h_d_temp := 0;
793 for i in 1..X_d_pers_per_yr loop
794 h_ctr := i;
795 if round (h_d_temp+h_d_period_fracs(i-1).frac,
796 fa_std_types.FA_ROUND_DECIMAL) >= round (
797 X_dy_frac,fa_std_types.FA_ROUND_DECIMAL) then
798 exit;
799 end if;
800 h_d_temp := h_d_temp + h_d_period_fracs(i-1).frac;
801 end loop;
802
803 X_dp_d_ptr := h_ctr;
804 end if;
805
806 X_dp_frac := X_dy_frac + h_d_temp;
807
808 if X_y_dead = X_y_ret then
809 if X_dy_frac > X_ry_frac then
810 X_dy_frac := X_ry_frac;
811
812 if X_dp_d_ptr = X_dp_r_ptr then
813 X_dp_frac := X_rp_frac;
814 else
815 X_dp_frac := 0;
816 end if;
817 end if;
818 end if;
819
820 else
821 X_dy_frac := 1;
822 h_dy_dfrac := 1;
823 X_dp_d_ptr := X_d_pers_per_yr;
824 X_dp_frac := 0;
825 end if;
826
827 return (TRUE);
828
829 exception
830 when others then
831 fa_srvr_msg.add_sql_error (calling_fn => 'fa_cde_pkg.faxcfyf'
832 ,p_log_level_rec => p_log_level_rec);
833 return (FALSE);
834 end FAXCFYF;
835
836 /*
837 ** Table to map new variable names to old variable names.
838
839 Old name New name Comment
840 -------- ------------ --------------------------------------
841 r_y_dead fy_fully_rsv fiscal year which asset becomes
842 fully reserved
843
844 c_r_y_dead fy_fully_rsv_1 Value of r_y_dead passing into
845 faxcfyf(
846 ,p_log_level_rec => p_log_level_rec) to calculate fraction of
847 last year of asset's life
848
849 r_dp_dead deprn_perd_fully_rsv depreciation period which asset
850 becomes fully reserved
851
852 r_pp_dead prate_perd_fully_rsv prorate period which asset becomes
853 fully reserved
854
855 dpr_flag dpr_cur_fy_flag depreciation in current fiscal year
856
857 calc_flag calc_rate_src_flag deprn method uses calculate rate
858 source rule
859
860 formula_flag formula_rate_src_flag deprn method uses formula rate
861 source rule
862
863 prod_flag prod_rate_src_flag deprn method uses production rate
864 source rule
865
866 table_flag table_rate_src_flag deprn method uses table rate source
867 rule
868
869 flat_flag flat_rate_src_flag deprn method uses flat rate source rule
870
871 cost_flag cost_deprn_basis_flag deprn method uses cost for
872 depreciation basis rule
873
874 nbv_flag nbv_deprn_basis_flag deprn method uses nbv
875 depreciation basis rule
876
877 fy fy_ctr fiscal year counter
878
879 per perd_ctr period counter
880
881 ctr dpr_arr_ctr dpr_arr array counter
882
883 initial_rsv initial_rsv reserve at beginning of calculation
884
885 initial_ltd_prod initial_ltd_prod life-to-date production at beginning of
886 calculation
887
888 c_amt deprn_ceiling_amt depreciation expense ceilings amount
889 from FA_CEILINGS to limit the annual
890 depreciation expense
891
892 r_amt deprn_method_amt depreciation expense calculated by
893 using depreciation method
894
895 c_min use_deprn_ceil_amt depreciation ceiling amount is less than
896 depreciation amount calculated using
897 depreciation method
898
899 r_min use_deprn_prate_amt depreciation amount calculated using
900 depreciation method is less than
901 using depreciation ceiling amount
902
903 temp_r_amt temp_prate_amt temporary amount calculated
904
905 rate
906 ann_deprn_rate annsal depreciation rate
907
908 N/A method_type type of formula-based method (prod or life)
909
910 y_first first_fy_flag fiscal year is first
911 year of asset's life
912
913 y_mid mid_fy_flag fiscal year is in middle of asset's
914 life
915
916 y_last last_fy_flag fiscal year is last year of asset's
917 life
918
919 y_retired ret_fy_flag fiscal year is year in which asset is
920 retired
921
922 y_after after_eol_fy_flag fiscal year is after last year of
923 asset's life
924
925 p_st deprn_start_perd first period in fiscal year to return
926 depreciation expense
927
928 p_end deprn_end_perd last period in fiscal year to return
929 depreciation expense
930
931 fy_nz_begin actual_deprn_start_perd first period in fiscal year that has
932 non-zero depreciation
933
934 fy_nz_end actual_deprn_end_perd last period in fiscal year that has
935 non-zero depreciation
936
937 fy_amt ann_fy_deprn annualized depreciation amount for
938 fiscal year
939
940 use_frac deprn_frac_of_yr fraction of year value used
941
942 p_deprn_exp perd_deprn_exp this period's depreciation amount
943
944 p_prod perd_prod this period's production
945
946 y_deprn_exp year_deprn_exp this year's Depreciation amount
947
948 y_reval_exp year_reval_exp this year's depreciation expense due
949 to revaluation
950
951 y_reval_amo year_reval_amo this year's revaluation amortization
952
953 y_prod year_prod this year's production
954
955 deprn_exp_sum deprn_exp_sum sum of depreciation calculated
956
957 reval_exp_sum reval_exp_sum sum of depreciation due to revaluation
958
959 reval_amo_sum reval_amo_sum sum of revaluation amortization
960
961 prod_sum prod_sum sum of production
962
963 cur_adj_cost cur_adj_cost current adjusted cost
964
965 cur_deprn_rsv cur_deprn_rsv current depreciation reserve
966
967 cur_reval_rsv cur_reval_rsv current revaluation reserve
968
969 cur_reval_amo_basis current revaluation amortization basis
970
971 cur_ltd_prod cur_ltd_prod current life-to-date production
972
973 rab_rc_ratio rab_rc_ratio ratio of revaluation amortization basis
974 to recoverable cost
975
976 bp_frac first_perd_frac fraction of annual depreciation to be
977 allocated to first period of life
978
979 by_frac first_year_frac fraction of annual depreciation to be
980 allocated to first year
981
982 by_factor adj_first_yr_frac actual fraction of annual depreciation to be
983 allocated to first year of asset's life based
984 on depreciation method
985 dp_frac last_perd_frac fraction of annual depreciation to be
986 allocated to last period of life
987
988 dy_frac last_year_frac fraction of annual depreciation to be
989 allocated to last year of life
990
991 rp_frac ret_perd_frac fraction of annual depreciation to be
992 allocated to retirement period
993
994 ry_frac ret_year_frac fraction of annual depreciation to be
995 allocated to retirement year
996
997 period_fracs perds_fracs_arr array to store period fractions of
998 fiscal year
999
1000 nbv_fabs nbv_absval nbv absolute value
1001
1002 rec_cost_fabs rec_cost_absval recoverable cost absolute value
1003
1004 adj_rec_cost_fabs adj_rec_cost_absval adjusted recoverable cost absolut
1005 value
1006
1007 rsv_fabs rsv_absval depreciation reserve absolute value
1008
1009
1010 temp_afnum
1011
1012 fy_name fy_name fiscal year name
1013
1014 method_id method_id depreciation method id
1015
1016 depr_last_year_flag depr_last_year_flag depreciate_lastyear_flag in
1017 fa_methods
1018
1019 rate_cal prorate_calendar prorate calendar
1020
1021 d_pers_per_yr perds_per_yr_dcal number of periods per year in
1022 depreciation calendar
1023
1024 p_pers_per_yr perds_per_yr_pcal number of periods per year in prorrate
1025 calendar
1026
1027 tmp_ub2
1028
1029 use_deprn_start_jdate actual_deprn_start_jdate
1030
1031 For stl method, actual depreciation
1032 start date equals to asset's porate
1033 date else equals to asset's
1034 deprn_start_date
1035
1036 dp_begin deprn_period_dcal_begin depreciation starting accounting
1037 period in deprn calendar which the
1038 actual_deprn_start_jdate falls into
1039
1040 dpp_begin deprn_period_pcal_begin depreciation starting prorate period
1041 in prorate calendar which the
1042 actual_deprn_start_jdate falls into
1043
1044 pp_begin prorate_period_pcal_begin depreciation starting prorate period
1045 in prorate calendar which
1046 prorate_date falls into
1047
1048 dp_ret ret_period_dcal retirement period in deprn calendar
1049 which retirement date falls into
1050
1051 dpp_ret ret_period_pcal retirement period in prorate
1052 calendar which retirement date
1053 falls into
1054
1055 pp_ret ret_prorate_period_pcal retirement prorate period in
1056 prorate calendar which retirement
1057 prorate date falls into
1058
1059 dy_begin deprn_year_dcal_begin depreciation starting year in
1060 depreciation calendar which the
1061 actual_deprn_start_jdate falls into
1062
1063 dpy_begin deprn_year_pcal_begin depreciation starting year in
1064 prorate calendar which the
1065 actual_deprn_start_jdate falls into
1066
1067 y_begin prorate_year_pcal_begin depreciation starting year in
1068 prorate calendar which
1069 prorate date falls into
1070
1071 y_ret ret_year_pcal retirement year in prorate calendar
1072 which retirement prorate date
1073 falls into
1074
1075 nbv_frac_thresh nbv_frac_thresh nbv_fraction_threshhold in
1076 fa_book_controls
1077
1078 nbv_amt_thresh nbv_amt_thresh nbv_amount_threshhold in
1079 fa_book_controls
1080
1081 projecting_flag deprn_projecting_flag
1082
1083
1084 amo_reval_rsv_flag amo_reval_rsv_flag amortize_reval_reserve_flag in
1085 fa_book_controls
1086
1087 raf rate_adj_factor rate_adjustment_factor in fa_books
1088
1089 cur_fy cur_fy current fiscal year
1090
1091 deprn_limit_flag use_deprn_limit_flag use depreciation limit flag
1092
1093 adj_rec_cost adj_rec_cost adjusted recoverable cost
1094
1095 new_deprn_exp last_period_deprn_exp depreciation expense for the last
1096 period of asset's life
1097
1098 ann_deprn_amt actual_annual_deprn_amt actual annual depreciation amount
1099
1100 ytd_deprn_sum ytd_deprn_sum sum of all year-to-date depreciation
1101 based on number of requested periods
1102 to depreciate in a fiscal year
1103
1104 pfy_exp_sum prior_fy_exp_sum sum of depreciation expense for
1105 prior fiscal years of all requested
1106 periods
1107
1108 exclude_salvage_value_flag
1109 excl_sal_val_flag exclude_salvage_value_flag in
1110 fa_methods
1111
1112 **
1113 */
1114
1115 FUNCTION faxcde ( dpr_in in out nocopy fa_std_types.dpr_struct
1116 , dpr_arr in out nocopy fa_std_types.dpr_arr_type
1117 , dpr_out in out nocopy fa_std_types.dpr_out_struct
1118 , fmode number
1119 , p_ind binary_integer default 0
1120 ,p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null)
1121 return boolean is
1122
1123 l_calling_fn varchar2(20) := 'faxcde';
1124
1125 dpr fa_std_types.dpr_struct;
1126 dpr_sub fa_std_types.dpr_struct;
1127 fy_fully_rsv number(5);
1128 fy_fully_rsv_1 number;
1129 deprn_perd_fully_rsv number;
1130 prate_perd_fully_rsv number;
1131 dpr_cur_fy_flag boolean;
1132 calc_rate_src_flag boolean;
1133 formula_rate_src_flag boolean;
1134 prod_rate_src_flag boolean;
1135 table_rate_src_flag boolean;
1136 flat_rate_src_flag boolean;
1137 cost_deprn_basis_flag boolean;
1138 nbv_deprn_basis_flag boolean;
1139 fy_ctr number;
1140 perd_ctr number;
1141 dpr_arr_ctr number;
1142 initial_rsv number;
1143 initial_ltd_prod number;
1144 use_deprn_ceil_amt boolean;
1145 use_deprn_prate_amt boolean;
1146 deprn_ceiling_amt number;
1147 temp_prate_amt number;
1148 temp_bonus_prate_amt number;
1149 deprn_method_amt number;
1150 bonus_deprn_method_amt number;
1151 ann_deprn_rate number;
1152 method_type number := 0;
1153 first_fy_flag boolean;
1154 mid_fy_flag boolean;
1155 last_fy_flag boolean;
1156 ret_fy_flag boolean;
1157 after_eol_fy_flag boolean;
1158 deprn_start_perd number;
1159 deprn_end_perd number;
1160 actual_deprn_start_perd number;
1161 actual_deprn_end_perd number;
1162 ann_fy_deprn number;
1163 bonus_ann_fy_deprn number;
1164 deprn_frac_of_yr number;
1165 perd_deprn_exp number;
1166 perd_bonus_deprn_amount number;
1167 perd_prod number;
1168 year_deprn_exp number;
1169 year_reval_exp number;
1170 year_reval_amo number;
1171 year_prod number;
1172 year_bonus_deprn_amount number;
1173 deprn_exp_sum number;
1174 reval_exp_sum number;
1175 bonus_deprn_exp_sum number;
1176 reval_amo_sum number;
1177 prod_sum number;
1178 cur_adj_cost number;
1179 cur_deprn_rsv number;
1180 cur_reval_rsv number;
1181 cur_reval_amo_basis number;
1182 cur_ltd_prod number;
1183 cur_bonus_deprn_rsv number;
1184 rab_rc_ratio number;
1185 first_perd_frac number;
1186 first_year_frac number;
1187 adj_first_yr_frac number;
1188 last_perd_frac number;
1189 last_year_frac number;
1190 ret_perd_frac number;
1191 ret_year_frac number;
1192 period_fracs_single fa_std_types.fa_cp_struct;
1193 perds_fracs_arr fa_std_types.table_fa_cp_struct;
1194 nbv_absval number;
1195 rec_cost_absval number;
1196 adj_rec_cost_absval number;
1197 rsv_absval number;
1198 temp_afnum number;
1199 fy_name varchar2(45);
1200 temp varchar2(45);
1201 method_id number;
1202 depr_last_year_flag boolean;
1203 rate_source_rule varchar2(40);
1204 deprn_basis_rule varchar2(14);
1205 prorate_calendar varchar2(48);
1206 perds_per_yr_dcal number;
1207 perds_per_yr_pcal number;
1208 tmp_ub2 number;
1209 actual_deprn_start_jdate number;
1210 deprn_period_dcal_begin number;
1211 deprn_period_pcal_begin number;
1212 ret_period_dcal number;
1213 ret_period_pcal number;
1214 ret_year_pcal number;
1215 ret_prorate_period_pcal number;
1216 deprn_year_dcal_begin number;
1217 deprn_year_pcal_begin number;
1218 prorate_year_pcal_begin number;
1219 prorate_period_pcal_begin number;
1220 nbv_frac_thresh number;
1221 nbv_amt_thresh number;
1222 deprn_projecting_flag boolean;
1223 amo_reval_rsv_flag boolean;
1224 rate_adj_factor number;
1225 cur_fy number;
1226 use_deprn_limit_flag boolean;
1227 adj_rec_cost number;
1228 last_period_deprn_exp number;
1229 actual_annual_deprn_amt number;
1230 actual_annual_bonus_deprn_amt number;
1231 ytd_deprn_sum number;
1232 ytd_bonus_deprn_sum number;
1233 prior_fy_exp_sum number;
1234 prior_fy_bonus_exp_sum number;
1235 excl_sal_val_flag boolean;
1236 ann_rounding_mode integer;
1237 h_dummy number;
1238 h_dummy_dpr fa_std_types.dpr_arr_type;
1239 h_dummy_bool boolean;
1240 success integer;
1241 ceiling_diff_amt number;
1242 deprn_override_flag varchar2(1);
1243 override_depr_amt number;
1244 override_bonus_amt number;
1245 l_ytd_deprn number;
1246 l_bonus_ytd_deprn number;
1247 l_polish_rule number;
1248 return_code number;
1249 value varchar2(40);
1250
1251 fy_ret number; -- Fix for Bug 1418257
1252
1253 -- For Track Member Assets
1254 p_subtract_ytd_flag varchar2(1);
1255 p_deprn_amount number;
1256 p_bonus_amount number;
1257 x_new_perd_exp number;
1258 x_new_perd_bonus_deprn_amount number;
1259 x_life_complete_flag boolean;
1260 x_fully_reserved_flag boolean;
1261 h_mode varchar2(15);
1262
1263 -- For depreciable basis rule
1264 h_eofy_flag varchar2(1);
1265 cur_eofy_reserve number;
1266
1267 l_rate number;
1268 polish_adj_calc_basis_flag varchar2(1);
1269
1270 -- Temporary deprn rsv bonus deprn rsv for call_deprn_basis
1271 cdb_deprn_rsv number;
1272 cdb_bonus_deprn_rsv number;
1273
1274 l_period_counter number(15); -- For Super Group
1275
1276 l_ind BINARY_INTEGER; -- For FA_BOOKS_SUMMARY
1277 l_accum_rsv_adj number; -- Store reserve adjustment_amount.
1278 -- It will be accumulated if faxcde is called for
1279 -- multiple periods
1280 l_rsv_adj number; -- Store reserve adjustment amount from fa_amort_pvt
1281 -- that exclude the amount of period faxcde is called
1282 -- so that it can be used when validating fully reserve or not.
1283 l_temp_adj_cost number; --Bug 5689910
1284
1285 l_adjusted_rsv_absval number; -- Bug 5948890
1286 h_adjusted_cost number; -- Bug 6665510: FP: Japan Tax Reform Project
1287 l_calling_interface varchar2(30); -- Bug 6665510: FP: Japan Tax Reform Project
1288 --Bug6187408
1289 --Added new cursor and variable to check for retirement in period of addition
1290 prd_flag varchar2(1);
1291 cursor c_prd_flag is
1292 select 'Y'
1293 from fa_calendar_periods fcp1,
1294 fa_calendar_periods fcp2,
1295 fa_book_controls fbc
1296 where to_date (dpr_in.prorate_jdate,'J') BETWEEN fcp1.start_date and fcp1.end_date
1297 and fbc.book_type_code = dpr_in.book
1298 and fcp1.calendar_type = fbc.deprn_calendar
1299 and to_date (decode( dpr_in.jdate_retired,0,null,dpr_in.jdate_retired),'J') BETWEEN fcp2.start_date and fcp2.end_date
1300 and fcp2.calendar_type=fcp1.calendar_type
1301 and fcp1.period_name=fcp2.period_name;
1302
1303 BEGIN <<FAXCDE>>
1304
1305 --code fix for bug no. 3909805.Used default value for
1306 -- year_depnr_exp in expressions if it is having null value.
1307
1308 dpr_out.full_rsv_flag := FALSE;
1309 dpr_out.life_comp_flag := FALSE;
1310
1311 --
1312 -- Debug
1313 --
1314 if (p_log_level_rec.statement_level) then
1315 h_dummy_bool := fa_cde_pkg.faprds(dpr_in
1316 ,p_log_level_rec => p_log_level_rec);
1317 end if;
1318
1319 -- int_debug.enable;
1320
1321 deprn_exp_sum := 0;
1322 bonus_deprn_exp_sum := 0;
1323 reval_exp_sum := 0;
1324 reval_amo_sum := 0;
1325 prod_sum := 0;
1326 year_deprn_exp := 0;
1327 year_bonus_deprn_amount :=0;
1328 year_reval_exp := 0;
1329 year_reval_amo := 0;
1330 year_prod := 0;
1331 rab_rc_ratio := 0;
1332 actual_annual_deprn_amt := 0;
1333 actual_annual_bonus_deprn_amt := 0;
1334 ytd_deprn_sum := 0;
1335 ytd_bonus_deprn_sum := 0;
1336 prior_fy_exp_sum := 0;
1337 prior_fy_bonus_exp_sum := 0;
1338
1339 dpr_out.new_deprn_rsv := 0;
1340 dpr_out.new_bonus_deprn_rsv := 0;
1341 dpr_out.new_adj_cost := 0;
1342 dpr_out.new_reval_rsv := 0;
1343 dpr_out.new_reval_amo_basis := 0;
1344 dpr_out.new_adj_capacity := 0;
1345 dpr_out.new_ltd_prod := 0;
1346 dpr_out.ann_adj_exp := 0;
1347 dpr_out.ann_adj_reval_exp := 0;
1348 dpr_out.ann_adj_reval_amo := 0;
1349 dpr_out.bonus_rate_used := 0;
1350 dpr_out.new_prior_fy_exp := 0;
1351 dpr_out.new_prior_fy_bonus_exp := 0;
1352
1353 -- Populate initial ytd_deprn
1354 dpr_out.new_ytd_deprn := dpr_in.ytd_deprn;
1355
1356 deprn_ceiling_amt := 0;
1357 first_perd_frac := 0;
1358 first_year_frac := 0;
1359 adj_first_yr_frac := 0;
1360 last_perd_frac := 0;
1361 last_year_frac := 0;
1362 ret_perd_frac := 0;
1363 ret_year_frac := 0;
1364
1365 if not fa_cache_pkg.fazccmt (dpr_in.method_code,dpr_in.life, p_log_level_rec) then
1366
1367 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.faxcde',
1368 p_log_level_rec => p_log_level_rec);
1369 return (FALSE);
1370 end if;
1371
1372 method_id := fa_cache_pkg.fazccmt_record.method_id;
1373 rate_source_rule := fa_cache_pkg.fazccmt_record.rate_source_rule;
1374 deprn_basis_rule := fa_cache_pkg.fazccmt_record.deprn_basis_rule;
1375 polish_adj_calc_basis_flag
1376 := fa_cache_pkg.fazccmt_record.polish_adj_calc_basis_flag;
1377 p_subtract_ytd_flag := fa_cache_pkg.fazcdrd_record.subtract_ytd_flag;
1378
1379 if fa_cache_pkg.fazccmt_record.exclude_salvage_value_flag = 'YES' then
1380 excl_sal_val_flag := TRUE;
1381 else
1382 excl_sal_val_flag := FALSE;
1383 end if;
1384
1385 if fa_cache_pkg.fazccmt_record.depreciate_lastyear_flag = 'YES' then
1386 depr_last_year_flag := TRUE;
1387 else
1388 depr_last_year_flag := FALSE;
1389 end if;
1390
1391 if (fa_cache_pkg.fazccmt_record.deprn_basis_rule_id is not null) then
1392 l_polish_rule := fa_cache_pkg.fazcdbr_record.polish_rule;
1393 end if;
1394
1395 -- One of these will be true
1396 calc_rate_src_flag := (rate_source_rule = 'CALCULATED');
1397 prod_rate_src_flag := (rate_source_rule = 'PRODUCTION');
1398 table_rate_src_flag := (rate_source_rule ='TABLE');
1399 flat_rate_src_flag := (rate_source_rule = 'FLAT');
1400 formula_rate_src_flag := (rate_source_rule = 'FORMULA');
1401
1402 -- Initialize indicator
1403 l_ind := p_ind;
1404
1405
1406 if not (calc_rate_src_flag or
1407 prod_rate_src_flag or
1408 table_rate_src_flag or
1409 flat_rate_src_flag or
1410 formula_rate_src_flag) then
1411
1412 fa_srvr_msg.add_message (
1413 calling_fn => 'fa_cde_pkg.faxcde',
1414 name => 'FA_SHARED_NO_RATE_SOURCE_RULE',
1415 translate => FALSE,
1416 p_log_level_rec => p_log_level_rec);
1417 return (FALSE);
1418 end if;
1419
1420 -- One of these will be true
1421 cost_deprn_basis_flag := (deprn_basis_rule = 'COST');
1422 nbv_deprn_basis_flag := (deprn_basis_rule = 'NBV');
1423
1424 if not (cost_deprn_basis_flag or nbv_deprn_basis_flag) then
1425
1426 fa_srvr_msg.add_message (
1427 calling_fn => 'fa_cde_pkg.faxcde',
1428 name => 'FA_SHARED_NO_DEPRN_BASIS_RULE',
1429 translate => FALSE,
1430 p_log_level_rec => p_log_level_rec);
1431
1432 return (FALSE);
1433 end if;
1434
1435 if nbv_deprn_basis_flag and
1436 not (flat_rate_src_flag or
1437 table_rate_src_flag or
1438 formula_rate_src_flag or -- ENERGY
1439 prod_rate_src_flag) then -- ENERGY
1440
1441 fa_srvr_msg.add_message (
1442 calling_fn => 'fa_cde_pkg.faxcde',
1443 name => 'FA_SHARED_NBV_NOT_FLAT',
1444 translate => FALSE,
1445 p_log_level_rec => p_log_level_rec);
1446 return (FALSE);
1447 end if;
1448
1449 --
1450 -- set use_deprn_limit_flag if asset's recoverable cost is not
1451 -- equal to adjusted recoverable cost and deprn_source_rule is
1452 -- not CALCULATED or FLAT or FORMULA
1453 --
1454 if (calc_rate_src_flag or
1455 flat_rate_src_flag or
1456 formula_rate_src_flag) and
1457 (dpr_in.rec_cost <> dpr_in.adj_rec_cost) then
1458
1459 use_deprn_limit_flag := TRUE;
1460 adj_rec_cost := dpr_in.adj_rec_cost;
1461 else
1462 use_deprn_limit_flag := FALSE;
1463 adj_rec_cost := dpr_in.rec_cost;
1464 end if;
1465
1466 deprn_projecting_flag := (fmode = fa_std_types.FA_DPR_PROJECT);
1467
1468 --
1469 -- Get the following information from the FA_BOOK_CONTROLS cache
1470 -- 1. Rate Calendar
1471 -- 2. NBV Fraction Threshold
1472 -- 3. NBV Amount Threshold
1473 -- 4. Amortize Reval Reserve Flag
1474 -- 5. Fiscal Year Name
1475 -- 6. Current Fiscal Year
1476 --
1477 -- fazcbc cache should have already been called don't call again
1478 -- BUG# 4027981 - use the mrc enabled cache for nbv_amount_threshold
1479
1480 prorate_calendar := fa_cache_pkg.fazcbc_record.PRORATE_CALENDAR;
1481 nbv_frac_thresh := nvl(fa_cache_pkg.fazcbc_record.NBV_FRACTION_THRESHOLD,
1482 fa_std_types.FA_DEF_NBV_FRAC);
1483 nbv_amt_thresh := nvl(fa_cache_pkg.fazcbcs_record.NBV_AMOUNT_THRESHOLD,
1484 fa_std_types.FA_DEF_NBV_AMT);
1485 amo_reval_rsv_flag :=
1486 (fa_cache_pkg.fazcbc_record.AMORTIZE_REVAL_RESERVE_FLAG = 'YES');
1487 fy_name := fa_cache_pkg.fazcbc_record.FISCAL_YEAR_NAME;
1488 cur_fy := fa_cache_pkg.fazcbc_record.CURRENT_FISCAL_YEAR;
1489
1490 --
1491 -- Get the number of periods per year in the depreciation calendar
1492 --
1493 if not fa_cache_pkg.fazcct(dpr_in.calendar_type) then
1494 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
1495 p_log_level_rec => p_log_level_rec);
1496 return (FALSE);
1497 end if;
1498
1499 perds_per_yr_dcal := fa_cache_pkg.fazcct_record.NUMBER_PER_FISCAL_YEAR;
1500
1501 --
1502 -- Get the number of periods per year in the rate calendar
1503 --
1504 if not fa_cache_pkg.fazcct(prorate_calendar) then
1505 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
1506 p_log_level_rec => p_log_level_rec);
1507 return (FALSE);
1508 end if;
1509
1510 perds_per_yr_pcal := fa_cache_pkg.fazcct_record.NUMBER_PER_FISCAL_YEAR;
1511
1512 --
1513 -- Determine the actual Deprn Start Date to use: this is the
1514 -- dpr_in.deprn_start_date, unless the method is STL (calc_rate_src_flag)
1515 -- Fix for Bug 903791. For formula_rate_src_flag we will use the
1516 -- deprn_start_date as determined by Depreciate When Placed in Service
1517 -- flag in Prorate Convention.
1518
1519 if calc_rate_src_flag then
1520 actual_deprn_start_jdate := dpr_in.prorate_jdate ;
1521 else
1522 actual_deprn_start_jdate := dpr_in.deprn_start_jdate;
1523 end if;
1524
1525 --
1526 -- Get the depreciation start period, and the corresponding
1527 -- fiscal year. We use h_dummy to hold the returned start
1528 -- date, which we don't need.
1529 --
1530 if not fa_cache_pkg.fazccp(dpr_in.calendar_type,
1531 fy_name,
1532 actual_deprn_start_jdate,
1533 deprn_period_dcal_begin,
1534 deprn_year_dcal_begin,
1535 h_dummy,
1536 p_log_level_rec) then
1537 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
1538 p_log_level_rec => p_log_level_rec);
1539 return (FALSE);
1540 end if;
1541
1542 --
1543 -- Get the depreciation start prorate period, and the corresponding
1544 -- fiscal year
1545 --
1546 if not fa_cache_pkg.fazccp(prorate_calendar
1547 , fy_name
1548 , actual_deprn_start_jdate
1549 , deprn_period_pcal_begin
1550 , deprn_year_pcal_begin
1551 , h_dummy
1552 , p_log_level_rec) then
1553 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
1554 p_log_level_rec => p_log_level_rec);
1555 return (FALSE);
1556 end if;
1557
1558 --
1559 -- Get the prorate period, and the corresponding fiscal year
1560 --
1561 if not fa_cache_pkg.fazccp(prorate_calendar
1562 , fy_name
1563 , dpr_in.prorate_jdate
1564 , prorate_period_pcal_begin
1565 , prorate_year_pcal_begin
1566 , h_dummy
1567 , p_log_level_rec) then
1568 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
1569 p_log_level_rec => p_log_level_rec);
1570 return (FALSE);
1571 end if;
1572
1573 if deprn_year_dcal_begin < prorate_year_pcal_begin then
1574 deprn_year_dcal_begin := prorate_year_pcal_begin;
1575 deprn_period_dcal_begin := 1;
1576 end if;
1577
1578 if deprn_year_pcal_begin < prorate_year_pcal_begin then
1579 deprn_year_pcal_begin := prorate_year_pcal_begin;
1580 deprn_period_pcal_begin := 1;
1581 end if;
1582
1583 if dpr_in.y_begin = 0 then
1584 dpr_in.y_begin := prorate_year_pcal_begin;
1585
1586 if deprn_year_dcal_begin = prorate_year_pcal_begin then
1587 dpr_in.p_cl_begin := deprn_period_dcal_begin;
1588 else
1589 dpr_in.p_cl_begin := 1;
1590 end if;
1591 end if;
1592
1593 if dpr_in.jdate_retired <> 0 and
1594 dpr_in.ret_prorate_jdate <> 0 then
1595 if not fa_cache_pkg.fazccp(dpr_in.calendar_type
1596 , fy_name
1597 , dpr_in.jdate_retired
1598 , ret_period_dcal
1599 , ret_year_pcal
1600 , h_dummy
1601 , p_log_level_rec) then
1602 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
1603 p_log_level_rec => p_log_level_rec);
1604 return (FALSE);
1605 end if;
1606
1607 -- assign y_ret to fy_ret as it gets overwritten in next call
1608 -- to fazccp. Fix for 1418257
1609 fy_ret := ret_year_pcal;
1610
1611 if not fa_cache_pkg.fazccp(prorate_calendar
1612 , fy_name
1613 , dpr_in.jdate_retired
1614 , ret_period_pcal
1615 , ret_year_pcal
1616 , h_dummy
1617 , p_log_level_rec) then
1618 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
1619 p_log_level_rec => p_log_level_rec);
1620 return (FALSE);
1621 end if;
1622
1623 if not fa_cache_pkg.fazccp(prorate_calendar
1624 , fy_name
1625 , dpr_in.ret_prorate_jdate
1626 , ret_prorate_period_pcal
1627 , ret_year_pcal
1628 , h_dummy
1629 , p_log_level_rec) then
1630 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
1631 p_log_level_rec => p_log_level_rec);
1632 return (FALSE);
1633 end if;
1634 else
1635 ret_period_dcal := 0;
1636 ret_prorate_period_pcal := 0;
1637 ret_year_pcal := 0;
1638 fy_ret := 0;
1639 end if; -- dpr_in.jdate_retired <> 0 and
1640
1641 --
1642 -- If Current reserve is not known, calculate what it
1643 -- should be by calling this routine starting at the
1644 -- beginning of the asset's life
1645 --
1646 -- bonus? When is rsv_known_flag false?
1647 -- FAWDPRB.pls, FAEXADJB.pls, FATXRSVB.pls, FAAMRT1B.pls checked
1648 -- and all return true.
1649 -- Included dpr.depn_rsv and dpr_out.new_bonus_deprn_rsv anyway.
1650 if not dpr_in.rsv_known_flag then
1651 dpr := dpr_in;
1652 dpr.deprn_rsv := 0;
1653 dpr.bonus_deprn_rsv := 0;
1654 dpr.ltd_prod := 0;
1655 initial_rsv := 0;
1656 initial_ltd_prod := 0;
1657 dpr.rsv_known_flag := TRUE;
1658 dpr.y_begin := prorate_year_pcal_begin;
1659
1660 if dpr_in.p_cl_begin = 1 then
1661 dpr.y_end := dpr_in.y_begin - 1;
1662 else
1663 dpr.y_end := dpr_in.y_begin;
1664 end if;
1665
1666 dpr.p_cl_begin := 1;
1667 dpr.p_cl_end := MOD(dpr_in.p_cl_begin - 2 + perds_per_yr_dcal,
1668 perds_per_yr_dcal) + 1;
1669
1670 if not fa_cde_pkg.faxcde(dpr
1671 , h_dummy_dpr
1672 , dpr_out
1673 , fmode, 0
1674 , p_log_level_rec) then
1675 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
1676 p_log_level_rec => p_log_level_rec);
1677 return (FALSE);
1678 end if;
1679
1680 dpr_in.rsv_known_flag := TRUE;
1681 dpr_in.deprn_rsv := dpr_out.new_deprn_rsv;
1682 dpr_in.bonus_deprn_rsv := dpr_out.new_bonus_deprn_rsv;
1683 dpr_in.adj_cost := dpr_out.new_adj_cost;
1684 dpr_in.ltd_prod := dpr_out.new_ltd_prod;
1685 dpr_in.prior_fy_exp := dpr_out.new_prior_fy_exp;
1686 dpr_in.prior_fy_bonus_exp := dpr_out.new_prior_fy_bonus_exp;
1687
1688 --
1689 -- Debug
1690 --
1691 if (p_log_level_rec.statement_level) then
1692 fa_debug_pkg.add('faxcde','new deprn_rsv',dpr_in.deprn_rsv, p_log_level_rec);
1693 fa_debug_pkg.add('faxcde','new adj_cost',dpr_in.adj_cost, p_log_level_rec);
1694 fa_debug_pkg.add('faxcde','new ltd_prod',dpr_in.ltd_prod, p_log_level_rec);
1695 fa_debug_pkg.add('faxcde','new prior_fy_exp',dpr_in.prior_fy_exp, p_log_level_rec);
1696
1697 fa_debug_pkg.add('faxcde','new prior_fy_bonus_exp',dpr_in.prior_fy_bonus_exp, p_log_level_rec);
1698 end if;
1699 end if; -- not dpr_in.rsv_known_flag
1700
1701 dpr := dpr_in;
1702
1703 cur_deprn_rsv := dpr.deprn_rsv;
1704 cur_reval_rsv := dpr.reval_rsv;
1705 cur_ltd_prod := dpr.ltd_prod;
1706 cur_adj_cost := dpr.adj_cost;
1707 cur_reval_amo_basis := dpr.reval_amo_basis;
1708 -- bonus. dpr.bonus_deprn_rsv should be known at this point
1709
1710 cur_bonus_deprn_rsv := dpr.bonus_deprn_rsv;
1711
1712 cur_eofy_reserve := dpr.eofy_reserve;
1713
1714 if (nbv_deprn_basis_flag and excl_sal_val_flag) then
1715 cur_adj_cost := cur_adj_cost + dpr.salvage_value;
1716 end if;
1717
1718 --
1719 -- Debug
1720 --
1721 if (p_log_level_rec.statement_level) then
1722 fa_debug_pkg.add('faxcde','cur_deprn_rsv',cur_deprn_rsv, p_log_level_rec);
1723 fa_debug_pkg.add('faxcde','cur_reval_rsv',cur_reval_rsv, p_log_level_rec);
1724 fa_debug_pkg.add('faxcde','cur_adj_cost',cur_adj_cost, p_log_level_rec);
1725 end if;
1726
1727 --
1728 -- If Flat-Rate or Production depreciation, do not use
1729 -- the asset's life
1730 --
1731 if flat_rate_src_flag or prod_rate_src_flag then
1732 prate_perd_fully_rsv := 1;
1733 fy_fully_rsv := 0;
1734 else
1735 prate_perd_fully_rsv := 1 + mod (prorate_period_pcal_begin - 2 +
1736 ceil(dpr.life * perds_per_yr_pcal / 12.0),
1737 perds_per_yr_pcal);
1738 fy_fully_rsv := prorate_year_pcal_begin + floor((dpr.life - 1) / 12.0);
1739
1740 if prate_perd_fully_rsv < prorate_period_pcal_begin then
1741 fy_fully_rsv := fy_fully_rsv + 1;
1742 end if;
1743 end if;
1744
1745 dpr_arr_ctr := 0;
1746
1747 if fy_fully_rsv <= dpr.y_end then
1748 fy_fully_rsv_1 := fy_fully_rsv ;
1749 else
1750 fy_fully_rsv_1 := 0;
1751 end if;
1752 --Bug6187408
1753 --Added check for retirement in period of addition
1754 open c_prd_flag;
1755 fetch c_prd_flag into prd_flag;
1756 if c_prd_flag%NOTFOUND then
1757 prd_flag := 'N';
1758 end if;
1759 close c_prd_flag;
1760 if not fa_cde_pkg.faxcfyf(dpr
1761 , perds_per_yr_dcal
1762 , rate_source_rule
1763 , prorate_year_pcal_begin
1764 , fy_fully_rsv_1
1765 , ret_year_pcal
1766 , deprn_period_dcal_begin
1767 , deprn_period_pcal_begin
1768 , deprn_perd_fully_rsv
1769 , ret_period_dcal
1770 , ret_period_pcal
1771 , prorate_period_pcal_begin
1772 , prate_perd_fully_rsv
1773 , ret_prorate_period_pcal
1774 , adj_first_yr_frac
1775 , first_perd_frac
1776 , last_perd_frac
1777 , ret_perd_frac
1778 , first_year_frac
1779 , last_year_frac
1780 , ret_year_frac
1781 , prd_flag
1782 , p_log_level_rec) then
1783
1784 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.faxcde',
1785 p_log_level_rec => p_log_level_rec);
1786 return (FALSE);
1787 end if;
1788
1789 ann_rounding_mode:= fadgpoar();
1790
1791 if (prod_rate_src_flag and ann_rounding_mode = ROUND_ALWAYS) then
1792 ann_rounding_mode:= ROUND_WITH_RESTRICTIONS;
1793 end if;
1794
1795 --
1796 -- Override depreciation functionality
1797 --
1798 if nvl(dpr_in.deprn_override_flag, fa_std_types.FA_NO_OVERRIDE) <>
1799 fa_std_types.FA_OVERRIDE_RECURSIVE then
1800 dpr_out.deprn_override_flag:= fa_std_types.FA_NO_OVERRIDE;
1801 end if;
1802
1803 -- Loop over all requested Fiscal Years --
1804 --
1805 -- YEAR LOOP
1806 --
1807 for fyctr in dpr.y_begin..dpr.y_end loop
1808
1809 fy_ctr := fyctr;
1810 year_deprn_exp :=0;
1811 year_reval_exp :=0;
1812 year_reval_amo :=0;
1813 year_bonus_deprn_amount :=0;
1814 year_prod :=0 ;
1815 actual_annual_deprn_amt := 0;
1816 actual_annual_bonus_deprn_amt := 0;
1817
1818 if not fa_cache_pkg.fazcff(dpr.calendar_type
1819 , dpr.book
1820 , fyctr
1821 , perds_fracs_arr
1822 , p_log_level_rec) then
1823 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.faxcde',
1824 p_log_level_rec => p_log_level_rec);
1825 return (FALSE);
1826 end if;
1827
1828 first_fy_flag := FALSE;
1829 mid_fy_flag := FALSE;
1830 last_fy_flag := FALSE;
1831 after_eol_fy_flag := FALSE;
1832 ret_fy_flag := FALSE;
1833
1834 if fyctr < prorate_year_pcal_begin then
1835 dpr_cur_fy_flag := FALSE;
1836 elsif fyctr = prorate_year_pcal_begin then
1837 first_fy_flag := TRUE;
1838 dpr_cur_fy_flag := TRUE;
1839 elsif (fyctr > prorate_year_pcal_begin) and (fy_fully_rsv = 0 or (fyctr < fy_fully_rsv) or
1840 flat_rate_src_flag or prod_rate_src_flag) then
1841 mid_fy_flag := TRUE;
1842 dpr_cur_fy_flag := TRUE;
1843 elsif fyctr = fy_fully_rsv then
1844 last_fy_flag := TRUE;
1845 dpr_cur_fy_flag := TRUE;
1846 elsif fyctr > fy_fully_rsv then
1847 after_eol_fy_flag := TRUE;
1848 --
1849 -- Continually depreciate an asset after its life is
1850 -- completed but it is not fully reserved yet.
1851 -- This handles the cases where an asset becomes
1852 -- fully reserved before reaching end of year loop.
1853 -- (e.g. prior period addition case)
1854 --
1855 dpr_cur_fy_flag := not dpr_out.full_rsv_flag;
1856 end if;
1857
1858 if fyctr = fy_ret then
1859 ret_fy_flag := TRUE;
1860 dpr_cur_fy_flag := dpr_cur_fy_flag and depr_last_year_flag;
1861 end if;
1862
1863 if ret_year_pcal <> 0 and fyctr > fy_ret then
1864 dpr_cur_fy_flag := FALSE;
1865 end if;
1866
1867 if fyctr = dpr.y_begin then
1868 deprn_start_perd := dpr.p_cl_begin;
1869 if dpr.y_begin = dpr.y_end then
1870 deprn_end_perd := dpr.p_cl_end;
1871 else
1872 deprn_end_perd := perds_per_yr_dcal;
1873 end if;
1874 elsif fyctr = dpr.y_end then
1875 deprn_start_perd := 1;
1876 deprn_end_perd := dpr.p_cl_end;
1877 else
1878 deprn_start_perd := 1;
1879 deprn_end_perd := perds_per_yr_dcal;
1880 end if;
1881
1882 -- bonus: put fa_cache_pkg.fazcbf here, and erase all calls later!
1883 --
1884 -- Get rate from FA_BONUS_RATES table
1885 --
1886 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
1887 --
1888 -- Get rate from FA_BONUS_RATES table
1889 --
1890
1891 if not fa_cache_pkg.fazcbr(dpr.bonus_rule
1892 , (fyctr - prorate_year_pcal_begin + 1)
1893 , dpr_out.bonus_rate_used
1894 , dpr_out.deprn_factor_used
1895 , dpr_out.alternate_deprn_factor_used
1896 , p_log_level_rec) then
1897
1898 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
1899 p_log_level_rec => p_log_level_rec);
1900 return (FALSE);
1901 end if;
1902
1903 else
1904 dpr_out.bonus_rate_used := 0;
1905 dpr_out.deprn_factor_used := 0;
1906 dpr_out.alternate_deprn_factor_used := 0;
1907 end if; -- nvl(dpr.bonus_rule, 'NONE') <> 'NONE'
1908
1909 -- Moved period loop for period update method
1910 --
1911 -- PERIOD LOOP
1912 --
1913 for perd_ctr in deprn_start_perd .. deprn_end_perd loop
1914
1915
1916 --
1917 -- Replace depreciation rate, adj_rec_cost if super group is assigned
1918 -- to this asset.
1919 --
1920 if (dpr.super_group_id is not null) then
1921
1922 l_period_counter := fyctr * fa_cache_pkg.fazcct_record.NUMBER_PER_FISCAL_YEAR + perd_ctr;
1923
1924 if not fa_cache_pkg.fazcsgr(x_super_group_id => dpr.super_group_id
1925 , x_book_type_code => dpr.book
1926 , x_period_counter => l_period_counter
1927 , p_log_level_rec => p_log_level_rec) then
1928 return (FALSE);
1929 end if;
1930
1931 dpr.adj_rate := nvl(fa_cache_pkg.fazcsgr_record.adjusted_rate, dpr.adj_rate);
1932 adj_rec_cost := nvl(dpr.cost * fa_cache_pkg.fazcsgr_record.percent_salvage_value, adj_rec_cost);
1933 fa_round_pkg.fa_floor(adj_rec_cost, dpr.book
1934 ,p_log_level_rec => p_log_level_rec);
1935
1936 if (p_log_level_rec.statement_level) then
1937 fa_debug_pkg.add('faxcde',
1938 'Super Group new adj cost', adj_rec_cost, p_log_level_rec);
1939 fa_debug_pkg.add('faxcde',
1940 'Super Group new adj rate', dpr.adj_rate, p_log_level_rec);
1941 end if;
1942
1943 end if;
1944
1945 --
1946 -- Calculate annual depreciation rate
1947 --
1948 if dpr_cur_fy_flag and (calc_rate_src_flag) then
1949 -- Calculate the rate for Straight-Line Depreciation --
1950
1951 if (dpr.life < 1) then
1952 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde'
1953 , name => 'FA_DEPRN_ILLEGAL_VALUE'
1954 , token1 => 'VARIABLE'
1955 , value1 => 'Life'
1956 , token2 => 'VALUE'
1957 , value2 => dpr.life
1958 , translate => FALSE,
1959 p_log_level_rec => p_log_level_rec);
1960 return (FALSE);
1961 end if;
1962
1963 ann_deprn_rate := 12 / dpr.life;
1964
1965 elsif dpr_cur_fy_flag and
1966 prod_rate_src_flag then
1967 --
1968 -- Temporarily use 100% as rate; get actual rate
1969 -- for period later
1970 --
1971 ann_deprn_rate := 1;
1972 -- bonus: not including bonus rate for production.
1973 dpr_out.bonus_rate_used := 0;
1974
1975 elsif (dpr_cur_fy_flag and
1976 table_rate_src_flag and
1977 not after_eol_fy_flag) then
1978 -- Get rate from FA_RATES table --
1979
1980 if not faxgtr(method_id
1981 , fyctr - prorate_year_pcal_begin + 1
1982 , prorate_period_pcal_begin
1983 , ann_deprn_rate
1984 , p_log_level_rec) then
1985 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
1986 p_log_level_rec => p_log_level_rec);
1987 return (FALSE);
1988 end if;
1989
1990 elsif (dpr_cur_fy_flag and formula_rate_src_flag) then
1991 -- Get rate from FA_FORMULAS table --
1992 -- bonus: including bonus_rate for formula
1993 -- therefore not clearing bonus_rate, compare with production method.
1994
1995 -- Bug 6665510: FP: Japan Tax Reform Project (Start)
1996 if nvl(fa_cache_pkg.fazccmt_record.guarantee_rate_method_flag, 'NO') = 'YES' then
1997 if (p_log_level_rec.statement_level) then
1998 fa_debug_pkg.add('faxcde', '+++ JAPAN ', 'in guarantee rate', p_log_level_rec);
1999 end if;
2000
2001 if dpr_in.jdate_retired <> 0 and -- retirement
2002 dpr_in.ret_prorate_jdate <> 0 then
2003 l_calling_interface := null;
2004 elsif dpr_in.transaction_type_code = 'REINSTATEMENT' then -- Bug:6665510
2005 l_calling_interface := null;
2006 else
2007 l_calling_interface := 'FAXCDE';
2008 end if;
2009 end if;
2010 -- Bug 6665510: FP: Japan Tax Reform Project (End)
2011
2012 faxgfr( X_Book_Type_Code => dpr.book,
2013 X_Asset_Id => dpr.asset_id,
2014 X_Short_Fiscal_Year_Flag => dpr.short_fiscal_year_flag,
2015 X_Conversion_Date => dpr.conversion_date,
2016 X_Prorate_Date => dpr.prorate_date,
2017 X_Orig_Deprn_Start_Date => dpr.orig_deprn_start_date,
2018 C_Prorate_Date => NULL,
2019 C_Conversion_Date => NULL,
2020 C_Orig_Deprn_Start_Date => NULL,
2021 X_Method_Code => dpr.method_code,
2022 X_Life_In_Months => dpr.life,
2023 X_Fiscal_Year => fyctr,
2024 X_Current_Period => perd_ctr,
2025
2026 -- Bug 6665510: FP: Japan Tax Reform Project
2027 X_calling_interface => l_calling_interface,
2028 X_new_cost => dpr.cost,
2029 X_adjusted_cost => dpr.cost - nvl(cur_eofy_reserve,0),
2030
2031 X_Rate => ann_deprn_rate,
2032 X_Method_Type => method_type,
2033 X_Success => success,
2034 p_log_level_rec => p_log_level_rec);
2035
2036 if (method_type = 1) then
2037 rate_source_rule := 'PRODUCTION';
2038 prod_rate_src_flag := (rate_source_rule = 'PRODUCTION');
2039 formula_rate_src_flag := (rate_source_rule = 'FORMULA');
2040 end if;
2041
2042 if (success <= 0) then
2043 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
2044 p_log_level_rec => p_log_level_rec);
2045 return (FALSE);
2046 end if;
2047
2048
2049 elsif (dpr_cur_fy_flag and flat_rate_src_flag) then
2050
2051 -- Bug 3187975. If Polish method, use special rate logic
2052 if (l_polish_rule in (FA_STD_TYPES.FAD_DBR_POLISH_1,
2053 FA_STD_TYPES.FAD_DBR_POLISH_2,
2054 FA_STD_TYPES.FAD_DBR_POLISH_3,
2055 FA_STD_TYPES.FAD_DBR_POLISH_4,
2056 FA_STD_TYPES.FAD_DBR_POLISH_5)) then
2057
2058 l_rate := dpr.adj_rate;
2059
2060 fa_cde_pkg.faxgpolr (
2061 X_Book_Type_Code => dpr.book,
2062 X_Asset_Id => dpr.asset_id,
2063 X_Polish_Rule => l_polish_rule,
2064 X_Deprn_Factor => dpr_out.deprn_factor_used,
2065 X_Alternate_Deprn_Factor =>
2066 dpr_out.alternate_deprn_factor_used,
2067 X_Polish_Adj_Calc_Basis_Flag
2068 => polish_adj_calc_basis_flag,
2069 X_Recoverable_Cost => dpr_in.rec_cost,
2070 X_Fiscal_Year => fyctr,
2071 X_Current_Period => perd_ctr,
2072 X_Periods_Per_Year => perds_per_yr_dcal,
2073 X_Year_Retired => ret_fy_flag,
2074 X_Projecting_Flag => deprn_projecting_flag,
2075 X_MRC_SOB_Type_Code => dpr.mrc_sob_type_code,
2076 X_Rate => l_rate,
2077 X_Depreciate_Flag => dpr_cur_fy_flag,
2078 X_Current_Adjusted_Cost => cur_adj_cost,
2079 X_Adjusted_Recoverable_Cost
2080 => adj_rec_cost,
2081 X_Success => success,
2082 X_Calling_Fn => 'fa_cde_pkg.faxcde'
2083 ,p_log_level_rec => p_log_level_rec);
2084 ann_deprn_rate := l_rate;
2085 else
2086 -- bonus: changed this so we keep deprn_exp and
2087 -- bonus_deprn_amount separated until later.
2088 -- ann_deprn_rate := dpr.adj_rate + dpr_out.bonus_rate_used;
2089
2090 ann_deprn_rate := dpr.adj_rate;
2091 end if;
2092 elsif dpr_cur_fy_flag then -- bonus: elsif for unknown rate_source_rule
2093 --
2094 -- Rate-based amount is total recoverable cost, all
2095 -- taken in current period (=> *perds_per_yr_dcal)
2096 -- No deprn limit for table_rate_src_flag
2097 --
2098 ann_deprn_rate := 1;
2099 temp_prate_amt := dpr.rec_cost * perds_per_yr_dcal;
2100
2101 -- Bonus Deprn - YYOON 7/7/2000
2102 -- In this case which is assumed to be
2103 -- a recoverable cost based method,
2104 -- the bonus deprn amount is only calculated
2105 -- as temp_prate_amt multiplied by bonus_rate */
2106
2107 if nvl(dpr_out.bonus_rate_used,0) <> 0 then
2108 temp_bonus_prate_amt := temp_prate_amt * dpr_out.bonus_rate_used;
2109 else
2110 temp_bonus_prate_amt := 0;
2111 end if;
2112 -- End of Bonus Deprn Change */
2113
2114 else
2115 --
2116 -- dpr_cur_fy_flag is FALSE
2117 --
2118 ann_deprn_rate := 0;
2119 dpr_out.bonus_rate_used := 0;
2120 temp_prate_amt := 0;
2121 temp_bonus_prate_amt := 0;
2122 end if;
2123
2124 -- Note: temp_prate_amt and temp_bonus_prate_amt have no value
2125 -- if rate_source_rule is provided.
2126 -- bonus: using same fraction for bonus rate as for regular deprn rate.
2127 -- dpr_out.bonus_rate_used := dpr_out.bonus_rate_used * ann_deprn_rate;
2128
2129 --
2130 -- Debug
2131 --
2132 if (p_log_level_rec.statement_level) then
2133 fa_debug_pkg.add('faxcde','fadpdp(2): ann_deprn_rate',ann_deprn_rate, p_log_level_rec);
2134 end if;
2135
2136 if ann_deprn_rate >= 0 then
2137 --
2138 -- Check that RAF is between 0 and 1
2139 --
2140 if dpr.rate_adj_factor not between 0 and 1 then
2141 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
2142 name => 'FA_DEPRN_ILLEGAL_VALUE',
2143 token1 => 'VARIABLE',
2144 value1 => 'Rate_Adjustment_Factor',
2145 token2 => 'VALUE',
2146 value2 => dpr.rate_adj_factor,
2147 translate => FALSE,
2148 p_log_level_rec => p_log_level_rec);
2149 return (FALSE);
2150 end if;
2151
2152 if dpr.rate_adj_factor = 0 then
2153 --
2154 -- If RAF = 0, then use a very small RAF
2155 -- so we don't divide by zero
2156 --
2157 rate_adj_factor := fa_std_types.FA_DPR_SMALL_RAF;
2158 else
2159 rate_adj_factor := dpr.rate_adj_factor;
2160 end if;
2161 --code fix for bug no.3909805. dpr.formula_factor can have null value.
2162 temp_prate_amt := (cur_adj_cost / rate_adj_factor) * ann_deprn_rate * nvl(dpr.formula_factor,1);
2163
2164
2165 --
2166 -- Bonus Deprn - YYOON
2167 -- Calcuate annual bonus deprn expense for current year
2168 -- NOTE:
2169 -- 1. The bonus deprn calculation should NOT be adjusted
2170 -- by the rate adjustment factor.(Please refer to HLD page 24)
2171 -- 2. The depreciable basis for the bonus deprn calculation should be
2172 -- the recoverable cost or NBV depending on the asset's method.
2173 -- (Please refer to HLD Example 1 and 3)
2174 -- 3. The bonus deprn calculation for assets with a cost-based method
2175 -- should NOT be based on the adjusted_cost which gets reset to NBV
2176 -- as of the period of amortized adjustment
2177 -- but should be based on the recoverable cost.
2178 -- (Please refer to HLD Example 6)
2179 -- 4. The adjusted_cost is calculated based only on the standard
2180 -- accumulated depreciation (total less bonus) as of the period of
2181 -- amortized adjustment. (This should be taken care of in forms level)
2182 -- (Please refer to HLD Example 6)
2183 -- 5. On 7/20/2000, a new logic to reset adjusted_cost of assets
2184 -- with NBV-based methods to Cost minus Regular Reserve
2185 -- at the end of each fiscal year. (bug# 1351870)
2186 -- 6. On 09/10/2000, backed out changes done for 1351870.
2187 --
2188 if nvl(dpr_out.bonus_rate_used,0) <> 0 then
2189 temp_bonus_prate_amt := cur_adj_cost * dpr_out.bonus_rate_used ;
2190 else
2191 temp_bonus_prate_amt := 0;
2192 end if;
2193 -- End of Bonus Deprn Change
2194
2195 end if; -- ann_deprn_rate >= 0
2196
2197 --
2198 -- Debug
2199 --
2200 if (p_log_level_rec.statement_level) then
2201 fa_debug_pkg.add('faxcde','fadpdp(3): temp_prate_amt',temp_prate_amt, p_log_level_rec);
2202 end if;
2203
2204 -- syoung: changed 0 to '0'. If ceil_name(varchar2) is not null, and
2205 -- if that is compared with 0, then would cause a value_error.
2206 if dpr_cur_fy_flag and nvl(dpr.ceil_name,'0') <> '0' then
2207 --
2208 -- Get Ceiling Information from FA_CEILING_TYPES
2209 -- and FA_CEILINGS
2210 --
2211 if not fa_cache_pkg.fazccl(dpr.ceil_name, dpr.jdate_in_service
2212 , fyctr - prorate_year_pcal_begin + 1, deprn_ceiling_amt
2213 ,p_log_level_rec => p_log_level_rec) then
2214 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
2215 p_log_level_rec => p_log_level_rec);
2216 return (FALSE);
2217 end if;
2218
2219 end if;
2220
2221
2222 if dpr.ceil_name is not null and
2223 (temp_prate_amt = 0 or
2224 deprn_ceiling_amt < temp_prate_amt + temp_bonus_prate_amt) then
2225 use_deprn_ceil_amt := true;
2226 use_deprn_prate_amt := false;
2227 else
2228 use_deprn_ceil_amt := false;
2229 use_deprn_prate_amt := true;
2230 end if;
2231
2232 -- Default initializations --
2233 actual_deprn_start_perd := 1;
2234 actual_deprn_end_perd := perds_per_yr_dcal;
2235
2236 --
2237 -- if asset is in the first year or last year of life then
2238 -- re-calculate annual deprn expense based on the fraction
2239 -- of year asset is held
2240 --
2241 if (first_fy_flag) then
2242 actual_deprn_start_perd := deprn_period_dcal_begin;
2243 -- 'Annualize' the Rate amount and Ceiling amount
2244 deprn_method_amt := temp_prate_amt * adj_first_yr_frac;
2245
2246 --
2247 -- bug 2182029. added condition, now not multipl. with fraction for table mthd.
2248 --
2249 if (not table_rate_src_flag) then
2250 bonus_deprn_method_amt := temp_bonus_prate_amt * adj_first_yr_frac;
2251 else
2252 bonus_deprn_method_amt := temp_bonus_prate_amt;
2253 end if;
2254 -- end 2182029
2255
2256 if (dpr.ceil_name is not null) then
2257 deprn_ceiling_amt := deprn_ceiling_amt * adj_first_yr_frac;
2258 end if;
2259
2260 if (dpr.ceil_name is not null and (
2261 deprn_method_amt = 0 or deprn_ceiling_amt < (deprn_method_amt + bonus_deprn_method_amt))) then
2262 use_deprn_ceil_amt := true;
2263 use_deprn_prate_amt := false;
2264 else
2265 use_deprn_prate_amt := true;
2266 use_deprn_ceil_amt := false;
2267 end if;
2268
2269 if use_deprn_prate_amt then
2270 ann_fy_deprn := deprn_method_amt;
2271 bonus_ann_fy_deprn := bonus_deprn_method_amt;
2272 else -- use_deprn_ceil_amt
2273
2274 if deprn_method_amt >= deprn_ceiling_amt then
2275 ann_fy_deprn := deprn_ceiling_amt;
2276 bonus_ann_fy_deprn := 0;
2277 else
2278 ann_fy_deprn := deprn_method_amt;
2279
2280 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2281 bonus_ann_fy_deprn := deprn_ceiling_amt - deprn_method_amt;
2282 else
2283 bonus_ann_fy_deprn := 0;
2284 end if;
2285
2286 end if;
2287
2288 end if; -- use_deprn_prate_amt then
2289
2290 actual_annual_deprn_amt := ann_fy_deprn;
2291 actual_annual_bonus_deprn_amt := bonus_ann_fy_deprn;
2292
2293 -- bonus: ann_fy_deprn and deprn_method_amt still not containing
2294 -- bonus_ann_fy_deprn or bonus_deprn_method_amt.
2295 -- first_year_frac holds fraction of the year, i.e. a decimal value.
2296 -- adj_first_yr_frac is the inverse
2297
2298 if (table_rate_src_flag) then
2299 actual_annual_deprn_amt := actual_annual_deprn_amt/adj_first_yr_frac;
2300
2301 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2302 actual_annual_bonus_deprn_amt := bonus_ann_fy_deprn/adj_first_yr_frac;
2303 end if;
2304
2305 else
2306 actual_annual_deprn_amt :=
2307 actual_annual_deprn_amt * (first_year_frac/adj_first_yr_frac);
2308
2309 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2310 -- bonus
2311 actual_annual_bonus_deprn_amt :=
2312 bonus_ann_fy_deprn * (first_year_frac/adj_first_yr_frac);
2313 end if;
2314 end if; --(table_rate_src_flag)
2315
2316 elsif mid_fy_flag then
2317
2318 deprn_method_amt := temp_prate_amt;
2319 bonus_deprn_method_amt := temp_bonus_prate_amt;
2320
2321 if use_deprn_prate_amt then
2322 ann_fy_deprn := deprn_method_amt;
2323 bonus_ann_fy_deprn := bonus_deprn_method_amt;
2324 else -- use_deprn_ceil_amt
2325
2326 if deprn_method_amt >= deprn_ceiling_amt then
2327 ann_fy_deprn := deprn_ceiling_amt;
2328 bonus_ann_fy_deprn := 0;
2329 else
2330 ann_fy_deprn := deprn_method_amt;
2331 -- bonus: prorate to bonus..
2332
2333 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2334 bonus_ann_fy_deprn := deprn_ceiling_amt - deprn_method_amt;
2335 else
2336 bonus_ann_fy_deprn := 0;
2337 end if;
2338
2339 end if; -- deprn_method_amt >= deprn_ceiling_amt
2340
2341 end if; --use_deprn_prate_amt
2342
2343 actual_annual_deprn_amt := ann_fy_deprn;
2344 actual_annual_bonus_deprn_amt := bonus_ann_fy_deprn;
2345
2346 elsif last_fy_flag then
2347 deprn_method_amt := temp_prate_amt;
2348 bonus_deprn_method_amt := temp_bonus_prate_amt;
2349
2350 if (use_deprn_ceil_amt) then
2351 actual_deprn_end_perd := deprn_perd_fully_rsv;
2352
2353 if deprn_method_amt >= deprn_ceiling_amt then
2354 ann_fy_deprn := deprn_ceiling_amt;
2355 bonus_ann_fy_deprn := 0;
2356 else
2357 ann_fy_deprn := deprn_method_amt;
2358
2359 -- bonus: prorate to bonus..
2360 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2361 bonus_ann_fy_deprn := deprn_ceiling_amt - deprn_method_amt;
2362 else
2363 bonus_ann_fy_deprn := 0;
2364 end if;
2365 end if; -- deprn_method_amt >= deprn_ceiling_amt
2366
2367 else
2368
2369 if (table_rate_src_flag) then
2370 if ( last_year_frac <= 0) then
2371 deprn_method_amt := 0;
2372 bonus_deprn_method_amt := 0;
2373 else
2374 -- Bug#4745217: To avoid doubled catchup when retiring assets with Half Yr convention in last FY
2375 if ret_fy_flag then
2376 deprn_method_amt := temp_prate_amt;
2377 bonus_deprn_method_amt := temp_bonus_prate_amt;
2378 else
2379 deprn_method_amt := temp_prate_amt / last_year_frac;
2380
2381 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2382 bonus_deprn_method_amt := temp_bonus_prate_amt / last_year_frac;
2383 end if;
2384 end if;
2385 end if;
2386 end if; -- (table_rate_src_flag)
2387
2388 -- For assets without depreciation limit,
2389 -- we stop depreciating in the last period of
2390 -- life, if asset has depreciation limit then
2391 -- it may continue to depreciate even past the
2392 -- last year of life. This only applies to assets
2393 -- without depreciation ceiling.
2394
2395 if not use_deprn_limit_flag then
2396 actual_deprn_end_perd := deprn_perd_fully_rsv;
2397 end if;
2398
2399 ann_fy_deprn := deprn_method_amt;
2400 bonus_ann_fy_deprn := bonus_deprn_method_amt;
2401
2402 end if; -- (use_deprn_ceil_amt) then
2403
2404 actual_annual_deprn_amt := ann_fy_deprn;
2405 actual_annual_bonus_deprn_amt := bonus_ann_fy_deprn;
2406
2407 elsif (after_eol_fy_flag) then
2408
2409 -- if asset does not has deprn limit then fully
2410 -- reserve the asset in the current period
2411 -- otherwise set annual deprn amount to
2412 -- temp_prate_amt as if asset is in the middle year
2413 -- of life
2414 -- bonus here?
2415 if not use_deprn_limit_flag then
2416
2417 if not use_deprn_ceil_amt then
2418 -- Fully reserve the asset in the
2419 -- current period
2420 use_deprn_ceil_amt := true;
2421 use_deprn_prate_amt := false;
2422 deprn_ceiling_amt := dpr.rec_cost * perds_per_yr_dcal;
2423 end if;
2424
2425 ann_fy_deprn := deprn_ceiling_amt;
2426 bonus_ann_fy_deprn := 0;
2427 else
2428 -- we assume that asset can only has deprn
2429 -- limit or deprn ceiling
2430 ann_fy_deprn := temp_prate_amt;
2431 bonus_ann_fy_deprn := temp_bonus_prate_amt;
2432 end if; -- not use_deprn_limit_flag then
2433
2434 actual_annual_deprn_amt := ann_fy_deprn;
2435 actual_annual_bonus_deprn_amt := bonus_ann_fy_deprn;
2436 else
2437 actual_deprn_end_perd := 0;
2438 ann_fy_deprn := 0;
2439 actual_annual_deprn_amt := 0;
2440 bonus_ann_fy_deprn := 0;
2441 actual_annual_bonus_deprn_amt := 0;
2442 end if; -- (first_fy_flag) then
2443 --
2444 -- Bug 3270280
2445 -- if ret_fy_flag then
2446 -- Bug3961991
2447 -- Added condition dpr_in.deprn_override_flag <> fa_std_types.FA_OVERRIDE_RECURSIVE
2448 -- so that following condition will not be true during recursive call.
2449 if ((ret_fy_flag) and (NOT depr_last_year_flag) or (ret_fy_flag and first_fy_flag))
2450 and dpr_in.deprn_override_flag <> fa_std_types.FA_OVERRIDE_RECURSIVE then
2451
2452 deprn_start_perd := ret_period_dcal;
2453 deprn_end_perd := ret_period_dcal;
2454
2455 actual_deprn_start_perd := ret_period_dcal;
2456 actual_deprn_end_perd := ret_period_dcal;
2457 --bug fix 3695153 starts
2458 if(ret_period_dcal < ret_prorate_period_pcal) and (first_fy_flag)then
2459 actual_deprn_start_perd := perd_ctr;
2460 actual_deprn_end_perd := perd_ctr;
2461 end if;
2462 --bug fix 3695153 ends
2463 end if;
2464
2465 -- bonus: sum bonus amount into ann_fy_deprn now.
2466 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2467 ann_fy_deprn := ann_fy_deprn + bonus_ann_fy_deprn;
2468 -- latest bonus addition:
2469 actual_annual_deprn_amt := actual_annual_deprn_amt + actual_annual_bonus_deprn_amt;
2470 end if;
2471
2472 -- currency formatting.
2473 h_dummy_bool := fa_utils_pkg.faxtru (ann_fy_deprn, dpr.book
2474 ,p_log_level_rec => p_log_level_rec);
2475 h_dummy_bool := fa_utils_pkg.faxtru (actual_annual_deprn_amt, dpr.book
2476 ,p_log_level_rec => p_log_level_rec);
2477
2478 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2479 h_dummy_bool := fa_utils_pkg.faxtru (bonus_ann_fy_deprn, dpr.book
2480 ,p_log_level_rec => p_log_level_rec);
2481 h_dummy_bool := fa_utils_pkg.faxtru (actual_annual_bonus_deprn_amt, dpr.book
2482 ,p_log_level_rec => p_log_level_rec);
2483 end if;
2484
2485 --
2486 -- Debug
2487 --
2488 if (p_log_level_rec.statement_level) then
2489 fa_debug_pkg.add('faxcde','fadpdp(4): ann_fy_deprn',ann_fy_deprn, p_log_level_rec);
2490 fa_debug_pkg.add('faxcde','actual_annual_deprn_amt',actual_annual_deprn_amt, p_log_level_rec);
2491 end if;
2492
2493 --
2494 -- deprn_start_perd is the first period in this fiscal year
2495 -- for which we want to return a value.
2496 -- deprn_end_perd is the last period in this fiscal year
2497 -- for which we want to return a value.
2498 --
2499 -- bonus: sum bonus amount into ann_fy_deprn now.
2500 -- if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2501 -- ann_fy_deprn := ann_fy_deprn + bonus_ann_fy_deprn;
2502 -- latest bonus addition:
2503 -- actual_annual_deprn_amt := actual_annual_deprn_amt + actual_annual_bonus_deprn_amt;
2504 -- end if;
2505
2506 -- *************************************************************
2507 -- Commented out and moved period loop for period update method
2508 -- This is the point where for loop for each period located
2509 -- for perd_ctr in deprn_start_perd .. deprn_end_perd loop
2510 -- ************************************************************
2511 deprn_override_flag:= fa_std_types.FA_NO_OVERRIDE;
2512
2513 --
2514 -- actual_deprn_start_perd is the first period in this fy
2515 -- for which the depreciation can be non-zero.
2516 -- actual_deprn_end_perd is the last period in this fy for
2517 -- which the depreciation can be non-zero.
2518 --
2519 if ((perd_ctr >= actual_deprn_start_perd) and
2520 (perd_ctr <= actual_deprn_end_perd)) then
2521
2522 if first_fy_flag and
2523 (perd_ctr = actual_deprn_start_perd) and
2524 (not ret_fy_flag) then
2525
2526 deprn_frac_of_yr := first_perd_frac;
2527 -- bug fix 3233833 starts
2528 -- code fix for bug4213110: enter the following condition only if the no of pds in deprn and prorate calendar are same.
2529 -- bug fix 5504993 (added and condition (perd_ctr <> ret_period_dcal) at the end of elsif)
2530 elsif ret_fy_flag and
2531 (ret_period_dcal < ret_prorate_period_pcal) and (perds_per_yr_pcal = perds_per_yr_dcal) and
2532 (perd_ctr <> ret_period_dcal) then
2533 deprn_frac_of_yr := (ret_prorate_period_pcal - perd_ctr)/perds_per_yr_dcal;
2534 --bug fix 3233833 ends
2535 elsif ret_fy_flag and
2536 (perd_ctr = ret_period_dcal) then
2537 deprn_frac_of_yr := ret_perd_frac;
2538 elsif use_deprn_prate_amt and
2539 (fyctr = fy_fully_rsv) and
2540 (perd_ctr = deprn_perd_fully_rsv) and
2541 not use_deprn_limit_flag then
2542 deprn_frac_of_yr := last_perd_frac;
2543 else
2544 --
2545 -- always get fraction from cache for
2546 -- assets using flat rate or having
2547 -- deprn limit
2548 --
2549 deprn_frac_of_yr := perds_fracs_arr(perd_ctr-1).frac;
2550 end if; -- first_fy_flag and
2551
2552 -- bonus: perd_deprn_exp including perd_bonus_deprn_amount, since ann_fy_deprn
2553 -- kept the total amount.
2554 perd_deprn_exp := ann_fy_deprn * deprn_frac_of_yr;
2555
2556 -- bonus? investigate.
2557 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2558 perd_bonus_deprn_amount := bonus_ann_fy_deprn * deprn_frac_of_yr;
2559 end if;
2560
2561
2562 --
2563 -- In case of subtract ytd falg is true, multiply number of
2564 -- period past in this fiscal year to periodic depreciation
2565 -- and subtract passed ytd deprn amount to find periodic exp.
2566 --
2567 if (p_log_level_rec.statement_level) then
2568 fa_debug_pkg.add(l_calling_fn, 'p_subtract_ytd_flag', p_subtract_ytd_flag, p_log_level_rec);
2569 end if;
2570
2571 if (nvl(p_subtract_ytd_flag,'N') = 'Y') then
2572
2573 if (p_log_level_rec.statement_level) then
2574 fa_debug_pkg.add(l_calling_fn||' OPA', 'cache: use_eofy_reserve_flag',
2575 fa_cache_pkg.fazcdrd_record.use_eofy_reserve_flag, p_log_level_rec);
2576 fa_debug_pkg.add(l_calling_fn||' OPA', 'cache: allow_reduction_rate_flag',
2577 fa_cache_pkg.fazcdrd_record.allow_reduction_rate_flag, p_log_level_rec);
2578 fa_debug_pkg.add(l_calling_fn||' OPA', 'cache: rate_source_rule',
2579 fa_cache_pkg.fazccmt_record.rate_source_rule, p_log_level_rec);
2580 fa_debug_pkg.add(l_calling_fn||' OPA', 'cache: deprn_basis_rule',
2581 fa_cache_pkg.fazccmt_record.deprn_basis_rule, p_log_level_rec);
2582 end if;
2583
2584 --
2585 -- Change for OPA
2586 --
2587 if (fa_cache_pkg.fazcdrd_record.use_eofy_reserve_flag = 'Y' and
2588 fa_cache_pkg.fazcdrd_record.allow_reduction_rate_flag = 'N' and
2589 fa_cache_pkg.fazccmt_record.rate_source_rule = 'FLAT' and
2590 fa_cache_pkg.fazccmt_record.deprn_basis_rule = 'COST') then
2591 --
2592 -- Find ytd using (reserve - eofy reserve)
2593 -- find remaining period in fy using (num per in fy - period num + 1)
2594 -- formula to find peridic exp is
2595 -- ((adj_cost * rate) - ytd) / remaining period in fy
2596 --
2597 if (p_log_level_rec.statement_level) then
2598 fa_debug_pkg.add(l_calling_fn||' OPA', 'ann_fy_deprn', ann_fy_deprn, p_log_level_rec);
2599 fa_debug_pkg.add(l_calling_fn||' OPA', 'ann_deprn_rate', ann_deprn_rate, p_log_level_rec);
2600 fa_debug_pkg.add(l_calling_fn||' OPA', 'cur_deprn_rsv', cur_deprn_rsv, p_log_level_rec);
2601 fa_debug_pkg.add(l_calling_fn||' OPA', 'cur_eofy_reserve', cur_eofy_reserve, p_log_level_rec);
2602 fa_debug_pkg.add(l_calling_fn||' OPA', 'perds_per_yr_dcal', perds_per_yr_dcal, p_log_level_rec);
2603 fa_debug_pkg.add(l_calling_fn||' OPA', 'perd_ctr', perd_ctr, p_log_level_rec);
2604 end if;
2605
2606 perd_deprn_exp := (cur_adj_cost * ann_deprn_rate -
2607 (nvl(cur_deprn_rsv,0)+ nvl(year_deprn_exp,0) - cur_eofy_reserve))/
2608 (perds_per_yr_dcal - perd_ctr + 1);
2609 if (p_log_level_rec.statement_level) then
2610 fa_debug_pkg.add(l_calling_fn||' OPA', 'perd_deprn_exp', perd_deprn_exp, p_log_level_rec);
2611 end if;
2612
2613 else
2614
2615 if (p_log_level_rec.statement_level) then
2616 fa_debug_pkg.add('HH DEBUG', 'perd_deprn_exp(before)',perd_deprn_exp, p_log_level_rec);
2617 fa_debug_pkg.add('HH DEBUG', 'perd_ctr',perd_ctr, p_log_level_rec);
2618 fa_debug_pkg.add('HH DEBUG', 'dpr_in.ytd_deprn',dpr_in.ytd_deprn, p_log_level_rec);
2619 fa_debug_pkg.add('HH DEBUG', 'year_deprn_exp',year_deprn_exp, p_log_level_rec);
2620 end if;
2621
2622 if (fyctr = dpr.y_begin) then
2623 perd_deprn_exp := perd_deprn_exp * perd_ctr - dpr_in.ytd_deprn;
2624
2625 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2626 perd_bonus_deprn_amount :=
2627 perd_bonus_deprn_amount * perd_ctr - dpr.bonus_ytd_deprn;
2628 end if;
2629
2630 else
2631 perd_deprn_exp := perd_deprn_exp * perd_ctr - nvl(year_deprn_exp,0);
2632
2633 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2634 perd_bonus_deprn_amount :=
2635 perd_bonus_deprn_amount * perd_ctr - year_bonus_deprn_amount;
2636 end if;
2637
2638 end if; -- (fyctr = dpr.y_begin)
2639 end if; -- Change for OPA
2640
2641 end if; -- (nvl(p_subtract_ytd_flag,'N') = 'Y')
2642
2643 dpr_out.ann_adj_exp := ann_fy_deprn;
2644 --
2645 -- Debug
2646 --
2647 if (p_log_level_rec.statement_level) then
2648 fa_debug_pkg.add('faxcde', 'fadpdp(4.0): ann_fy_deprn',ann_fy_deprn, p_log_level_rec);
2649 fa_debug_pkg.add('faxcde', 'deprn_frac_of_yr',deprn_frac_of_yr, p_log_level_rec);
2650 fa_debug_pkg.add('faxcde', 'perd_deprn_exp',perd_deprn_exp, p_log_level_rec);
2651 end if;
2652
2653 --
2654 -- if the profile option:FA_DEPRN_OVERRIDE_ENABLED = 'Y' and
2655 -- this is not for what-if analysis, call FAODDA funtion to
2656 -- upload the override depreciation data
2657 --
2658 override_depr_amt:= NULL;
2659 override_bonus_amt:= NULL;
2660
2661 if (fa_cache_pkg.fa_deprn_override_enabled) then
2662 value := 'Y';
2663 else
2664 value := 'N';
2665 end if;
2666
2667 if (p_log_level_rec.statement_level) then
2668 fa_debug_pkg.add('faxcde', 'FA_DEPRN_OVERRIDE_ENABLED', value, p_log_level_rec);
2669 end if;
2670
2671 if value = 'Y' and
2672 nvl(dpr_in.deprn_override_flag, fa_std_types.FA_NO_OVERRIDE) <> fa_std_types.FA_OVERRIDE_RECURSIVE then
2673 l_bonus_ytd_deprn := 0;
2674
2675 if fyctr = dpr.y_begin then
2676 l_ytd_deprn := dpr_in.ytd_deprn;
2677
2678 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2679 l_bonus_ytd_deprn := dpr.bonus_ytd_deprn;
2680 end if;
2681 else
2682 l_ytd_deprn := nvl(year_deprn_exp,0);
2683
2684 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2685 l_bonus_ytd_deprn := year_bonus_deprn_amount;
2686 end if;
2687 end if;
2688
2689 if (p_log_level_rec.statement_level) then
2690 fa_debug_pkg.add('faxcde', 'fadpdp: dpr_in.deprn_override_flag',dpr_in.deprn_override_flag, p_log_level_rec);
2691 end if;
2692
2693 if not FAODDA(dpr.book
2694 , dpr.used_by_adjustment
2695 , dpr.asset_id
2696 , dpr.bonus_rule
2697 , fyctr
2698 , perd_ctr
2699 , prod_rate_src_flag
2700 , deprn_projecting_flag
2701 , l_ytd_deprn
2702 , l_bonus_ytd_deprn
2703 , override_depr_amt
2704 , override_bonus_amt
2705 , deprn_override_flag
2706 , return_code
2707 , dpr.mrc_sob_type_code
2708 , dpr.rec_cost
2709 , dpr.salvage_value
2710 , dpr.update_override_status
2711 , p_log_level_rec) then
2712
2713 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faooda',
2714 p_log_level_rec => p_log_level_rec);
2715 dpr_out.deprn_override_flag:= fa_std_types.FA_NO_OVERRIDE;
2716 return(FALSE);
2717
2718 end if;
2719
2720 if (p_log_level_rec.statement_level) then
2721 fa_debug_pkg.add('faxcde', 'fadpdp: deprn_override_flag',deprn_override_flag,p_log_level_rec);
2722 fa_debug_pkg.add('faxcde', 'fadpdp: faodda:return_code',return_code,p_log_level_rec);
2723 end if;
2724
2725 end if; -- value = 'Y' and
2726
2727 --
2728 -- re-calculate perd_deprn_exp to use substraction method
2729 -- if current period is the last period of fiscal year
2730 -- and deprn_rounding_flag is NULL or ADD
2731 -- perd_deprn_exp = actual_annual_deprn_amt -
2732 -- ((dpr.ytd_deprn + ytd_deprn_sum) -
2733 -- (dpr.prior_fy_exp +prior_fy_exp_sum ))
2734 --
2735 -- we can not use substraction method for projection
2736 -- since dpr.ytd_deprn has incorrect value if the
2737 -- projection staring period is later than the current
2738 -- period. it's a temp fix. To fix tis problem, we
2739 -- need to return the value of ytd_deprn in dpr_out
2740 -- then copy it to dpr.ytd_deprn when calling the
2741 -- faxcde at the second time
2742
2743 --
2744 -- This is set appropriately in what-if so take what is passed
2745 -- to faxcde. or apply this only for the first year.
2746 --if deprn_projecting_flag then
2747 -- dpr.deprn_rounding_flag:= fa_std_types.FA_DPR_ROUND_RES;
2748 --end if;
2749
2750 -- Bug #2686687
2751 -- Annual rounding should be performed if current period is
2752 -- the last period of fiscal year; AND
2753 -- when there was no override; OR
2754 -- when overridden only bonus depreciation amount
2755
2756 if (perd_ctr=perds_per_yr_dcal and
2757 (deprn_override_flag = fa_std_types.FA_NO_OVERRIDE or
2758 deprn_override_flag = fa_std_types.FA_OVERRIDE_BONUS) and
2759 nvl(fa_cache_pkg.fazcdrd_record.period_update_flag,'N') ='N' and
2760 nvl(fa_cache_pkg.fazcdrd_record.subtract_ytd_flag,'N') ='N') then
2761
2762 if (dpr.deprn_rounding_flag = fa_std_types.FA_DPR_ROUND_ADD or
2763 dpr.deprn_rounding_flag is null) then
2764 --
2765 -- Go into following logic if this is group (except sumup) or calculating member
2766 --
2767 if (nvl(dpr.asset_type, 'CAPITALIZED') = 'GROUP' and
2768 nvl(dpr.member_rollup_flag, 'N') <> 'Y') or
2769 (nvl(dpr.asset_type, 'CAPITALIZED') <> 'GROUP' and
2770 nvl(dpr.tracking_method, 'NULL') = 'CALCULATE') then
2771
2772 perd_deprn_exp := actual_annual_deprn_amt -
2773 (nvl(cur_deprn_rsv,0)+ nvl(year_deprn_exp,0) - cur_eofy_reserve);
2774
2775 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2776 perd_bonus_deprn_amount := perd_deprn_exp *
2777 (dpr_out.bonus_rate_used /
2778 (ann_deprn_rate + dpr_out.bonus_rate_used));
2779 end if;
2780
2781 else
2782 -- Bonus
2783 -- Should actual_annual_deprn_amt be added with actual_annual_bonus_deprn_amt?
2784 -- Yes, included. See before the loop.
2785 -- Original equation only works for first year in fy loop.
2786 --
2787 -- Bug5152481: Added "(dpr_in.p_cl_begin <> 1)" to the following
2788 -- if statement.
2789 if (fyctr = dpr.y_begin) and (dpr_in.p_cl_begin <> 1) then
2790 perd_deprn_exp := (actual_annual_deprn_amt -
2791 ((dpr.ytd_deprn + ytd_deprn_sum) -
2792 (dpr.prior_fy_exp + prior_fy_exp_sum)));
2793 else
2794 perd_deprn_exp := actual_annual_deprn_amt - nvl(year_deprn_exp,0);
2795 end if;
2796
2797 -- bonus? Investigate the statement below! This case is for last period in fiscal year.
2798 -- Now added prior_fy_bonus_exp_sum.
2799 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
2800 -- Bug 5057908: Added nvl
2801 perd_bonus_deprn_amount := (actual_annual_bonus_deprn_amt -
2802 ((dpr.bonus_ytd_deprn + ytd_bonus_deprn_sum) -
2803 (nvl(dpr.prior_fy_bonus_exp,0) + prior_fy_bonus_exp_sum)));
2804 end if;
2805 end if; -- (nvl(dpr.asset_type, 'CAPITALIZED') = 'GROUP' and ..
2806
2807 elsif (dpr.deprn_rounding_flag = fa_std_types.FA_DPR_ROUND_ADJ or
2808 dpr.deprn_rounding_flag = fa_std_types.FA_DPR_ROUND_RET or
2809 dpr.deprn_rounding_flag = fa_std_types.FA_DPR_ROUND_REV or
2810 dpr.deprn_rounding_flag = fa_std_types.FA_DPR_ROUND_TFR or
2811 dpr.deprn_rounding_flag = fa_std_types.FA_DPR_ROUND_RES or
2812 dpr.deprn_rounding_flag = fa_std_types.FA_DPR_ROUND_OVE) then
2813
2814 if ann_rounding_mode=ROUND_ALWAYS then
2815 dpr_sub:= dpr_in;
2816 dpr_sub.bonus_deprn_rsv:= 0;
2817 dpr_sub.deprn_rsv:= 0;
2818 dpr_sub.ltd_prod:= 0;
2819 dpr_sub.ytd_deprn:= 0;
2820
2821 dpr_sub.y_begin:= fyctr;
2822 dpr_sub.y_end:= fyctr;
2823 dpr_sub.p_cl_begin:= 1;
2824 dpr_sub.p_cl_end:= perds_per_yr_dcal - 1;
2825
2826 dpr_sub.deprn_override_flag:= fa_std_types.FA_OVERRIDE_RECURSIVE;
2827
2828 -- Bug3493721:
2829 -- Rounding should always be done during recursive call
2830 --
2831 dpr_sub.deprn_rounding_flag := null;
2832
2833 if (nbv_deprn_basis_flag and excl_sal_val_flag) then
2834 dpr_sub.adj_cost := cur_adj_cost - dpr.salvage_value;
2835 else
2836 dpr_sub.adj_cost := cur_adj_cost;
2837 end if;
2838
2839 if not fa_cde_pkg.faxcde (dpr_sub, h_dummy_dpr, dpr_out, fmode) then
2840 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
2841 p_log_level_rec => p_log_level_rec);
2842 return (FALSE);
2843 end if;
2844
2845 perd_deprn_exp := actual_annual_deprn_amt - dpr_out.deprn_exp;
2846 end if; -- ann_rounding_mode=ROUND_ALWAYS then
2847
2848 else
2849 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
2850 name => 'FA_DEPRN_ILLEGAL_VALUE',
2851 token1 => 'VARIABLE',
2852 value1 => 'Deprn_Rounding_Flag',
2853 token2 => 'VALUE',
2854 value2 => dpr.deprn_rounding_flag,
2855 translate => FALSE,
2856 p_log_level_rec => p_log_level_rec);
2857 return (FALSE);
2858 end if; -- (dpr.deprn_rounding_flag = fa_std_types.FA_DPR_ROUND_ADD or
2859
2860 --
2861 -- Debug
2862 --
2863 if (p_log_level_rec.statement_level) then
2864 fa_debug_pkg.add('faxcde', 'fadpdp(4.1): IN :perd_deprn_exp ', perd_deprn_exp,p_log_level_rec);
2865 fa_debug_pkg.add('faxcde', 'actual_annual_deprn_amt',actual_annual_deprn_amt,p_log_level_rec);
2866 fa_debug_pkg.add('faxcde', 'dpr.ytd_deprn',dpr.ytd_deprn,p_log_level_rec);
2867 fa_debug_pkg.add('faxcde', 'ytd_deprn_sum',ytd_deprn_sum,p_log_level_rec);
2868 fa_debug_pkg.add('faxcde', 'dpr.prior_fy_exp', dpr.prior_fy_exp,p_log_level_rec);
2869 fa_debug_pkg.add('faxcde', 'dpr.prior_fy_bonus_exp', dpr.prior_fy_exp,p_log_level_rec);
2870 fa_debug_pkg.add('faxcde', 'prior_fy_exp_sum',prior_fy_exp_sum,p_log_level_rec);
2871 fa_debug_pkg.add('faxcde', 'fadpdp(4.1) OUT :perd_deprn_exp ', perd_deprn_exp,p_log_level_rec);
2872 end if;
2873 end if; -- (perd_ctr=perds_per_yr_dcal and
2874
2875 if (prod_rate_src_flag) then
2876 period_fracs_single.frac := perds_fracs_arr(perd_ctr-1).frac;
2877 period_fracs_single.start_jdate :=
2878 perds_fracs_arr(perd_ctr-1).start_jdate;
2879 period_fracs_single.end_jdate :=
2880 perds_fracs_arr(perd_ctr-1).end_jdate;
2881
2882 if not fa_cde_pkg.faxgpr(dpr
2883 , period_fracs_single
2884 , deprn_projecting_flag
2885 , perd_prod
2886 , p_log_level_rec) then
2887
2888 fa_srvr_msg.add_message ( calling_fn => 'fa_cde_pkg.faxcde',
2889 p_log_level_rec => p_log_level_rec);
2890 return (FALSE);
2891 end if;
2892
2893 if dpr.rate_adj_factor <= 0 then
2894 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
2895 name => 'FA_DEPRN_ILLEGAL_VALUE',
2896 token1 => 'VARIABLE',
2897 value1 => 'Rate_Adjustment_Factor',
2898 token2 => 'VALUE',
2899 value2 => dpr.rate_adj_factor,
2900 translate => FALSE,
2901 p_log_level_rec => p_log_level_rec);
2902 return (FALSE);
2903 end if;
2904
2905 if dpr.capacity <= 0 then
2906 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
2907 name => 'FA_DEPRN_ILLEGAL_VALUE',
2908 token1 => 'VARIABLE',
2909 value1 => 'Capacity',
2910 token2 => 'VALUE',
2911 value2 => dpr.capacity,
2912 translate => FALSE,
2913 p_log_level_rec => p_log_level_rec);
2914 return (FALSE);
2915 end if;
2916
2917 if dpr.adj_capacity <= 0 then
2918 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
2919 name => 'FA_DEPRN_ILLEGAL_VALUE',
2920 token1 => 'VARIABLE',
2921 value1 => 'Adjusted_Capacity',
2922 token2 => 'VALUE',
2923 value2 => dpr.adj_capacity,
2924 translate => FALSE,
2925 p_log_level_rec => p_log_level_rec);
2926 return (FALSE);
2927 end if;
2928 --
2929 -- Debug
2930 --
2931 if (p_log_level_rec.statement_level) then
2932 fa_debug_pkg.add('faxcde', 'fadpdp(5): cur_adj_cost', cur_adj_cost,p_log_level_rec);
2933 fa_debug_pkg.add('faxcde', 'dpr.rate_adj_factor', dpr.rate_adj_factor,p_log_level_rec);
2934 fa_debug_pkg.add('faxcde', 'perd_prod', perd_prod,p_log_level_rec);
2935 fa_debug_pkg.add('faxcde', 'dpr.adj_capacity', dpr.adj_capacity,p_log_level_rec);
2936 end if;
2937
2938 perd_deprn_exp := (cur_adj_cost / dpr.rate_adj_factor) *
2939 (perd_prod / dpr.adj_capacity);
2940
2941 -- Main tain adj_capacity
2942 if (nvl(fa_cache_pkg.fazcdrd_record.period_update_flag,'N') ='Y') then -- ENERGY
2943 dpr.adj_capacity := dpr.adj_capacity - perd_prod; -- ENERGY
2944 end if; -- ENERGY
2945
2946 -- bonus: Not tracking for production.
2947 perd_bonus_deprn_amount := 0;
2948 dpr_out.ann_adj_exp := 0;
2949
2950 --
2951 -- Debug
2952 --
2953 if (p_log_level_rec.statement_level) then
2954 fa_debug_pkg.add('faxcde', 'fadpdp(6): perd_deprn_exp', perd_deprn_exp,p_log_level_rec);
2955 end if;
2956 else
2957 perd_prod := 0;
2958 end if; -- (prod_rate_src_flag) then
2959
2960 if (deprn_projecting_flag or
2961 ann_rounding_mode=ROUND_ALWAYS) then
2962 --
2963 -- Round perd_deprn_exp ONLY if Projecting
2964 --
2965
2966 if not fa_utils_pkg.faxrnd(perd_deprn_exp, dpr.book) then
2967 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
2968 p_log_level_rec => p_log_level_rec);
2969 return (FALSE);
2970 end if;
2971
2972 -- bonus: Assignment to perd_bonus_deprn_amount earlier should be checked.
2973 if not fa_utils_pkg.faxrnd(perd_bonus_deprn_amount, dpr.book) then
2974 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
2975 p_log_level_rec => p_log_level_rec);
2976 return (FALSE);
2977 end if;
2978
2979 end if; -- (deprn_projecting_flag or
2980
2981 -- perform override depreciation for each uploaded data from the interface table
2982 if (deprn_override_flag <> fa_std_types.FA_NO_OVERRIDE) then
2983
2984 --Bug 5689910
2985 select adjusted_cost
2986 into l_temp_adj_cost
2987 from fa_books
2988 where book_type_code = dpr.book
2989 and asset_id = dpr.asset_id
2990 and transaction_header_id_out is null;
2991
2992 if (l_temp_adj_cost <> dpr_in.adj_cost) then -- Bug 5689910
2993 --
2994 -- Debug
2995 --
2996 if (p_log_level_rec.statement_level) then
2997 fa_debug_pkg.add('faxcde', 'perd_deprn_exp(default)', perd_deprn_exp,p_log_level_rec);
2998
2999 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
3000 fa_debug_pkg.add('faxcde', 'perd_bonus_deprn_amount(default)', perd_bonus_deprn_amount,p_log_level_rec);
3001 end if;
3002 end if;
3003
3004 if deprn_override_flag = fa_std_types.FA_OVERRIDE_BONUS or
3005 deprn_override_flag = fa_std_types.FA_OVERRIDE_DPR_BONUS then
3006 perd_deprn_exp:= perd_deprn_exp - nvl(perd_bonus_deprn_amount, 0);
3007 perd_bonus_deprn_amount:= nvl(override_bonus_amt,0);
3008 end if;
3009
3010 if deprn_override_flag = fa_std_types.FA_OVERRIDE_DPR or
3011 deprn_override_flag = fa_std_types.FA_OVERRIDE_DPR_BONUS then
3012
3013 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
3014 perd_deprn_exp:= override_depr_amt + nvl(perd_bonus_deprn_amount,0);
3015 else
3016 perd_deprn_exp:= override_depr_amt;
3017 end if;
3018 else
3019 perd_deprn_exp:= perd_deprn_exp + perd_bonus_deprn_amount;
3020 end if;
3021
3022 --
3023 -- Debug
3024 --
3025 if (p_log_level_rec.statement_level) then
3026 fa_debug_pkg.add('faxcde', 'perd_deprn_exp(new)', perd_deprn_exp,p_log_level_rec);
3027
3028 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
3029 fa_debug_pkg.add('faxcde', 'perd_bonus_deprn_amount(new)', perd_bonus_deprn_amount,p_log_level_rec);
3030 end if;
3031 end if;
3032
3033 -- Bug 5689910: Added following else part
3034 else
3035 perd_deprn_exp := 0;
3036 perd_bonus_deprn_amount := 0;
3037
3038 end if; -- Bug 5689910
3039
3040 end if; -- (deprn_override_flag <> fa_std_types.FA_NO_OVERRIDE) then
3041 -- End of override depreciation logic
3042
3043 --
3044 -- If the remaining depreciation is small (absolutely OR
3045 -- relatively), then fully depreciate the asset
3046 --
3047 -- Calculate the absolute value of the asset's new NBV
3048 -- Use adj_rec_cost as base instead of dpr.rec_cost
3049 --
3050 nbv_absval := abs(adj_rec_cost -
3051 (cur_deprn_rsv + nvl(year_deprn_exp,0) + perd_deprn_exp));
3052
3053 -- bonus? Shouldn't really have to bother about bonus nbv, as long as regular deprn figures
3054 -- contain bonus figures. skipping.
3055
3056 --
3057 -- Debug
3058 --
3059 if (p_log_level_rec.statement_level) then
3060 fa_debug_pkg.add('faxcde', 'fadpdp(7): adj_rec_cost', adj_rec_cost,p_log_level_rec);
3061 fa_debug_pkg.add('faxcde', 'cur_deprn_rsv', cur_deprn_rsv,p_log_level_rec);
3062 fa_debug_pkg.add('faxcde', 'year_deprn_exp', year_deprn_exp,p_log_level_rec);
3063 fa_debug_pkg.add('faxcde', 'perd_deprn_exp', perd_deprn_exp,p_log_level_rec);
3064 fa_debug_pkg.add('faxcde', 'nbv_absval', nbv_absval,p_log_level_rec);
3065 fa_debug_pkg.add('faxcde', 'nbv_frac_thresh', nbv_frac_thresh,p_log_level_rec);
3066 fa_debug_pkg.add('faxcde', 'nbv_amt_thresh', nbv_amt_thresh,p_log_level_rec);
3067 end if;
3068
3069 --
3070 -- Get the absolute value of the asset's Adjusted
3071 -- Recoverable Cost, do not use Recoverable Cost
3072 --
3073 adj_rec_cost_absval := abs (adj_rec_cost);
3074
3075 --
3076 -- Check the NBV against the constant value, and then
3077 -- against the fraction of the Adjusted Recoverable Cost
3078 --
3079 if deprn_override_flag = fa_std_types.FA_NO_OVERRIDE then
3080 if (nbv_absval < nbv_amt_thresh) or
3081 (nbv_absval < nbv_frac_thresh * adj_rec_cost_absval) then
3082 last_period_deprn_exp := adj_rec_cost - (cur_deprn_rsv + nvl(year_deprn_exp,0));
3083
3084 --
3085 -- recalculate annual deprn amount if asset will became
3086 -- fully reserved in the last period of fiscal year
3087 --
3088 if (nbv_deprn_basis_flag and (deprn_end_perd = perds_per_yr_dcal)) then
3089 if perd_deprn_exp < last_period_deprn_exp then
3090
3091 --
3092 -- use ann_fy_deprn to avoid rounding twice
3093 -- on annual depreciation amount
3094 --
3095 actual_annual_deprn_amt := ann_fy_deprn + (last_period_deprn_exp - perd_deprn_exp);
3096
3097 -- bonus: how prorate to bonus?
3098 -- maybe don't need assign any value to bonus. See hld regardin last period deprn.
3099 -- maybe we need actual_annual_bonus_deprn_amt variable in addition to bonus_ann_fy_deprn.
3100 -- We probably don't need to assign actual_annual_bonus_deprn_amt ? Investigate.
3101 -- actual_annual_bonus_deprn_amt := 0;
3102 h_dummy_bool := fa_utils_pkg.faxtru(actual_annual_deprn_amt, dpr.book
3103 ,p_log_level_rec => p_log_level_rec);
3104
3105 end if;
3106
3107 end if; -- (nbv_deprn_basis_flag and (deprn_end_perd = perds_per_yr_dcal)) then
3108
3109 end if; -- (nbv_absval < nbv_amt_thresh) or
3110
3111 end if; -- deprn_override_flag = fa_std_types.FA_NO_OVERRIDE then
3112
3113 else
3114 perd_deprn_exp := 0;
3115 perd_bonus_deprn_amount := 0;
3116 perd_prod := 0;
3117 end if; -- if ((perd_ctr >= actual_deprn_start_perd) and
3118
3119 --
3120 -- if excl_sal_val_flag='YES' then add salvage_value
3121 -- back to rec_cost_absval, and if it is less than rsv_absval then
3122 -- mark this asset as life complete
3123 --
3124 if (nbv_deprn_basis_flag and excl_sal_val_flag) then
3125 rec_cost_absval := abs(dpr.rec_cost + dpr.salvage_value);
3126 else
3127 rec_cost_absval := abs(dpr.rec_cost);
3128 end if;
3129
3130 rec_cost_absval := abs(dpr.rec_cost);
3131 adj_rec_cost_absval := abs(adj_rec_cost);
3132
3133 -- Bug4037112:
3134 -- Need to prepare local variables include reserve adjustment amounts
3135 -- If the period has reset_adjusted_cost_flag, then current reserve
3136 -- has already include the adjustment and for other period, it needs
3137 -- accumulated reserve adjsutment amount to verify whether the asset
3138 -- is fully reserved or not.
3139 --
3140 if ((l_ind <> 0) and
3141 (fa_amort_pvt.t_reset_adjusted_cost_flag(l_ind) = 'Y')) then
3142 l_accum_rsv_adj := 0;
3143 l_rsv_adj := 0;
3144 elsif ((l_ind <> 0) and
3145 (fa_amort_pvt.t_reset_adjusted_cost_flag(l_ind) = 'N')) then
3146 l_accum_rsv_adj := nvl(l_accum_rsv_adj, 0) +
3147 fa_amort_pvt.t_reserve_adjustment_amount(l_ind);
3148 l_rsv_adj := l_accum_rsv_adj;
3149 else
3150 l_rsv_adj := 0;
3151 end if;
3152
3153 --
3154 -- If this is called for maintaining FA_BOOKS_SUMAMRY table,
3155 -- consider reserve_adjustment_amount when calculating absolute
3156 -- value of reserve
3157 --
3158 if (l_ind <> 0) and
3159 (fa_amort_pvt.t_reset_adjusted_cost_flag(l_ind) = 'N') then
3160
3161 rsv_absval := abs (cur_deprn_rsv + year_deprn_exp +
3162 perd_deprn_exp + l_rsv_adj);
3163 else
3164 rsv_absval := abs (cur_deprn_rsv + year_deprn_exp +perd_deprn_exp);
3165 end if;
3166
3167 -- bonus?
3168 --
3169 -- if asset's depreciation reserve is greater than it's
3170 -- recoverable cost, set life completed flag
3171 --
3172 if (rec_cost_absval <= rsv_absval) then
3173 dpr_out.life_comp_flag := TRUE;
3174 else
3175 -- Reserve is now less than rec cost. Unset fully reserved flag
3176 -- and life complete flag.
3177 -- This is to restart calculating expense again
3178 dpr_out.full_rsv_flag := FALSE;
3179 dpr_out.life_comp_flag :=FALSE;
3180 end if;
3181
3182 -- Fix for Bug #2833307. Add the following logic for over
3183 -- depreciate option:
3184 --
3185 -- FA_OVER_DEPR_NULL : No change in deprn logic
3186 -- FA_OVER_DEPR_NO : No change in deprn logic
3187 -- FA_OVER_DEPR_YES : If reserve is already exceeds
3188 -- adj_rec_cost, do nothing and mark the
3189 -- asset fully reserved. If not, calculate
3190 -- periodic depreciation. If it results in
3191 -- rsv exceeding adj_rec_cost, do nothing
3192 -- but mark the asset as fully reserved.
3193 -- FA_OVER_DEPR_DEPRN: Asset will never stop depreciation
3194 -- unless all member asset has been fully
3195 -- retired, or depreciate flag is unchecked.
3196 --
3197 -- NOTE: All life base methods will not value other than
3198 -- FA_OVER_DEPR_NULL or FA_OVER_DEPR_NO.
3199 if (dpr.over_depreciate_option = fa_std_types.FA_OVER_DEPR_YES) then
3200
3201 -- BUg3315683:
3202 -- Group could have situation whether rsv_absval is greater than adj_rec_cost_absval
3203 -- but still not fully reserved because rsv is -ve and adj_rec_cost is +ve.
3204 --if (adj_rec_cost_absval < rsv_absval) then
3205 if ((adj_rec_cost > 0) and
3206 (adj_rec_cost < (cur_deprn_rsv + nvl(year_deprn_exp,0) +perd_deprn_exp+l_rsv_adj))) or
3207 ((adj_rec_cost < 0) and (adj_rec_cost_absval < rsv_absval)) then
3208
3209 -- Bug4037112: Need to add accumulated reserve adjustment in order to identify
3210 -- whether the group asset is fully reserved or not because cur_deprn_rsv does not
3211 -- include the amount.
3212 if (l_ind <> 0) then
3213 if((adj_rec_cost > 0) and
3214 (adj_rec_cost < (cur_deprn_rsv +
3215 nvl(year_deprn_exp,0) +
3216 perd_deprn_exp+l_rsv_adj))) or
3217 ((adj_rec_cost < 0) and (adj_rec_cost_absval < rsv_absval)) then
3218
3219 dpr_out.full_rsv_flag := TRUE;
3220
3221 if not dpr_out.life_comp_flag then
3222 dpr_out.life_comp_flag := TRUE;
3223 end if;
3224
3225 else
3226 -- Reserve is now less than rec cost. Unset fully reserved flag
3227 -- and life complete flag.
3228 -- This is to restart calculating expense again
3229 dpr_out.full_rsv_flag := FALSE;
3230 dpr_out.life_comp_flag :=FALSE;
3231 end if;
3232 else
3233 dpr_out.full_rsv_flag := TRUE;
3234
3235 if not dpr_out.life_comp_flag then
3236 dpr_out.life_comp_flag := TRUE;
3237 end if;
3238 end if;
3239
3240 else
3241
3242 -- Reserve is now less than rec cost. Unset fully reserved flag
3243 -- and life complete flag.
3244 -- This is to restart calculating expense again
3245 dpr_out.full_rsv_flag := FALSE;
3246 dpr_out.life_comp_flag :=FALSE;
3247
3248 end if;
3249
3250 elsif (dpr.over_depreciate_option = fa_std_types.FA_OVER_DEPR_DEPRN) then
3251 -- continue depreciating
3252 null;
3253 else
3254
3255 -- Bug fix 5948890
3256 if dpr.cost_frac is not null then
3257 l_adjusted_rsv_absval := ((rsv_absval - nvl(perd_deprn_exp,0) - nvl(year_deprn_exp,0))
3258 * (1 - dpr.cost_frac))
3259 + nvl(perd_deprn_exp,0) + nvl(year_deprn_exp,0);
3260
3261 if not fa_utils_pkg.faxrnd(l_adjusted_rsv_absval, dpr.book) then
3262 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde');
3263 return (FALSE);
3264 end if;
3265
3266
3267 if (p_log_level_rec.statement_level) then
3268 fa_debug_pkg.add('faxcde', 'dpr.cost_frac', dpr.cost_frac);
3269 fa_debug_pkg.add('faxcde', 'rsv_absval', rsv_absval);
3270 fa_debug_pkg.add('faxcde', 'before rounding: l_adjusted_rsv_absval', l_adjusted_rsv_absval);
3271 end if;
3272
3273 else
3274 l_adjusted_rsv_absval := rsv_absval;
3275 end if;
3276
3277 if (p_log_level_rec.statement_level) then
3278 fa_debug_pkg.add('faxcde', 'l_adjusted_rsv_absval', l_adjusted_rsv_absval);
3279 end if;
3280
3281 -- End bug fix 5948890
3282 --
3283 -- if asset's deprn reserve is greater than adjusted revoverable
3284 -- cost, set fully reserve flag.
3285 -- For assets which do not have deprn limit, recoverable cost is
3286 -- always equal to adjusted recoverable cost
3287 --
3288 if adj_rec_cost_absval <= l_adjusted_rsv_absval then -- Bug fix 5948890 (replaced rsv_absval with l_adjusted_rsv_absval)
3289
3290 if (deprn_override_flag <> fa_std_types.FA_NO_OVERRIDE) and
3291 (adj_rec_cost_absval < rsv_absval) and
3292 not (deprn_projecting_flag) then
3293
3294 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
3295 name => 'FA_OVER_DEPRN_LIMIT',
3296 translate=> FALSE,
3297 p_log_level_rec => p_log_level_rec);
3298 dpr_out.deprn_override_flag:= fa_std_types.FA_NO_OVERRIDE;
3299 Return(FALSE);
3300 end if;
3301
3302 dpr_out.full_rsv_flag := TRUE;
3303
3304 --
3305 -- Always set life complete once asset is fully reserved.
3306 -- This handles the case where the adjusted recoverable
3307 -- cost is less than recoverable cost
3308 --
3309 if not dpr_out.life_comp_flag then
3310 dpr_out.life_comp_flag := TRUE;
3311 end if;
3312 else
3313 -- Reserve is now less than rec cost. Unset fully reserved flag
3314 -- and life complete flag.
3315 -- This is to restart calculating expense again
3316 dpr_out.full_rsv_flag := FALSE;
3317 dpr_out.life_comp_flag :=FALSE;
3318 end if; -- adj_rec_cost_absval <= rsv_absval then
3319
3320 end if; -- (dpr.over_depreciate_option = fa_std_types.FA_OVER_DEPR_YES) then
3321
3322 --
3323 -- If the Depreciate_Flag is 'NO', then don't depreciate
3324 --
3325 if not dpr_cur_fy_flag then
3326
3327 if deprn_override_flag <> fa_std_types.FA_NO_OVERRIDE then
3328
3329 fa_srvr_msg.add_message(calling_fn => 'fa_cde_pkg.faxcde',
3330 name => 'FA_NO_DEPRECIATION',
3331 translate=> FALSE,
3332 p_log_level_rec => p_log_level_rec);
3333 dpr_out.deprn_override_flag:= fa_std_types.FA_NO_OVERRIDE;
3334 return(FALSE);
3335 else
3336 perd_deprn_exp := 0;
3337 perd_bonus_deprn_amount := 0;
3338 end if;
3339
3340 end if; -- not dpr_cur_fy_flag then
3341
3342 --
3343 -- For projection/what-if
3344 -- Set fully reserved flag if asset hits the end of life
3345 --
3346 if (deprn_projecting_flag) and
3347 (fyctr = fy_fully_rsv) and
3348 (perd_ctr = actual_deprn_end_perd) then
3349 dpr_out.full_rsv_flag := TRUE;
3350 end if;
3351
3352 if dpr_out.full_rsv_flag then
3353
3354 if deprn_override_flag = fa_std_types.FA_NO_OVERRIDE then
3355
3356 if (dpr.over_depreciate_option = fa_std_types.FA_OVER_DEPR_YES) then
3357
3358 if (sign(adj_rec_cost) < 0 and
3359 (adj_rec_cost > (cur_deprn_rsv + nvl(year_deprn_exp,0)+ l_rsv_adj)))
3360 or
3361 (sign(cur_deprn_rsv + nvl(year_deprn_exp,0)+ l_rsv_adj) > 0 and
3362 (adj_rec_cost < (cur_deprn_rsv + nvl(year_deprn_exp,0)+ l_rsv_adj))) then
3363 perd_deprn_exp := 0;
3364 else
3365 perd_deprn_exp := adj_rec_cost - (cur_deprn_rsv + nvl(year_deprn_exp,0)+ l_rsv_adj);
3366 end if;
3367
3368 elsif (dpr.over_depreciate_option = fa_std_types.FA_OVER_DEPR_DEPRN) then
3369 null;
3370 else
3371 perd_deprn_exp := adj_rec_cost - (cur_deprn_rsv + nvl(year_deprn_exp,0)+ l_rsv_adj);
3372 end if;
3373
3374 -- bonus?
3375 -- According to hld, no bonus deprn amount should be charged in last period of life.
3376 -- Effects should be tested.
3377 perd_bonus_deprn_amount := 0;
3378
3379 end if; -- deprn_override_flag = fa_std_types.FA_NO_OVERRIDE then
3380
3381 if prod_rate_src_flag then
3382 --
3383 -- Reset to FALSE for Production-Based assets, because
3384 -- they never become marked as fully-reserved
3385 --
3386 dpr_out.full_rsv_flag := FALSE;
3387 end if;
3388
3389 end if; -- dpr_out.full_rsv_flag then
3390
3391 -- Added for Track Member Assets:
3392 --
3393 -- Round amount calculated
3394 --
3395 h_dummy_bool := fa_utils_pkg.faxrnd (perd_deprn_exp, dpr.book
3396 ,p_log_level_rec => p_log_level_rec);
3397 -- bonus
3398 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
3399 h_dummy_bool := fa_utils_pkg.faxrnd (perd_bonus_deprn_amount, dpr.book
3400 ,p_log_level_rec => p_log_level_rec);
3401 end if;
3402
3403 if nvl(dpr.tracking_method,'OTHER') = 'ALLOCATE' and
3404 nvl(dpr_in.deprn_override_flag, fa_std_types.FA_NO_OVERRIDE)
3405 <> fa_std_types.FA_OVERRIDE_RECURSIVE then
3406
3407 -- Check if subtract ytd flag is enabled or not
3408 if nvl(p_subtract_ytd_flag,'N') = 'Y' then
3409
3410 if (fyctr = dpr.y_begin) then
3411 p_deprn_amount := dpr_in.ytd_deprn + perd_deprn_exp;
3412
3413 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
3414 p_bonus_amount := dpr.bonus_ytd_deprn + perd_bonus_deprn_amount;
3415 end if;
3416
3417 else
3418 p_deprn_amount := nvl(year_deprn_exp,0) + perd_deprn_exp;
3419
3420 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
3421 p_bonus_amount := year_bonus_deprn_amount + perd_bonus_deprn_amount;
3422 end if;
3423
3424 end if;
3425
3426 else
3427 p_deprn_amount := perd_deprn_exp;
3428
3429 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
3430 p_bonus_amount := perd_bonus_deprn_amount;
3431 end if;
3432
3433 end if; -- nvl(p_subtract_ytd_flag,'N') = 'Y' then
3434
3435 -- Set Mode following used_by_adjustment flag
3436 if dpr.used_by_adjustment = TRUE then
3437 h_mode := 'ADJUSTMENT';
3438 else
3439 h_mode := NULL;
3440 end if;
3441
3442 -- Call FATRKM to call track member function
3443 if not FATRKM (p_dpr => dpr,
3444 p_perd_deprn_exp => p_deprn_amount,
3445 p_perd_bonus_deprn_amount => p_bonus_amount,
3446 p_perd_ctr => perd_ctr,
3447 p_fyctr => fyctr,
3448 p_loop_end_year => dpr.y_end,
3449 p_loop_end_period => dpr.p_cl_end,
3450 p_exclude_salvage_value_flag => excl_sal_val_flag,
3451 p_deprn_basis_rule => deprn_basis_rule,
3452 p_deprn_override_flag => deprn_override_flag,
3453 p_subtract_ytd_flag => p_subtract_ytd_flag,
3454 p_life_complete_flag => dpr_out.life_comp_flag,
3455 p_fully_reserved_flag => dpr_out.full_rsv_flag,
3456 p_year_deprn_exp => year_deprn_exp,
3457 p_recoverable_cost => dpr.rec_cost,
3458 p_adj_rec_cost => adj_rec_cost,
3459 p_current_deprn_reserve => cur_deprn_rsv,
3460 p_nbv_threshold => nbv_frac_thresh,
3461 p_nbv_thresh_amount => nbv_amt_thresh,
3462 p_rec_cost_abs_value => rec_cost_absval,
3463 p_mode => h_mode,
3464 x_new_perd_exp => x_new_perd_exp,
3465 x_new_perd_bonus_deprn_amount => x_new_perd_bonus_deprn_amount,
3466 x_life_complete_flag => x_life_complete_flag,
3467 x_fully_reserved_flag => x_fully_reserved_flag,
3468 p_log_level_rec => p_log_level_rec) then
3469 return(false);
3470 else
3471 perd_deprn_exp := x_new_perd_exp;
3472 perd_bonus_deprn_amount := x_new_perd_bonus_deprn_amount;
3473 dpr_out.life_comp_flag := x_life_complete_flag;
3474 dpr_out.full_rsv_flag := x_fully_reserved_flag;
3475 end if; -- not FATRKM (p_dpr => dpr,
3476
3477 end if; -- Tracking_Method = 'ALLOCATE'?
3478 year_deprn_exp := nvl(year_deprn_exp,0) + perd_deprn_exp;
3479 ytd_deprn_sum := ytd_deprn_sum + perd_deprn_exp;
3480 year_prod := year_prod + perd_prod ;
3481 -- bonus: investigate how perd_bonus_deprn_amount can be calculated earlier
3482 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
3483 year_bonus_deprn_amount := year_bonus_deprn_amount + perd_bonus_deprn_amount;
3484 ytd_bonus_deprn_sum := ytd_bonus_deprn_sum + perd_bonus_deprn_amount;
3485 end if;
3486
3487 --
3488 -- Debug
3489 --
3490 if (p_log_level_rec.statement_level) then
3491 fa_debug_pkg.add('faxcde', 'fadpdp(8): perd_deprn_exp', perd_deprn_exp,p_log_level_rec);
3492 fa_debug_pkg.add('faxcde', 'perd_bonus_deprn_amount', perd_bonus_deprn_amount,p_log_level_rec);
3493 fa_debug_pkg.add('faxcde', 'year_deprn_exp', year_deprn_exp,p_log_level_rec);
3494 fa_debug_pkg.add('faxcde', 'adj_rec_cost', adj_rec_cost,p_log_level_rec);
3495 fa_debug_pkg.add('faxcde', 'perd_prod', perd_prod,p_log_level_rec);
3496 fa_debug_pkg.add('faxcde', 'year_prod', year_prod,p_log_level_rec);
3497 end if;
3498
3499 -- bonus: perd_bonus_deprn_amount will now go into dpr_arr struct.
3500 -- bonus_value added to dpr_arr.
3501 dpr_arr(dpr_arr_ctr).value := perd_deprn_exp;
3502 dpr_arr(dpr_arr_ctr).bonus_value := perd_bonus_deprn_amount;
3503 dpr_arr(dpr_arr_ctr).period_num := perd_ctr;
3504 dpr_arr(dpr_arr_ctr).fiscal_year := fyctr;
3505
3506 -- Manual Override
3507 if deprn_override_flag <> fa_std_types.FA_NO_OVERRIDE and not (deprn_projecting_flag) then
3508 dpr_out.deprn_override_flag:= deprn_override_flag;
3509 end if;
3510 -- End of Manual Override
3511
3512 ----------------------------------------------
3513 -- Call Depreciable Basis Rule
3514 -- for depreciation
3515 ----------------------------------------------
3516 if perd_ctr = perds_per_yr_dcal then
3517 h_eofy_flag :='Y';
3518 else
3519 h_eofy_flag :='N';
3520 end if;
3521
3522 -- Set deprn reserve for depreciable basis rule function
3523 cdb_deprn_rsv := nvl(cur_deprn_rsv,0)+ nvl(year_deprn_exp,0);
3524 cdb_bonus_deprn_rsv := nvl(cur_bonus_deprn_rsv,0) +
3525 nvl(year_bonus_deprn_amount,0);
3526
3527 --
3528 -- if excl_sal_val_flag='YES' then
3529 -- reduce salvage_value from adjusted cost
3530 --
3531 if (nbv_deprn_basis_flag and excl_sal_val_flag) then
3532 cur_adj_cost := cur_adj_cost - dpr.salvage_value;
3533 end if;
3534
3535 if (p_log_level_rec.statement_level) then
3536 fa_debug_pkg.add('faxcde','deprn_period_dcal_begin' , deprn_period_dcal_begin,p_log_level_rec);
3537 fa_debug_pkg.add('faxcde','perd_ctr' , perd_ctr,p_log_level_rec);
3538 end if;
3539
3540 -- call deprn basis rule logic.
3541 -- if perd_deprn_exp <> 0 then
3542
3543 if (fyctr = deprn_year_dcal_begin and
3544 perd_ctr >= deprn_period_dcal_begin) or
3545 fyctr > deprn_year_dcal_begin then
3546
3547 -- BUG# 3769466
3548 -- avoid deprn basis call when not needed
3549
3550 if (nbv_deprn_basis_flag or
3551 (fa_cache_pkg.fazccmt_record.deprn_basis_rule_id is not null and
3552 not (rate_source_rule = 'CALCULATED' and
3553 cost_deprn_basis_flag and
3554 nvl(fa_cache_pkg.fazcdrd_record.period_update_flag,'N') ='N' and
3555 nvl(p_subtract_ytd_flag,'N') = 'N' and
3556 nvl(fa_cache_pkg.fazcdrd_record.use_eofy_reserve_flag, 'N') = 'N'))) then
3557
3558 -- Bug 6665510: FP: Japan Tax Reform Project (Start)
3559 if nvl(fa_cache_pkg.fazccmt_record.guarantee_rate_method_flag, 'NO') = 'YES' then
3560
3561 if (p_log_level_rec.statement_level) then
3562 fa_debug_pkg.add('faxcde', '+++ JAPAN ', 'in guarantee rate call deprn basis', p_log_level_rec);
3563 end if;
3564
3565 h_adjusted_cost := nvl(cur_adj_cost,0);
3566
3567 else
3568 h_adjusted_cost := null;
3569 end if;
3570 -- Bug 6665510: FP: Japan Tax Reform Project (End)
3571
3572 if (not FA_CALC_DEPRN_BASIS1_PKG.CALL_DEPRN_BASIS (
3573 p_event_type => 'AFTER_DEPRN',
3574 p_dpr => dpr,
3575 p_fiscal_year => fyctr,
3576 p_period_num => perd_ctr,
3577 p_period_counter => fyctr*perds_per_yr_dcal+perd_ctr,
3578 p_adjusted_cost => h_adjusted_cost, -- Bug 6665510: FP: Japan Tax Reform Project
3579 p_current_total_rsv => cdb_deprn_rsv,
3580 p_current_rsv => cdb_deprn_rsv
3581 - nvl(cdb_bonus_deprn_rsv,0),
3582 p_current_total_ytd => ytd_deprn_sum,
3583 p_eofy_reserve => cur_eofy_reserve,
3584 p_used_by_adjustment => h_mode,
3585 p_eofy_flag => h_eofy_flag,
3586 px_new_adjusted_cost => cur_adj_cost,
3587 px_new_raf => dpr.rate_adj_factor,
3588 px_new_formula_factor => dpr.formula_factor,
3589 x_annual_deprn_rounding_flag => dpr.deprn_rounding_flag)) then
3590
3591 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.faxcde',
3592 p_log_level_rec => p_log_level_rec);
3593 return (FALSE);
3594 end if;
3595 else
3596 if (p_log_level_rec.statement_level) then
3597
3598 FA_DEBUG_PKG.ADD(fname=>'faxcde ',
3599 element => 'skipping',
3600 value=> 'deprn basis call',
3601 p_log_level_rec => p_log_level_rec);
3602
3603
3604 end if;
3605 end if;
3606 end if; -- (fyctr = deprn_year_dcal_begin and
3607
3608 if (p_log_level_rec.statement_level) then
3609 fa_debug_pkg.add('faxcde','l_dpr_in.deprn_rounding_flag(after CALL_DEPRN_BASIS)',
3610 dpr.deprn_rounding_flag,p_log_level_rec);
3611 end if;
3612
3613 --
3614 -- if excl_sal_val_flag='YES' then
3615 -- add salvage_value back to adjusted cost
3616 --
3617 if (nbv_deprn_basis_flag and excl_sal_val_flag) then
3618 cur_adj_cost := cur_adj_cost + dpr.salvage_value;
3619 end if;
3620
3621 dpr_arr_ctr := dpr_arr_ctr + 1;
3622
3623 if (l_ind <> 0) then
3624 --
3625 -- Maintain Books Summary Table
3626 --
3627 if (p_log_level_rec.statement_level) then
3628 fa_debug_pkg.add('faxcde','Maintain Books Summary Table',
3629 to_char(l_ind)||':'||to_char(fa_amort_pvt.t_deprn_amount.COUNT),p_log_level_rec);
3630 end if;
3631
3632 if (l_ind <= fa_amort_pvt.t_deprn_amount.COUNT) then
3633
3634 if (nbv_deprn_basis_flag and excl_sal_val_flag) then
3635 fa_amort_pvt.t_adjusted_cost(l_ind + 1) := cur_adj_cost - dpr.salvage_value;
3636 else
3637 fa_amort_pvt.t_adjusted_cost(l_ind + 1) := cur_adj_cost;
3638 end if;
3639
3640 fa_amort_pvt.t_formula_factor(l_ind + 1) := dpr.formula_factor;
3641 fa_amort_pvt.t_deprn_amount(l_ind) :=
3642 perd_deprn_exp +
3643 fa_amort_pvt.t_expense_adjustment_amount(l_ind);
3644 fa_amort_pvt.t_bonus_deprn_amount(l_ind) := perd_bonus_deprn_amount;
3645
3646 if (l_ind = 1) then
3647 fa_amort_pvt.t_deprn_reserve(l_ind) :=
3648 fa_amort_pvt.t_deprn_amount(l_ind) +
3649 fa_amort_pvt.t_reserve_adjustment_amount(l_ind);
3650 fa_amort_pvt.t_bonus_deprn_reserve(l_ind) := perd_bonus_deprn_amount;
3651 else
3652 fa_amort_pvt.t_deprn_reserve(l_ind) :=
3653 fa_amort_pvt.t_deprn_reserve(l_ind - 1) +
3654 fa_amort_pvt.t_deprn_amount(l_ind) +
3655 fa_amort_pvt.t_reserve_adjustment_amount(l_ind);
3656 fa_amort_pvt.t_bonus_deprn_reserve(l_ind) :=
3657 fa_amort_pvt.t_bonus_deprn_reserve(l_ind- 1) +
3658 perd_bonus_deprn_amount;
3659 end if;
3660
3661 if dpr.bonus_rule is null then
3662 fa_amort_pvt.t_bonus_rate(l_ind) := null;
3663 else
3664 fa_amort_pvt.t_bonus_rate(l_ind) := dpr_out.bonus_rate_used;
3665 end if;
3666
3667 if (fa_amort_pvt.t_period_num(l_ind) = 1) then
3668 fa_amort_pvt.t_ytd_deprn(l_ind) := fa_amort_pvt.t_deprn_amount(l_ind);
3669 fa_amort_pvt.t_bonus_ytd_deprn(l_ind) := perd_bonus_deprn_amount;
3670
3671 if (l_ind = 1) then
3672 fa_amort_pvt.t_eofy_reserve(l_ind) := 0;
3673 fa_amort_pvt.t_eofy_adj_cost(l_ind) := 0;
3674 fa_amort_pvt.t_eofy_formula_factor(l_ind) := 1;
3675 else
3676 fa_amort_pvt.t_eofy_reserve(l_ind) :=
3677 fa_amort_pvt.t_deprn_reserve(l_ind - 1);
3678 fa_amort_pvt.t_eofy_adj_cost(l_ind) :=
3679 fa_amort_pvt.t_adjusted_cost(l_ind - 1);
3680 fa_amort_pvt.t_eofy_formula_factor(l_ind) :=
3681 fa_amort_pvt.t_formula_factor(l_ind - 1);
3682 end if;
3683
3684 else
3685
3686 if (l_ind = 1) then
3687 fa_amort_pvt.t_ytd_deprn(l_ind) := fa_amort_pvt.t_deprn_amount(l_ind);
3688 fa_amort_pvt.t_bonus_ytd_deprn(l_ind) := perd_bonus_deprn_amount;
3689 fa_amort_pvt.t_eofy_reserve(l_ind) := 0;
3690 fa_amort_pvt.t_eofy_adj_cost(l_ind) := 0;
3691 fa_amort_pvt.t_eofy_formula_factor(l_ind) := 1;
3692 else
3693 fa_amort_pvt.t_ytd_deprn(l_ind) :=
3694 fa_amort_pvt.t_ytd_deprn(l_ind - 1) +
3695 fa_amort_pvt.t_deprn_amount(l_ind);
3696 fa_amort_pvt.t_bonus_ytd_deprn(l_ind) :=
3697 fa_amort_pvt.t_bonus_ytd_deprn(l_ind - 1) +
3698 perd_bonus_deprn_amount;
3699 fa_amort_pvt.t_eofy_reserve(l_ind) :=
3700 fa_amort_pvt.t_eofy_reserve(l_ind - 1);
3701 fa_amort_pvt.t_eofy_adj_cost(l_ind) :=
3702 fa_amort_pvt.t_eofy_adj_cost(l_ind - 1);
3703 fa_amort_pvt.t_eofy_formula_factor(l_ind) :=
3704 fa_amort_pvt.t_eofy_formula_factor(l_ind - 1);
3705 end if;
3706
3707 end if; -- (fa_amort_pvt.t_period_num(l_ind) = 1) then
3708
3709 if (l_ind = 1) then
3710 fa_amort_pvt.t_eop_adj_cost(l_ind) := 0;
3711 else
3712 fa_amort_pvt.t_eop_adj_cost(l_ind) :=
3713 fa_amort_pvt.t_adjusted_cost(l_ind - 1);
3714 end if;
3715
3716 fa_amort_pvt.t_eop_formula_factor(l_ind) :=
3717 fa_amort_pvt.t_formula_factor(l_ind);
3718
3719 if (p_log_level_rec.statement_level) then
3720 fa_debug_pkg.add('faxcde','period_counter', fa_amort_pvt.t_period_counter(l_ind),p_log_level_rec);
3721 fa_debug_pkg.add('faxcde','deprn_amount', fa_amort_pvt.t_deprn_amount(l_ind),p_log_level_rec);
3722 fa_debug_pkg.add('faxcde','ytd_deprn', fa_amort_pvt.t_ytd_deprn(l_ind),p_log_level_rec);
3723 fa_debug_pkg.add('faxcde','deprn_reserve', fa_amort_pvt.t_deprn_reserve(l_ind),p_log_level_rec);
3724 fa_debug_pkg.add('faxcde','bonus_deprn_amount', fa_amort_pvt.t_bonus_deprn_amount(l_ind),p_log_level_rec);
3725 fa_debug_pkg.add('faxcde','bonus_ytd_deprn', fa_amort_pvt.t_bonus_ytd_deprn(l_ind),p_log_level_rec);
3726 fa_debug_pkg.add('faxcde','bonus_deprn_reserve', fa_amort_pvt.t_bonus_deprn_reserve(l_ind),p_log_level_rec);
3727 fa_debug_pkg.add('faxcde','eofy_reserve', fa_amort_pvt.t_eofy_reserve(l_ind),p_log_level_rec);
3728 fa_debug_pkg.add('faxcde','eofy_adj_cost', fa_amort_pvt.t_eofy_adj_cost(l_ind),p_log_level_rec);
3729 fa_debug_pkg.add('faxcde','eofy_formula_factor', fa_amort_pvt.t_eofy_formula_factor(l_ind),p_log_level_rec);
3730 fa_debug_pkg.add('faxcde','eop_adj_cost', fa_amort_pvt.t_eop_adj_cost(l_ind),p_log_level_rec);
3731 fa_debug_pkg.add('faxcde','eop_formula_factor', fa_amort_pvt.t_eop_formula_factor(l_ind),p_log_level_rec);
3732 end if;
3733
3734
3735 --
3736 -- Revaluation and Production related amounts needs to be corrected
3737 -- fa_amort_pvt.t_reval_amortization(l_ind) :=
3738 -- fa_amort_pvt.t_ytd_reval_deprn_expense(l_ind) :=
3739 -- fa_amort_pvt.t_reval_reserve(l_ind) :=
3740 -- fa_amort_pvt.t_production(l_ind) :=
3741 -- fa_amort_pvt.t_ytd_production(l_ind) :=
3742 -- fa_amort_pvt.t_ltd_production(l_ind) :=
3743 -- fa_amort_pvt.t_remaining_life1(l_ind) :=
3744 -- fa_amort_pvt.t_remaining_life2(l_ind) :=
3745
3746 l_ind := l_ind + 1;
3747 end if; -- (l_ind <= fa_amort_pvt.t_deprn_amount.COUNT) then
3748
3749 end if; -- (l_ind <> 0))
3750
3751 if (p_log_level_rec.statement_level) then
3752 fa_debug_pkg.add(l_calling_fn, 'p_ind', p_ind,p_log_level_rec);
3753 fa_debug_pkg.add(l_calling_fn, 'dpr_out.full_rsv_flag', dpr_out.full_rsv_flag,p_log_level_rec);
3754 fa_debug_pkg.add(l_calling_fn, 'adj_rec_cost', adj_rec_cost,p_log_level_rec);
3755 fa_debug_pkg.add(l_calling_fn, 'cur_deprn_rsv', cur_deprn_rsv,p_log_level_rec);
3756 fa_debug_pkg.add(l_calling_fn, 'year_deprn_exp', year_deprn_exp,p_log_level_rec);
3757 end if;
3758
3759 --
3760 -- Stop and exit period loop if
3761 -- 1. This is not group related trx
3762 -- 2. method is NBV base
3763 -- 3. reserve will be equal to limit
3764 -- 4. reserve before deprn is more than the limit
3765 -- 5. This is not projection.
3766 --
3767 if (p_ind = 0) and
3768 (nbv_deprn_basis_flag) and
3769 (dpr_out.full_rsv_flag) and
3770 (adj_rec_cost = (cur_deprn_rsv + nvl(year_deprn_exp,0))) and
3771 ((adj_rec_cost > 0 and adj_rec_cost <= cur_deprn_rsv) or
3772 (adj_rec_cost < 0 and adj_rec_cost >= cur_deprn_rsv)) and
3773 (not(deprn_projecting_flag)) then
3774
3775 if (p_log_level_rec.statement_level) then
3776 fa_debug_pkg.add(l_calling_fn, 'Exiting PERIOD LOOP', '.',p_log_level_rec);
3777 fa_debug_pkg.add(l_calling_fn, 'Fully reserved during recalculation',
3778 to_char(adj_rec_cost)||':'||to_char(cur_deprn_rsv + year_deprn_exp),p_log_level_rec);
3779 end if;
3780
3781 exit;
3782
3783 end if; -- (p_ind = 0) and
3784
3785 end loop; -- End of period loop
3786
3787 --
3788 -- Round amount calculated
3789 h_dummy_bool := fa_utils_pkg.faxrnd (year_deprn_exp, dpr.book
3790 ,p_log_level_rec => p_log_level_rec);
3791
3792 -- bonus
3793 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
3794 h_dummy_bool := fa_utils_pkg.faxrnd (year_bonus_deprn_amount, dpr.book
3795 ,p_log_level_rec => p_log_level_rec);
3796 end if;
3797
3798 /* modified the below for bug 3991232
3799 if dpr.rec_cost = 0 then
3800 rab_rc_ratio := 0;
3801 else
3802 rab_rc_ratio := cur_reval_amo_basis / dpr.rec_cost;
3803 end if;
3804 */
3805 if cur_adj_cost = 0 then
3806 rab_rc_ratio := 0;
3807 else
3808 rab_rc_ratio := cur_reval_amo_basis / cur_adj_cost;
3809 end if;
3810
3811 year_reval_exp := nvl(year_deprn_exp,0) * rab_rc_ratio;
3812 h_dummy_bool := fa_utils_pkg.faxrnd (year_reval_exp, dpr.book
3813 ,p_log_level_rec => p_log_level_rec);
3814
3815 if (amo_reval_rsv_flag) then
3816 year_reval_amo := year_reval_exp;
3817 else
3818 year_reval_amo := 0;
3819 end if;
3820 deprn_exp_sum := deprn_exp_sum + nvl(year_deprn_exp,0);
3821 cur_deprn_rsv := cur_deprn_rsv + nvl(year_deprn_exp,0);
3822
3823 -- bonus
3824 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
3825 bonus_deprn_exp_sum := bonus_deprn_exp_sum + year_bonus_deprn_amount;
3826 cur_bonus_deprn_rsv := cur_bonus_deprn_rsv + year_bonus_deprn_amount;
3827 end if;
3828
3829 reval_exp_sum := reval_exp_sum + year_reval_exp;
3830 reval_amo_sum := reval_amo_sum + year_reval_amo;
3831 cur_reval_rsv := cur_reval_rsv - year_reval_amo;
3832 prod_sum := prod_sum + year_prod;
3833 cur_ltd_prod := cur_ltd_prod + year_prod;
3834
3835 --
3836 -- Debug
3837 --
3838 if (p_log_level_rec.statement_level) then
3839 fa_debug_pkg.add('faxcde', 'fadpdp(9): deprn_exp_sum', deprn_exp_sum,p_log_level_rec);
3840 fa_debug_pkg.add('faxcde', 'cur_deprn_rsv', cur_deprn_rsv,p_log_level_rec);
3841 fa_debug_pkg.add('faxcde', 'reval_exp_sum', reval_exp_sum,p_log_level_rec);
3842 fa_debug_pkg.add('faxcde', 'reval_amo_sum', reval_amo_sum,p_log_level_rec);
3843 fa_debug_pkg.add('faxcde', 'cur_reval_rsv', cur_reval_rsv,p_log_level_rec);
3844 fa_debug_pkg.add('faxcde', 'prod_sum', prod_sum,p_log_level_rec);
3845 fa_debug_pkg.add('faxcde', 'cur_ltd_prod', cur_ltd_prod,p_log_level_rec);
3846 fa_debug_pkg.add('faxcde', 'year_deprn_exp', year_deprn_exp,p_log_level_rec);
3847 fa_debug_pkg.add('faxcde', 'ytd_deprn_sum', ytd_deprn_sum,p_log_level_rec);
3848 end if;
3849
3850 if (deprn_end_perd = perds_per_yr_dcal) then
3851
3852 -- bonus? We need to investigate how to treat prior_bonus_fy_exp_sum
3853 --
3854 -- prior_fy_exp_sum needs to include dpr.ytd_deprn to make sure
3855 -- subtraction method to work correctly for subsequent years
3856 --
3857 if (fyctr = dpr.y_begin) then
3858 prior_fy_exp_sum := prior_fy_exp_sum + nvl(year_deprn_exp,0) + dpr.ytd_deprn;
3859 prior_fy_bonus_exp_sum := prior_fy_bonus_exp_sum + year_bonus_deprn_amount + dpr.bonus_ytd_deprn;
3860 else
3861 prior_fy_exp_sum := prior_fy_exp_sum + nvl(year_deprn_exp,0);
3862 prior_fy_bonus_exp_sum := prior_fy_bonus_exp_sum + year_bonus_deprn_amount;
3863 end if;
3864
3865 end if; -- (deprn_end_perd = perds_per_yr_dcal) then
3866
3867 --
3868 -- If necessary, recompute the current adjusted cost based on
3869 -- the new depreciation reserve
3870 -- Also, recompute the current revaluation amortization basis
3871 -- to be the new revaluation reserve
3872 --
3873 if nbv_deprn_basis_flag and deprn_end_perd = perds_per_yr_dcal then
3874 --
3875 -- Instead of using adj_rec_cost, still use rec_cost to
3876 -- calculate asset's nbv after normal life completed
3877 --
3878 cur_reval_amo_basis := cur_reval_rsv;
3879
3880 --
3881 -- Debug
3882 --
3883 if (p_log_level_rec.statement_level) then
3884 fa_debug_pkg.add('faxcde', 'cur_reval_amo_basis', cur_reval_amo_basis,p_log_level_rec);
3885 end if;
3886
3887 end if; -- nbv_deprn_basis_flag and deprn_end_perd = perds_per_yr_dcal then
3888
3889 --
3890 -- Populate YTD deprn as of end of calculation.
3891 --
3892 if (fyctr = dpr.y_begin) then
3893 dpr_out.new_ytd_deprn := dpr_out.new_ytd_deprn + nvl(year_deprn_exp,0);
3894 else
3895 dpr_out.new_ytd_deprn := nvl(year_deprn_exp,0);
3896 end if;
3897
3898 --
3899 -- For second year during catchup, rounding flag should be set
3900 -- to null.
3901 dpr.deprn_rounding_flag := NULL;
3902
3903 -- Set eofy amount
3904 if deprn_end_perd = perds_per_yr_dcal then
3905 cur_eofy_reserve := cur_deprn_rsv;
3906 end if;
3907
3908 --
3909 -- Stop and exit period loop if
3910 -- 1. This is not group related trx
3911 -- 2. method is NBV base
3912 -- 3. reserve is equal to limit
3913 -- 4. reserve before deprn is more than the limit
3914 -- 5. This is not projection.
3915 --
3916 if (p_ind = 0) and
3917 (nbv_deprn_basis_flag) and
3918 (dpr_out.full_rsv_flag) and
3919 (adj_rec_cost = (cur_deprn_rsv)) and
3920 ((adj_rec_cost > 0 and adj_rec_cost <= cur_deprn_rsv - nvl(year_deprn_exp,0)) or
3921 (adj_rec_cost < 0 and adj_rec_cost >= cur_deprn_rsv - nvl(year_deprn_exp,0))) and
3922 (not(deprn_projecting_flag)) then
3923 fa_debug_pkg.add(l_calling_fn, 'EXITING YEAR LOOP', '.',p_log_level_rec);
3924 fa_debug_pkg.add(l_calling_fn, 'Fully reserved during recalculation',
3925 to_char(adj_rec_cost)||':'||to_char(cur_deprn_rsv + year_deprn_exp),p_log_level_rec);
3926 cur_adj_cost := 0;
3927 exit;
3928 end if;
3929
3930 end loop; -- End fiscal year loop --
3931
3932 --
3933 -- We increment fy by 1 to emulate the C lang for loop behavior
3934 -- where the loop counter is incremented before the loop condition
3935 -- is tested. PL/SQL doesnt.
3936 --
3937 fy_ctr := fy_ctr + 1;
3938
3939 -- bug 894937 and 1330860
3940 -- '+' changed to '-'
3941 if (nbv_deprn_basis_flag and excl_sal_val_flag) then
3942 cur_adj_cost := cur_adj_cost - dpr.salvage_value;
3943 end if;
3944
3945 --
3946 -- Bug4037112: Need to return reserve that includes
3947 -- Reserve adjustments amount which can only
3948 -- find in fa_amort_pvt pl/sql table.
3949 --
3950 if (l_ind<>0) and
3951 (l_ind <= fa_amort_pvt.t_deprn_amount.COUNT) then
3952 dpr_out.new_deprn_rsv := fa_amort_pvt.t_deprn_reserve(l_ind-1)+
3953 fa_amort_pvt.t_reserve_adjustment_amount(l_ind) +
3954 fa_amort_pvt.t_expense_adjustment_amount(l_ind);
3955 else
3956 dpr_out.new_deprn_rsv := cur_deprn_rsv;
3957 end if;
3958
3959 if nvl(dpr.bonus_rule, 'NONE') <> 'NONE' then
3960 dpr_out.new_bonus_deprn_rsv := cur_bonus_deprn_rsv;
3961 else
3962 dpr_out.new_bonus_deprn_rsv := 0;
3963 end if;
3964
3965 dpr_out.new_adj_cost := cur_adj_cost;
3966 dpr_out.new_reval_rsv := cur_reval_rsv;
3967 dpr_out.new_reval_amo_basis := cur_reval_amo_basis;
3968 dpr_out.new_ltd_prod := cur_ltd_prod;
3969 dpr_out.deprn_exp := deprn_exp_sum;
3970 -- bonus? necessary? if so we need to add to dpr_out_struct.
3971 -- dpr_out.bonus_deprn_amount := bonus_deprn_exp_sum;
3972 dpr_out.bonus_deprn_exp := bonus_deprn_exp_sum; -- YYOON
3973 dpr_out.reval_exp := reval_exp_sum;
3974 dpr_out.reval_amo := reval_amo_sum;
3975 dpr_out.prod := prod_sum;
3976 dpr_out.ann_adj_reval_exp := dpr_out.ann_adj_exp * rab_rc_ratio;
3977 h_dummy_bool := fa_utils_pkg.faxrnd(dpr_out.ann_adj_reval_exp, dpr.book
3978 ,p_log_level_rec => p_log_level_rec);
3979 dpr_out.new_eofy_reserve := cur_eofy_reserve;
3980
3981 if (p_log_level_rec.statement_level) then
3982 fa_debug_pkg.add('faxcde', 'fadpdp: dpr_out.deprn_override_flag',dpr_out.deprn_override_flag,p_log_level_rec);
3983 end if;
3984
3985 if (amo_reval_rsv_flag) then
3986 dpr_out.ann_adj_reval_amo := dpr_out.ann_adj_reval_exp ;
3987 else
3988 dpr_out.ann_adj_reval_amo := 0;
3989 end if;
3990
3991 -- old bonus code, where is -1 evaluated.
3992 -- Maybe: if prod_rate_src_flag or nvl(dpr.bonus_rule, 'NONE') = 'NONE' then
3993 if nvl(dpr.bonus_rule, 'NONE') = 'NONE' then
3994 dpr_out.bonus_rate_used := -1;
3995 end if;
3996
3997 -- if the period is the last period of current the fiscal year, or
3998 -- the year is greater than current fiscal year then reset deprn
3999 -- expense of all prior fiscal years to 0, otherwise increase
4000 -- prior_fy_exp by sum of deprn expense for all prior fiscal years
4001 -- of requested periods
4002 --
4003 if (fy_ctr - 1 <= cur_fy) then
4004
4005 if (deprn_end_perd = perds_per_yr_dcal and fy_ctr = cur_fy) then
4006 dpr_out.new_prior_fy_exp := 0;
4007 dpr_out.new_prior_fy_bonus_exp := 0;
4008 else
4009 dpr_out.new_prior_fy_exp := prior_fy_exp_sum + dpr.prior_fy_exp;
4010 dpr_out.new_prior_fy_bonus_exp := prior_fy_bonus_exp_sum + dpr.prior_fy_bonus_exp;
4011 end if;
4012
4013 else
4014 dpr_out.new_prior_fy_exp := 0;
4015 dpr_out.new_prior_fy_bonus_exp := 0;
4016 end if;
4017
4018 --
4019 -- Debug
4020 --
4021 if (p_log_level_rec.statement_level) then
4022 h_dummy_bool := fa_cde_pkg.faprdos(dpr_out
4023 ,p_log_level_rec => p_log_level_rec);
4024 end if;
4025
4026 return (TRUE);
4027
4028 EXCEPTION
4029 when others then
4030 fa_srvr_msg.add_sql_error (calling_fn => 'fa_cde_pkg.faxcde'
4031 ,p_log_level_rec => p_log_level_rec);
4032 return (FALSE);
4033
4034 END FAXCDE;
4035
4036 FUNCTION faprds
4037 (
4038 X_dpr in fa_std_types.dpr_struct,
4039 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null)
4040 return boolean is
4041 begin <<FAPRDS>>
4042
4043 fa_debug_pkg.add('faxcde','Contents of dpr_struct for asset_id',X_dpr.asset_id,p_log_level_rec);
4044 fa_debug_pkg.add('faxcde','asset_num',X_dpr.asset_num,p_log_level_rec);
4045 fa_debug_pkg.add('faxcde','book',X_dpr.book,p_log_level_rec);
4046 fa_debug_pkg.add('faxcde','calendar_type',X_dpr.calendar_type,p_log_level_rec);
4047 fa_debug_pkg.add('faxcde','ceil_name',X_dpr.ceil_name,p_log_level_rec);
4048 fa_debug_pkg.add('faxcde','bonus_rule',X_dpr.bonus_rule,p_log_level_rec);
4049 fa_debug_pkg.add('faxcde','method_code',X_dpr.method_code,p_log_level_rec);
4050 fa_debug_pkg.add('faxcde','adj_cost',X_dpr.adj_cost,p_log_level_rec);
4051 fa_debug_pkg.add('faxcde','rec_cost',X_dpr.rec_cost,p_log_level_rec);
4052 fa_debug_pkg.add('faxcde','reval_amo_basis',X_dpr.reval_amo_basis,p_log_level_rec);
4053 fa_debug_pkg.add('faxcde','deprn_rsv',X_dpr.deprn_rsv,p_log_level_rec);
4054 fa_debug_pkg.add('faxcde','reval_rsv',X_dpr.reval_rsv,p_log_level_rec);
4055 fa_debug_pkg.add('faxcde','adj_rate',X_dpr.adj_rate,p_log_level_rec);
4056 fa_debug_pkg.add('faxcde','rate_adj_factor',X_dpr.rate_adj_factor,p_log_level_rec);
4057 fa_debug_pkg.add('faxcde','capacity',X_dpr.capacity,p_log_level_rec);
4058 fa_debug_pkg.add('faxcde','adj_capacity',X_dpr.adj_capacity,p_log_level_rec);
4059 fa_debug_pkg.add('faxcde','ltd_prod',X_dpr.ltd_prod,p_log_level_rec);
4060 fa_debug_pkg.add('faxcde','adj_rec_cost',X_dpr.adj_rec_cost,p_log_level_rec);
4061 fa_debug_pkg.add('faxcde','salvage_value',X_dpr.salvage_value,p_log_level_rec);
4062 fa_debug_pkg.add('faxcde','prior_fy_exp',X_dpr.prior_fy_exp,p_log_level_rec);
4063 fa_debug_pkg.add('faxcde','ytd_deprn',X_dpr.ytd_deprn,p_log_level_rec);
4064 fa_debug_pkg.add('faxcde','asset_id',X_dpr.asset_id,p_log_level_rec);
4065 fa_debug_pkg.add('faxcde','jdate_in_service',X_dpr.jdate_in_service,p_log_level_rec);
4066 fa_debug_pkg.add('faxcde','prorate_jdate',X_dpr.prorate_jdate,p_log_level_rec);
4067 fa_debug_pkg.add('faxcde','deprn_start_jdate',X_dpr.deprn_start_jdate,p_log_level_rec);
4068 fa_debug_pkg.add('faxcde','jdate_retired',X_dpr.jdate_retired,p_log_level_rec);
4069 fa_debug_pkg.add('faxcde','ret_prorate_jdate',X_dpr.ret_prorate_jdate,p_log_level_rec);
4070 fa_debug_pkg.add('faxcde','life',X_dpr.life,p_log_level_rec);
4071 fa_debug_pkg.add('faxcde','prorate_year_pcal_begin',X_dpr.y_begin,p_log_level_rec);
4072 fa_debug_pkg.add('faxcde','y_end',X_dpr.y_end,p_log_level_rec);
4073 fa_debug_pkg.add('faxcde','p_cl_begin',X_dpr.p_cl_begin,p_log_level_rec);
4074 fa_debug_pkg.add('faxcde','p_cl_end',X_dpr.p_cl_end,p_log_level_rec);
4075 fa_debug_pkg.add('faxcde','pc_life_end',X_dpr.pc_life_end,p_log_level_rec);
4076
4077 if (X_dpr.rsv_known_flag) then
4078 fa_debug_pkg.add('faxcde','rsv_known_flag','TRUE',p_log_level_rec);
4079 else
4080 fa_debug_pkg.add('faxcde','rsv_known_flag','FALSE',p_log_level_rec);
4081 end if;
4082
4083 fa_debug_pkg.add('faxcde','deprn_rounding_flag',X_dpr.deprn_rounding_flag,p_log_level_rec);
4084
4085 return (TRUE);
4086
4087 exception
4088 when others then
4089 fa_srvr_msg.add_sql_error (calling_fn => 'fa_cde_pkg.faprds'
4090 ,p_log_level_rec => p_log_level_rec);
4091 return (FALSE);
4092 end FAPRDS;
4093
4094 FUNCTION faprdos
4095 (
4096 X_dpr in fa_std_types.dpr_out_struct,
4097 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null)
4098 return boolean is
4099 begin <<FAPRDOS>>
4100
4101 fa_debug_pkg.add('faxcde','new_deprn_rsv',X_dpr.new_deprn_rsv,p_log_level_rec);
4102 fa_debug_pkg.add('faxcde','new_adj_cost',X_dpr.new_adj_cost,p_log_level_rec);
4103 fa_debug_pkg.add('faxcde','new_reval_rsv',X_dpr.new_reval_rsv,p_log_level_rec);
4104 fa_debug_pkg.add('faxcde','new_reval_amo_basis',X_dpr.new_reval_amo_basis,p_log_level_rec);
4105 fa_debug_pkg.add('faxcde','new_adj_capacity',X_dpr.new_adj_capacity,p_log_level_rec);
4106 fa_debug_pkg.add('faxcde','new_ltd_prod',X_dpr.new_ltd_prod,p_log_level_rec);
4107 fa_debug_pkg.add('faxcde','deprn_exp',X_dpr.deprn_exp,p_log_level_rec);
4108 fa_debug_pkg.add('faxcde','reval_exp',X_dpr.reval_exp,p_log_level_rec);
4109 fa_debug_pkg.add('faxcde','reval_amo',X_dpr.reval_amo,p_log_level_rec);
4110 fa_debug_pkg.add('faxcde','prod',X_dpr.prod,p_log_level_rec);
4111 fa_debug_pkg.add('faxcde','ann_adj_exp',X_dpr.ann_adj_exp,p_log_level_rec);
4112 fa_debug_pkg.add('faxcde','ann_adj_reval_exp',X_dpr.ann_adj_reval_exp,p_log_level_rec);
4113 fa_debug_pkg.add('faxcde','ann_adj_reval_amo',X_dpr.ann_adj_reval_amo,p_log_level_rec);
4114 fa_debug_pkg.add('faxcde','bonus_rate_used',X_dpr.bonus_rate_used,p_log_level_rec);
4115
4116 if (X_dpr.full_rsv_flag) then
4117 fa_debug_pkg.add('faxcde','full_rsv_flag','TRUE',p_log_level_rec);
4118 else
4119 fa_debug_pkg.add('faxcde','full_rsv_flag','FALSE',p_log_level_rec);
4120 end if;
4121
4122 if (X_dpr.life_comp_flag) then
4123 fa_debug_pkg.add('faxcde','life_comp_flag','TRUE',p_log_level_rec);
4124 else
4125 fa_debug_pkg.add('faxcde','life_comp_flag','FALSE',p_log_level_rec);
4126 end if;
4127
4128 fa_debug_pkg.add('faxcde','new_prior_fy_exp',X_dpr.new_prior_fy_exp,p_log_level_rec);
4129
4130 return (TRUE);
4131
4132 exception
4133 when others then
4134 fa_srvr_msg.add_sql_error (calling_fn => 'fa_cde_pkg.faprdos'
4135 ,p_log_level_rec => p_log_level_rec);
4136 return (FALSE);
4137 end FAPRDOS;
4138
4139 FUNCTION fadgpoar return INTEGER is
4140
4141 -- value VARCHAR2(40);
4142
4143 begin <<FADGPOAR>>
4144
4145 if (not g_tested_use_annual_round) then
4146 -- fnd_profile.get('FA_ANNUAL_ROUND', value);
4147 if fa_cache_pkg.fa_annual_round = 'ALWAYS' then
4148 g_use_annual_round := ROUND_ALWAYS;
4149 else
4150 g_use_annual_round := ROUND_WITH_RESTRICTIONS;
4151 end if;
4152
4153 g_tested_use_annual_round := TRUE;
4154 end if;
4155
4156 return g_use_annual_round;
4157
4158 exception
4159 when others then
4160 return (g_use_annual_round);
4161 end FADGPOAR;
4162
4163
4164 FUNCTION faodda(book in varchar2,
4165 used_by_adjustment in boolean,
4166 asset_id in number,
4167 bonus_rule in varchar2,
4168 fyctr in number,
4169 perd_ctr in number,
4170 prod_rate_src_flag in boolean,
4171 deprn_projecting_flag in boolean,
4172 p_ytd_deprn IN NUMBER,
4173 p_bonus_ytd_deprn IN NUMBER,
4174 override_depr_amt out nocopy number,
4175 override_bonus_amt out nocopy number,
4176 deprn_override_flag out nocopy varchar2,
4177 return_code out nocopy number,
4178 p_mrc_sob_type_code IN VARCHAR2,
4179 p_recoverable_cost IN NUMBER,
4180 p_salvage_value IN NUMBER,
4181 p_update_override_status IN BOOLEAN,
4182 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) return boolean is
4183
4184 h_calendar_type varchar2(15);
4185 h_fy_name varchar2(30);
4186 subtract_ytd_flag varchar2(1);
4187 h_num_per_fy number(5);
4188 h_set_of_books_id number;
4189 h_prim_set_of_books_id number;
4190 h_reporting_flag varchar2(1);
4191 h_asset_id number(15);
4192 h_deprn_override_id number(15);
4193 h_success boolean;
4194 deprn_summary fa_std_types.fa_deprn_row_struct;
4195 perd_name varchar2(15);
4196 report_cost number;
4197 l_exchange_rate number;
4198 l_avg_rate number;
4199 l_calling_fn varchar2(40) := 'fa_cde_pkg.faodda';
4200 faodda_err EXCEPTION;
4201
4202 begin <<FAODDA>>
4203
4204 -- BMR: do not clear the message stack
4205 -- fa_debug_pkg.initialize;
4206
4207 return_code:= 11;
4208 -- call the cache for the primary transaction book
4209 if NOT fa_cache_pkg.fazcbc(X_book => book
4210 ,p_log_level_rec => p_log_level_rec) then
4211 return_code:= 7;
4212 raise faodda_err;
4213 end if;
4214
4215 if (p_log_level_rec.statement_level) then
4216 fa_debug_pkg.add('faodda', 'book_type_code', book,p_log_level_rec);
4217 fa_debug_pkg.add('faodda', 'asset_id', asset_id,p_log_level_rec);
4218 fa_debug_pkg.add('faodda', 'used_by_adjustment', used_by_adjustment,p_log_level_rec);
4219 fa_debug_pkg.add('faodda', 'p_update_override_status', p_update_override_status,p_log_level_rec);
4220 fa_debug_pkg.add('faodda', 'p_mrc_sob_type_code', p_mrc_sob_type_code,p_log_level_rec);
4221 end if;
4222
4223
4224 -- Modified for MRC
4225 -- couldn't get set_of_books_id correctly,
4226 -- so added p_mrc_sob_type_code to paramter
4227 IF p_mrc_sob_type_code = 'R' THEN
4228 h_set_of_books_id := NVL(fa_cache_pkg.fazcbcs_record.set_of_books_id,
4229 fa_cache_pkg.fazcbc_record.set_of_books_id);
4230 h_reporting_flag := 'R';
4231 ELSE
4232 h_set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
4233 h_reporting_flag := 'P';
4234 END IF;
4235
4236 if (p_log_level_rec.statement_level) then
4237 fa_debug_pkg.add('faodda', 'set_of_books_id', h_set_of_books_id,p_log_level_rec);
4238 fa_debug_pkg.add('faodda', 'reporting_flag', h_reporting_flag,p_log_level_rec);
4239 end if;
4240
4241
4242 return_code:=12;
4243
4244 /* select the corresponding period_counter for the current period: fyctr, perd_ctr */
4245
4246 -- Get calendar Info: type, fy_name and num_per_fiscal_year
4247 /* SELECT bc.deprn_calendar, bc.fiscal_year_name,
4248 ct.number_per_fiscal_year
4249 into h_calendar_type, h_fy_name, h_num_per_fy
4250 from fa_book_controls bc, fa_calendar_types ct
4251 where bc.book_type_code = book
4252 and bc.deprn_calendar = ct.calendar_type;
4253 */
4254 h_calendar_type:= fa_cache_pkg.fazcbc_record.deprn_calendar;
4255 h_fy_name:= fa_cache_pkg.fazcbc_record.fiscal_year_name;
4256 h_num_per_fy:= fa_cache_pkg.fazcct_record.number_per_fiscal_year;
4257
4258 return_code:= 13;
4259
4260
4261 /* -- FIGURE OUT THE PERIOD_COUNTER for the current fyctr and perd_ctr
4262 select fy.fiscal_year * h_num_per_fy + cp.period_num
4263 into perd_c
4264 from fa_calendar_periods cp, fa_fiscal_year fy
4265 where cp.period_num = perd_ctr
4266 and fy.fiscal_year = fyctr
4267 and cp.calendar_type = h_calendar_type
4268 and cp.start_date >= fy.start_date
4269 and cp.end_date <= fy.end_date
4270 and fy.fiscal_year_name = h_fy_name;
4271 */
4272
4273 -- FIGURE OUT THE PERIOD_NAME for the current fyctr and perd_ctr
4274 if perd_ctr <> nvl(g_pre_period_ctr, 0) or fyctr <> nvl(g_pre_fyctr,0) then
4275
4276 select cp.period_name into perd_name
4277 from fa_calendar_periods cp, fa_fiscal_year fy
4278 where cp.calendar_type = h_calendar_type and
4279 cp.period_num = perd_ctr and
4280 cp.start_date >= fy.start_date and
4281 cp.end_date <= fy.end_date and
4282 fy.fiscal_year_name = h_fy_name and
4283 fy.fiscal_year = fyctr;
4284
4285 g_pre_period_name:= perd_name;
4286 g_pre_period_ctr:= perd_ctr;
4287 g_pre_fyctr:= fyctr;
4288 else
4289 perd_name := g_pre_period_name;
4290 end if;
4291
4292 h_asset_id:= asset_id;
4293
4294 if (p_log_level_rec.statement_level) then
4295 fa_debug_pkg.add('faodda', 'period_name', perd_name,p_log_level_rec);
4296 end if;
4297
4298
4299 if used_by_adjustment = TRUE then
4300 SELECT deprn_amount, bonus_deprn_amount, subtract_ytd_flag, deprn_override_id
4301 INTO override_depr_amt, override_bonus_amt, subtract_ytd_flag, h_deprn_override_id
4302 FROM FA_DEPRN_OVERRIDE
4303 WHERE
4304 book_type_code = book and
4305 asset_id = h_asset_id and
4306 period_name = perd_name and
4307 used_by = 'ADJUSTMENT' and
4308 status = 'POST';
4309 else
4310 SELECT deprn_amount, bonus_deprn_amount, subtract_ytd_flag, deprn_override_id
4311 INTO override_depr_amt, override_bonus_amt, subtract_ytd_flag, h_deprn_override_id
4312 FROM FA_DEPRN_OVERRIDE
4313 WHERE
4314 book_type_code = book and
4315 asset_id = h_asset_id and
4316 period_name = perd_name and
4317 used_by = 'DEPRECIATION' and
4318 status = 'POST';
4319 end if;
4320
4321
4322 if (p_log_level_rec.statement_level) then
4323 fa_debug_pkg.add('faodda', 'primary override_depr_amt', override_depr_amt,p_log_level_rec);
4324 fa_debug_pkg.add('faodda', 'primary override_bonus_amt', override_bonus_amt,p_log_level_rec);
4325 fa_debug_pkg.add('faodda', 'deprn_projecting_flag', deprn_projecting_flag,p_log_level_rec);
4326 fa_debug_pkg.add('faodda', 'p_ytd_deprn', p_ytd_deprn,p_log_level_rec);
4327 fa_debug_pkg.add('faodda', 'p_bonus_ytd_deprn', p_bonus_ytd_deprn,p_log_level_rec);
4328 fa_debug_pkg.add('faodda', 'p_recoverable_cost', p_recoverable_cost,p_log_level_rec);
4329 fa_debug_pkg.add('faodda', 'p_salvage_value', p_salvage_value,p_log_level_rec);
4330 end if;
4331
4332
4333 -- Data Validation for manual override feature
4334 IF (nvl(bonus_rule,'NONE') = 'NONE' and override_bonus_amt is not null) then
4335 -- need to raise an error even for projection because projection needs to output the bonus account on the report.
4336 fa_srvr_msg.add_message(
4337 calling_fn => 'fa_cde_pkg.faodda',
4338 name => 'FA_NO_BONUS_RULE',
4339 translate=> FALSE,
4340 p_log_level_rec => p_log_level_rec);
4341
4342 return_code:= 3;
4343 raise faodda_err;
4344 END IF;
4345
4346 if used_by_adjustment = TRUE then
4347
4348 if (h_reporting_flag <> 'R') then
4349 primary_cost:= p_recoverable_cost + p_salvage_value;
4350 else
4351 report_cost:= p_recoverable_cost + p_salvage_value;
4352 end if;
4353
4354 if (p_log_level_rec.statement_level) then
4355 fa_debug_pkg.add('faodda', 'primary_cost', primary_cost,p_log_level_rec);
4356 fa_debug_pkg.add('faodda', 'report_cost', report_cost,p_log_level_rec);
4357 end if;
4358
4359
4360 -- ratio = Reporting Books Cost / Primary books Cost for adjustment.
4361 -- the above calculation can be used once the depreciaion
4362 -- program was built in one-step.
4363 -- = use latest average rate for depreciation until one-step depreciation is built.
4364
4365 l_avg_rate:= report_cost / primary_cost;
4366
4367 if (p_log_level_rec.statement_level) then
4368 fa_debug_pkg.add('faodda', 'l_avg_rate', l_avg_rate,p_log_level_rec);
4369 end if;
4370
4371 else -- Depreciation Run
4372 if (h_reporting_flag = 'R') then
4373 select bk.cost into report_cost from fa_books_mrc_v bk
4374 where bk.book_type_code = book and
4375 bk.asset_id = h_asset_id and
4376 bk.transaction_header_id_out is null;
4377
4378 if (p_log_level_rec.statement_level) then
4379 fa_debug_pkg.add('faodda', 'report_cost', report_cost,p_log_level_rec);
4380 end if;
4381
4382 select bk.cost into primary_cost from fa_books bk
4383 where bk.book_type_code = book and
4384 bk.asset_id = h_asset_id and
4385 bk.transaction_header_id_out is null;
4386
4387 if (p_log_level_rec.statement_level) then
4388 fa_debug_pkg.add('faxcde', 'faodda:primary_cost', primary_cost,p_log_level_rec);
4389 end if;
4390
4391 l_avg_rate:= report_cost / primary_cost;
4392
4393 if (p_log_level_rec.statement_level) then
4394 fa_debug_pkg.add('faodda', 'l_avg_rate', l_avg_rate,p_log_level_rec);
4395 end if;
4396 end if;
4397 end if;
4398
4399
4400 IF override_depr_amt is not null THEN
4401 deprn_override_flag:= fa_std_types.FA_OVERRIDE_DPR;
4402 deprn_override_flag:= fa_std_types.FA_OVERRIDE_DPR;
4403 if (h_reporting_flag = 'R') then
4404 override_depr_amt:= override_depr_amt * l_avg_rate;
4405 end if;
4406 IF override_bonus_amt is not null and not(prod_rate_src_flag) THEN
4407 deprn_override_flag:= fa_std_types.FA_OVERRIDE_DPR_BONUS;
4408 if (h_reporting_flag = 'R') then
4409 override_bonus_amt:= override_bonus_amt * l_avg_rate;
4410 end if;
4411 END IF;
4412 ELSIF override_bonus_amt is not null and not(prod_rate_src_flag) THEN
4413 deprn_override_flag:= fa_std_types.FA_OVERRIDE_BONUS;
4414 if (h_reporting_flag = 'R') then
4415 override_bonus_amt:= override_bonus_amt * l_avg_rate;
4416 end if;
4417 ELSE
4418 deprn_override_flag:= fa_std_types.FA_NO_OVERRIDE;
4419 END IF;
4420
4421 if deprn_override_flag <> fa_std_types.FA_NO_OVERRIDE
4422 AND not (deprn_projecting_flag)
4423 AND h_reporting_flag = 'P' then
4424
4425 fa_std_types.deprn_override_trigger_enabled:= FALSE;
4426
4427 IF used_by_adjustment = FALSE THEN
4428 UPDATE fa_deprn_override
4429 SET status = 'POSTED'
4430 WHERE deprn_override_id = h_deprn_override_id;
4431
4432 ELSIF p_update_override_status THEN
4433 UPDATE fa_deprn_override
4434 SET status = 'SELECTED'
4435 WHERE deprn_override_id = h_deprn_override_id;
4436 END IF;
4437
4438 fa_std_types.deprn_override_trigger_enabled:= TRUE;
4439 end if;
4440 return_code:= 4;
4441
4442
4443 -- When user provided YTD amount
4444 IF NVL(subtract_ytd_flag,'N') = 'Y' THEN
4445 override_depr_amt := override_depr_amt - (p_ytd_deprn - p_bonus_ytd_deprn);
4446 override_bonus_amt := override_bonus_amt - p_bonus_ytd_deprn;
4447 END IF;
4448
4449 if (p_log_level_rec.statement_level) then
4450 fa_debug_pkg.add('faodda', 'override_depr_amt', override_depr_amt,p_log_level_rec);
4451 fa_debug_pkg.add('faodda', 'override_bonus_amt', override_bonus_amt,p_log_level_rec);
4452 fa_debug_pkg.add('faodda', 'deprn_override_flag', deprn_override_flag,p_log_level_rec);
4453 end if;
4454
4455 return(TRUE);
4456
4457 exception
4458 WHEN faodda_err THEN
4459 fa_srvr_msg.add_message(calling_fn => l_calling_fn,
4460 p_log_level_rec => p_log_level_rec);
4461 return(FALSE);
4462 when no_data_found then
4463 deprn_override_flag:= fa_std_types.FA_NO_OVERRIDE;
4464 return_code:= 5;
4465 return(TRUE);
4466 when others then
4467 deprn_override_flag:= fa_std_types.FA_NO_OVERRIDE;
4468 return_code:= 6;
4469 fa_srvr_msg.add_message(calling_fn => l_calling_fn,
4470 p_log_level_rec => p_log_level_rec);
4471 return(TRUE);
4472
4473 end FAODDA;
4474
4475
4476 ------------------------------------------------------------------
4477 -- Function:
4478 -- FATRKM
4479 --
4480 -- Description:
4481 -- Main entry to call Tracking feature
4482 -- This function will call TRACK_MEMBER function
4483 --
4484 ------------------------------------------------------------------
4485 FUNCTION fatrkm(p_dpr in fa_std_types.dpr_struct,
4486 p_perd_deprn_exp in number,
4487 p_perd_bonus_deprn_amount in number,
4488 p_perd_ctr in number,
4489 p_fyctr in number,
4490 p_loop_end_year in number,
4491 p_loop_end_period in number,
4492 p_exclude_salvage_value_flag in boolean,
4493 p_deprn_basis_rule in varchar2,
4494 p_deprn_override_flag in out nocopy varchar2,
4495 p_subtract_ytd_flag in varchar2,
4496 p_life_complete_flag in boolean,
4497 p_fully_reserved_flag in boolean,
4498 p_year_deprn_exp in number,
4499 p_recoverable_cost in number,
4500 p_adj_rec_cost in number,
4501 p_current_deprn_reserve in number,
4502 p_nbv_threshold in number,
4503 p_nbv_thresh_amount in number,
4504 p_rec_cost_abs_value in number,
4505 p_mode in varchar2 default NULL,
4506 x_new_perd_exp out nocopy number,
4507 x_new_perd_bonus_deprn_amount out nocopy number,
4508 x_life_complete_flag out nocopy boolean,
4509 x_fully_reserved_flag out nocopy boolean,
4510 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) return boolean is
4511
4512 --* Variables to call TRACK ASSETS
4513 h_book_type_code varchar2(15);
4514 h_group_asset_id number(15);
4515 h_deprn_bonus_rule varchar2(15);
4516 h_exclude_salvage_value_flag varchar2(1);
4517 h_tracking_method varchar2(15);
4518 h_alloc_fully_ret_flag varchar2(1);
4519 h_alloc_fully_rsv_flag varchar2(1);
4520 h_excess_alloc_option varchar2(15);
4521 h_depreciation_option varchar2(15);
4522 h_member_rollup_flag varchar2(1);
4523 h_group_override varchar2(1);
4524
4525 h_new_deprn_amount number;
4526 h_new_bonus_amount number;
4527
4528 h_life_complete_flag varchar2(1);
4529 h_fully_reserved_flag varchar2(1);
4530
4531 x_ret_code number;
4532
4533 begin <<FATRKM>>
4534
4535 if (p_log_level_rec.statement_level) then
4536 fa_debug_pkg.add('faxcde', 'fatrkm', 'Just Started',p_log_level_rec);
4537 end if;
4538
4539 -- Set Data into variables to call TRACK_ASSETS
4540
4541 h_book_type_code := p_dpr.book;
4542 h_group_asset_id := p_dpr.asset_id;
4543 h_deprn_bonus_rule := p_dpr.bonus_rule;
4544
4545 if (p_exclude_salvage_value_flag) then
4546 h_exclude_salvage_value_flag := 'Y';
4547 else
4548 h_exclude_salvage_value_flag := 'N';
4549 end if;
4550
4551 h_tracking_method := p_dpr.tracking_method;
4552 h_alloc_fully_ret_flag := p_dpr.allocate_to_fully_ret_flag;
4553 h_alloc_fully_rsv_flag := p_dpr.allocate_to_fully_rsv_flag;
4554 h_excess_alloc_option := p_dpr.excess_allocation_option;
4555 h_depreciation_option := p_dpr.depreciation_option;
4556 h_member_rollup_flag := p_dpr.member_rollup_flag;
4557
4558 if p_deprn_override_flag <> fa_std_types.FA_NO_OVERRIDE then
4559 h_group_override := 'Y';
4560 else
4561 h_group_override := 'N';
4562 end if;
4563
4564 if (p_log_level_rec.statement_level) then
4565 fa_debug_pkg.add('faxcde', 'fatrkm:book_type_code ', h_book_type_code,p_log_level_rec);
4566 fa_debug_pkg.add('faxcde', 'fatrkm:group_asset_id ', h_group_asset_id,p_log_level_rec);
4567 fa_debug_pkg.add('faxcde', 'fatrkm:period_counter ', p_perd_ctr,p_log_level_rec);
4568 fa_debug_pkg.add('faxcde', 'fatrkm:fiscal_year ', p_fyctr,p_log_level_rec);
4569 fa_debug_pkg.add('faxcde', 'fatrkm:loop_end_year ', p_loop_end_year,p_log_level_rec);
4570 fa_debug_pkg.add('faxcde', 'fatrkm:loop_end_periods ', p_loop_end_period,p_log_level_rec);
4571 fa_debug_pkg.add('faxcde', 'fatrkm:exclude_salvage_value_flag ', h_exclude_salvage_value_flag,p_log_level_rec);
4572 fa_debug_pkg.add('faxcde', 'fatrkm:group_bonus_rule ', h_deprn_bonus_rule,p_log_level_rec);
4573 fa_debug_pkg.add('faxcde', 'fatrkm:group_deprn_amount ', p_perd_deprn_exp,p_log_level_rec);
4574 fa_debug_pkg.add('faxcde', 'fatrkm:group_bonus_amount ', p_perd_bonus_deprn_amount,p_log_level_rec);
4575 fa_debug_pkg.add('faxcde', 'fatrkm:tracking_method ', h_tracking_method,p_log_level_rec);
4576 fa_debug_pkg.add('faxcde', 'fatrkm:allocate_to_fully_ret_flag ', h_alloc_fully_ret_flag,p_log_level_rec);
4577 fa_debug_pkg.add('faxcde', 'fatrkm:allocate_to_fully_rsv_flag ', h_alloc_fully_rsv_flag,p_log_level_rec);
4578 fa_debug_pkg.add('faxcde', 'fatrkm:excess_allocation_option ', h_excess_alloc_option,p_log_level_rec);
4579 fa_debug_pkg.add('faxcde', 'fatrkm:depreciation_option ', h_depreciation_option,p_log_level_rec);
4580 fa_debug_pkg.add('faxcde', 'fatrkm:member_rollup_flag ', h_member_rollup_flag,p_log_level_rec);
4581 fa_debug_pkg.add('faxcde', 'fatrkm:group_override_flag ', h_group_override,p_log_level_rec);
4582 fa_debug_pkg.add('faxcde', 'fatrkm:subtract_ytd_flag ', p_subtract_ytd_flag,p_log_level_rec);
4583 fa_debug_pkg.add('faxcde', 'fatrkm:mode ', p_mode,p_log_level_rec);
4584 end if;
4585
4586 x_ret_code := FA_TRACK_MEMBER_PVT.TRACK_ASSETS(P_book_type_code => h_book_type_code,
4587 P_group_asset_id => h_group_asset_id,
4588 P_period_counter => p_perd_ctr,
4589 P_fiscal_year => p_fyctr,
4590 P_loop_end_year => p_loop_end_year,
4591 P_loop_end_period => p_loop_end_period,
4592 P_group_deprn_basis => p_deprn_basis_rule,
4593 P_group_exclude_salvage => h_exclude_salvage_value_flag,
4594 P_group_bonus_rule => h_deprn_bonus_rule,
4595 P_group_deprn_amount => p_perd_deprn_exp,
4596 P_group_bonus_amount => p_perd_bonus_deprn_amount,
4597 P_tracking_method => h_tracking_method,
4598 P_allocate_to_fully_ret_flag => h_alloc_fully_ret_flag,
4599 P_allocate_to_fully_rsv_flag => h_alloc_fully_rsv_flag,
4600 P_excess_allocation_option => h_excess_alloc_option,
4601 P_depreciation_option => h_depreciation_option,
4602 P_member_rollup_flag => h_member_rollup_flag,
4603 P_subtraction_flag => p_subtract_ytd_flag,
4604 P_group_level_override => h_group_override,
4605 P_mode => p_mode,
4606 P_mrc_sob_type_code => p_dpr.mrc_sob_type_code,
4607 X_new_deprn_amount => h_new_deprn_amount,
4608 X_new_bonus_amount => h_new_bonus_amount
4609 ,p_log_level_rec => p_log_level_rec);
4610 if x_ret_code <> 0 then
4611
4612 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.fatrkm',
4613 p_log_level_rec => p_log_level_rec);
4614 return (FALSE);
4615 else
4616 if (p_log_level_rec.statement_level) then
4617 fa_debug_pkg.add('faxcde', 'fatrkm:new_deprn_amount ', h_new_deprn_amount,p_log_level_rec);
4618 fa_debug_pkg.add('faxcde', 'fatrkm:new_bonus_amount ', h_new_bonus_amount, p_log_level_rec);
4619 end if;
4620
4621 p_deprn_override_flag := h_group_override;
4622
4623 if h_new_deprn_amount is NULL then
4624 x_new_perd_exp := 0;
4625 end if;
4626 if h_new_bonus_amount is NULL then
4627 x_new_perd_bonus_deprn_amount := 0;
4628 end if;
4629
4630 if h_new_deprn_amount <= p_perd_deprn_exp then
4631 x_new_perd_exp := h_new_deprn_amount;
4632 x_new_perd_bonus_deprn_amount := h_new_bonus_amount;
4633 if h_new_deprn_amount = p_perd_deprn_exp then
4634 x_life_complete_flag := p_life_complete_flag;
4635 x_fully_reserved_flag := p_fully_reserved_flag;
4636 else
4637 x_life_complete_flag := FALSE;
4638 x_fully_reserved_flag := FALSE;
4639 end if;
4640 elsif (p_life_complete_flag and p_fully_reserved_flag) then
4641
4642 -- Fix for Bug #6417506. Need to comment the return false and
4643 -- pass back the values for life complete and fully rsvd flags.
4644 --return(FALSE);
4645
4646 x_life_complete_flag := p_life_complete_flag;
4647 x_fully_reserved_flag := p_fully_reserved_flag;
4648
4649 else
4650 x_ret_code := 0;
4651
4652 x_ret_code := FA_TRACK_MEMBER_PVT.CHECK_GROUP_AMOUNTS(P_book_type_code => h_book_type_code,
4653 P_group_asset_id => h_group_asset_id,
4654 P_period_counter => p_perd_ctr,
4655 P_perd_deprn_exp => h_new_deprn_amount,
4656 P_year_deprn_exp => p_year_deprn_exp,
4657 P_recoverable_cost => p_recoverable_cost,
4658 P_adj_rec_cost => p_adj_rec_cost,
4659 P_current_deprn_reserve => p_current_deprn_reserve,
4660 P_nbv_threshold => p_nbv_threshold,
4661 P_nbv_thresh_amount => P_nbv_thresh_amount,
4662 P_rec_cost_abs_value => P_rec_cost_abs_value,
4663 X_life_complete_flag => h_life_complete_flag,
4664 X_fully_reserved_flag => h_fully_reserved_flag
4665 ,p_log_level_rec => p_log_level_rec);
4666 if x_ret_code <> 0 then
4667
4668 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.fatrkm',
4669 p_log_level_rec => p_log_level_rec);
4670 return (FALSE);
4671
4672 else
4673 if nvl(h_life_complete_flag,'N') = 'Y' then
4674 x_life_complete_flag := TRUE;
4675 else
4676 x_life_complete_flag := FALSE;
4677 end if;
4678
4679 if nvl(h_fully_reserved_flag,'N') = 'Y' then
4680 x_fully_reserved_flag := TRUE;
4681 else
4682 x_fully_reserved_flag := FALSE;
4683 end if;
4684 x_new_perd_exp := h_new_deprn_amount;
4685 x_new_perd_bonus_deprn_amount := h_new_bonus_amount;
4686 end if;
4687
4688 end if;
4689
4690 end if;
4691
4692 return(true);
4693
4694 exception
4695 when others then
4696 fa_srvr_msg.add_message (calling_fn => 'fa_cde_pkg.fatrkm',
4697 p_log_level_rec => p_log_level_rec);
4698 return(TRUE);
4699
4700 end FATRKM;
4701
4702 procedure faxgpolr (X_Book_Type_Code IN VARCHAR2,
4703 X_Asset_Id IN NUMBER,
4704 X_Polish_Rule IN NUMBER,
4705 X_Deprn_Factor IN NUMBER,
4706 X_Alternate_Deprn_Factor IN NUMBER,
4707 X_Polish_Adj_Calc_Basis_Flag
4708 IN VARCHAR2,
4709 X_Recoverable_Cost IN NUMBER,
4710 X_Fiscal_Year IN NUMBER,
4711 X_Current_Period IN NUMBER,
4712 X_Periods_Per_Year IN NUMBER,
4713 X_Year_Retired IN BOOLEAN,
4714 X_Projecting_Flag IN BOOLEAN,
4715 X_MRC_Sob_Type_Code IN VARCHAR2,
4716 X_Rate IN OUT NOCOPY NUMBER,
4717 X_Depreciate_Flag IN OUT NOCOPY BOOLEAN,
4718 X_Current_Adjusted_Cost IN OUT NOCOPY NUMBER,
4719 X_Adjusted_Recoverable_Cost
4720 IN OUT NOCOPY NUMBER,
4721 X_Success OUT NOCOPY INTEGER,
4722 X_Calling_Fn IN VARCHAR2,
4723 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null)
4724
4725 IS
4726
4727 l_calling_fn varchar2(80);
4728 l_year_retired varchar2(1);
4729 l_old_rate number;
4730 l_old_depreciate_flag varchar2(3);
4731 l_old_adjusted_cost number;
4732 l_old_adjusted_rec_cost number;
4733 l_new_rate number;
4734 l_new_depreciate_flag varchar2(3);
4735 l_new_adjusted_cost number;
4736 l_new_adjusted_rec_cost number;
4737 l_success number;
4738
4739 faxgpolr_err exception;
4740
4741 BEGIN
4742
4743 l_old_rate := X_Rate;
4744 l_old_adjusted_cost := X_Current_Adjusted_Cost;
4745 l_old_adjusted_rec_cost := X_Adjusted_Recoverable_Cost;
4746
4747 if (X_Depreciate_Flag) then
4748 l_old_depreciate_flag := 'YES';
4749 else
4750 l_old_depreciate_flag := 'NO';
4751 end if;
4752
4753 if (X_Year_Retired) then
4754 l_year_retired := 'Y';
4755 else
4756 l_year_retired := 'N';
4757 end if;
4758
4759 if (X_Projecting_Flag) then
4760 l_calling_fn := 'fa_cde_pkg.whatif.faxgpolr';
4761 else
4762 l_calling_fn := 'fa_cde_pkg.faxgpolr';
4763 end if;
4764
4765 FA_POLISH_PVT.Calc_Polish_Rate_Cost (
4766 p_Book_Type_Code => X_Book_Type_Code,
4767 p_Asset_Id => X_Asset_Id,
4768 p_Polish_Rule => X_Polish_Rule,
4769 p_Deprn_Factor => X_Deprn_Factor,
4770 p_Alternate_Deprn_Factor => X_Alternate_Deprn_Factor,
4771 p_Polish_Adj_Calc_Basis_Flag => nvl(X_Polish_Adj_Calc_Basis_Flag, 'N'),
4772 p_Rate => l_old_rate,
4773 p_Depreciate_Flag => l_old_depreciate_flag,
4774 p_Adjusted_Cost => l_old_adjusted_cost,
4775 p_Recoverable_Cost => X_Recoverable_Cost,
4776 p_Adjusted_Recoverable_Cost => l_old_adjusted_rec_cost,
4777 p_Fiscal_Year => X_Fiscal_Year,
4778 p_Period_Num => X_Current_Period,
4779 p_Periods_Per_Year => X_Periods_Per_Year,
4780 p_Year_Retired => l_year_retired,
4781 p_MRC_Sob_Type_Code => X_MRC_Sob_Type_Code,
4782 x_Rate => l_new_rate,
4783 x_Depreciate_Flag => l_new_depreciate_flag,
4784 x_Adjusted_Cost => l_new_adjusted_cost,
4785 x_Adjusted_Recoverable_Cost => l_new_adjusted_rec_cost,
4786 x_Success => l_success,
4787 p_Calling_Fn => l_calling_fn);
4788
4789 if (l_success <> 1) then raise faxgpolr_err; end if;
4790
4791 X_Rate := l_new_rate;
4792 X_Current_Adjusted_Cost := l_new_adjusted_cost;
4793 x_Adjusted_Recoverable_cost := l_new_adjusted_rec_cost;
4794
4795 if (l_new_depreciate_flag = 'YES') then
4796 X_Depreciate_Flag := TRUE;
4797 else
4798 X_Depreciate_Flag := FALSE;
4799 end if;
4800
4801 X_Success := 1;
4802
4803 EXCEPTION
4804 WHEN faxgpolr_err THEN
4805 fa_srvr_msg.add_sql_error (calling_fn => 'fa_cde_pkg.faxgpolr'
4806 ,p_log_level_rec => p_log_level_rec);
4807 X_rate := 0;
4808 X_Success := 0;
4809
4810 WHEN OTHERS THEN
4811 fa_srvr_msg.add_sql_error (calling_fn => 'fa_cde_pkg.faxgpolr'
4812 ,p_log_level_rec => p_log_level_rec);
4813 X_rate := 0;
4814 X_Success := 0;
4815
4816 END faxgpolr;
4817
4818 END FA_CDE_PKG;