1 PACKAGE BODY FA_ASSET_CALC_PVT as
2 /* $Header: FAVCALB.pls 120.138.12010000.9 2009/01/21 10:22:09 pmadas ship $ */
3
4 G_primary_new_cost NUMBER;
5 G_primary_salvage_value NUMBER;
6 G_primary_deprn_limit_amount NUMBER;
7
8 FUNCTION calc_fin_info
9 (px_trans_rec IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
10 p_inv_trans_rec IN FA_API_TYPES.inv_trans_rec_type,
11 p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
12 p_asset_desc_rec IN FA_API_TYPES.asset_desc_rec_type,
13 p_asset_type_rec IN FA_API_TYPES.asset_type_rec_type,
14 p_asset_cat_rec IN FA_API_TYPES.asset_cat_rec_type,
15 p_asset_fin_rec_old IN FA_API_TYPES.asset_fin_rec_type,
16 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
17 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
18 p_asset_deprn_rec_old IN FA_API_TYPES.asset_deprn_rec_type,
19 p_asset_deprn_rec_adj IN FA_API_TYPES.asset_deprn_rec_type,
20 px_asset_deprn_rec_new IN OUT NOCOPY FA_API_TYPES.asset_deprn_rec_type,
21 p_period_rec IN FA_API_TYPES.period_rec_type,
22 p_reclassed_asset_id IN NUMBER default null,
23 p_reclass_src_dest IN VARCHAR2 default null,
24 p_reclassed_asset_dpis IN DATE default null,
25 p_mrc_sob_type_code IN VARCHAR2,
26 p_group_reclass_options_rec IN OUT NOCOPY FA_API_TYPES.group_reclass_options_rec_type,
27 p_calling_fn IN VARCHAR2,
28 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
29 ) RETURN BOOLEAN IS
30
31
32 l_adjust_type varchar2(15);
33 l_deprn_exp number := 0;
34 l_bonus_deprn_exp number := 0;
35 l_deprn_rsv number := 0;
36 l_bonus_deprn_rsv number := 0;
37 l_ann_adj_deprn_exp number := 0;
38 l_ann_adj_bonus_deprn_exp number := 0;
39
40 l_clearing number := 0;
41 l_cost_to_insert number := 0;
42 l_clearing_to_insert number := 0;
43 l_jdpis number;
44 l_asset_deprn_rec_adj FA_API_TYPES.asset_deprn_rec_type;
45
46 -- used for method cache
47 l_method_id number;
48 l_rate_source_rule varchar2(10);
49 l_deprn_basis_rule varchar2(4);
50
51 l_amortization_start_date date;
52 l_old_amortization_start_date date;
53
54 l_group_level_override varchar2(1) := NULL;
55 x_new_deprn_amount number;
56 x_new_bonus_amount number;
57 l_rc number;
58
59 l_trxs_exist VARCHAR2(1);
60 l_calling_fn varchar2(40) := 'fa_asset_calc_pvt.calc_fin_info';
61 l_last_trx_count number;
62
63 l_deprn_reserve_exists number := 0;--intialized bug 5260170
64
65 l_temp_deprn_reserve number; -- Used to pass deprn reserve depending whether
66 -- asset is in period of addition or not.
67 l_call_faxama boolean;
68
69 l_disabled_flag_changed boolean :=FALSE; --HH used to check
70 l_call_bs boolean := TRUE; --whether faxama for group should be called
71 -- or not
72 l_old_dpis date;
73
74 l_cap_temp_value number; -- temporary variable to manipulate eop(fy)_rec_cost(sal)
75 -- for capitalization.
76
77 CURSOR c_get_member_trx is
78 select asset_id
79 , transaction_header_id
80 , transaction_type_code
81 , transaction_date_entered
82 , transaction_name
83 , source_transaction_header_id
84 , mass_reference_id
85 , transaction_subtype
86 , transaction_key
87 , amortization_start_date
88 , calling_interface
89 , mass_transaction_id
90 , member_transaction_header_id
91 , trx_reference_id
92 , last_update_date
93 , last_updated_by
94 , last_update_login
95 from fa_transaction_headers
96 where transaction_header_id = px_trans_rec.member_transaction_header_id;
97
98 -- Bug4958977: Introducing new cursor to trap dpis change only trx.
99 CURSOR c_check_dpis_change is
100 select inbk.transaction_header_id_in
101 from fa_books inbk
102 , fa_books outbk
103 where inbk.transaction_header_id_in = px_trans_rec.member_transaction_header_id
104 and outbk.asset_id = inbk.asset_id
105 and outbk.book_type_code = p_asset_hdr_rec.book_type_code
106 and outbk.transaction_header_id_out = px_trans_rec.member_transaction_header_id
107 and inbk.cost = outbk.cost
108 and nvl(inbk.salvage_value, 0) = nvl(outbk.salvage_value, 0)
109 and nvl(inbk.allowed_deprn_limit_amount, 0) = nvl(outbk.allowed_deprn_limit_amount, 0)
110 and inbk.date_placed_in_service <> outbk.date_placed_in_service;
111
112 -- Bug4958977: following 2 new variables
113 l_temp_thid number;
114 l_dpis_change boolean := FALSE;
115
116 l_trans_rec FA_API_TYPES.trans_rec_type;
117 l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
118 l_asset_desc_rec FA_API_TYPES.asset_desc_rec_type;
119 l_asset_fin_rec FA_API_TYPES.asset_fin_rec_type;
120 l_asset_cat_rec FA_API_TYPES.asset_cat_rec_type;
121 l_asset_type_rec FA_API_TYPES.asset_type_rec_type;
122
123
124 calc_err EXCEPTION;
125
126 BEGIN
127
128 if (p_log_level_rec.statement_level) then
129 fa_debug_pkg.add('calc_fin_info', 'at beginning of', 'calc_fin_info');
130 fa_debug_pkg.add('calc_fin_info',
131 'p_asset_fin_rec_adj.over_depreciate_option',
132 p_asset_fin_rec_adj.over_depreciate_option);
133 end if;
134
135
136 -- get category default info
137
138 l_jdpis := to_number(to_char(
139 nvl(px_asset_fin_rec_new.date_placed_in_service,
140 nvl(p_asset_fin_rec_adj.date_placed_in_service,
141 p_asset_fin_rec_old.date_placed_in_service)), 'J'));
142
143 if not fa_cache_pkg.fazccbd (X_book => p_asset_hdr_rec.book_type_code,
144 X_cat_id => p_asset_cat_rec.category_id,
145 X_jdpis => l_jdpis,
146 p_log_level_rec => p_log_level_rec) then
147 raise calc_err;
148 end if;
149
150
151 -- load the global attribute information
152 FA_UTIL_PVT.load_char_value
153 (p_char_old => p_asset_fin_rec_old.global_attribute1,
154 p_char_adj => p_asset_fin_rec_adj.global_attribute1,
155 x_char_new => px_asset_fin_rec_new.global_attribute1);
156
157 FA_UTIL_PVT.load_char_value
158 (p_char_old => p_asset_fin_rec_old.global_attribute2,
159 p_char_adj => p_asset_fin_rec_adj.global_attribute2,
160 x_char_new => px_asset_fin_rec_new.global_attribute2);
161
162 FA_UTIL_PVT.load_char_value
163 (p_char_old => p_asset_fin_rec_old.global_attribute3,
164 p_char_adj => p_asset_fin_rec_adj.global_attribute3,
165 x_char_new => px_asset_fin_rec_new.global_attribute3);
166
167 FA_UTIL_PVT.load_char_value
168 (p_char_old => p_asset_fin_rec_old.global_attribute4,
169 p_char_adj => p_asset_fin_rec_adj.global_attribute4,
170 x_char_new => px_asset_fin_rec_new.global_attribute4);
171
172 FA_UTIL_PVT.load_char_value
173 (p_char_old => p_asset_fin_rec_old.global_attribute5,
174 p_char_adj => p_asset_fin_rec_adj.global_attribute5,
175 x_char_new => px_asset_fin_rec_new.global_attribute5);
176
177 FA_UTIL_PVT.load_char_value
178 (p_char_old => p_asset_fin_rec_old.global_attribute6,
179 p_char_adj => p_asset_fin_rec_adj.global_attribute6,
180 x_char_new => px_asset_fin_rec_new.global_attribute6);
181
182 FA_UTIL_PVT.load_char_value
183 (p_char_old => p_asset_fin_rec_old.global_attribute7,
184 p_char_adj => p_asset_fin_rec_adj.global_attribute7,
185 x_char_new => px_asset_fin_rec_new.global_attribute7);
186
187 FA_UTIL_PVT.load_char_value
188 (p_char_old => p_asset_fin_rec_old.global_attribute8,
189 p_char_adj => p_asset_fin_rec_adj.global_attribute8,
190 x_char_new => px_asset_fin_rec_new.global_attribute8);
191
192 FA_UTIL_PVT.load_char_value
193 (p_char_old => p_asset_fin_rec_old.global_attribute9,
194 p_char_adj => p_asset_fin_rec_adj.global_attribute9,
195 x_char_new => px_asset_fin_rec_new.global_attribute9);
196
197 FA_UTIL_PVT.load_char_value
198 (p_char_old => p_asset_fin_rec_old.global_attribute10,
199 p_char_adj => p_asset_fin_rec_adj.global_attribute10,
200 x_char_new => px_asset_fin_rec_new.global_attribute10);
201
202 FA_UTIL_PVT.load_char_value
203 (p_char_old => p_asset_fin_rec_old.global_attribute11,
204 p_char_adj => p_asset_fin_rec_adj.global_attribute11,
205 x_char_new => px_asset_fin_rec_new.global_attribute11);
206
207 FA_UTIL_PVT.load_char_value
208 (p_char_old => p_asset_fin_rec_old.global_attribute12,
209 p_char_adj => p_asset_fin_rec_adj.global_attribute12,
210 x_char_new => px_asset_fin_rec_new.global_attribute12);
211
212 FA_UTIL_PVT.load_char_value
213 (p_char_old => p_asset_fin_rec_old.global_attribute13,
214 p_char_adj => p_asset_fin_rec_adj.global_attribute13,
215 x_char_new => px_asset_fin_rec_new.global_attribute13);
216
217 FA_UTIL_PVT.load_char_value
218 (p_char_old => p_asset_fin_rec_old.global_attribute14,
219 p_char_adj => p_asset_fin_rec_adj.global_attribute14,
220 x_char_new => px_asset_fin_rec_new.global_attribute14);
221
222 FA_UTIL_PVT.load_char_value
223 (p_char_old => p_asset_fin_rec_old.global_attribute15,
224 p_char_adj => p_asset_fin_rec_adj.global_attribute15,
225 x_char_new => px_asset_fin_rec_new.global_attribute15);
226
227 FA_UTIL_PVT.load_char_value
228 (p_char_old => p_asset_fin_rec_old.global_attribute16,
229 p_char_adj => p_asset_fin_rec_adj.global_attribute16,
230 x_char_new => px_asset_fin_rec_new.global_attribute16);
231
232 FA_UTIL_PVT.load_char_value
233 (p_char_old => p_asset_fin_rec_old.global_attribute17,
234 p_char_adj => p_asset_fin_rec_adj.global_attribute17,
235 x_char_new => px_asset_fin_rec_new.global_attribute17);
236
237 FA_UTIL_PVT.load_char_value
238 (p_char_old => p_asset_fin_rec_old.global_attribute18,
239 p_char_adj => p_asset_fin_rec_adj.global_attribute18,
240 x_char_new => px_asset_fin_rec_new.global_attribute18);
241
242 FA_UTIL_PVT.load_char_value
243 (p_char_old => p_asset_fin_rec_old.global_attribute19,
244 p_char_adj => p_asset_fin_rec_adj.global_attribute19,
245 x_char_new => px_asset_fin_rec_new.global_attribute19);
246
247 FA_UTIL_PVT.load_char_value
248 (p_char_old => p_asset_fin_rec_old.global_attribute20,
249 p_char_adj => p_asset_fin_rec_adj.global_attribute20,
250 x_char_new => px_asset_fin_rec_new.global_attribute20);
251
252 FA_UTIL_PVT.load_char_value
253 (p_char_old => p_asset_fin_rec_old.global_attribute_category,
254 p_char_adj => p_asset_fin_rec_adj.global_attribute_category,
255 x_char_new => px_asset_fin_rec_new.global_attribute_category);
256
257 if (px_trans_rec.transaction_type_code = 'ADDITION' or
258 px_trans_rec.transaction_type_code = 'CIP ADDITION' or
259 px_trans_rec.transaction_type_code = 'GROUP ADDITION' or
260 px_trans_rec.transaction_type_code = 'ADJUSTMENT' or
261 px_trans_rec.transaction_type_code = 'CIP ADJUSTMENT' or
262 px_trans_rec.transaction_type_code = 'GROUP ADJUSTMENT') then
263
264 -- Bug:6021567
265 FA_UTIL_PVT.load_num_value
266 (p_num_old => p_asset_fin_rec_old.contract_id,
267 p_num_adj => p_asset_fin_rec_adj.contract_id,
268 x_num_new => px_asset_fin_rec_new.contract_id,
269 p_log_level_rec => p_log_level_rec);
270
271 px_asset_fin_rec_new.prorate_convention_code :=
272 nvl(p_asset_fin_rec_adj.prorate_convention_code,
273 nvl(p_asset_fin_rec_old.prorate_convention_code,
274 fa_cache_pkg.fazccbd_record.prorate_convention_code));
275 px_asset_fin_rec_new.depreciate_flag :=
276 nvl(p_asset_fin_rec_adj.depreciate_flag,
277 nvl(p_asset_fin_rec_old.depreciate_flag,
278 fa_cache_pkg.fazccbd_record.depreciate_flag));
279
280 --HH group ed.
281 px_asset_fin_rec_new.disabled_flag := p_asset_fin_rec_adj.disabled_flag;
282 --End HH
283 -- the following values can be nulled out either during
284 -- an adjustment (exc bonus) or during addition in comparison to
285 -- what would have been defaulted from the category.
286
287 -- note we check the old method because trx_type is not
288 -- enough as we only want the cat defaulting to occur
289 -- during the initial addition, not during a void in period of add
290
291 FA_UTIL_PVT.load_char_value
292 (p_char_old => p_asset_fin_rec_old.bonus_rule,
293 p_char_adj => p_asset_fin_rec_adj.bonus_rule,
294 x_char_new => px_asset_fin_rec_new.bonus_rule,
295 p_log_level_rec => p_log_level_rec);
296
297 -- do not allow the nulling out of bonus rule during adj
298 if (px_asset_fin_rec_new.bonus_rule is null and
299 p_asset_fin_rec_old.bonus_rule is not null) then
300 fa_srvr_msg.add_message(
301 calling_fn => l_calling_fn,
302 name => 'FA_DEPRN_UPDATE_BONUS_RULE');
303 raise calc_err;
304 end if;
305
306 FA_UTIL_PVT.load_char_value
307 (p_char_old => p_asset_fin_rec_old.ceiling_name,
308 p_char_adj => p_asset_fin_rec_adj.ceiling_name,
309 x_char_new => px_asset_fin_rec_new.ceiling_name,
310 p_log_level_rec => p_log_level_rec);
311
312 -- This is for FLAT RATE EXTENSION deprn basis rule
313 FA_UTIL_PVT.load_char_value
314 (p_char_old => p_asset_fin_rec_old.exclude_fully_rsv_flag,
315 p_char_adj => p_asset_fin_rec_adj.exclude_fully_rsv_flag,
316 x_char_new => px_asset_fin_rec_new.exclude_fully_rsv_flag,
320
317 p_log_level_rec => p_log_level_rec);
318
319 if p_asset_type_rec.asset_type <> 'GROUP' then
321 FA_UTIL_PVT.load_num_value
322 (p_num_old => p_asset_fin_rec_old.group_asset_id,
323 p_num_adj => p_asset_fin_rec_adj.group_asset_id,
324 x_num_new => px_asset_fin_rec_new.group_asset_id,
325 p_log_level_rec => p_log_level_rec);
326
327 -- validate new group info
328 if (px_asset_fin_rec_new.group_asset_id is not null) then
329 -- verify the asset exist in the book already
330 if not FA_ASSET_VAL_PVT.validate_group_asset
331 (p_group_asset_id => px_asset_fin_rec_new.group_asset_id,
332 p_book_type_code => p_asset_hdr_rec.book_type_code,
333 p_asset_type => p_asset_type_rec.asset_type,
334 p_log_level_rec => p_log_level_rec
335 ) then
336 raise calc_err;
337 end if;
338
339 end if;
340
341 end if;
342
343 if not calc_new_amounts
344 (px_trans_rec => px_trans_rec,
345 p_asset_hdr_rec => p_asset_hdr_rec,
346 p_asset_desc_rec => p_asset_desc_rec,
347 p_asset_type_rec => p_asset_type_rec,
348 p_asset_cat_rec => p_asset_cat_rec,
349 p_asset_fin_rec_old => p_asset_fin_rec_old,
350 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
351 px_asset_fin_rec_new => px_asset_fin_rec_new,
352 p_asset_deprn_rec_old => p_asset_deprn_rec_old,
353 p_asset_deprn_rec_adj => p_asset_deprn_rec_adj,
354 px_asset_deprn_rec_new => px_asset_deprn_rec_new,
355 p_mrc_sob_type_code => p_mrc_sob_type_code,
356 p_log_level_rec => p_log_level_rec
357 ) then
358 raise calc_err;
359 end if;
360
361 -- BUG# 3200703
362 -- do not allow amortization if not allowed at book level
363
364 if ((px_trans_rec.transaction_subtype = 'AMORTIZED' or
365 px_trans_rec.amortization_start_date is not null) and
366 fa_cache_pkg.fazcbc_record.amortize_flag = 'NO') then
367 fa_srvr_msg.add_message(
368 calling_fn => l_calling_fn,
369 name => 'FA_BOOK_AMORTIZED_NOT_ALLOW');
370 raise calc_err;
371 end if;
372
373 -- keeping this code after moving validate_asset_book call above
374 -- but not sure if it's correct ???
375 if (px_asset_fin_rec_new.group_asset_id is not null) then
376 if (px_asset_fin_rec_new.super_group_id is not null) then
377 -- *** validate super group exists ***
378 fa_srvr_msg.add_message(
379 calling_fn => l_calling_fn,
380 name => 'FA_NO_SUPER_GROUP_ALLOWED');
381 raise calc_err;
382 end if;
383 end if;
384
385 if (p_calling_fn = 'fa_cip_pvt.do_cap_rev') then
386 l_old_dpis := px_asset_fin_rec_new.date_placed_in_service;
387 else
388 l_old_dpis := p_asset_fin_rec_old.date_placed_in_service;
389 end if;
390
391 if not fa_asset_val_pvt.validate_dpis
392 (p_transaction_type_code => px_trans_rec.transaction_type_code,
393 p_book_type_code => p_asset_hdr_rec.book_type_code,
394 p_date_placed_in_service =>
395 px_asset_fin_rec_new.date_placed_in_service,
396 p_prorate_convention_code =>
397 px_asset_fin_rec_new.prorate_convention_code,
398 p_old_date_placed_in_service => -- Bug3724207
399 l_old_dpis, -- Bug3724207
400 p_asset_id => p_asset_hdr_rec.asset_id, -- Bug3724207
401 p_calling_interface => px_trans_rec.calling_interface,
402 p_calling_fn => l_calling_fn,
403 p_log_level_rec => p_log_level_rec,
404 p_transaction_subtype => px_trans_rec.transaction_subtype,
405 p_asset_type => p_asset_type_rec.asset_type -- bug 5501090
406 )then
407 raise calc_err;
408 end if;
409
410 if (px_asset_fin_rec_new.group_asset_id is not null) then
411 if not fa_asset_val_pvt.validate_member_dpis
412 (p_book_type_code => p_asset_hdr_rec.book_type_code,
413 p_date_placed_in_service =>
414 px_asset_fin_rec_new.date_placed_in_service,
415 p_group_asset_Id =>
416 px_asset_fin_rec_new.group_asset_id,
417 p_calling_fn => l_calling_fn,
418 p_log_level_rec => p_log_level_rec) then
419 raise calc_err;
420 end if;
421 end if;
422
423 if not fa_asset_val_pvt.validate_depreciate_flag
424 (p_depreciate_flag => px_asset_fin_rec_new.depreciate_flag,
425 p_calling_fn => l_calling_fn ,
426 p_log_level_rec => p_log_level_rec
427 ) then
428 raise calc_err;
429 end if;
430
431 -- need to calc the prorate date before calling calc_deprn_info
435 if not calc_prorate_date
432 -- due to subcomponent life rule defaulting
433
434
436 (p_asset_hdr_rec => p_asset_hdr_rec,
437 p_asset_type_rec => p_asset_type_rec,
438 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
439 px_asset_fin_rec_new => px_asset_fin_rec_new,
440 p_period_rec => p_period_rec,
441 p_log_level_rec => p_log_level_rec
442 ) then
443 raise calc_err;
444 end if;
445
446 if not calc_deprn_info
447 (p_trans_rec => px_trans_rec,
448 p_asset_hdr_rec => p_asset_hdr_rec,
449 p_asset_desc_rec => p_asset_desc_rec,
450 p_asset_cat_rec => p_asset_cat_rec,
451 p_asset_type_rec => p_asset_type_rec,
452 p_asset_fin_rec_old => p_asset_fin_rec_old,
453 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
454 px_asset_fin_rec_new => px_asset_fin_rec_new,
455 p_asset_deprn_rec_adj => p_asset_deprn_rec_adj,
456 p_asset_deprn_rec_new => px_asset_deprn_rec_new,
457 p_period_rec => p_period_rec,
458 p_log_level_rec => p_log_level_rec
459 ) then
460 raise calc_err;
461 end if;
462
463 if not calc_derived_amounts
464 (px_trans_rec => px_trans_rec,
465 p_asset_hdr_rec => p_asset_hdr_rec,
466 p_asset_desc_rec => p_asset_desc_rec,
467 p_asset_type_rec => p_asset_type_rec,
468 p_asset_cat_rec => p_asset_cat_rec,
469 p_asset_fin_rec_old => p_asset_fin_rec_old,
470 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
471 px_asset_fin_rec_new => px_asset_fin_rec_new,
472 p_asset_deprn_rec_old => p_asset_deprn_rec_old,
473 p_asset_deprn_rec_adj => p_asset_deprn_rec_adj,
474 px_asset_deprn_rec_new => px_asset_deprn_rec_new,
475 p_period_rec => p_period_rec,
476 p_mrc_sob_type_code => p_mrc_sob_type_code,
477 p_log_level_rec => p_log_level_rec
478 ) then
479 raise calc_err;
480 end if;
481
482 if p_asset_type_rec.asset_type <> 'GROUP' then
483
484 -- member level information must be copied from old to new
485
486 if px_asset_fin_rec_new.group_asset_id is not null then
487
488 if not calc_member_info
489 (p_trans_rec => px_trans_rec,
490 p_asset_hdr_rec => p_asset_hdr_rec,
491 p_asset_fin_rec_old => p_asset_fin_rec_old,
492 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
493 px_asset_fin_rec_new => px_asset_fin_rec_new,
494 p_asset_deprn_rec_old => p_asset_deprn_rec_old,
495 p_log_level_rec => p_log_level_rec
496 ) then
497 raise calc_err;
498 end if;
499
500 else
501
502 if not calc_standalone_info
503 (p_asset_hdr_rec => p_asset_hdr_rec,
504 p_asset_fin_rec_old => p_asset_fin_rec_old,
505 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
506 px_asset_fin_rec_new => px_asset_fin_rec_new,
507 p_asset_deprn_rec_new => px_asset_deprn_rec_new,
508 p_log_level_rec => p_log_level_rec
509 ) then
510 raise calc_err;
511 end if;
512 end if; -- (px_asset_fin_rec_new.group_asset_id is not null)
513
514 else -- Asset type is Group
515 --HH Validate disabled_flag
516 if not FA_ASSET_VAL_PVT.validate_disabled_flag
517 (p_group_asset_id => px_asset_fin_rec_new.group_asset_id,
518 p_book_type_code => p_asset_hdr_rec.book_type_code,
519 p_old_flag => p_asset_fin_rec_old.disabled_flag,
520 p_new_flag => px_asset_fin_rec_new.disabled_flag,
521 p_log_level_rec => p_log_level_rec
522 ) then
523 raise calc_err;
524 end if;
525
526 --Check for flag change
527 if nvl(p_asset_fin_rec_old.disabled_flag, FND_API.G_MISS_CHAR) <>
528 nvl(px_asset_fin_rec_new.disabled_flag,
529 nvl(p_asset_fin_rec_old.disabled_flag, FND_API.G_MISS_CHAR)) then
530 l_disabled_flag_changed := TRUE;
531 end if;--End HH
532 -- the following line is where we could allowed multi-tier
533 -- group associates / hierarchies is desired
534 px_asset_fin_rec_new.group_asset_id := NULL;
535
536 if (p_log_level_rec.statement_level) then
537 fa_debug_pkg.add('calc_new_info before calc group',
538 'p_asset_fin_rec_adj.over_depreciate_option',
539 p_asset_fin_rec_adj.over_depreciate_option);
540 end if;
541
542 if not FA_ASSET_VAL_PVT.validate_super_group (
543 p_book_type_code => p_asset_hdr_rec.book_type_code,
547 p_log_level_rec => p_log_level_rec) then
544 p_old_super_group_id => p_asset_fin_rec_old.super_group_id,
545 p_new_super_group_id => px_asset_fin_rec_new.super_group_id,
546 p_calling_fn => l_calling_fn,
548
549 if (p_log_level_rec.statement_level) then
550 fa_debug_pkg.add(l_calling_fn, 'Error calling function', 'FA_ASSET_VAL_PVT.validate_super_group');
551 end if;
552
553 raise calc_err;
554 end if;
555
556 if not calc_group_info
557 (p_trans_rec => px_trans_rec,
558 p_asset_hdr_rec => p_asset_hdr_rec,
559 p_asset_fin_rec_old => p_asset_fin_rec_old,
560 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
561 px_asset_fin_rec_new => px_asset_fin_rec_new,
562 p_asset_deprn_rec_old => p_asset_deprn_rec_old,
563 p_log_level_rec => p_log_level_rec
564 ) then
565 raise calc_err;
566 end if;
567
568 -- SLA: ***REVISIT***
569
570 if p_asset_hdr_rec.period_of_addition = 'Y' then
571 l_temp_deprn_reserve := px_asset_deprn_rec_new.deprn_reserve;
572 else
573 l_temp_deprn_reserve := to_number(null);
574 end if;
575
576 if not fa_asset_val_pvt.validate_over_depreciate
577 (p_asset_hdr_rec => p_asset_hdr_rec,
578 p_asset_type => p_asset_type_rec.asset_type,
579 p_over_depreciate_option => px_asset_fin_rec_new.over_depreciate_option,
580 p_adjusted_recoverable_cost => px_asset_fin_rec_new.adjusted_recoverable_cost,
581 p_recoverable_cost => px_asset_fin_rec_new.recoverable_cost,
582 p_deprn_reserve_new => l_temp_deprn_reserve,
583 p_rate_source_rule => fa_cache_pkg.fazccmt_record.rate_source_rule,
584 p_deprn_basis_rule => fa_cache_pkg.fazccmt_record.deprn_basis_rule,
585 p_recapture_reserve_flag => px_asset_fin_rec_new.recapture_reserve_flag,
586 p_deprn_limit_type => px_asset_fin_rec_new.deprn_limit_type,
587 p_log_level_rec => p_log_level_rec
588 ) then
589 raise calc_err;
590 end if;
591
592 end if; --p_asset_type_rec.asset_type
593
594 -- Check to prevent prior period trx with Energy UOP
595 if not FA_ASSET_VAL_PVT.validate_egy_prod_date (
596 p_calendar_period_start_date => p_period_rec.calendar_period_open_date,
597 p_transaction_date => nvl(px_trans_rec.amortization_start_date,
598 px_trans_rec.transaction_date_entered),
599 p_transaction_key => px_trans_rec.transaction_key,
600 p_rate_source_rule => fa_cache_pkg.fazccmt_record.rate_source_rule,
601 p_rule_name => fa_cache_pkg.fazcdrd_record.rule_name,
602 p_calling_fn => l_calling_fn,
603 p_log_level_rec => p_log_level_rec) then
604 if (p_log_level_rec.statement_level) then
605 fa_debug_pkg.add(l_calling_fn, 'Failed calling',
606 'FA_ASSET_VAL_PVT.validate_egy_prod_date');
607 end if;
608 raise calc_err;
609 end if;
610
611 if (px_trans_rec.transaction_type_code in
612 ('ADDITION', 'CIP ADDITION', 'GROUP ADDITION',
613 'ADJUSTMENT', 'CIP ADJUSTMENT', 'GROUP ADJUSTMENT')) then
614
615 -- Fix for Bug #3187975. Do Polish rule validations.
616
617 -- Check adjustment (since old rec is null for regular addition)
618 -- For adjustment, this is to prevent a method change out of a
619 -- polish rule as well as a regular adjustment.
620 if (p_asset_fin_rec_old.deprn_method_code is not null) then
621 if not FA_ASSET_VAL_PVT.validate_polish (
622 p_transaction_type_code => 'ADJUSTMENT',
623 p_method_code => p_asset_fin_rec_old.deprn_method_code,
624 p_life_in_months => p_asset_fin_rec_old.life_in_months,
625 p_asset_type => p_asset_type_rec.asset_type,
626 p_bonus_rule => p_asset_fin_rec_old.bonus_rule,
627 p_ceiling_name => p_asset_fin_rec_old.ceiling_name,
628 p_deprn_limit_type => p_asset_fin_rec_old.deprn_limit_type,
629 p_group_asset_id => p_asset_fin_rec_old.group_asset_id,
630 p_calling_fn => l_calling_fn,
631 p_log_level_rec => p_log_level_rec
632 ) then
633 raise calc_err;
634 end if;
635
636 -- For adjustment, this is to prevent a method change into a
637 -- polish rule as well as a regular adjustment.
638 if not FA_ASSET_VAL_PVT.validate_polish (
639 p_transaction_type_code => 'ADJUSTMENT',
640 p_method_code =>
641 px_asset_fin_rec_new.deprn_method_code,
642 p_life_in_months => px_asset_fin_rec_new.life_in_months,
643 p_asset_type => p_asset_type_rec.asset_type,
647 p_calling_fn => l_calling_fn,
644 p_bonus_rule => px_asset_fin_rec_new.bonus_rule,
645 p_ceiling_name => px_asset_fin_rec_new.ceiling_name,
646 p_deprn_limit_type => px_asset_fin_rec_new.deprn_limit_type, p_group_asset_id => px_asset_fin_rec_new.group_asset_id,
648 p_log_level_rec => p_log_level_rec
649 ) then
650 raise calc_err;
651 end if;
652 else
653 -- Validate addition since old rec is null.
654 if not FA_ASSET_VAL_PVT.validate_polish (
655 p_transaction_type_code => 'ADDITION',
656 p_method_code =>
657 px_asset_fin_rec_new.deprn_method_code,
658 p_life_in_months => px_asset_fin_rec_new.life_in_months,
659 p_asset_type => p_asset_type_rec.asset_type,
660 p_bonus_rule => px_asset_fin_rec_new.bonus_rule,
661 p_ceiling_name => px_asset_fin_rec_new.ceiling_name,
662 p_deprn_limit_type => px_asset_fin_rec_new.deprn_limit_type,
663 p_group_asset_id => px_asset_fin_rec_new.group_asset_id,
664 p_date_placed_in_service
665 =>
666 px_asset_fin_rec_new.date_placed_in_service,
667 p_calendar_period_open_date
668 =>
669 p_period_rec.calendar_period_open_date,
670 p_ytd_deprn => px_asset_deprn_rec_new.ytd_deprn,
671 p_deprn_reserve => px_asset_deprn_rec_new.deprn_reserve,
672 p_calling_fn => l_calling_fn,
673 p_log_level_rec => p_log_level_rec
674 ) then
675 raise calc_err;
676 end if;
677 end if;
678 end if;
679
680 -- perform final validation on all calculated amounts
681 -- and only do so in the period of addition
682
683 -- do not perform this check on groups nor on assets which
684 -- may have been in a group during the period of addition
685 -- the latter poses a problem in that this could be called
686 -- from a transaction following a group reclass such that
687 -- there is no difference in old and new. We might have
688 -- do see if the asset was ever in a group than bypass
689
690 -- SLA Uptake
691 -- further restricting only to the first ADDITION
692
693 if (p_asset_hdr_rec.period_of_addition = 'Y' and
694 p_asset_type_rec.asset_type <> 'GROUP' and
695 p_asset_fin_rec_old.group_asset_id is null and
696 px_asset_fin_rec_new.group_asset_id is null and
697 (px_trans_rec.transaction_type_code = 'ADDITION' or
698 px_trans_rec.transaction_type_code = 'CIP ADDITION')) then
699
700 -- BUG# 2323997
701 -- no longer calling validate_rec_cost_reserve here
702 -- as it is handled by the following check for non-deprn-basis
703 -- assets... also changed passed value to be adj_rec_cost - BMR
704
705 if not fa_asset_val_pvt.validate_adj_rec_cost
706 (p_adjusted_recoverable_cost => px_asset_fin_rec_new.adjusted_recoverable_cost,
707 p_deprn_reserve => px_asset_deprn_rec_new.deprn_reserve,
708 p_calling_fn => l_calling_fn,
709 p_log_level_rec => p_log_level_rec
710 ) then
711 raise calc_err;
712 end if;
713
714 if not fa_asset_val_pvt.validate_ytd_reserve
715 (p_book => p_asset_hdr_rec.book_type_code,
716 p_date_placed_in_service => px_asset_fin_rec_new.date_placed_in_service,
717 p_asset_type => p_asset_type_rec.asset_type,
718 p_ytd_deprn => px_asset_deprn_rec_new.ytd_deprn,
719 p_deprn_reserve => px_asset_deprn_rec_new.deprn_reserve,
720 p_bonus_ytd_deprn => px_asset_deprn_rec_new.bonus_ytd_deprn,
721 p_bonus_deprn_reserve => px_asset_deprn_rec_new.bonus_deprn_reserve,
722 p_reval_reserve => px_asset_deprn_rec_new.reval_deprn_reserve,
723 p_ytd_reval_deprn_expense => px_asset_deprn_rec_new.reval_ytd_deprn,
724 p_reval_amortization_basis => px_asset_fin_rec_new.reval_amortization_basis,
725 p_fully_rsvd_revals_counter => px_asset_fin_rec_new.fully_rsvd_revals_counter,
726 p_period_rec => p_period_rec,
727 p_calling_fn => l_calling_fn,
728 p_log_level_rec => p_log_level_rec
729 ) then
730 raise calc_err;
731 end if;
732 end if;
733
734 if (p_log_level_rec.statement_level) then
735 fa_debug_pkg.add('calc_fin_info',
736 'px_asset_fin_rec_new.production_capacity',
737 px_asset_fin_rec_new.production_capacity);
738 fa_debug_pkg.add('calc_fin_info',
739 'px_asset_deprn_rec_new.ltd_prod',
740 px_asset_deprn_rec_new.ltd_production);
741 fa_debug_pkg.add('calc_fin_info',
745 'px_asset_fin_rec_new.short_fiscal_year_flag',
742 'px_asset_deprn_rec_new.ytd_prod',
743 px_asset_deprn_rec_new.ytd_production);
744 fa_debug_pkg.add('calc_fin_info',
746 px_asset_fin_rec_new.short_fiscal_year_flag);
747 end if;
748
749 -- New Adjustments Behavior
750 -- ------------------------
751 -- Original versions simply called faadjust as usual.
752 -- New model is as follows:
753 --
754 -- 1) the invoice engine will cllear all payables cost against
755 -- the payables ccid for each line (prim and reporting)
756 -- 2) faadjust is called with ins_adj passed as false
757 -- and returns the amounts for expense and bonus expense
758 -- 3) we determine any difference between the payables cost cleared
759 -- and the delta cost which still needs to be flex built and posted
760 -- 4) we pass all four amounts to a new version of faxiat which
761 -- will insert them
762 --
763 -- Note: we can potentially enabled this at the time of addition
764 -- as well instead of relying on CJE when desired.
765
766 if not fa_cache_pkg.fazccmt
767 (X_method => px_asset_fin_rec_new.Deprn_Method_Code,
768 X_life => px_asset_fin_rec_new.Life_In_Months,
769 p_log_level_rec => p_log_level_rec
770 ) then
771 raise calc_err;
772 end if;
773
774 l_method_id := fa_cache_pkg.fazccmt_record.method_id;
775 l_rate_source_rule := fa_cache_pkg.fazccmt_record.rate_source_rule;
776 l_deprn_basis_rule := fa_cache_pkg.fazccmt_record.deprn_basis_rule;
777
778 ----------------------------------------------
779 -- Call Depreciable Basis Rule
780 -- Event type: Initial Addition
781 -- This event type calculates adjusted_cost
782 -- at the period of DPIS.
783 ----------------------------------------------
784 /*while manually adjusting reserve in period of addition we should not call it as
785 there is no effect on cost bug 4439919*/
786
787 /* Bug7678082: Raf,adj_cost,ff need to calculated for group asset with reserve
788 adjustment even in period of addition */
789
790
791 if (not FA_CALC_DEPRN_BASIS1_PKG.CALL_DEPRN_BASIS
792 (
793 p_event_type => 'INITIAL_ADDITION',
794 p_asset_fin_rec_new => px_asset_fin_rec_new,
795 p_asset_fin_rec_old => p_asset_fin_rec_old,
796 p_asset_hdr_rec => p_asset_hdr_rec,
797 p_asset_type_rec => p_asset_type_rec,
798 p_asset_deprn_rec => px_asset_deprn_rec_new,
799 p_trans_rec => px_trans_rec,
800 p_period_rec => p_period_rec,
801 p_used_by_adjustment => 'ADJUSTMENT',
802 p_mrc_sob_type_code => p_mrc_sob_type_code,
803 px_new_adjusted_cost => px_asset_fin_rec_new.adjusted_cost,
804 px_new_raf => px_asset_fin_rec_new.rate_adjustment_factor,
805 px_new_formula_factor => px_asset_fin_rec_new.formula_factor,
806 p_log_level_rec => p_log_level_rec
807 )
808 )
809 then
810 raise calc_err;
811 end if;
812
813 if (p_log_level_rec.statement_level) then
814 fa_debug_pkg.add('calc_fin_info', 'trx_subtype',px_trans_rec.transaction_subtype );
815 fa_debug_pkg.add('calc_fin_info',
816 'transaction_type_code',
817 px_trans_rec.transaction_type_code);
818 end if;
819
820 if (px_trans_rec.transaction_subtype = 'AMORTIZED') then
821
822 -- validate the amortization_start_date (do for add and adj)
823 -- when not in period of addition, amort date is set to trx date
824 -- BUG# 3194910 - for group, only do this for direct adjustments
825 -- and not those spawned by members
826
827 if (px_trans_rec.transaction_type_code = 'ADJUSTMENT' or
828 px_trans_rec.transaction_type_code = 'CIP ADJUSTMENT' or
829 (px_trans_rec.transaction_type_code = 'GROUP ADJUSTMENT' and
830 px_trans_rec.transaction_key = 'GJ')) then
831 l_amortization_start_date := px_trans_rec.transaction_date_entered;
832 else
833 l_amortization_start_date := px_trans_rec.amortization_start_date;
834 end if;
835
836 -- Fix for Bug #2668073. Need to pass different variables to OUT
837 -- NOCOPY and IN parameters for amort start date;
838 l_old_amortization_start_date := l_amortization_start_date;
839
840
841 if not FA_ASSET_VAL_PVT.validate_amort_start_date
842 (p_transaction_type_code => px_trans_rec.transaction_type_code,
843 p_asset_id => p_asset_hdr_rec.asset_id,
844 p_book_type_code => p_asset_hdr_rec.book_type_code,
845 p_date_placed_in_service => px_asset_fin_rec_new.date_placed_in_service,
846 p_conversion_date => px_asset_fin_rec_new.conversion_date,
850 p_rate_source_rule => fa_cache_pkg.fazccmt_record.rate_source_rule,
847 p_period_rec => p_period_rec,
848 p_amortization_start_date => l_old_amortization_start_date,
849 p_db_rule_name => fa_cache_pkg.fazcdrd_record.rule_name,
851 p_transaction_key => px_trans_rec.transaction_key,
852 x_amortization_start_date => l_amortization_start_date,
853 x_trxs_exist => l_trxs_exist,
854 p_calling_fn => l_calling_fn,
855 p_log_level_rec => p_log_level_rec) then
856 raise calc_err;
857 end if;
858
859 if (px_trans_rec.transaction_type_code = 'ADJUSTMENT' or
860 px_trans_rec.transaction_type_code = 'CIP ADJUSTMENT' or
861 px_trans_rec.transaction_type_code = 'GROUP ADJUSTMENT') then
862 px_trans_rec.transaction_date_entered := l_amortization_start_date;
863 px_trans_rec.amortization_start_date := l_amortization_start_date;
864 else
865 px_trans_rec.amortization_start_date := l_amortization_start_date;
866 end if;
867 end if;
868
869 if (px_trans_rec.transaction_subtype = 'AMORTIZED') and
870 (px_trans_rec.transaction_type_code = 'ADJUSTMENT' or
871 px_trans_rec.transaction_type_code = 'CIP ADJUSTMENT') then
872
873 if not FA_ASSET_VAL_PVT.validate_cost_change (
874 p_asset_id => p_asset_hdr_rec.asset_id,
875 p_group_asset_id => px_asset_fin_rec_new.group_asset_id, --hh
876 p_book_type_code => p_asset_hdr_rec.book_type_code,
877 p_asset_type => p_asset_type_rec.asset_type,
878 p_transaction_header_id => px_trans_rec.transaction_header_id,
879 p_transaction_date => nvl(px_trans_rec.amortization_start_date,
880 px_trans_rec.transaction_date_entered),
881 p_cost => p_asset_fin_rec_old.cost,
882 p_cost_adj => p_asset_fin_rec_adj.cost,
883 p_salvage_value => p_asset_fin_rec_old.salvage_value,
884 p_salvage_value_adj => p_asset_fin_rec_adj.salvage_value,
885 p_deprn_limit_amount => p_asset_fin_rec_old.allowed_deprn_limit_amount,
886 p_deprn_limit_amount_adj => p_asset_fin_rec_adj.allowed_deprn_limit_amount,
887 p_mrc_sob_type_code => p_mrc_sob_type_code,
888 p_over_depreciate_option => px_asset_fin_rec_new.over_depreciate_option, --hh
889 p_log_level_rec => p_log_level_rec) then
890 raise calc_err;
891 end if;
892
893 end if;
894
895 -- note: we want to pick up adjustments to group assets in the period
896 -- of addition, but not the initial shell. in that case, the
897 -- old struct will be null so comparing that
898
899 -- do not pick up such groups if an initial reserve adjustment has
900 -- already been performed
901
902 -- SLA: since voids are obsolete changing the condition
903
904 -- if (px_trans_rec.transaction_type_code = 'GROUP ADDITION' and
905
906 if (px_trans_rec.transaction_type_code = 'GROUP ADJUSTMENT' and
907 p_asset_hdr_rec.period_of_addition = 'Y' and
908 p_asset_fin_rec_old.rate_adjustment_factor is not null ) then
909 select count(*)
910 into l_deprn_reserve_exists
911 from fa_deprn_summary
912 where asset_id = p_asset_hdr_rec.asset_id
913 and book_type_code = p_asset_hdr_rec.book_type_code
914 and deprn_source_code = 'BOOKS'
915 and deprn_reserve <> 0;
916
917 if (p_log_level_rec.statement_level) then
918 fa_debug_pkg.add('calc_fin_info', 'l_deprn_reserve_exists for group', l_deprn_reserve_exists, p_log_level_rec);
919 end if;
920
921 end if;
922
923 if (p_log_level_rec.statement_level) then
924 fa_debug_pkg.add(l_calling_fn, 'p_asset_fin_rec_old.rate_adjustment_factor', p_asset_fin_rec_old.rate_adjustment_factor, p_log_level_rec);
925 fa_debug_pkg.add(l_calling_fn, 'l_deprn_reserve_exists', l_deprn_reserve_exists, p_log_level_rec);
926 fa_debug_pkg.add(l_calling_fn, 'p_asset_deprn_rec_adj.deprn_reserve', p_asset_deprn_rec_adj.deprn_reserve, p_log_level_rec);
927 end if;
928
929 -- SLA Uptake
930 -- enter this code for additions and adjustments in period of addition
931 -- to force catchup where needed too
932 -- ** doesn't work coes asset isn't inserted yet **
933
934 /* if (px_trans_rec.transaction_type_code = 'ADJUSTMENT' or
935 px_trans_rec.transaction_type_code = 'CIP ADJUSTMENT' or
936 px_trans_rec.transaction_type_code = 'GROUP ADJUSTMENT' or
937 -- SLA: adding next two lines for capitalization
938 (px_trans_rec.transaction_type_code = 'ADDITION' and
939 p_asset_fin_rec_old.rate_adjustment_factor is not null) or
940 -- (px_trans_rec.transaction_type_code = 'ADDITION' and
941 -- px_asset_fin_rec_new.annual_deprn_rounding_flag <> 'RES') or
942 (px_trans_rec.transaction_type_code = 'GROUP ADDITION' and
943 p_asset_fin_rec_old.rate_adjustment_factor is not null and
944 l_deprn_reserve_exists = 0 and
948 there is no effect on cost bug 4439919*/
945 nvl(p_asset_deprn_rec_adj.deprn_reserve, 0) = 0)) then
946
947 while manually adjusting reserve in period of addition we should not call it as
949
950 -- Bug7017134: Modified condition below to handle adjustment in period of
951 -- group addition. Following condition has to be true in order to properly
952 -- skip call to any functions in faxama
953 if ( px_trans_rec.transaction_type_code = 'ADJUSTMENT' or
954 px_trans_rec.transaction_type_code = 'CIP ADJUSTMENT' or
955 ( px_trans_rec.transaction_type_code = 'GROUP ADJUSTMENT'
956 and nvl(l_deprn_reserve_exists,0) = 0
957 and (px_trans_rec.transaction_key <> 'GJ' or
958 (px_trans_rec.transaction_key = 'GJ' and nvl(p_asset_deprn_rec_adj.deprn_reserve, 0) = 0))
959 )
960 )
961 or ( px_trans_rec.transaction_type_code = 'ADDITION' and
962 p_asset_fin_rec_old.rate_adjustment_factor is not null
963 ) then
964
965 if (p_log_level_rec.statement_level) then
966 fa_debug_pkg.add('calc_fin_info', 'in adjustment logic', 'before check for dep_flag', p_log_level_rec);
967 end if;
968
969 -- much of this logic is based upon faxfa2b.pls
970
971 if (px_trans_rec.transaction_subtype = 'AMORTIZED' and
972 px_asset_fin_rec_new.cost <> 0) or
973 (px_trans_rec.transaction_type_code = 'GROUP ADJUSTMENT' or
974 px_trans_rec.transaction_type_code = 'GROUP ADDITION') then
975 l_adjust_type := 'AMORTIZED';
976 else
977 l_adjust_type := 'EXPENSED';
978 end if;
979
980 -- temporarily adding this until they are correctly built into the calc routines
981 px_asset_fin_rec_new.rate_adjustment_factor := p_asset_fin_rec_old.rate_adjustment_factor;
982 px_asset_fin_rec_new.formula_factor := 1;
983
984 -- Bug#3845714
985 -- Following logic was added not to process BS for Sumup Case (to fix Bug3737670)
986 -- Now Sumup Group will not be processed for FA_ADJ row
987 if (px_asset_fin_rec_new.group_asset_id is null and
988 nvl(px_asset_fin_rec_new.member_rollup_flag,'N') = 'Y') then
989 l_call_bs := FALSE;
990 end if;
991
992 -- SLA Uptake
993 -- adding nvl around old value since additions will enter this code now -- also entering this logic when dep flag is set to yes when
994 -- previously was no
995
996 if ((px_asset_fin_rec_new.depreciate_flag = nvl(p_asset_fin_rec_old.depreciate_flag,
997 px_asset_fin_rec_new.depreciate_flag) or
998 (px_asset_fin_rec_new.depreciate_flag = 'YES' and
999 nvl(p_asset_fin_rec_old.depreciate_flag, 'YES') = 'NO' and
1000 px_asset_fin_rec_new.adjustment_required_status = 'ADD')) and
1001 --HH only if disabled_flag is not Y.
1002 nvl(px_asset_fin_rec_new.disabled_flag,'N') = nvl(p_asset_fin_rec_old.disabled_flag,'N') and
1003 nvl(px_asset_fin_rec_new.reval_ceiling, 0) = nvl(p_asset_fin_rec_old.reval_ceiling, 0)) then
1004
1005 if (p_log_level_rec.statement_level) then
1006 fa_debug_pkg.add('calc_fin_info', 'inside',
1007 'main adjustment logic');
1008 fa_debug_pkg.add('calc_fin_info', 'calling_interface', px_trans_rec.calling_interface);
1009 fa_debug_pkg.add('calc_fin_info', 'TRX_KEY before faxama', px_trans_rec.transaction_key);
1010 fa_debug_pkg.add('calc_fin_info', 'group_reclass_type before faxama',
1011 p_group_reclass_options_rec.group_reclass_type);
1012
1013 end if;
1014
1015 -- BUG# 4684363
1016 -- removing validation originally added for FA_NO_GC_CALC_FULLYRSV
1017 -- see older code for details
1018
1019 if ((px_asset_fin_rec_new.group_asset_id is null and
1020 nvl(px_asset_fin_rec_new.member_rollup_flag,'N') <> 'Y') or
1021 (px_asset_fin_rec_new.group_asset_id is not null and
1022 nvl(px_asset_fin_rec_new.tracking_method,'NULL') = 'CALCULATE')) then
1023
1024 -- new method
1025 -- BUG# 3134846
1026 -- need to account for the value of l_adjust_type rather than just
1027 -- just the value of the subtype here (see above)
1028 --
1029 -- if (px_trans_rec.transaction_subtype = 'AMORTIZED' and
1030 if (l_adjust_type = 'AMORTIZED' and
1031 --HH
1032 (nvl(px_asset_fin_rec_new.disabled_flag,'N') = 'N')) then
1033
1034 l_call_faxama := TRUE;
1035
1036 -- BUG# 6987729
1037 -- determine reclass case in order to skip calc/expense logic
1038 -- when inbound or outbound from a group
1039 -- and avoid calling as we don't want to double the
1040 -- hits to faxama/faxinaj here and in favgrecb.pls
1041
1042 if ((nvl(px_asset_fin_rec_new.group_asset_id, -99) <>
1043 nvl(p_asset_fin_rec_old.group_asset_id, -99)) AND
1044 (px_asset_fin_rec_new.group_asset_id is null OR
1045 p_asset_fin_rec_old.group_asset_id is null)) then
1049
1046 l_call_faxama := FALSE;
1047 l_call_bs := FALSE;
1048 end if;
1050 -- if called from faxasset set flag for conc program
1051 -- to call faxama for backdated transactions.
1052 -- This is for backdated transactions that affect a group
1053 -- asset so that faxama is not invoked from form but from
1054 -- process group adjustments.
1055
1056 --
1057 -- This is the place where prior period transaction and group reclass
1058 -- to be processed with Process Group Adjustment concurrent program.
1059 -- Comment following if statement out for testing with script.
1060 -- There are 5 more places needs to be commented out in FAVGRECB.pls in
1061 -- order to make process to be done without concurrent program
1062 --
1063 if (px_trans_rec.calling_interface = 'FAXASSET') then
1064 if (p_asset_type_rec.asset_type = 'GROUP') then
1065 if (px_trans_rec.transaction_key in(
1066 'MA','MJ','MC','MV','MD','MN','GJ') and
1067 px_trans_rec.amortization_start_date <
1068 p_period_rec.calendar_period_open_date) then
1069
1070 px_asset_fin_rec_new.adjustment_required_status := 'GADJ';
1071 l_call_faxama := FALSE;
1072 l_call_bs := FALSE;
1073 elsif (px_trans_rec.transaction_key = 'GC' and
1074 p_group_reclass_options_rec.group_reclass_type = 'CALC') then
1075 px_asset_fin_rec_new.adjustment_required_status := 'GADJ';
1076 l_call_faxama := FALSE;
1077 l_call_bs := FALSE;
1078 elsif (px_trans_rec.transaction_key = 'GC' and
1079 p_group_reclass_options_rec.group_reclass_type = 'MANUAL') then
1080 l_call_faxama := FALSE;
1081 l_call_bs := FALSE;
1082 elsif (px_trans_rec.transaction_key in ('MR', 'MS')) and -- ENERGY
1083 (px_asset_fin_rec_new.tracking_method = 'ALLOCATE') and -- ENERGY
1084 (fa_cache_pkg.fazcdrd_record.rule_name = 'ENERGY PERIOD END BALANCE') then -- ENERGY
1085 -- Energy implementation requires FA_RETIREMENT_PVT.Do_Allocate to -- ENERGY
1086 -- be called from Process Group Adjsutment Conc program. -- ENERGY
1087 px_asset_fin_rec_new.adjustment_required_status := 'GADJ'; -- ENERGY
1088 end if;
1089 elsif (p_asset_type_rec.asset_type <> 'GROUP' and
1090 p_asset_fin_rec_old.group_asset_id is not null and
1091 px_asset_fin_rec_new.group_asset_id is null and
1092 p_group_reclass_options_rec.group_reclass_type is not null) then
1093 l_call_faxama := FALSE;
1094 l_call_bs := FALSE;
1095 end if;
1096 end if;
1097 --
1098 --
1099 --
1100
1101 if (p_log_level_rec.statement_level) then
1102 fa_debug_pkg.add('calc_fin_info', 'adjustment_required_status',
1103 px_asset_fin_rec_new.adjustment_required_status);
1104 fa_debug_pkg.add('calc_fin_info', 'l_call_faxama', l_call_faxama);
1105 end if;
1106
1107 --HH we want to skip over faxama and faxexp below if disabled_flag is 'Y'
1108 if l_disabled_flag_changed then
1109 if (p_log_level_rec.statement_level) then
1110 fa_debug_pkg.add('calc_fin_info', 'Disabled_flag Change', l_disabled_flag_changed);
1111 end if;
1112 l_call_faxama := FALSE;
1113 end if; --end HH
1114
1115 --* Bug#3737670
1116 -- Skip to call faxama if the processing asset and transaction is matched with followings.
1117 -- Transaction - Group Reclassification
1118 -- Tracking Method - Calculate
1119 -- Depreciation Option - Member
1120 if nvl(px_asset_fin_rec_new.group_asset_id,-99) <> nvl(p_asset_fin_rec_old.group_asset_id,-99) and
1121 nvl(px_asset_fin_rec_new.tracking_method,'NONE') = 'CALCULATE' and
1122 nvl(px_asset_fin_rec_new.depreciation_option,'NONE') = 'MEMBER' then
1123 if (p_log_level_rec.statement_level) then
1124 fa_debug_pkg.add('calc_fin_info', 'Skip faxama since group reclass in calculate and Member', 'l_call_faxama is FALSE');
1125 end if;
1126 l_call_faxama := FALSE;
1127 end if;
1128
1129 -- Fix for Bug #3846324. Do not call faxama if the asset is not depreciating. We
1130 -- do not want a deprn expense catchup row created here.
1131 -- Bug4318400: for group(non-sumup group), faxama needs to be called.
1132 -- Not to call faxama for sumup group is taken care before this point
1136 end if;
1133 if (px_asset_fin_rec_new.depreciate_flag = 'NO') and
1134 (p_asset_type_rec.asset_type <> 'GROUP') then
1135 l_call_faxama := FALSE;
1137
1138 -- Bug4958977: Adding following entire if statement.
1139 -- trx could be dpis change if following conditions are met
1140 -- even though trx date is in current period
1141 if (px_trans_rec.transaction_key = 'MJ' and
1142 nvl(p_asset_fin_rec_adj.cost, 0) = 0 and
1143 nvl(p_asset_fin_rec_adj.cip_cost, 0) = 0 and
1144 nvl(p_asset_fin_rec_adj.salvage_value, 0) = 0 and
1145 nvl(p_asset_fin_rec_adj.allowed_deprn_limit_amount, 0) = 0) and
1146 (nvl(px_trans_rec.amortization_start_date,
1147 px_trans_rec.transaction_date_entered) >=
1148 p_period_rec.calendar_period_open_date) then
1149
1150 if (p_log_level_rec.statement_level) then
1151 fa_debug_pkg.add('calc_fin_info', 'could be dpis change', 'cont');
1152 end if;
1153
1154 OPEN c_check_dpis_change;
1155 FETCH c_check_dpis_change INTO l_temp_thid;
1156 CLOSE c_check_dpis_change;
1157
1158 if (p_log_level_rec.statement_level) then
1159 fa_debug_pkg.add('calc_fin_info', 'temp_thid', l_temp_thid);
1160 end if;
1161
1162 if (l_temp_thid is not null) then
1163 l_dpis_change := TRUE;
1164 else
1165 l_dpis_change := FALSE;
1166 end if;
1167 end if;
1168
1169 -- Call faxama only if this is prior period trx
1170 -- Bug4958977: Added condition "or (l_dpis_change)"
1171 if (((p_period_rec.calendar_period_open_date >
1172 px_trans_rec.amortization_start_date) or
1173 (l_dpis_change)) and
1174 l_call_faxama) then
1175
1176
1177 if (p_log_level_rec.statement_level) then
1178 fa_debug_pkg.add('calc_fin_info', 'calling FAXAMA', 'faxama');
1179 end if;
1180
1181 if (p_asset_type_rec.asset_type <> 'GROUP') then
1182 -- Bug# 7245510:Expense not calculated for Only Contract_id adjustment
1183 if not nvl(p_asset_fin_rec_adj.contract_change_flag,FALSE) then /*Bug 7712756 added nvl */
1184 if not FA_AMORT_PVT.faxama
1185 (px_trans_rec => px_trans_rec,
1186 p_asset_hdr_rec => p_asset_hdr_rec,
1187 p_asset_desc_rec => p_asset_desc_rec,
1188 p_asset_cat_rec => p_asset_cat_rec,
1189 p_asset_type_rec => p_asset_type_rec,
1190 p_asset_fin_rec_old => p_asset_fin_rec_old,
1191 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
1192 px_asset_fin_rec_new => px_asset_fin_rec_new,
1193 p_asset_deprn_rec => p_asset_deprn_rec_old,
1194 p_asset_deprn_rec_adj => p_asset_deprn_rec_adj,
1195 p_period_rec => p_period_rec,
1196 p_mrc_sob_type_code => p_mrc_sob_type_code,
1197 p_running_mode => fa_std_types.FA_DPR_NORMAL,
1198 p_used_by_revaluation => null,
1199 p_reclassed_asset_id => p_reclassed_asset_id,
1200 p_reclass_src_dest => p_reclass_src_dest,
1201 p_reclassed_asset_dpis => p_reclassed_asset_dpis,
1202 x_deprn_exp => l_deprn_exp,
1203 x_bonus_deprn_exp => l_bonus_deprn_exp,
1204 p_log_level_rec => p_log_level_rec
1205 ) then
1206 return (FALSE);
1207 end if;
1208 end if;
1209 end if; -- (p_asset_type_rec.asset_type <> 'GROUP')
1210
1211 else
1212 -- calc_raf_adj_cost is the function to recalculate adj cost,
1213 -- raf, and formular factor and it is godd enough for current
1214 -- period trx.
1215 if ((px_trans_rec.calling_interface <> 'FAXASSET') and
1216 (px_trans_rec.transaction_key = 'GC' and
1217 (p_group_reclass_options_rec.group_reclass_type = 'CALC'))) or
1218 (px_trans_rec.transaction_key in ('MR', 'MS')) then
1219 l_call_bs := TRUE;
1220 else
1221 l_call_bs := FALSE;
1222 end if;
1223 /*Bug 6950629 -> Only Contract_id adjustment, adjusted_cost calc is not updated*/
1224 if not nvl(p_asset_fin_rec_adj.contract_change_flag,FALSE) then /*Bug 7712756 added nvl */
1225 -- Bug7017134: There is no need to call calc_raf_adj_cost in case of
1226 -- GC, MR, MS.
1230 (p_trans_rec => px_trans_rec,
1227 --Bug7446301: added nvl
1228 if (nvl(px_trans_rec.transaction_key, 'XX') not in ('GC', 'MR', 'MS')) then
1229 if not FA_AMORT_PVT.calc_raf_adj_cost
1231 p_asset_hdr_rec => p_asset_hdr_rec,
1232 p_asset_desc_rec => p_asset_desc_rec,
1233 p_asset_type_rec => p_asset_type_rec,
1234 p_asset_fin_rec_old => p_asset_fin_rec_old,
1235 px_asset_fin_rec_new => px_asset_fin_rec_new,
1236 p_asset_deprn_rec_adj => p_asset_deprn_rec_adj,
1237 p_asset_deprn_rec_new => px_asset_deprn_rec_new,
1238 p_period_rec => p_period_rec,
1239 p_group_reclass_options_rec => p_group_reclass_options_rec,
1240 p_mrc_sob_type_code => p_mrc_sob_type_code,
1241 p_log_level_rec => p_log_level_rec
1242 ) then
1243 raise calc_err;
1244 end if;
1245 end if;
1246 end if;
1247 /* Begin of Bug 6803812 : Reverse the fa_adj entry created for period of addition
1248 if reserve change is made */
1249 if (((nvl(p_asset_deprn_rec_adj.deprn_reserve,0) <> 0) or
1250 (nvl(p_asset_deprn_rec_adj.ytd_deprn,0) <> 0)) and
1251 (p_asset_fin_rec_old.date_placed_in_service < p_period_rec.calendar_period_open_date) and
1252 (p_asset_hdr_rec.period_of_addition = 'Y')) then
1253
1254 begin
1255 if (p_mrc_sob_type_code <> 'R') then
1256 SELECT sum(decode(adj.debit_credit_flag,'DR',
1257 -1 * adj.adjustment_amount,
1258 adj.adjustment_amount))
1259 INTO l_deprn_exp
1260 FROM fa_adjustments adj,
1261 fa_transaction_headers th
1262 WHERE th.book_type_code = p_asset_hdr_rec.book_type_code
1263 and th.asset_id = p_asset_hdr_rec.asset_id
1264 and th.transaction_type_code in ('ADDITION', 'ADJUSTMENT') --Bug7409454
1265 and adj.book_type_code = p_asset_hdr_rec.book_type_code
1266 and adj.asset_id = p_asset_hdr_rec.asset_id
1267 and adj.transaction_header_id = th.transaction_header_id
1268 and adj.source_type_code = 'DEPRECIATION'
1269 and adj.adjustment_type = 'EXPENSE'
1270 and adj.period_counter_created = p_period_rec.period_counter;
1271
1272 else
1273
1274 SELECT sum(decode(adj.debit_credit_flag,'DR',
1275 -1 * adj.adjustment_amount,
1276 adj.adjustment_amount))
1277 INTO l_deprn_exp
1278 FROM fa_adjustments_mrc_v adj,
1279 fa_transaction_headers th
1280 WHERE th.book_type_code = p_asset_hdr_rec.book_type_code
1281 and th.asset_id = p_asset_hdr_rec.asset_id
1282 and th.transaction_type_code in ('ADDITION', 'ADJUSTMENT') ----Bug7409454
1283 and adj.book_type_code = p_asset_hdr_rec.book_type_code
1284 and adj.asset_id = p_asset_hdr_rec.asset_id
1285 and adj.transaction_header_id = th.transaction_header_id
1286 and adj.source_type_code = 'DEPRECIATION'
1287 and adj.adjustment_type = 'EXPENSE'
1288 and adj.period_counter_created = p_period_rec.period_counter;
1289
1290 end if;
1291 EXCEPTION
1292 WHEN OTHERS THEN
1293 l_deprn_exp := 0;
1294 END;
1295
1296 end if; /* End of Bug 6803812 */
1297
1298 end if; -- (p_period_rec.calendar_period_open_date >
1299
1300 else
1301 /* Begin of Bug 7153740 : Reverse the fa_adj entry created for period of addition
1302 if manual reserve change is done */
1303 if (((nvl(p_asset_deprn_rec_adj.deprn_reserve,0) <> 0) or
1304 (nvl(p_asset_deprn_rec_adj.ytd_deprn,0) <> 0)) and
1305 (p_asset_fin_rec_old.date_placed_in_service < p_period_rec.calendar_period_open_date) and
1306 (p_asset_hdr_rec.period_of_addition = 'Y')) then
1307
1308 begin
1309 if (p_mrc_sob_type_code <> 'R') then
1313 INTO l_deprn_exp
1310 SELECT sum(decode(adj.debit_credit_flag,'DR',
1311 -1 * adj.adjustment_amount,
1312 adj.adjustment_amount))
1314 FROM fa_adjustments adj,
1315 fa_transaction_headers th
1316 WHERE th.book_type_code = p_asset_hdr_rec.book_type_code
1317 and th.asset_id = p_asset_hdr_rec.asset_id
1318 and th.transaction_type_code in ('ADDITION', 'ADJUSTMENT')
1319 and adj.book_type_code = p_asset_hdr_rec.book_type_code
1320 and adj.asset_id = p_asset_hdr_rec.asset_id
1321 and adj.transaction_header_id = th.transaction_header_id
1322 and adj.source_type_code = 'DEPRECIATION'
1323 and adj.adjustment_type = 'EXPENSE'
1324 and adj.period_counter_created = p_period_rec.period_counter;
1325
1326 else
1327
1328 SELECT sum(decode(adj.debit_credit_flag,'DR',
1329 -1 * adj.adjustment_amount,
1330 adj.adjustment_amount))
1331 INTO l_deprn_exp
1332 FROM fa_adjustments_mrc_v adj,
1333 fa_transaction_headers th
1334 WHERE th.book_type_code = p_asset_hdr_rec.book_type_code
1335 and th.asset_id = p_asset_hdr_rec.asset_id
1336 and th.transaction_type_code in ('ADDITION', 'ADJUSTMENT')
1337 and adj.book_type_code = p_asset_hdr_rec.book_type_code
1338 and adj.asset_id = p_asset_hdr_rec.asset_id
1339 and adj.transaction_header_id = th.transaction_header_id
1340 and adj.source_type_code = 'DEPRECIATION'
1341 and adj.adjustment_type = 'EXPENSE'
1342 and adj.period_counter_created = p_period_rec.period_counter;
1343
1344 end if;
1345 EXCEPTION
1346 WHEN OTHERS THEN
1347 l_deprn_exp := 0;
1348 END;
1349 else
1350 --HH we want to skip over faxexp if disabled_flag just changed
1351 --although we probably should never get in here.
1352 if not l_disabled_flag_changed then
1353 if not FA_EXP_PVT.faxexp
1354 (px_trans_rec => px_trans_rec,
1355 p_asset_hdr_rec => p_asset_hdr_rec,
1356 p_asset_desc_rec => p_asset_desc_rec,
1357 p_asset_cat_rec => p_asset_cat_rec,
1358 p_asset_type_rec => p_asset_type_rec,
1359 p_asset_fin_rec_old => p_asset_fin_rec_old,
1360 px_asset_fin_rec_new => px_asset_fin_rec_new,
1361 p_asset_deprn_rec => p_asset_deprn_rec_old,
1362 p_period_rec => p_period_rec,
1363 p_mrc_sob_type_code => p_mrc_sob_type_code,
1364 p_running_mode => fa_std_types.FA_DPR_NORMAL,
1365 p_used_by_revaluation => null,
1366 x_deprn_exp => l_deprn_exp,
1367 x_bonus_deprn_exp => l_bonus_deprn_exp,
1368 x_ann_adj_deprn_exp => l_ann_adj_deprn_exp,
1369 x_ann_adj_bonus_deprn_exp => l_ann_adj_bonus_deprn_exp,
1370 p_log_level_rec => p_log_level_rec
1371 ) then
1372 raise calc_err;
1373 end if;
1374 end if; --disabled_flag changed.
1375 end if; -- if (((nvl(p_asset_deprn_rec_adj.deprn_reserve,0) <> 0)..
1376 end if;
1377
1378 if (p_log_level_rec.statement_level) then
1379 fa_debug_pkg.add('calc_fin_info', 'after user exits, adj_cost',
1380 px_asset_fin_rec_new.adjusted_cost);
1381 fa_debug_pkg.add(l_calling_fn, 'after user exits, l_deprn_exp',
1382 l_deprn_exp);
1383 end if;
1384
1385 -- manual override - this is the only section in faadjust that
1386 -- needs to be propogated here
1387 if px_trans_rec.deprn_override_flag in (fa_std_types.FA_OVERRIDE_DPR,
1388 fa_std_types.FA_OVERRIDE_BONUS,
1389 fa_std_types.FA_OVERRIDE_DPR_BONUS) then
1390
1394 UPDATE FA_DEPRN_OVERRIDE ov
1391 fa_std_types.deprn_override_trigger_enabled:= FALSE;
1392
1393 if (NVL(p_asset_fin_rec_old.tracking_method, ' ') = 'ALLOCATE') then
1395 SET ov.transaction_header_id = px_trans_rec.transaction_header_id
1396 WHERE ov.book_type_code = p_asset_hdr_rec.book_type_code
1397 AND ov.used_by = 'ADJUSTMENT'
1398 AND ov.status = 'SELECTED'
1399 AND ov.transaction_header_id is null
1400 AND ov.asset_id IN
1401 (SELECT bk.asset_id
1402 FROM fa_books bk
1403 WHERE bk.book_type_code = ov.book_type_code
1404 AND bk.group_asset_id = p_asset_hdr_rec.asset_id
1405 AND bk.date_ineffective IS NULL);
1406 else
1407 UPDATE FA_DEPRN_OVERRIDE
1408 SET transaction_header_id = px_trans_rec.transaction_header_id
1409 WHERE book_type_code = p_asset_hdr_rec.book_type_code
1410 AND asset_id = p_asset_hdr_rec.asset_id
1411 AND used_by = 'ADJUSTMENT'
1412 AND status = 'SELECTED'
1413 AND transaction_header_id is null;
1414 end if;
1415
1416 fa_std_types.deprn_override_trigger_enabled:= TRUE;
1417 end if;
1418
1419 -- need to account for the value of l_adjust_type rather than just
1420 -- just the value of the subtype here (see above)
1421 --
1422 -- if (px_trans_rec.transaction_subtype = 'AMORTIZED' and
1423 if (l_adjust_type = 'AMORTIZED' and
1424 px_asset_fin_rec_new.cost = 0) then
1425 px_asset_fin_rec_new.rate_adjustment_factor := 1;
1426 end if;
1427
1428 if ((px_asset_fin_rec_new.formula_factor <> 1 or
1429 px_asset_fin_rec_new.rate_adjustment_factor <> 1) and
1430 l_rate_source_rule = 'FORMULA') then
1431 px_asset_fin_rec_new.old_adjusted_cost := p_asset_fin_rec_old.adjusted_cost;
1432 end if;
1433
1434 elsif p_asset_type_rec.asset_type='GROUP' and
1435 nvl(px_asset_fin_rec_new.tracking_method,'NULL') = 'CALCULATE' and
1436 nvl(px_asset_fin_rec_new.member_rollup_flag,'N') = 'Y'
1437 then
1438
1439 -- The returned adjusted_cost is supported only CCA.
1440
1441 if (not FA_CALC_DEPRN_BASIS1_PKG.CALL_DEPRN_BASIS
1442 (p_event_type => 'AMORT_ADJ',
1443 p_asset_fin_rec_new => px_asset_fin_rec_new,
1444 p_asset_fin_rec_old => p_asset_fin_rec_old,
1445 p_asset_hdr_rec => p_asset_hdr_rec,
1446 p_asset_type_rec => p_asset_type_rec,
1447 p_asset_deprn_rec => px_asset_deprn_rec_new,
1448 p_trans_rec => px_trans_rec,
1449 p_period_rec => p_period_rec,
1450 p_current_total_rsv => px_asset_deprn_rec_new.deprn_reserve,
1451 p_current_rsv => px_asset_deprn_rec_new.deprn_reserve -
1452 px_asset_deprn_rec_new.bonus_deprn_reserve,
1453 p_current_total_ytd => px_asset_deprn_rec_new.ytd_deprn,
1454 p_adj_reserve => p_asset_deprn_rec_adj.deprn_reserve,
1455 p_mrc_sob_type_code => p_mrc_sob_type_code,
1456 p_used_by_adjustment => 'ADJUSTMENT',
1457 px_new_adjusted_cost => px_asset_fin_rec_new.adjusted_cost,
1458 px_new_raf => px_asset_fin_rec_new.rate_adjustment_factor,
1459 px_new_formula_factor => px_asset_fin_rec_new.formula_factor,
1460 p_log_level_rec => p_log_level_rec)
1461 ) then
1462 raise calc_err;
1463 end if;
1464
1465 end if; -- Tracking Method is not Allocate for Group Member Asset.
1466
1467 elsif not (p_inv_trans_rec.invoice_transaction_id is not null and
1468 nvl(p_asset_fin_rec_adj.cost, 0) = 0) then -- depreciate flag changed
1469
1470 if (p_log_level_rec.statement_level) then
1471 fa_debug_pkg.add('calc_fin_info', 'entering',
1472 'logic for depreciate flag change');
1473 end if;
1474
1475 -- Recalculate eofy_reserve
1476 if px_asset_fin_rec_new.depreciate_flag='YES' and
1477 px_asset_deprn_rec_new.ytd_deprn =0
1478 then
1479 px_asset_fin_rec_new.eofy_reserve := px_asset_deprn_rec_new.deprn_reserve;
1480 end if;
1481
1482 ----------------------------------------------
1483 -- Call Depreciable Basis Rule
1484 -- for depreciate flag adjustment
1485 ----------------------------------------------
1486 if (not FA_CALC_DEPRN_BASIS1_PKG.CALL_DEPRN_BASIS
1487 (
1488 p_event_type => 'DEPRECIATE_FLAG_ADJ',
1492 p_asset_type_rec => p_asset_type_rec,
1489 p_asset_fin_rec_new => px_asset_fin_rec_new,
1490 p_asset_fin_rec_old => p_asset_fin_rec_old,
1491 p_asset_hdr_rec => p_asset_hdr_rec,
1493 p_asset_deprn_rec => px_asset_deprn_rec_new,
1494 p_trans_rec => px_trans_rec,
1495 p_period_rec => p_period_rec,
1496 p_mrc_sob_type_code => p_mrc_sob_type_code,
1497 px_new_adjusted_cost => px_asset_fin_rec_new.adjusted_cost,
1498 px_new_raf => px_asset_fin_rec_new.rate_adjustment_factor,
1499 px_new_formula_factor => px_asset_fin_rec_new.formula_factor,
1500 p_log_level_rec => p_log_level_rec
1501 )
1502 )
1503 then
1504 raise calc_err;
1505 end if;
1506 else -- BUG# 3615096: 0 cost change from invoice transaction
1507 if (p_log_level_rec.statement_level) then
1508 fa_debug_pkg.add('calc_fin_info', 'entering',
1509 'logic for zero cost invoice changes');
1510 end if;
1511
1512 px_asset_fin_rec_new := p_asset_fin_rec_old;
1513 end if; -- change in depreciate flag
1514
1515 -- SLA: since voids are obsolete chaning condition for group
1516 elsif (px_trans_rec.transaction_type_code = 'ADDITION' or
1517 px_trans_rec.transaction_type_code = 'CIP ADDITION' or
1518 -- px_trans_rec.transaction_type_code = 'GROUP ADDITION') then
1519 px_trans_rec.transaction_type_code = 'GROUP ADDITION' or
1520 (px_trans_rec.transaction_type_code = 'GROUP ADJUSTMENT' and
1521 p_asset_hdr_rec.period_of_addition = 'Y')) then
1522 if (p_asset_type_rec.asset_type = 'GROUP') and
1523 (l_deprn_reserve_exists <> 0 )then
1524
1525 if ((px_trans_rec.calling_interface <> 'FAXASSET') and
1526 (px_trans_rec.transaction_key = 'GC')) or
1527 (px_trans_rec.transaction_key in ('MR', 'MS')) then
1528 l_call_bs := TRUE;
1529 else
1530 l_call_bs := FALSE;
1531 end if;
1532
1533 if not FA_AMORT_PVT.calc_raf_adj_cost
1534 (p_trans_rec => px_trans_rec,
1535 p_asset_hdr_rec => p_asset_hdr_rec,
1536 p_asset_desc_rec => p_asset_desc_rec,
1537 p_asset_type_rec => p_asset_type_rec,
1538 p_asset_fin_rec_old => p_asset_fin_rec_old,
1539 px_asset_fin_rec_new => px_asset_fin_rec_new,
1540 p_asset_deprn_rec_adj => p_asset_deprn_rec_adj,
1541 p_asset_deprn_rec_new => px_asset_deprn_rec_new,
1542 p_period_rec => p_period_rec,
1543 p_mrc_sob_type_code => p_mrc_sob_type_code,
1544 p_log_level_rec => p_log_level_rec
1545 ) then
1546 raise calc_err;
1547 end if;
1548
1549 else
1550 ----------------------------------------------
1551 -- Call Depreciable Basis Rule
1552 -- for Addition
1553 ----------------------------------------------
1554 -- Bug4403330: passing 0 values to p_eofy_recoverable_cost,
1555 -- p_eop_recoverable_cost, p_eofy_salvage_value, and p_eop_salvage_value
1556 -- is necessary to avoid calling GET_EOFY_EOP in deprn basis function because
1557 -- the sql gets old non depreciable value that should be excluded.
1558 if (px_trans_rec.transaction_type_code = 'ADDITION') and
1559 (p_calling_fn = 'fa_cip_pvt.do_cap_rev') then
1560 l_cap_temp_value := 0;
1561 else
1562 l_cap_temp_value := null;
1563 end if;
1564
1565 if (not FA_CALC_DEPRN_BASIS1_PKG.CALL_DEPRN_BASIS
1566 (
1567 p_event_type => 'ADDITION',
1568 p_asset_fin_rec_new => px_asset_fin_rec_new,
1569 p_asset_fin_rec_old => p_asset_fin_rec_old,
1570 p_asset_hdr_rec => p_asset_hdr_rec,
1571 p_asset_type_rec => p_asset_type_rec,
1572 p_asset_deprn_rec => px_asset_deprn_rec_new,
1573 p_trans_rec => px_trans_rec,
1574 p_period_rec => p_period_rec,
1575 p_eofy_recoverable_cost => l_cap_temp_value,
1576 p_eop_recoverable_cost => l_cap_temp_value,
1577 p_eofy_salvage_value => l_cap_temp_value,
1578 p_eop_salvage_value => l_cap_temp_value,
1579 p_mrc_sob_type_code => p_mrc_sob_type_code,
1580 px_new_adjusted_cost => px_asset_fin_rec_new.adjusted_cost,
1581 px_new_raf => px_asset_fin_rec_new.rate_adjustment_factor,
1582 px_new_formula_factor => px_asset_fin_rec_new.formula_factor,
1583 p_log_level_rec => p_log_level_rec
1584 )
1585 )
1589
1586 then
1587 raise calc_err;
1588 end if;
1590 end if;
1591
1592 end if;
1593
1594
1595 --
1596 -- Following faxama will return catch-up for group.
1597 -- This is the one will use FA_BOOKS_SUMMARY table to calculate
1598 -- and maintain FA_BOOKS_SUMMARY.
1599 --
1600 if (p_asset_type_rec.asset_type = 'GROUP') and
1601 (l_call_bs) then
1602
1603 if -- (p_group_reclass_options_rec.group_reclass_type = 'CALC') and
1604 (p_asset_type_rec.asset_type = 'GROUP') and
1605 (p_reclass_src_dest = 'DESTINATION') then
1606 l_asset_deprn_rec_adj.deprn_reserve := nvl(l_asset_deprn_rec_adj.deprn_reserve, 0) +
1607 p_group_reclass_options_rec.reserve_amount;
1608 else
1609 l_asset_deprn_rec_adj := p_asset_deprn_rec_adj;
1610 end if;
1611
1612 if (not FA_AMORT_PVT.faxama(
1613 px_trans_rec => px_trans_rec,
1614 p_asset_hdr_rec => p_asset_hdr_rec,
1615 p_asset_desc_rec => p_asset_desc_rec,
1616 p_asset_cat_rec => p_asset_cat_rec,
1617 p_asset_type_rec => p_asset_type_rec,
1618 p_asset_fin_rec_old => p_asset_fin_rec_old,
1619 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
1620 px_asset_fin_rec_new => px_asset_fin_rec_new,
1621 p_asset_deprn_rec => p_asset_deprn_rec_old,
1622 p_asset_deprn_rec_adj => l_asset_deprn_rec_adj,
1623 p_period_rec => p_period_rec,
1624 p_mrc_sob_type_code => p_mrc_sob_type_code,
1625 p_running_mode => fa_std_types.FA_DPR_NORMAL,
1626 p_used_by_revaluation => null,
1627 p_reclassed_asset_id => p_reclassed_asset_id,
1628 p_reclass_src_dest => p_reclass_src_dest,
1629 p_group_reclass_type => p_group_reclass_options_rec.group_reclass_type, --Bug6792185
1630 p_reclassed_asset_dpis => p_reclassed_asset_dpis,
1631 p_update_books_summary => TRUE,
1632 p_proceeds_of_sale => 0,
1633 p_cost_of_removal => 0,
1634 x_deprn_exp => l_deprn_exp,
1635 x_bonus_deprn_exp => l_bonus_deprn_exp,
1636 x_deprn_rsv => l_deprn_rsv,
1637 p_log_level_rec => p_log_level_rec)) then
1638
1639 if (p_log_level_rec.statement_level) then
1640 fa_debug_pkg.add('calc_fin_info', 'calling FA_AMORT_PVT.faxama', 'FAILED');
1641 end if;
1642
1643 raise calc_err;
1644
1645 end if; -- (not FA_AMORT_PVT.faxama
1646
1647 if (p_group_reclass_options_rec.group_reclass_type = 'CALC') and
1648 (p_asset_type_rec.asset_type = 'GROUP') and
1649 (p_reclass_src_dest = 'SOURCE') then
1650 p_group_reclass_options_rec.reserve_amount := -1 * l_deprn_rsv;
1651 end if;
1652
1653 end if; -- (p_asset_type_rec.asset_type = 'GROUP')
1654
1655 if (px_trans_rec.transaction_type_code = 'ADJUSTMENT' or
1656 px_trans_rec.transaction_type_code = 'CIP ADJUSTMENT') then
1657
1658 -- get the total amounted cleared for payables cost
1659 -- from the invoice engine (assumes its been flushed)
1660 if (p_mrc_sob_type_code <> 'R') then
1661 select nvl(sum(decode(debit_credit_flag,
1662 'CR', adjustment_amount,
1663 adjustment_amount * -1)), 0)
1664 into l_clearing
1665 from fa_adjustments
1666 where asset_id = p_asset_hdr_rec.asset_id
1667 and book_type_code = p_asset_hdr_rec.book_type_code
1668 and period_counter_created = p_period_rec.period_counter
1669 and transaction_header_id = px_trans_rec.transaction_header_id
1670 and adjustment_type = 'COST CLEARING';
1671 else
1672 select nvl(sum(decode(debit_credit_flag,
1673 'CR', adjustment_amount,
1674 adjustment_amount * -1)), 0)
1675 into l_clearing
1676 from fa_adjustments_mrc_v
1677 where asset_id = p_asset_hdr_rec.asset_id
1678 and book_type_code = p_asset_hdr_rec.book_type_code
1679 and period_counter_created = p_period_rec.period_counter
1680 and transaction_header_id = px_trans_rec.transaction_header_id
1681 and adjustment_type = 'COST CLEARING';
1682 end if;
1683 end if;
1684
1685 -- process groups here to for the catchup but not for clearing
1686 -- SLA: now insert catchup for capitalization
1687
1688 if (px_trans_rec.transaction_type_code in ('ADJUSTMENT', 'CIP ADJUSTMENT', 'GROUP ADDITION', 'GROUP ADJUSTMENT') or
1689 (px_trans_rec.transaction_type_code = 'ADDITION' and
1690 p_asset_fin_rec_old.rate_adjustment_factor is not null)) then
1691
1692
1696 --Bug7409454 removed the check for px_asset_deprn_rec_new.deprn_reserve = 0 and px_asset_deprn_rec_new.ytd_deprn = 0
1693 -- SLA: voids are obsolete so handleperiod of addition here too
1694 --Bug6838135 Added the or condition so that deprn reserve and ytd
1695 -- are processed for cases other than manual reserve change.
1697 if (px_trans_rec.transaction_type_code = 'GROUP ADDITION' or
1698 (px_trans_rec.transaction_type_code = 'GROUP ADJUSTMENT' and
1699 p_asset_hdr_rec.period_of_addition = 'Y')
1700 or (px_trans_rec.transaction_type_code = 'ADJUSTMENT' and
1701 p_asset_hdr_rec.period_of_addition = 'Y'
1702 and ( nvl(p_asset_deprn_rec_adj.deprn_reserve, 0) = 0 and nvl(p_asset_deprn_rec_adj.ytd_deprn, 0) = 0 ))) then
1703
1704 px_asset_deprn_rec_new.deprn_reserve := nvl(px_asset_deprn_rec_new.deprn_reserve, 0) + nvl(l_deprn_exp, 0);
1705 px_asset_deprn_rec_new.ytd_deprn := nvl(px_asset_deprn_rec_new.ytd_deprn, 0) + nvl(l_deprn_exp, 0);
1706 end if;
1707
1708 -- insure we do not post any catchup for group member
1709 if (px_asset_fin_rec_new.group_asset_id is not null) and
1710 nvl(px_asset_fin_rec_new.tracking_method,'OTHER') <> 'CALCULATE' then
1711 l_deprn_exp := 0;
1712 l_bonus_deprn_exp := 0;
1713 end if;
1714
1715
1716 if (p_log_level_rec.statement_level) then
1717 fa_debug_pkg.add('calx_fin_info', 'calling', 'faxiat');
1718 fa_debug_pkg.add('calc_fin_info', 'after user exits, adj_cost',
1719 px_asset_fin_rec_new.adjusted_cost);
1720 fa_debug_pkg.add(l_calling_fn, 'l_deprn_exp before faxiat', l_deprn_exp);
1721 end if;
1722
1723 -- insert all the amounts
1724 -- HH only if this is not a disabled_flag transaction
1725
1726 -- SLA do not insert cost/clearing for capitalization
1727 if (px_trans_rec.transaction_type_code = 'ADDITION' and
1728 p_asset_fin_rec_old.rate_adjustment_factor is not null) then
1729 l_cost_to_insert := 0;
1730 l_clearing_to_insert := 0;
1731 else
1732 l_cost_to_insert := p_asset_fin_rec_adj.cost;
1733 l_clearing_to_insert := p_asset_fin_rec_adj.cost - l_clearing;
1734 end if;
1735
1736 if not l_disabled_flag_changed then
1737 if not FA_INS_ADJ_PVT.faxiat
1738 (p_trans_rec => px_trans_rec,
1739 p_asset_hdr_rec => p_asset_hdr_rec,
1740 p_asset_desc_rec => p_asset_desc_rec,
1741 p_asset_cat_rec => p_asset_cat_rec,
1742 p_asset_type_rec => p_asset_type_rec,
1743 p_cost => l_cost_to_insert,
1744 p_clearing => l_clearing_to_insert,
1745 p_deprn_expense => l_deprn_exp,
1746 p_bonus_expense => l_bonus_deprn_exp,
1747 p_deprn_reserve => l_deprn_rsv,
1748 p_bonus_reserve => l_bonus_deprn_rsv,
1749 p_ann_adj_amt => l_ann_adj_deprn_exp, -- 0,
1750 p_mrc_sob_type_code => p_mrc_sob_type_code,
1751 p_calling_fn => l_calling_fn,
1752 p_log_level_rec => p_log_level_rec
1753 ) then raise calc_err;
1754 end if;
1755 end if; --no change to disabled_flag
1756
1757 -- ENERGY and allocate in general
1758 -- Dupulicate group FA_ADJUSTMENTS entries on member asset
1759 --
1760 if (p_log_level_rec.statement_level) then
1761 fa_debug_pkg.add(l_calling_fn, 'l_deprn_exp', l_deprn_exp);
1762 fa_debug_pkg.add(l_calling_fn, 'l_bonus_deprn_exp', l_bonus_deprn_exp);
1763 fa_debug_pkg.add(l_calling_fn, 'p_asset_type_rec.asset_type', p_asset_type_rec.asset_type);
1764 fa_debug_pkg.add(l_calling_fn, 'px_trans_rec.member_transaction_header_id',
1765 px_trans_rec.member_transaction_header_id);
1766 fa_debug_pkg.add(l_calling_fn, 'l_disabled_flag_changed', l_disabled_flag_changed);
1767 end if;
1768
1769 if (nvl(l_deprn_exp, 0) <> 0 or nvl(l_bonus_deprn_exp, 0) <> 0) and
1770 (p_asset_type_rec.asset_type = 'GROUP') and
1771 (px_trans_rec.member_transaction_header_id is not null) and
1772 (not (l_disabled_flag_changed)) and
1773 (nvl(px_asset_fin_rec_new.tracking_method,'NO TRACK') = 'ALLOCATE') and
1774 (px_trans_rec.transaction_key not in ('MR', 'MS')) then
1775
1776 OPEN c_get_member_trx;
1777 FETCH c_get_member_trx INTO l_asset_hdr_rec.asset_id
1778 , l_trans_rec.transaction_header_id
1779 , l_trans_rec.transaction_type_code
1780 , l_trans_rec.transaction_date_entered
1781 , l_trans_rec.transaction_name
1782 , l_trans_rec.source_transaction_header_id
1783 , l_trans_rec.mass_reference_id
1784 , l_trans_rec.transaction_subtype
1785 , l_trans_rec.transaction_key
1786 , l_trans_rec.amortization_start_date
1787 , l_trans_rec.calling_interface
1791 , l_trans_rec.who_info.last_update_date
1788 , l_trans_rec.mass_transaction_id
1789 , l_trans_rec.member_transaction_header_id
1790 , l_trans_rec.trx_reference_id
1792 , l_trans_rec.who_info.last_updated_by
1793 , l_trans_rec.who_info.last_update_login;
1794 CLOSE c_get_member_trx;
1795
1796 l_trans_rec.who_info.created_by := l_trans_rec.who_info.last_updated_by;
1797 l_trans_rec.who_info.creation_date := l_trans_rec.who_info.last_update_date;
1798
1799 l_asset_hdr_rec.book_type_code := p_asset_hdr_rec.book_type_code;
1800 l_asset_hdr_rec.set_of_books_id := p_asset_hdr_rec.set_of_books_id;
1801
1802 -- load the old structs
1803 if not FA_UTIL_PVT.get_asset_fin_rec
1804 (p_asset_hdr_rec => l_asset_hdr_rec,
1805 px_asset_fin_rec => l_asset_fin_rec,
1806 p_transaction_header_id => NULL,
1807 p_mrc_sob_type_code => p_mrc_sob_type_code,
1808 p_log_level_rec => p_log_level_rec) then
1809 raise calc_err;
1810 end if;
1811
1812 if not FA_UTIL_PVT.get_asset_desc_rec
1813 (p_asset_hdr_rec => l_asset_hdr_rec,
1814 px_asset_desc_rec => l_asset_desc_rec,
1815 p_log_level_rec => p_log_level_rec) then
1816 raise calc_err;
1817 end if;
1818
1819 if not FA_UTIL_PVT.get_asset_cat_rec
1820 (p_asset_hdr_rec => l_asset_hdr_rec,
1821 px_asset_cat_rec => l_asset_cat_rec,
1822 p_date_effective => null,
1823 p_log_level_rec => p_log_level_rec) then
1824 raise calc_err;
1825 end if;
1826
1827 if not FA_UTIL_PVT.get_asset_type_rec
1828 (p_asset_hdr_rec => l_asset_hdr_rec,
1829 px_asset_type_rec => l_asset_type_rec,
1830 p_date_effective => null,
1831 p_log_level_rec => p_log_level_rec) then
1832 raise calc_err;
1833 end if;
1834
1835 if not FA_INS_ADJ_PVT.faxiat
1836 (p_trans_rec => l_trans_rec,
1837 p_asset_hdr_rec => l_asset_hdr_rec,
1838 p_asset_desc_rec => l_asset_desc_rec,
1839 p_asset_cat_rec => l_asset_cat_rec,
1840 p_asset_type_rec => l_asset_type_rec,
1841 p_cost => 0,
1842 p_clearing => 0,
1843 p_deprn_expense => l_deprn_exp,
1844 p_bonus_expense => l_bonus_deprn_exp,
1845 p_ann_adj_amt => 0,
1846 p_track_member_flag => 'Y',
1847 p_mrc_sob_type_code => p_mrc_sob_type_code,
1848 p_calling_fn => l_calling_fn,
1849 p_log_level_rec => p_log_level_rec) then
1850 raise calc_err;
1851 end if;
1852
1853 end if;
1854 -- End of ENERGY Change
1855
1856 -- When Group Adjustment is processed for the group whose tracking
1857 -- method is allocate but the transaction kicked at group level,
1858 -- expense must be allocated to members.
1859 -- HH assuming this is not a change to disabled_flag
1860
1861 -- SLA voids are obsolete so group adjustments happen in period of add
1862 -- why are group adjustments i period of add not processed here
1863
1864 -- if px_trans_rec.transaction_type_code = 'GROUP ADJUSTMENT' and
1865 if px_trans_rec.transaction_type_code = 'GROUP ADJUSTMENT' and
1866 p_asset_hdr_rec.period_of_addition <> 'Y' and
1867 px_trans_rec.member_transaction_header_id is null and
1868 nvl(px_asset_fin_rec_new.tracking_method,'OTHER') = 'ALLOCATE' and
1869 not l_disabled_flag_changed then
1870
1871 -- Call TRACK_ASSETS
1872 l_rc := fa_track_member_pvt.track_assets
1873 (P_book_type_code => p_asset_hdr_rec.book_type_code,
1874 P_group_asset_id => p_asset_hdr_rec.asset_id,
1875 P_period_counter => p_period_rec.period_num,
1876 P_fiscal_year => p_period_rec.fiscal_year,
1877 P_group_deprn_basis => fa_cache_pkg.fazccmt_record.deprn_basis_rule,
1878 P_group_exclude_salvage => fa_cache_pkg.fazccmt_record.exclude_salvage_value_flag,
1879 P_group_bonus_rule => px_asset_fin_rec_new.bonus_rule,
1880 P_group_deprn_amount => l_deprn_exp,
1881 P_group_bonus_amount => l_bonus_deprn_exp,
1882 P_tracking_method => px_asset_fin_rec_new.tracking_method,
1883 P_allocate_to_fully_ret_flag => px_asset_fin_rec_new.allocate_to_fully_ret_flag,
1884 P_allocate_to_fully_rsv_flag => px_asset_fin_rec_new.allocate_to_fully_rsv_flag,
1885 P_excess_allocation_option => px_asset_fin_rec_new.excess_allocation_option,
1889 P_period_of_addition => p_asset_hdr_rec.period_of_addition,
1886 P_depreciation_option => px_asset_fin_rec_new.depreciation_option,
1887 P_member_rollup_flag => px_asset_fin_rec_new.member_rollup_flag,
1888 P_group_level_override => l_group_level_override,
1890 P_transaction_date_entered => px_trans_rec.transaction_date_entered, --Added for bug 5359142
1891 P_mode => 'GROUP ADJUSTMENT',
1892 P_mrc_sob_type_code => p_mrc_sob_type_code,
1893 X_new_deprn_amount => x_new_deprn_amount,
1894 X_new_bonus_amount => x_new_bonus_amount,
1895 p_log_level_rec => p_log_level_rec);
1896 if l_rc <> 0 then
1897 raise calc_err;
1898 end if;
1899 end if;
1900
1901
1902 end if;
1903
1904 end if;
1905
1906 return true;
1907
1908 EXCEPTION
1909
1910 when calc_err then
1911 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
1912 return false;
1913
1914 when others then
1915 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
1916 return false;
1917
1918 END calc_fin_info;
1919
1920
1921 FUNCTION calc_new_amounts
1922 (px_trans_rec IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
1923 p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
1924 p_asset_desc_rec IN FA_API_TYPES.asset_desc_rec_type,
1925 p_asset_type_rec IN FA_API_TYPES.asset_type_rec_type,
1926 p_asset_cat_rec IN FA_API_TYPES.asset_cat_rec_type,
1927 p_asset_fin_rec_old IN FA_API_TYPES.asset_fin_rec_type,
1928 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
1929 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
1930 p_asset_deprn_rec_old IN FA_API_TYPES.asset_deprn_rec_type,
1931 p_asset_deprn_rec_adj IN FA_API_TYPES.asset_deprn_rec_type,
1932 px_asset_deprn_rec_new IN OUT NOCOPY FA_API_TYPES.asset_deprn_rec_type,
1933 p_mrc_sob_type_code IN VARCHAR2,
1934 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
1935 ) RETURN BOOLEAN IS
1936
1937 l_reval_ceiling_adj NUMBER; -- BUG 2620221
1938
1939 l_calling_fn VARCHAR2(40) := 'fa_asset_calc_pvt.calc_new_amounts';
1940 calc_err EXCEPTION;
1941
1942 BEGIN
1943
1944
1945 -- This procedure basically sets all new info by deriving it from the old and adjustment structures.
1946 -- For additions, all will end up coming from the adj struct.
1947 --
1948 -- Different values can be intentionally nulled out / removed, but most can not...
1949 -- The depreciation related info, including method, life, short tax, bonus, etc will all
1950 -- be addressed by the validate_deprn_info function
1951
1952 -- Set all non-calculated and non-method info
1953
1954 -- these values can be nulled out intentionally so we use
1955 -- G_MISS values for defaults - ceiling hand group have been removed
1956 -- and merged in the bonus area becuase of the impacts of
1957 -- defaulting for additions
1958
1959 FA_UTIL_PVT.load_num_value
1960 (p_num_old => p_asset_fin_rec_old.itc_amount_id,
1961 p_num_adj => p_asset_fin_rec_adj.itc_amount_id,
1962 x_num_new => px_asset_fin_rec_new.itc_amount_id);
1963
1964 -- added for group enhancements
1965
1966 FA_UTIL_PVT.load_num_value
1967 (p_num_old => p_asset_fin_rec_old.super_group_id,
1968 p_num_adj => p_asset_fin_rec_adj.super_group_id,
1969 x_num_new => px_asset_fin_rec_new.super_group_id);
1970
1971
1972 -- moved dirivation of the salvage and limit types back down to their respective functions
1973
1974 -- these values must be populated - null in adjust means they must be set to old values
1975
1976 px_asset_fin_rec_new.date_placed_in_service := nvl(p_asset_fin_rec_adj.date_placed_in_service,
1977 p_asset_fin_rec_old.date_placed_in_service);
1978
1979 -- amounts that may increase to adjustment
1980 px_asset_fin_rec_new.cost := nvl(p_asset_fin_rec_adj.cost, 0) +
1981 nvl(p_asset_fin_rec_old.cost, 0);
1982
1983 if (p_asset_type_rec.asset_type = 'CIP' or
1984 p_asset_type_rec.asset_type = 'GROUP') then
1985 px_asset_fin_rec_new.cip_cost := nvl(p_asset_fin_rec_adj.cip_cost, 0) +
1986 nvl(p_asset_fin_rec_old.cip_cost, 0);
1987 else
1988 px_asset_fin_rec_new.cip_cost := 0;
1989 end if;
1990
1991 px_asset_fin_rec_new.production_capacity := nvl(p_asset_fin_rec_adj.production_capacity, 0) +
1992 nvl(p_asset_fin_rec_old.production_capacity, 0);
1993 px_asset_fin_rec_new.fully_rsvd_revals_counter := nvl(p_asset_fin_rec_adj.fully_rsvd_revals_counter, 0) +
1994 nvl(p_asset_fin_rec_old.fully_rsvd_revals_counter, 0);
1995 px_asset_fin_rec_new.reval_amortization_basis := nvl(p_asset_fin_rec_adj.reval_amortization_basis, 0) +
1996 nvl(p_asset_fin_rec_old.reval_amortization_basis, 0);
1997
2001 p_asset_fin_rec_adj.reval_ceiling is null) then
1998 -- Commenting this for the bug 2620221
1999 /*
2000 if (p_asset_fin_rec_old.reval_ceiling is null and
2002 px_asset_fin_rec_new.reval_ceiling := null;
2003 else
2004 px_asset_fin_rec_new.reval_ceiling := nvl(p_asset_fin_rec_adj.reval_ceiling, 0) +
2005 nvl(p_asset_fin_rec_old.reval_ceiling, 0);
2006 end if;
2007 */
2008
2009
2010 -- Adding this for the BUG 2620221
2011 -- If the value of p_asset_fin_rec_adj.reval_ceiling is FND_API.G_MISS_NUM then make it NULL
2012 -- And after this calculate the value of New Reval Ceiling differently when the Adjusted Reval
2013 -- Ceiling is NULL.
2014 if (p_asset_fin_rec_adj.reval_ceiling = FND_API.G_MISS_NUM) then
2015 l_reval_ceiling_adj := null;
2016 else
2017 l_reval_ceiling_adj := p_asset_fin_rec_adj.reval_ceiling;
2018 end if;
2019
2020 if (l_reval_ceiling_adj is NULL) then
2021 px_asset_fin_rec_new.reval_ceiling := NULL;
2022 else
2023 px_asset_fin_rec_new.reval_ceiling := nvl(l_reval_ceiling_adj, 0) +
2024 nvl(p_asset_fin_rec_old.reval_ceiling, 0);
2025 end if;
2026
2027 px_asset_fin_rec_new.unrevalued_cost := nvl(p_asset_fin_rec_adj.unrevalued_cost,
2028 nvl(p_asset_fin_rec_adj.cost, 0)) +
2029 nvl(p_asset_fin_rec_old.unrevalued_cost,
2030 nvl(p_asset_fin_rec_old.cost, 0));
2031 px_asset_fin_rec_new.cip_cost := nvl(p_asset_fin_rec_adj.cip_cost, 0) +
2032 nvl(p_asset_fin_rec_old.cip_cost, 0);
2033
2034 -- SLA Uptake
2035 -- keeping this for now, but it may need to change
2036 -- intention is to allow the new amounts to be calculated,
2037 -- but insert the ADJ via faxiat
2038
2039 if (p_asset_hdr_rec.period_of_addition = 'Y') then
2040
2041 -- Bug:5154035
2042 if FA_ASSET_VAL_PVT.validate_reval_exists (p_asset_hdr_rec.book_type_code,
2043 p_asset_hdr_rec.asset_id,
2044 'FA_ASSET_CALC_PVT.calc_new_amounts') then
2045 if (nvl(p_asset_deprn_rec_adj.bonus_ytd_deprn, 0) <> 0 or
2046 nvl(p_asset_deprn_rec_adj.bonus_deprn_reserve, 0) <> 0 or
2047 nvl(p_asset_deprn_rec_adj.deprn_reserve, 0) <> 0 or
2048 nvl(p_asset_deprn_rec_adj.ytd_deprn, 0) <> 0 or
2049 nvl(p_asset_deprn_rec_adj.reval_deprn_reserve, 0) <> 0 or
2050 nvl(p_asset_deprn_rec_adj.reval_ytd_deprn, 0) <> 0) then
2051
2052 if (p_log_level_rec.statement_level) then
2053 fa_debug_pkg.add(l_calling_fn, 'Revaluation', 'Reserve adjustments restricted after reval in period of addition.');
2054 end if;
2055
2056 fa_srvr_msg.add_message(calling_fn => l_calling_fn,
2057 name => 'FA_TAX_ASSET_IS_REV');
2058 raise calc_err;
2059 end if;
2060 end if;
2061
2062 px_asset_fin_rec_new.original_cost := nvl(p_asset_fin_rec_adj.original_cost,
2063 nvl(p_asset_fin_rec_adj.cost, 0)) +
2064 nvl(p_asset_fin_rec_old.original_cost,
2065 nvl(p_asset_fin_rec_old.cost, 0));
2066 px_asset_deprn_rec_new.deprn_amount := 0;
2067 px_asset_deprn_rec_new.deprn_reserve := nvl(p_asset_deprn_rec_adj.deprn_reserve, 0) +
2068 nvl(p_asset_deprn_rec_old.deprn_reserve, 0);
2069 px_asset_deprn_rec_new.ytd_deprn := nvl(p_asset_deprn_rec_adj.ytd_deprn, 0) +
2070 nvl(p_asset_deprn_rec_old.ytd_deprn, 0);
2071 px_asset_deprn_rec_new.reval_deprn_reserve := nvl(p_asset_deprn_rec_adj.reval_deprn_reserve, 0) +
2072 nvl(p_asset_deprn_rec_old.reval_deprn_reserve, 0);
2073 px_asset_deprn_rec_new.reval_ytd_deprn := nvl(p_asset_deprn_rec_adj.reval_ytd_deprn, 0) +
2074 nvl(p_asset_deprn_rec_old.reval_ytd_deprn, 0);
2075 px_asset_deprn_rec_new.production := nvl(p_asset_deprn_rec_adj.production, 0) +
2076 nvl(p_asset_deprn_rec_old.production, 0);
2077 px_asset_deprn_rec_new.ltd_production := nvl(p_asset_deprn_rec_adj.ltd_production, 0) +
2078 nvl(p_asset_deprn_rec_old.ltd_production, 0);
2079 px_asset_deprn_rec_new.ytd_production := nvl(p_asset_deprn_rec_adj.ytd_production, 0) +
2080 nvl(p_asset_deprn_rec_old.ytd_production, 0);
2081
2082 px_asset_deprn_rec_new.bonus_deprn_amount := 0;
2083 px_asset_deprn_rec_new.bonus_deprn_reserve := nvl(p_asset_deprn_rec_adj.bonus_deprn_reserve, 0) +
2084 nvl(p_asset_deprn_rec_old.bonus_deprn_reserve, 0);
2085 px_asset_deprn_rec_new.bonus_ytd_deprn := nvl(p_asset_deprn_rec_adj.bonus_ytd_deprn, 0) +
2086 nvl(p_asset_deprn_rec_old.bonus_ytd_deprn, 0);
2087 else
2088
2092 px_asset_deprn_rec_new.reval_deprn_reserve := nvl(p_asset_deprn_rec_old.reval_deprn_reserve, 0);
2089 px_asset_fin_rec_new.original_cost := nvl(p_asset_fin_rec_old.original_cost,0);
2090 px_asset_deprn_rec_new.deprn_reserve := nvl(p_asset_deprn_rec_old.deprn_reserve, 0);
2091 px_asset_deprn_rec_new.ytd_deprn := nvl(p_asset_deprn_rec_old.ytd_deprn, 0);
2093 px_asset_deprn_rec_new.reval_ytd_deprn := nvl(p_asset_deprn_rec_old.reval_ytd_deprn, 0);
2094 px_asset_deprn_rec_new.ltd_production := nvl(p_asset_deprn_rec_old.ltd_production, 0);
2095 px_asset_deprn_rec_new.ytd_production := nvl(p_asset_deprn_rec_old.ytd_production, 0);
2096 px_asset_deprn_rec_new.bonus_deprn_reserve := nvl(p_asset_deprn_rec_old.bonus_deprn_reserve, 0);
2097 px_asset_deprn_rec_new.bonus_ytd_deprn := nvl(p_asset_deprn_rec_old.bonus_ytd_deprn, 0);
2098 end if;
2099
2100 px_asset_fin_rec_new.short_fiscal_year_flag := nvl(p_asset_fin_rec_adj.short_fiscal_year_flag,
2101 nvl(p_asset_fin_rec_old.short_fiscal_year_flag, 'NO'));
2102
2103 if (px_asset_fin_rec_new.short_fiscal_year_flag = 'YES') then
2104 px_asset_fin_rec_new.conversion_date := nvl(p_asset_fin_rec_adj.conversion_date,
2105 p_asset_fin_rec_old.conversion_date);
2106 px_asset_fin_rec_new.orig_deprn_start_date := nvl(p_asset_fin_rec_adj.orig_deprn_start_date,
2107 p_asset_fin_rec_old.orig_deprn_start_date);
2108 else
2109 px_asset_fin_rec_new.conversion_date := null;
2110 px_asset_fin_rec_new.orig_deprn_start_date := null;
2111 end if;
2112
2113 -- Japan Tax Phase3
2114 FA_UTIL_PVT.load_char_value
2115 (p_char_old => p_asset_fin_rec_old.extended_deprn_flag,
2116 p_char_adj => p_asset_fin_rec_adj.extended_deprn_flag,
2117 x_char_new => px_asset_fin_rec_new.extended_deprn_flag,
2118 p_log_level_rec => p_log_level_rec);
2119
2120 FA_UTIL_PVT.load_num_value
2121 (p_num_old => p_asset_fin_rec_old.extended_depreciation_period,
2122 p_num_adj => p_asset_fin_rec_adj.extended_depreciation_period,
2123 x_num_new => px_asset_fin_rec_new.extended_depreciation_period,
2124 p_log_level_rec => p_log_level_rec);
2125
2126 -- round those values holding currency amounts
2127 -- converted to use utils package instead of fa_round_pkg
2128 -- so that the correct sob (P/R) is always used to get currency
2129
2130
2131 if not FA_UTILS_PKG.faxrnd(px_asset_fin_rec_new.cost,
2132 p_asset_hdr_rec.book_type_code,
2133 p_log_level_rec => p_log_level_rec) then
2134 raise calc_err;
2135 end if;
2136
2137
2138 if not FA_UTILS_PKG.faxrnd(px_asset_fin_rec_new.original_cost,
2139 p_asset_hdr_rec.book_type_code,
2140 p_log_level_rec => p_log_level_rec) then
2141 raise calc_err;
2142 end if;
2143
2144 if not FA_UTILS_PKG.faxrnd(px_asset_fin_rec_new.reval_amortization_basis,
2145 p_asset_hdr_rec.book_type_code,
2146 p_log_level_rec => p_log_level_rec) then
2147 raise calc_err;
2148 end if;
2149
2150 if not FA_UTILS_PKG.faxrnd(px_asset_fin_rec_new.reval_ceiling,
2151 p_asset_hdr_rec.book_type_code,
2152 p_log_level_rec => p_log_level_rec) then
2153 raise calc_err;
2154 end if;
2155
2156 if not FA_UTILS_PKG.faxrnd(px_asset_fin_rec_new.unrevalued_cost,
2157 p_asset_hdr_rec.book_type_code,
2158 p_log_level_rec => p_log_level_rec) then
2159 raise calc_err;
2160 end if;
2161
2162 if not FA_UTILS_PKG.faxrnd(px_asset_fin_rec_new.cip_cost,
2163 p_asset_hdr_rec.book_type_code,
2164 p_log_level_rec => p_log_level_rec) then
2165 raise calc_err;
2166 end if;
2167
2168 if not FA_UTILS_PKG.faxrnd(px_asset_deprn_rec_new.deprn_reserve,
2169 p_asset_hdr_rec.book_type_code,
2170 p_log_level_rec => p_log_level_rec) then
2171 raise calc_err;
2172 end if;
2173
2174 if not FA_UTILS_PKG.faxrnd(px_asset_deprn_rec_new.ytd_deprn,
2175 p_asset_hdr_rec.book_type_code,
2176 p_log_level_rec => p_log_level_rec) then
2177 raise calc_err;
2178 end if;
2179
2180 if not FA_UTILS_PKG.faxrnd(px_asset_deprn_rec_new.reval_deprn_reserve,
2181 p_asset_hdr_rec.book_type_code,
2182 p_log_level_rec => p_log_level_rec) then
2183 raise calc_err;
2184 end if;
2185
2186 if not FA_UTILS_PKG.faxrnd(px_asset_deprn_rec_new.reval_ytd_deprn,
2187 p_asset_hdr_rec.book_type_code,
2188 p_log_level_rec => p_log_level_rec) then
2189 raise calc_err;
2190 end if;
2191
2192 if not FA_UTILS_PKG.faxrnd(px_asset_deprn_rec_new.bonus_deprn_reserve,
2193 p_asset_hdr_rec.book_type_code,
2194 p_log_level_rec => p_log_level_rec) then
2195 raise calc_err;
2196 end if;
2197
2201 raise calc_err;
2198 if not FA_UTILS_PKG.faxrnd(px_asset_deprn_rec_new.bonus_ytd_deprn,
2199 p_asset_hdr_rec.book_type_code,
2200 p_log_level_rec => p_log_level_rec) then
2202 end if;
2203
2204 if (p_mrc_sob_type_code <> 'R') then
2205 G_primary_new_cost := px_asset_fin_rec_new.cost;
2206 end if;
2207
2208 return true;
2209
2210 EXCEPTION
2211 when calc_err then
2212 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
2213 return false;
2214
2215 when others then
2216 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
2217 return false;
2218
2219
2220 END calc_new_amounts;
2221
2222 FUNCTION calc_derived_amounts
2223 (px_trans_rec IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
2224 p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
2225 p_asset_desc_rec IN FA_API_TYPES.asset_desc_rec_type,
2226 p_asset_type_rec IN FA_API_TYPES.asset_type_rec_type,
2227 p_asset_cat_rec IN FA_API_TYPES.asset_cat_rec_type,
2228 p_asset_fin_rec_old IN FA_API_TYPES.asset_fin_rec_type,
2229 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
2230 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
2231 p_asset_deprn_rec_old IN FA_API_TYPES.asset_deprn_rec_type,
2232 p_asset_deprn_rec_adj IN FA_API_TYPES.asset_deprn_rec_type,
2233 px_asset_deprn_rec_new IN OUT NOCOPY FA_API_TYPES.asset_deprn_rec_type,
2234 p_period_rec IN FA_API_TYPES.period_rec_type,
2235 p_mrc_sob_type_code IN VARCHAR2,
2236 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
2237 ) RETURN BOOLEAN IS
2238
2239 l_count number := 0;
2240 l_calling_fn VARCHAR2(40) := 'fa_asset_calc_pvt.calc_derived_amounts';
2241 calc_err EXCEPTION;
2242
2243 BEGIN
2244
2245 if not calc_deprn_start_date
2246 (p_asset_hdr_rec => p_asset_hdr_rec,
2247 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
2248 px_asset_fin_rec_new => px_asset_fin_rec_new,
2249 p_log_level_rec => p_log_level_rec
2250 ) then
2251 raise calc_err;
2252 end if;
2253
2254 if not calc_salvage_value
2255 (p_trans_rec => px_trans_rec,
2256 p_asset_hdr_rec => p_asset_hdr_rec,
2257 p_asset_type_rec => p_asset_type_rec,
2258 p_asset_fin_rec_old => p_asset_fin_rec_old,
2259 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
2260 px_asset_fin_rec_new => px_asset_fin_rec_new,
2261 p_mrc_sob_type_code => p_mrc_sob_type_code,
2262 p_log_level_rec => p_log_level_rec
2263 ) then
2264 raise calc_err;
2265 end if;
2266
2267 -- BUG# 2650528
2268 -- need to call calc_itc_info before calc_rec_cost
2269 -- in order to get the itc_basis otherwise the rec_cost
2270 -- would just be set to null
2271
2272 if (fa_cache_pkg.fazcbc_record.book_class = 'TAX' and
2273 px_asset_fin_rec_new.itc_amount_id is not null) then
2274 if not calc_itc_info
2275 (p_asset_hdr_rec => p_asset_hdr_rec,
2276 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
2277 px_asset_fin_rec_new => px_asset_fin_rec_new,
2278 p_log_level_rec => p_log_level_rec
2279 ) then
2280 raise calc_err;
2281 end if;
2282 end if;
2283
2284 if not calc_rec_cost
2285 (p_asset_hdr_rec => p_asset_hdr_rec,
2286 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
2287 px_asset_fin_rec_new => px_asset_fin_rec_new,
2288 p_log_level_rec => p_log_level_rec
2289 ) then
2290 raise calc_err;
2291 end if;
2292
2293
2294 if not calc_deprn_limit_adj_rec_cost
2295 (p_asset_hdr_rec => p_asset_hdr_rec,
2296 p_asset_type_rec => p_asset_type_rec,
2297 p_asset_fin_rec_old => p_asset_fin_rec_old,
2298 p_asset_fin_rec_adj => p_asset_fin_rec_adj,
2299 px_asset_fin_rec_new => px_asset_fin_rec_new,
2300 p_mrc_sob_type_code => p_mrc_sob_type_code,
2301 p_log_level_rec => p_log_level_rec
2302 ) then
2303 raise calc_err;
2304 end if;
2305
2306
2307 if not calc_flags
2308 (p_trans_rec => px_trans_rec,
2309 p_asset_hdr_rec => p_asset_hdr_rec,
2310 p_asset_type_rec => p_asset_type_rec,
2311 p_asset_fin_rec_old => p_asset_fin_rec_old,
2312 px_asset_fin_rec_new => px_asset_fin_rec_new,
2313 p_asset_deprn_rec => px_asset_deprn_rec_new,
2314 p_period_rec => p_period_rec,
2315 p_log_level_rec => p_log_level_rec
2316 ) then
2317 raise calc_err;
2318 end if;
2319
2320 /* Bug 7707540: load_num_value is called only while setting/resetting the extended_deprn_flag */
2321 if (nvl(p_asset_fin_rec_old.extended_deprn_flag, '-1') <> nvl(p_asset_fin_rec_adj.extended_deprn_flag, '-1'))
2322 and nvl(fnd_profile.value('FA_JAPAN_TAX_REFORMS'),'N') = 'Y' then
2323
2324 -- Japan Tax phase3 Start
2325 FA_UTIL_PVT.load_num_value
2326 (p_num_old => p_asset_fin_rec_old.period_counter_life_complete,
2330
2327 p_num_adj => p_asset_fin_rec_adj.period_counter_life_complete,
2328 x_num_new => px_asset_fin_rec_new.period_counter_life_complete,
2329 p_log_level_rec => p_log_level_rec);
2331 FA_UTIL_PVT.load_num_value
2332 (p_num_old => p_asset_fin_rec_old.period_counter_fully_reserved,
2333 p_num_adj => p_asset_fin_rec_adj.period_counter_fully_reserved,
2334 x_num_new => px_asset_fin_rec_new.period_counter_fully_reserved,
2335 p_log_level_rec => p_log_level_rec);
2336
2337 -- Bug 7707540: Commented the fix for bug 7478217
2338 /* Added for bug 7478217 */
2339 /* if (p_asset_fin_rec_old.period_counter_fully_reserved is not null and
2340 (p_asset_fin_rec_adj.LIFE_IN_MONTHS > 0 OR abs(p_asset_fin_rec_adj.cost) > 0)) then
2341 px_asset_fin_rec_new.period_counter_fully_reserved := null;
2342 px_asset_fin_rec_new.period_counter_life_complete := null;
2343 end if; */
2344 end if;
2345 -- End Bug 7707540
2346
2347 if (p_log_level_rec.statement_level) then
2348 fa_debug_pkg.add(l_calling_fn, 'Japan Tax:1 fa_books deprn_method_code', px_asset_fin_rec_new.deprn_method_code);
2349 fa_debug_pkg.add(l_calling_fn, 'Japan Tax:1 fa_books life_in_months', px_asset_fin_rec_new.life_in_months);
2350 fa_debug_pkg.add(l_calling_fn, 'Japan Tax:1 fa_books salvage_value', px_asset_fin_rec_new.salvage_value);
2351 fa_debug_pkg.add(l_calling_fn, 'Japan Tax:1 fa_books period_counter_fully_reserved', px_asset_fin_rec_new.period_counter_fully_reserved);
2352 fa_debug_pkg.add(l_calling_fn, 'Japan Tax:1 fa_books period_counter_life_complete', px_asset_fin_rec_new.period_counter_life_complete);
2353 fa_debug_pkg.add(l_calling_fn, 'Japan Tax:1 fa_books basic_rate', px_asset_fin_rec_new.basic_rate);
2354 fa_debug_pkg.add(l_calling_fn, 'Japan Tax:1 fa_books adjusted_rate', px_asset_fin_rec_new.adjusted_rate);
2355 fa_debug_pkg.add(l_calling_fn, 'Japan Tax:1 fa_books allowed_deprn_limit', px_asset_fin_rec_new.allowed_deprn_limit);
2356 fa_debug_pkg.add(l_calling_fn, 'Japan Tax:1 fa_books deprn_limit_type', px_asset_fin_rec_new.deprn_limit_type);
2357 fa_debug_pkg.add(l_calling_fn, 'Japan Tax:1 fa_books allowed_deprn_limit_amount', px_asset_fin_rec_new.allowed_deprn_limit_amount);
2358 fa_debug_pkg.add(l_calling_fn, 'Japan Tax:1 px_asset_fin_rec_new.recoverable_cost', px_asset_fin_rec_new.recoverable_cost);
2359 end if;
2360
2361 return true;
2362
2363 EXCEPTION
2364 when calc_err then
2365 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
2366 return false;
2367
2368 when others then
2369 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
2370 return false;
2371
2372 END calc_derived_amounts;
2373
2374
2375 FUNCTION calc_prorate_date
2376 (p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
2377 p_asset_type_rec IN FA_API_TYPES.asset_type_rec_type,
2378 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
2379 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
2380 p_period_rec IN FA_API_TYPES.period_rec_type,
2381 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
2382 ) RETURN BOOLEAN IS
2383
2384 l_count number:= 0;
2385 l_prorate_calendar varchar2(15);
2386 l_fiscal_year_name varchar2(30);
2387 l_calling_fn varchar2(40) := 'fa_asset_calc_pvt.calc_prorate_date';
2388 calc_err EXCEPTION;
2389
2390 BEGIN
2391
2392 l_prorate_calendar := fa_cache_pkg.fazcbc_record.prorate_calendar;
2393 l_fiscal_year_name := fa_cache_pkg.fazcbc_record.fiscal_year_name;
2394
2395 if (p_asset_type_rec.asset_type = 'GROUP') then
2396 px_asset_fin_rec_new.prorate_date := px_asset_fin_rec_new.date_placed_in_service;
2397 else
2398
2399 if (px_asset_fin_rec_new.prorate_convention_code is null) then
2400 fa_srvr_msg.add_message(
2401 calling_fn => l_calling_fn,
2402 name => 'FA_EXP_GET_PRORATE_INFO');
2403 raise calc_err;
2404 end if;
2405
2406 if not fa_cache_pkg.fazccvt
2407 (x_prorate_convention_code => px_asset_fin_rec_new.prorate_convention_code,
2408 x_fiscal_year_name => l_fiscal_year_name,
2409 p_log_level_rec => p_log_level_rec) then
2410 raise calc_err;
2411 end if;
2412
2413 if (p_log_level_rec.statement_level) then
2414 fa_debug_pkg.add(l_calling_fn, 'px_asset_fin_rec_new.prorate_convention_code', px_asset_fin_rec_new.prorate_convention_code);
2415 fa_debug_pkg.add(l_calling_fn, 'px_asset_fin_rec_new.date_placed_in_service', px_asset_fin_rec_new.date_placed_in_service);
2416 fa_debug_pkg.add(l_calling_fn, 'l_prorate_calendar', l_prorate_calendar);
2417 end if;
2418
2419 select /*+ leading(conv) use_nl(conv cp) index(cp) */
2420 prorate_date
2421 into px_asset_fin_rec_new.prorate_date
2422 from fa_calendar_periods cp,
2423 fa_conventions conv
2424 where conv.prorate_convention_code = px_asset_fin_rec_new.prorate_convention_code
2425 and conv.start_date <= px_asset_fin_rec_new.date_placed_in_service
2426 and conv.end_date >= px_asset_fin_rec_new.date_placed_in_service
2427 and cp.calendar_type = l_prorate_calendar
2428 and conv.prorate_date >= cp.start_date
2429 and conv.prorate_date <= cp.end_date;
2430
2434 --
2431 -- BUG# 2251278
2432 -- removing the following as it prevent prorate periods that
2433 -- fall in a future period (such as FOL-MONTH)
2435 -- and conv.prorate_date <= p_period_rec.fy_end_date;
2436
2437 end if; -- (p_asset_type_rec.asset_type = 'GROUP')
2438
2439 -- For Polish, we need additional changes here.
2440 -- First find out if we have a polish mechanism here
2441 if (nvl(px_asset_fin_rec_new.deprn_method_code,
2442 p_asset_fin_rec_adj.deprn_method_code) is not null) and
2443 (fa_cache_pkg.fazccmt (
2444 X_method => nvl(px_asset_fin_rec_new.deprn_method_code,
2445 p_asset_fin_rec_adj.deprn_method_code),
2446 X_life => nvl(px_asset_fin_rec_new.life_in_months,
2447 p_asset_fin_rec_adj.life_in_months),
2448 p_log_level_rec => p_log_level_rec
2449 )) then
2450 if (fa_cache_pkg.fazccmt_record.deprn_basis_rule_id is not null) then
2451 if (fa_cache_pkg.fazcdbr_record.polish_rule in (
2452 FA_STD_TYPES.FAD_DBR_POLISH_1,
2453 FA_STD_TYPES.FAD_DBR_POLISH_2)) then
2454 -- For Polish rules 1 and 2, set prorate_date based on dpis
2455 -- regardless of prorate convention.
2456 px_asset_fin_rec_new.prorate_date :=
2457 px_asset_fin_rec_new.date_placed_in_service;
2458 end if;
2459 end if;
2460 end if;
2461
2462 return true;
2463
2464 EXCEPTION
2465 when calc_err then
2466 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
2467 return false;
2468
2469 when no_data_found then
2470 fa_srvr_msg.add_message(
2471 calling_fn => l_calling_fn,
2472 name => 'FA_EXP_GET_PRORATE_INFO');
2473 return FALSE;
2474
2475 when others then
2476 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
2477
2478 return false;
2479
2480 END calc_prorate_date;
2481
2482 FUNCTION calc_deprn_start_date
2483 (p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
2484 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
2485 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
2486 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
2487 ) RETURN BOOLEAN IS
2488
2489 l_dwaf varchar2(3);
2490 l_fiscal_year_name varchar2(30);
2491 l_calling_fn varchar2(40) := 'fa_asset_calc_pvt.calc_deprn_start_date';
2492 calc_err EXCEPTION;
2493
2494 BEGIN
2495
2496 l_fiscal_year_name := fa_cache_pkg.fazcbc_record.fiscal_year_name;
2497
2498 if not fa_cache_pkg.fazccvt
2499 (x_prorate_convention_code => px_asset_fin_rec_new.prorate_convention_code,
2500 x_fiscal_year_name => l_fiscal_year_name,
2501 p_log_level_rec => p_log_level_rec) then
2502 raise calc_err;
2503 end if;
2504
2505 l_dwaf := fa_cache_pkg.fazccvt_record.depr_when_acquired_flag;
2506
2507 if (l_dwaf = 'YES') then
2508 px_asset_fin_rec_new.deprn_start_date := px_asset_fin_rec_new.date_placed_in_service;
2509 else
2510 px_asset_fin_rec_new.deprn_start_date := px_asset_fin_rec_new.prorate_date;
2511 end if;
2512
2513 if px_asset_fin_rec_new.deprn_start_date is null then
2514 raise calc_err;
2515 end if;
2516
2517 return true;
2518
2519 EXCEPTION
2520 when calc_err then
2521 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
2522 return false;
2523
2524 when others then
2525 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
2526 return false;
2527
2528 END calc_deprn_start_date;
2529
2530
2531 FUNCTION calc_rec_cost
2532 (p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
2533 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
2534 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
2535 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
2536 ) RETURN BOOLEAN IS
2537
2538 CURSOR c_get_rec_cost_w_ceiling IS
2539 select least(px_asset_fin_rec_new.cost - px_asset_fin_rec_new.salvage_value,
2540 nvl(ce.limit, px_asset_fin_rec_new.cost - px_asset_fin_rec_new.salvage_value))
2541 from fa_ceilings ce
2542 where ce.ceiling_name = px_asset_fin_rec_new.ceiling_name
2543 and px_asset_fin_rec_new.date_placed_in_service
2544 between ce.start_date and
2545 nvl(ce.end_date, px_asset_fin_rec_new.date_placed_in_service);
2546
2547 l_ceiling_type varchar2(30);
2548 l_calling_fn varchar2(40) := 'fa_asset_calc_pvt.calc_rec_cost';
2549
2550 l_temp_rec_cost number;
2551
2552 calc_err EXCEPTION;
2553
2554 BEGIN
2555
2556 -- can probably convert to cache calls here
2557
2558 if (px_asset_fin_rec_new.ceiling_name is not null) then
2559 select ceiling_type
2560 into l_ceiling_type
2561 from fa_ceiling_types
2562 where ceiling_name = px_asset_fin_rec_new.ceiling_name;
2563 end if;
2564
2565 if (px_asset_fin_rec_new.itc_amount_id is null) then
2566
2570 FETCH c_get_rec_cost_w_ceiling INTO l_temp_rec_cost;
2567 if l_ceiling_type = 'RECOVERABLE COST CEILING' then
2568
2569 OPEN c_get_rec_cost_w_ceiling;
2571
2572 if c_get_rec_cost_w_ceiling%NOTFOUND then
2573 px_asset_fin_rec_new.recoverable_cost := px_asset_fin_rec_new.cost -
2574 px_asset_fin_rec_new.salvage_value;
2575 else
2576 px_asset_fin_rec_new.recoverable_cost := l_temp_rec_cost;
2577 end if;
2578
2579 CLOSE c_get_rec_cost_w_ceiling;
2580
2581 else
2582 px_asset_fin_rec_new.recoverable_cost :=
2583 px_asset_fin_rec_new.cost - px_asset_fin_rec_new.salvage_value;
2584
2585 end if;
2586 else
2587 if (l_ceiling_type = 'RECOVERABLE COST CEILING') then
2588 select least(px_asset_fin_rec_new.cost - px_asset_fin_rec_new.salvage_value -
2589 px_asset_fin_rec_new.itc_basis * ir.basis_reduction_rate,
2590 nvl(ce.limit, px_asset_fin_rec_new.cost - px_asset_fin_rec_new.salvage_value -
2591 px_asset_fin_rec_new.itc_basis * ir.basis_reduction_rate))
2592 into px_asset_fin_rec_new.recoverable_cost
2593 from fa_ceilings ce,
2594 fa_itc_rates ir
2595 where ir.itc_amount_id = px_asset_fin_rec_new.itc_amount_id
2596 and ce.ceiling_name = px_asset_fin_rec_new.ceiling_name
2597 and px_asset_fin_rec_new.date_placed_in_service
2598 between ce.start_date and
2599 nvl(ce.end_date, px_asset_fin_rec_new.date_placed_in_service);
2600
2601 else
2602 select px_asset_fin_rec_new.cost - px_asset_fin_rec_new.salvage_value -
2603 px_asset_fin_rec_new.itc_basis * ir.basis_reduction_rate
2604 into px_asset_fin_rec_new.recoverable_cost
2605 from fa_itc_rates ir
2606 where ir.itc_amount_id = px_asset_fin_rec_new.itc_amount_id;
2607 end if;
2608 end if;
2609
2610 return true;
2611
2612 EXCEPTION
2613 when calc_err then
2614 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
2615 return false;
2616
2617 when others then
2618 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
2619 return false;
2620
2621 END calc_rec_cost;
2622
2623
2624 FUNCTION calc_deprn_limit_adj_rec_cost
2625 (p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
2626 p_asset_type_rec IN FA_API_TYPES.asset_type_rec_type,
2627 p_asset_fin_rec_old IN FA_API_TYPES.asset_fin_rec_type,
2628 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
2629 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
2630 p_mrc_sob_type_code IN VARCHAR2,
2631 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
2632 ) RETURN BOOLEAN IS
2633
2634 l_calling_fn VARCHAR2(40) := 'fa_asset_calc_pvt.calc_deprn_limit';
2635 calc_err EXCEPTION;
2636
2637 BEGIN
2638
2639 -- like % salvage, we will now allow direct entry of limits on
2640 -- an asset by asset basis as part of the group project and
2641 -- no longer mandate from category
2642
2643 -- reclass with redefault MUST explicitly populate the
2644 -- fin_adj rec with the new categories info (including treating
2645 -- the amount as a delta) ??? verify feasibility of ths last point ???
2646
2647 if (p_log_level_rec.statement_level) then
2648 fa_debug_pkg.add(l_calling_fn,
2649 'deprn_limit type',
2650 p_asset_fin_rec_old.deprn_limit_type);
2651 fa_debug_pkg.add(l_calling_fn,
2652 'salvage type',
2653 p_asset_fin_rec_adj.deprn_limit_type);
2654 fa_debug_pkg.add(l_calling_fn,
2655 'delta deprn limit',
2656 p_asset_fin_rec_adj.allowed_deprn_limit);
2657 fa_debug_pkg.add(l_calling_fn,
2658 'delta deprn limit amount',
2659 p_asset_fin_rec_adj.allowed_deprn_limit_amount);
2660 end if;
2661
2662 px_asset_fin_rec_new.deprn_limit_type :=
2663 nvl(p_asset_fin_rec_adj.deprn_limit_type,
2664 nvl(p_asset_fin_rec_old.deprn_limit_type, 'NONE'));
2665
2666 if (p_log_level_rec.statement_level) then
2667 fa_debug_pkg.add(l_calling_fn,
2668 'limit type',
2669 px_asset_fin_rec_new.deprn_limit_type);
2670 end if;
2671
2672 if (px_asset_fin_rec_new.deprn_limit_type = 'SUM' and
2673 p_asset_type_rec.asset_type <> 'GROUP') then
2674 fa_srvr_msg.add_message(
2675 calling_fn => l_calling_fn,
2676 name => '***FA_NO_SUM_NO_GROUP***');
2677 raise calc_err;
2678 elsif (px_asset_fin_rec_new.deprn_limit_type = 'AMT' and
2679 p_asset_type_rec.asset_type = 'GROUP') then
2680 fa_srvr_msg.add_message(
2681 calling_fn => l_calling_fn,
2682 name => '***FA_NO_LIM_AMT_FOR_GROUP***');
2683 raise calc_err;
2684 elsif (px_asset_fin_rec_new.deprn_limit_type <> 'AMT' and
2685 px_asset_fin_rec_new.deprn_limit_type <> 'PCT' and
2686 px_asset_fin_rec_new.deprn_limit_type <> 'SUM' and
2687 px_asset_fin_rec_new.deprn_limit_type <> 'NONE') then
2688 fa_srvr_msg.add_message(
2689 calling_fn => l_calling_fn,
2693 token2 => 'PARAM',
2690 name => 'FA_INVALID_PARAMETER',
2691 token1 => 'VALUE',
2692 value1 => px_asset_fin_rec_new.deprn_limit_type,
2694 value2 => 'DEPRN_LIMIT_TYPE');
2695 raise calc_err;
2696 end if;
2697
2698
2699
2700 -- enhancing for group and core to allow direct percentage
2701 -- entry for the assets and not just defaults from category
2702 -- note that we initially set the new value for the salvage %
2703 -- in calc_new_amounts and use that here.
2704 --
2705 -- NOTE: we loaded the "new.deprn_limit_type" value previously
2706 -- NOTE2: limit amount must be truncated
2707 --
2708 if (px_asset_fin_rec_new.deprn_limit_type = 'PCT') then
2709 -- use the percentage
2710 px_asset_fin_rec_new.allowed_deprn_limit := (nvl(p_asset_fin_rec_adj.allowed_deprn_limit, 0) +
2711 nvl(p_asset_fin_rec_old.allowed_deprn_limit, 0));
2712
2713 px_asset_fin_rec_new.allowed_deprn_limit_amount := px_asset_fin_rec_new.cost -
2714 (px_asset_fin_rec_new.cost *
2715 px_asset_fin_rec_new.allowed_deprn_limit);
2716
2717 -- BUG# 3092066
2718 -- use ceiling here, not round
2719 -- this results in a floor on the final amount
2720 if not FA_UTILS_PKG.faxceil(px_asset_fin_rec_new.allowed_deprn_limit_amount,
2721 p_asset_hdr_rec.book_type_code,
2722 p_log_level_rec => p_log_level_rec) then
2723 raise calc_err;
2724 end if;
2725
2726 px_asset_fin_rec_new.adjusted_recoverable_cost :=
2727 px_asset_fin_rec_new.cost - px_asset_fin_rec_new.allowed_deprn_limit_amount;
2728
2729 elsif (px_asset_fin_rec_new.deprn_limit_type = 'SUM') then
2730 -- this is used only for group assets
2731 -- performance may not be too great here
2732
2733
2734 -- BUG# 3198440
2735 -- for additions (old rec is null) just set to 0
2736
2737 px_asset_fin_rec_new.allowed_deprn_limit := null;
2738
2739 if (p_asset_fin_rec_old.deprn_limit_type is null) then
2740 px_asset_fin_rec_new.allowed_deprn_limit_amount := 0;
2741 elsif (p_asset_fin_rec_old.deprn_limit_type <> 'SUM') then
2742 if (p_mrc_sob_type_code <> 'R') then
2743 select nvl(sum(allowed_deprn_limit_amount), 0)
2744 into px_asset_fin_rec_new.allowed_deprn_limit_amount
2745 from fa_books bk,
2746 fa_additions_b ad
2747 where bk.transaction_header_id_out is null
2748 and bk.group_asset_id = p_asset_hdr_rec.asset_id
2749 and bk.asset_id = ad.asset_id
2750 and bk.book_type_code = p_asset_hdr_rec.book_type_code
2751 and ad.asset_type = 'CAPITALIZED';
2752 else
2753 select nvl(sum(allowed_deprn_limit_amount), 0)
2754 into px_asset_fin_rec_new.allowed_deprn_limit_amount
2755 from fa_books_mrc_v bk,
2756 fa_additions_b ad
2757 where bk.transaction_header_id_out is null
2758 and bk.group_asset_id = p_asset_hdr_rec.asset_id
2759 and bk.asset_id = ad.asset_id
2760 and bk.book_type_code = p_asset_hdr_rec.book_type_code
2761 and ad.asset_type = 'CAPITALIZED';
2762 end if;
2763
2764 else
2765 px_asset_fin_rec_new.allowed_deprn_limit_amount :=
2766 nvl(p_asset_fin_rec_adj.allowed_deprn_limit_amount, 0) +
2767 nvl(p_asset_fin_rec_old.allowed_deprn_limit_amount, 0);
2768 end if;
2769
2770 -- validation
2771 if (px_asset_fin_rec_new.allowed_deprn_limit_amount = 0) then
2772 px_asset_fin_rec_new.adjusted_recoverable_cost :=
2773 px_asset_fin_rec_new.recoverable_cost;
2774 else
2775 px_asset_fin_rec_new.adjusted_recoverable_cost :=
2776 px_asset_fin_rec_new.cost - px_asset_fin_rec_new.allowed_deprn_limit_amount;
2777 end if;
2778 elsif (px_asset_fin_rec_new.deprn_limit_type = 'AMT') then
2779 px_asset_fin_rec_new.allowed_deprn_limit := null;
2780
2781 -- delta salvage amount may or may not be null
2782 -- use it or 0 for the delta
2783 if (p_mrc_sob_type_code <> 'R') then
2784
2785 -- BUG# 3516255
2786 -- when changing types, the delta is treated as the new amount
2787 -- we will not add to the prior value that may have been
2788 -- existed/calculated from previous type of PCT or SUM
2789
2790 -- Bug 6705332 While extending assets
2791 -- p_asset_fin_rec_adj.allowed_deprn_limit_amount contains the final value.
2792 if (p_asset_fin_rec_old.deprn_limit_type <> 'AMT') or
2793 ((nvl(p_asset_fin_rec_old.extended_deprn_flag,'N') <> 'Y') and
2794 (nvl(px_asset_fin_rec_new.extended_deprn_flag,'N') = 'Y')) then
2795 px_asset_fin_rec_new.allowed_deprn_limit_amount :=
2796 nvl(p_asset_fin_rec_adj.allowed_deprn_limit_amount, 0);
2797 else
2798 px_asset_fin_rec_new.allowed_deprn_limit_amount :=
2799 nvl(p_asset_fin_rec_adj.allowed_deprn_limit_amount, 0) +
2800 nvl(p_asset_fin_rec_old.allowed_deprn_limit_amount, 0);
2801 end if;
2802
2803 if ((px_asset_fin_rec_new.cost > 0 and
2804 px_asset_fin_rec_new.allowed_deprn_limit_amount < 0) or
2808 calling_fn => l_calling_fn,
2805 (px_asset_fin_rec_new.cost < 0 and
2806 px_asset_fin_rec_new.allowed_deprn_limit_amount > 0)) then
2807 fa_srvr_msg.add_message(
2809 name => '***FA_DIFF_SIGN_LIMIT***');
2810 raise calc_err;
2811 elsif (px_asset_fin_rec_new.cost = 0) then
2812 px_asset_fin_rec_new.allowed_deprn_limit_amount := 0;
2813 end if;
2814
2815 G_primary_deprn_limit_amount := px_asset_fin_rec_new.allowed_deprn_limit_amount;
2816
2817 else
2818 -- Fix for Bug #2914328. Need to also make sure that
2819 -- G_primary_new_cost is not zero to avoid zero divide error.
2820 if (px_asset_fin_rec_new.cost <> 0) and
2821 (G_primary_new_cost <> 0) then
2822 px_asset_fin_rec_new.allowed_deprn_limit_amount :=
2823 G_primary_deprn_limit_amount *
2824 (px_asset_fin_rec_new.cost / G_primary_new_cost);
2825 else
2826 px_asset_fin_rec_new.allowed_deprn_limit_amount := 0;
2827 end if;
2828
2829 end if;
2830
2831 -- round the limit
2832 if not FA_UTILS_PKG.faxrnd(px_asset_fin_rec_new.allowed_deprn_limit_amount,
2833 p_asset_hdr_rec.book_type_code,
2834 p_log_level_rec => p_log_level_rec) then
2835 raise calc_err;
2836 end if;
2837
2838 px_asset_fin_rec_new.adjusted_recoverable_cost :=
2839 px_asset_fin_rec_new.cost - px_asset_fin_rec_new.allowed_deprn_limit_amount;
2840
2841 else -- NONE
2842 px_asset_fin_rec_new.allowed_deprn_limit_amount := NULL;
2843 px_asset_fin_rec_new.allowed_deprn_limit := NULL;
2844
2845 px_asset_fin_rec_new.adjusted_recoverable_cost :=
2846 px_asset_fin_rec_new.recoverable_cost;
2847
2848 end if;
2849
2850 -- round the adj_rec_cost
2851 if not FA_UTILS_PKG.faxfloor(px_asset_fin_rec_new.adjusted_recoverable_cost,
2852 p_asset_hdr_rec.book_type_code,
2853 p_log_level_rec => p_log_level_rec) then
2854 raise calc_err;
2855 end if;
2856
2857 if (p_log_level_rec.statement_level) then
2858 fa_debug_pkg.add(l_calling_fn,
2859 'new allowed_deprn_limit_amount',
2860 px_asset_fin_rec_new.allowed_deprn_limit_amount);
2861 fa_debug_pkg.add(l_calling_fn,
2862 'px_asset_fin_rec_new.adjusted_recoverable_cost',
2863 px_asset_fin_rec_new.adjusted_recoverable_cost);
2864 end if;
2865
2866 return true;
2867
2868 EXCEPTION
2869 when calc_err then
2870 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
2871 return false;
2872
2873 when others then
2874 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
2875 return false;
2876
2877 END calc_deprn_limit_adj_rec_cost;
2878
2879
2880 FUNCTION calc_itc_info
2881 (p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
2882 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
2883 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
2884 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
2885 ) RETURN BOOLEAN IS
2886
2887
2888 l_itc_amount_rate number;
2889 l_basis_reduction_rate number;
2890 l_itc_basis number;
2891 l_itc_basis_reduction_amount number;
2892 l_ceiling_limit number := 0;
2893 l_calling_fn varchar2(40) := 'fa_asset_calc_pvt.calc_itc_info';
2894 calc_err EXCEPTION;
2895
2896 BEGIN
2897
2898 select itc_amount_rate,
2899 basis_reduction_rate
2900 into l_itc_amount_rate,
2901 l_basis_reduction_rate
2902 from fa_itc_rates
2903 where itc_amount_id = px_asset_fin_rec_new.itc_amount_id;
2904
2905 if (px_asset_fin_rec_new.ceiling_name is not null) then
2906 select limit
2907 into l_ceiling_limit
2908 from fa_ceilings
2909 where ceiling_name = px_asset_fin_rec_new.ceiling_name
2910 and px_asset_fin_rec_new.date_placed_in_service between
2911 start_date and nvl(end_date, px_asset_fin_rec_new.date_placed_in_service);
2912 end if;
2913
2914 if (nvl(l_ceiling_limit, 0) = 0) then
2915 px_asset_fin_rec_new.itc_basis := px_asset_fin_rec_new.cost;
2916 else
2917 px_asset_fin_rec_new.itc_basis := least(px_asset_fin_rec_new.cost, l_ceiling_limit);
2918 end if;
2919
2920
2921 px_asset_fin_rec_new.itc_amount := px_asset_fin_rec_new.itc_basis * l_itc_amount_rate;
2922
2923 -- ????
2924
2925 -- round the amounts
2926 if not FA_UTILS_PKG.faxrnd(px_asset_fin_rec_new.itc_amount,
2927 p_asset_hdr_rec.book_type_code,
2928 p_log_level_rec => p_log_level_rec) then
2929 raise calc_err;
2930 end if;
2931
2932 if not FA_UTILS_PKG.faxrnd(px_asset_fin_rec_new.itc_basis,
2933 p_asset_hdr_rec.book_type_code,
2934 p_log_level_rec => p_log_level_rec) then
2935 raise calc_err;
2936 end if;
2937
2938
2939 return true;
2940
2941 EXCEPTION
2942 when calc_err then
2946 when others then
2943 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
2944 return false;
2945
2947 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
2948 return false;
2949
2950 END calc_itc_info;
2951
2952 FUNCTION calc_salvage_value
2953 (p_trans_rec IN FA_API_TYPES.trans_rec_type,
2954 p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
2955 p_asset_type_rec IN FA_API_TYPES.asset_type_rec_type,
2956 p_asset_fin_rec_old IN FA_API_TYPES.asset_fin_rec_type,
2957 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
2958 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
2959 p_mrc_sob_type_code IN VARCHAR2,
2960 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
2961 ) RETURN BOOLEAN IS
2962
2963 calc_err EXCEPTION;
2964 l_calling_fn VARCHAR2(40) := 'fa_asset_calc_pvt.calc_salvage_value';
2965
2966 BEGIN
2967
2968 if (p_log_level_rec.statement_level) then
2969 fa_debug_pkg.add(l_calling_fn,
2970 'old salvage type',
2971 p_asset_fin_rec_old.salvage_type);
2972 fa_debug_pkg.add(l_calling_fn,
2973 'adj salvage type',
2974 p_asset_fin_rec_adj.salvage_type);
2975 fa_debug_pkg.add(l_calling_fn,
2976 'delta salvage',
2977 p_asset_fin_rec_adj.salvage_value);
2978 fa_debug_pkg.add(l_calling_fn,
2979 'delta percent salvage',
2980 p_asset_fin_rec_adj.percent_salvage_value);
2981 end if;
2982
2983 -- note that the addition api will already derive the type
2984 -- so it should never be null here, but placing just in case
2985
2986 if (p_asset_type_rec.asset_type = 'GROUP') then
2987 px_asset_fin_rec_new.salvage_type :=
2988 nvl(p_asset_fin_rec_adj.salvage_type,
2989 nvl(p_asset_fin_rec_old.salvage_type, 'PCT'));
2990 else
2991 px_asset_fin_rec_new.salvage_type :=
2992 nvl(p_asset_fin_rec_adj.salvage_type,
2993 nvl(p_asset_fin_rec_old.salvage_type, 'AMT'));
2994 end if;
2995
2996 if (p_log_level_rec.statement_level) then
2997 fa_debug_pkg.add(l_calling_fn,
2998 'salvage type',
2999 px_asset_fin_rec_new.salvage_type);
3000 end if;
3001
3002 if (px_asset_fin_rec_new.salvage_type = 'SUM' and
3003 p_asset_type_rec.asset_type <> 'GROUP') then
3004 fa_srvr_msg.add_message(
3005 calling_fn => l_calling_fn,
3006 name => '***FA_NO_SUM_NO_GROUP***');
3007 raise calc_err;
3008 elsif (px_asset_fin_rec_new.salvage_type = 'AMT' and
3009 p_asset_type_rec.asset_type = 'GROUP') then
3010 fa_srvr_msg.add_message(
3011 calling_fn => l_calling_fn,
3012 name => '***FA_NO_SAL_AMT_FOR_GROUP***');
3013 raise calc_err;
3014 elsif (px_asset_fin_rec_new.salvage_type <> 'AMT' and
3015 px_asset_fin_rec_new.salvage_type <> 'PCT' and
3016 px_asset_fin_rec_new.salvage_type <> 'SUM') then
3017 fa_srvr_msg.add_message(
3018 calling_fn => l_calling_fn,
3019 name => 'FA_INVALID_PARAMETER',
3020 token1 => 'VALUE',
3021 value1 => px_asset_fin_rec_new.salvage_type,
3022 token2 => 'PARAM',
3023 value2 => 'SALVAGE_TYPE');
3024 raise calc_err;
3025 end if;
3026
3027
3028
3029 -- enhancing for group and core to allow direct percentage
3030 -- entry for the assets and not just defaults from category
3031 -- note that we initially set the new value for the salvage %
3032 -- in calc_new_amounts and use that here.
3033 --
3034 -- NOTE: we loaded the "new.type" value previously
3035
3036 if (px_asset_fin_rec_new.salvage_type = 'PCT') then
3037
3038 px_asset_fin_rec_new.percent_salvage_value := (nvl(p_asset_fin_rec_adj.percent_salvage_value, 0) +
3039 nvl(p_asset_fin_rec_old.percent_salvage_value, 0));
3040
3041 px_asset_fin_rec_new.salvage_value := (px_asset_fin_rec_new.cost *
3042 px_asset_fin_rec_new.percent_salvage_value);
3043
3044 if not FA_UTILS_PKG.faxceil(px_asset_fin_rec_new.salvage_value,
3045 p_asset_hdr_rec.book_type_code,
3046 p_log_level_rec => p_log_level_rec) then
3047 raise calc_err;
3048 end if;
3049
3050 elsif (px_asset_fin_rec_new.salvage_type = 'SUM') then
3051 -- this is used only for group assets
3052 -- performance may not be too great here
3053
3054 -- BUG# 3198440
3055 -- for additions (old rec is null) just set to 0
3056 px_asset_fin_rec_new.percent_salvage_value := null;
3057
3058 if (p_asset_fin_rec_old.salvage_type is null) then
3059 px_asset_fin_rec_new.salvage_value := 0;
3060 elsif (p_asset_fin_rec_old.salvage_type <> 'SUM') then
3061 if (p_mrc_sob_type_code <> 'R') then
3062 select nvl(sum(salvage_value), 0)
3063 into px_asset_fin_rec_new.salvage_value
3064 from fa_books bk,
3065 fa_additions_b ad
3066 where bk.transaction_header_id_out is null
3067 and bk.group_asset_id = p_asset_hdr_rec.asset_id
3071 else
3068 and bk.asset_id = ad.asset_id
3069 and bk.book_type_code = p_asset_hdr_rec.book_type_code
3070 and ad.asset_type = 'CAPITALIZED';
3072 select nvl(sum(salvage_value), 0)
3073 into px_asset_fin_rec_new.salvage_value
3074 from fa_books_mrc_v bk,
3075 fa_additions_b ad
3076 where bk.transaction_header_id_out is null
3077 and bk.group_asset_id = p_asset_hdr_rec.asset_id
3078 and bk.asset_id = ad.asset_id
3079 and bk.book_type_code = p_asset_hdr_rec.book_type_code
3080 and ad.asset_type = 'CAPITALIZED';
3081 end if;
3082 else
3083 px_asset_fin_rec_new.salvage_value :=
3084 nvl(p_asset_fin_rec_adj.salvage_value, 0) +
3085 nvl(p_asset_fin_rec_old.salvage_value, 0);
3086 end if;
3087
3088 else -- AMT
3089
3090 px_asset_fin_rec_new.percent_salvage_value := null;
3091
3092 if (p_mrc_sob_type_code <> 'R') then
3093 -- delta salvage amount may or may not be null
3094 -- use it or 0 for the delta
3095
3096 -- NOTE: when changing types, the delta is treated as the new amount
3097 -- we will not add to the prior value that may have been
3098 -- existed/calculated from previous type of PCT or SUM
3099
3100 if (nvl(p_asset_fin_rec_old.salvage_type, 'AMT') <> 'AMT') then
3101 px_asset_fin_rec_new.salvage_value := nvl(p_asset_fin_rec_adj.salvage_value, 0);
3102 else
3103 px_asset_fin_rec_new.salvage_value := nvl(p_asset_fin_rec_adj.salvage_value, 0) +
3104 nvl(p_asset_fin_rec_old.salvage_value, 0);
3105 end if;
3106
3107 -- BUG# 3873652
3108 if (px_asset_fin_rec_new.cost = 0) then
3109 px_asset_fin_rec_new.salvage_value := 0;
3110 end if;
3111
3112 G_primary_salvage_value := px_asset_fin_rec_new.salvage_value;
3113
3114 else
3115 if (G_primary_new_cost <> 0) then
3116 px_asset_fin_rec_new.salvage_value := G_primary_salvage_value *
3117 (px_asset_fin_rec_new.cost / G_primary_new_cost);
3118 else
3119 px_asset_fin_rec_new.salvage_value := 0;
3120 end if;
3121 end if;
3122 end if;
3123
3124 -- round the amount
3125 if not FA_UTILS_PKG.faxrnd(px_asset_fin_rec_new.salvage_value,
3126 p_asset_hdr_rec.book_type_code,
3127 p_log_level_rec => p_log_level_rec) then
3128 raise calc_err;
3129 end if;
3130
3131 if (p_log_level_rec.statement_level) then
3132 fa_debug_pkg.add(l_calling_fn,
3133 'new salvage',
3134 px_asset_fin_rec_new.salvage_value);
3135 end if;
3136
3137 return true;
3138
3139 EXCEPTION
3140 when calc_err then
3141 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
3142 return false;
3143 when others then
3144 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
3145 return false;
3146
3147 END calc_salvage_value;
3148
3149
3150 FUNCTION calc_subcomp_life
3151 (p_trans_rec IN FA_API_TYPES.trans_rec_type,
3152 p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
3153 p_asset_cat_rec IN FA_API_TYPES.asset_cat_rec_type,
3154 p_asset_desc_rec IN FA_API_TYPES.asset_desc_rec_type,
3155 p_period_rec IN FA_API_TYPES.period_rec_type,
3156 px_asset_fin_rec IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
3157 p_calling_fn IN VARCHAR2,
3158 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
3159 ) RETURN BOOLEAN IS
3160
3161 l_asset_type_rec FA_API_TYPES.asset_type_rec_type;
3162 l_calling_fn varchar2(40) := 'fa_asset_calc_pvt.calc_subcomp_life';
3163
3164 CURSOR RATE_DEF IS
3165 SELECT DISTINCT RATE_SOURCE_RULE
3166 FROM FA_METHODS
3167 WHERE METHOD_CODE = px_asset_fin_rec.deprn_method_code;
3168
3169 l_rate_source_rule varchar2(10);
3170
3171 l_cat_bk_lim number;
3172 l_min_life_in_months number;
3173 l_sub_life_rule varchar2(13);
3174
3175 CURSOR LIFE1_DEF IS
3176 select nvl(life_in_months,0),
3177 nvl(life_in_months,0),
3178 prorate_date
3179 from fa_books
3180 where book_type_code = p_asset_hdr_rec.book_type_code
3181 and asset_id = p_asset_desc_rec.parent_asset_id
3182 and transaction_header_id_out is null;
3183
3184 l_lim number;
3185 l_parent_life number;
3186 l_parent_prorate_date date;
3187
3188 -- can cache bc, ct, use dep_rec fpr fy
3189 CURSOR FY_DEF IS
3190 select round
3191 (nvl(sum
3192 (decode (bc.deprn_allocation_code,'E',
3193 1/ct.number_per_fiscal_year,
3194 (cp.end_date + 1 - cp.start_date) /
3195 (fy.end_date + 1 - fy.start_date))),0) * 12, 0)
3196 from fa_calendar_periods cp,
3197 fa_calendar_types ct,
3198 fa_book_controls bc,
3199 fa_fiscal_year fy
3200 where bc.book_type_code = p_asset_hdr_rec.book_type_code
3201 and bc.date_ineffective is null
3205 and ((cp.start_date >= l_parent_prorate_date and
3202 and ct.calendar_type = bc.prorate_calendar
3203 and ct.fiscal_year_name = bc.fiscal_year_name
3204 and cp.calendar_type = ct.calendar_type
3206 cp.end_date <= px_asset_fin_rec.prorate_date) )
3207 and fy.fiscal_year_name = bc.fiscal_year_name
3208 and fy.start_date <= cp.start_date
3209 and fy.end_date >= cp.end_date;
3210
3211 -- excluded due to bug 3872361
3212 /*
3213 or
3214 (cp.start_date <= l_parent_prorate_date and
3215 cp.end_date >= l_parent_prorate_date and
3216 cp.start_date <= px_asset_fin_rec.prorate_date and
3217 cp.end_date <= px_asset_fin_rec.prorate_date)
3218 */
3219
3220 l_fy number;
3221 l_new_life number;
3222
3223 calc_err EXCEPTION;
3224
3225 BEGIN
3226
3227 if (p_log_level_rec.statement_level) then
3228 fa_debug_pkg.add(l_calling_fn, 'entering', 'subcomponent life logic');
3229 end if;
3230
3231 OPEN RATE_DEF;
3232 FETCH RATE_DEF INTO
3233 l_rate_source_rule;
3234
3235 if (RATE_DEF%NOTFOUND) then
3236 CLOSE RATE_DEF;
3237 fa_srvr_msg.add_message(
3238 CALLING_FN => l_calling_fn,
3239 NAME => 'FA_SHARED_OBJECT_NOT_DEF',
3240 TOKEN1 => 'OBJECT',
3241 VALUE1 => 'Method');
3242 raise calc_err;
3243 else
3244 CLOSE RATE_DEF;
3245 end if;
3246
3247 if (l_rate_source_rule in ('FLAT', 'PRODUCTION')) then
3248 fa_srvr_msg.add_message(
3249 CALLING_FN => l_calling_fn,
3250 NAME => 'FA_MTH_LFR_INCOMPAT');
3251 raise calc_err;
3252 end if;
3253
3254 if not fa_cache_pkg.fazccbd
3255 (X_book => p_asset_hdr_rec.book_type_code,
3256 X_cat_id => p_asset_cat_rec.category_id,
3257 X_jdpis => to_number(to_char(px_asset_fin_rec.date_placed_in_service, 'J')),
3258 p_log_level_rec => p_log_level_rec
3259 ) then
3260 raise calc_err;
3261 else
3262 l_cat_bk_lim := nvl(fa_cache_pkg.fazccbd_record.life_in_months, 0);
3263 l_min_life_in_months := nvl(fa_cache_pkg.fazccbd_record.minimum_life_in_months, 0);
3264 l_sub_life_rule := fa_cache_pkg.fazccbd_record.subcomponent_life_rule;
3265 end if;
3266
3267 -- get the parents info
3268 OPEN LIFE1_DEF;
3269 FETCH LIFE1_DEF INTO
3270 l_lim,
3271 l_parent_life,
3272 l_parent_prorate_date;
3273
3274 if (LIFE1_DEF%NOTFOUND) then
3275 CLOSE LIFE1_DEF;
3276 fa_srvr_msg.add_message(
3277 CALLING_FN => l_calling_fn,
3278 NAME => 'FA_PARENT_BKS_NOT_EXIST');
3279 raise calc_err;
3280 else
3281 CLOSE LIFE1_DEF;
3282 end if;
3283
3284 if (p_log_level_rec.statement_level) then
3285 fa_debug_pkg.add(l_calling_fn, 'l_cat_bk_lim', l_cat_bk_lim);
3286 fa_debug_pkg.add(l_calling_fn, 'l_min_life_in_months', l_min_life_in_months);
3287 fa_debug_pkg.add(l_calling_fn, 'l_sub_life_rule', l_sub_life_rule);
3288 fa_debug_pkg.add(l_calling_fn, 'l_lim', l_lim);
3289 fa_debug_pkg.add(l_calling_fn, 'l_parent_life', l_parent_life);
3290 fa_debug_pkg.add(l_calling_fn, 'l_parent_prorate_date', l_parent_prorate_date);
3291 fa_debug_pkg.add(l_calling_fn, 'l_rate_source_rule', l_rate_source_rule);
3292 end if;
3293
3294 if (l_sub_life_rule = 'SAME LIFE') then
3295 if (l_lim = 0) then
3296 l_lim := l_cat_bk_lim;
3297 fa_srvr_msg.add_message(
3298 CALLING_FN => l_calling_fn,
3299 NAME => 'FA_PARENT_LIFE_NOT_SETUP');
3300 raise calc_err;
3301 end if;
3302 elsif (l_sub_life_rule = 'SAME END DATE') then
3303 if (l_parent_life = 0) then
3304 l_lim := l_cat_bk_lim;
3305 fa_srvr_msg.add_message(
3306 CALLING_FN => l_calling_fn,
3307 NAME => 'FA_PARENT_LIFE_NOT_SETUP');
3308 raise calc_err;
3309 else
3310
3311 -- need to derive the prorate convention and date if
3312 -- needed here as this is being called before
3313 -- the calc engine for an addition and cursor will
3314 -- return 0
3315
3316 if (px_asset_fin_rec.prorate_convention_code is null) then
3317 px_asset_fin_rec.prorate_convention_code :=
3318 fa_cache_pkg.fazccbd_record.prorate_convention_code;
3319 end if;
3320
3321 -- just needs to be <> GROUP
3322 l_asset_type_rec.asset_type := 'CAPITALIZED';
3323
3324 if not calc_prorate_date
3325 (p_asset_hdr_rec => p_asset_hdr_rec,
3326 p_asset_type_rec => l_asset_type_rec,
3327 p_asset_fin_rec_adj => px_asset_fin_rec,
3328 px_asset_fin_rec_new => px_asset_fin_rec,
3329 p_period_rec => p_period_rec,
3330 p_log_level_rec => p_log_level_rec
3331 ) then
3332 raise calc_err;
3333 end if;
3334
3335 if (p_log_level_rec.statement_level) then
3336 fa_debug_pkg.add(l_calling_fn, 'px_asset_fin_rec.prorate_date ', px_asset_fin_rec.prorate_date );
3337 end if;
3338
3339
3343 if (FY_DEF%NOTFOUND) then
3340 l_fy := 0;
3341 OPEN FY_DEF;
3342 FETCH FY_DEF INTO l_fy;
3344 CLOSE FY_DEF;
3345 fa_srvr_msg.add_message(
3346 CALLING_FN => l_calling_fn,
3347 NAME => 'FA_SHARED_OBJECT_NOT_DEF',
3348 TOKEN1 => 'OBJECT',
3349 VALUE1 => 'Fiscal Year or Calendar Period');
3350 raise calc_err;
3351 end if;
3352 CLOSE FY_DEF;
3353
3354 if (p_log_level_rec.statement_level) then
3355 fa_debug_pkg.add(l_calling_fn, 'l_fy', l_fy);
3356 end if;
3357
3358 -- If the parent asset is fully reserved i.e it's remaining life as
3359 -- computed here is <= 0 then the life of the subcomponent asset
3360 -- is one month.
3361
3362 if (l_fy >= l_parent_life) then
3363 -- If the parent asset is fully rsvd
3364 l_lim := 1;
3365 else
3366 -- The life is the lesser of the Category's life and parent's remaining life
3367 -- BUG# 1898874 - correcting the check to use l_cat_bk_lim instead of l_lim
3368 -- so that this is actually what happens. Previously, the same end date
3369 -- was always implemented no matter how much the child's life was inflated.
3370 -- bridgway 07/24/01
3371
3372 if ((l_parent_life - l_fy) < l_cat_bk_lim) then
3373 l_lim := l_parent_life - l_fy;
3374 else
3375 l_lim := l_cat_bk_lim;
3376 end if;
3377
3378 if (l_lim < l_min_life_in_months) then
3379 if (l_cat_bk_lim < l_min_life_in_months) then
3380 l_lim := l_min_life_in_months;
3381 else
3382 l_lim := l_cat_bk_lim;
3383 end if;
3384 end if;
3385
3386 end if; -- If the parent asset is fully reserved
3387
3388 end if; -- If parent's life is not setup
3389
3390 else
3391
3392 l_lim := l_cat_bk_lim;
3393
3394 end if;
3395
3396 -- l_new_life := 0; -- Change to l_lim to fix bug 737503
3397 l_new_life := l_lim;
3398
3399 if (p_log_level_rec.statement_level) then
3400 fa_debug_pkg.add(l_calling_fn, 'calling', 'validate_life');
3401 fa_debug_pkg.add(l_calling_fn, 'p_deprn_method', px_asset_fin_rec.deprn_method_code);
3402 fa_debug_pkg.add(l_calling_fn, 'l_cat_bk_lim', l_cat_bk_lim);
3403 fa_debug_pkg.add(l_calling_fn, 'l_lim', l_lim);
3404 fa_debug_pkg.add(l_calling_fn, 'l_new_life', l_new_life);
3405 end if;
3406
3407 if not fa_asset_val_pvt.validate_life
3408 (p_deprn_method => px_asset_fin_rec.deprn_method_code,
3409 p_rate_source_rule => l_rate_source_rule,
3410 p_life_in_months => l_cat_bk_lim,
3411 p_lim => l_lim,
3412 p_user_id => p_trans_rec.who_info.last_updated_by,
3413 p_curr_date => p_trans_rec.who_info.last_update_date,
3414 px_new_life => l_new_life,
3415 p_calling_fn => l_calling_fn,
3416 p_log_level_rec => p_log_level_rec
3417 ) then
3418 raise calc_err;
3419 else
3420
3421 if (l_new_life <> 0) then
3422 px_asset_fin_rec.life_in_months := l_new_life;
3423 end if;
3424
3425 end if;
3426
3427 return TRUE;
3428
3429
3430 EXCEPTION
3431 when calc_err then
3432 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
3433 return false;
3434
3435 when others then
3436 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
3437 return false;
3438
3439 END calc_subcomp_life;
3440
3441
3442
3443 FUNCTION calc_flags
3444 (p_trans_rec IN FA_API_TYPES.trans_rec_type,
3445 p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
3446 p_asset_type_rec IN FA_API_TYPES.asset_type_rec_type,
3447 p_asset_fin_rec_old IN FA_API_TYPES.asset_fin_rec_type,
3448 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
3449 p_asset_deprn_rec IN FA_API_TYPES.asset_deprn_rec_type,
3450 p_period_rec IN FA_API_TYPES.period_rec_type,
3451 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
3452 ) RETURN BOOLEAN IS
3453
3454 l_first_period number := 0;
3455
3456 l_current_fiscal_year number;
3457 l_fiscal_year_name varchar2(30);
3458
3459 l_rate_source_rule varchar2(10);
3460 l_deprn_basis_rule varchar2(4);
3461
3462 l_depreciate_flag varchar2(3);
3463 l_dep_flag_thid number;
3464 l_count_dep_flag number;
3465
3466 l_sty_success varchar2(3) := 'NO';
3467 l_calling_fn varchar2(40) := 'fa_asset_calc_pvt.calc_flags';
3468
3469 calc_err EXCEPTION;
3470
3471 BEGIN
3472
3473 -- this logic needs verification - ref faxfa2b.pls
3474
3475 l_current_fiscal_year := fa_cache_pkg.fazcbc_record.current_fiscal_year;
3476 l_fiscal_year_name := fa_cache_pkg.fazcbc_record.fiscal_year_name;
3477
3478 if not fa_cache_pkg.fazccmt
3479 ( X_method => px_asset_fin_rec_new.Deprn_Method_Code
3480 ,X_life => px_asset_fin_rec_new.Life_In_Months,
3484
3481 p_log_level_rec => p_log_level_rec) then
3482 raise calc_err;
3483 end if;
3485 l_rate_source_rule := fa_cache_pkg.fazccmt_record.rate_source_rule;
3486 l_deprn_basis_rule := fa_cache_pkg.fazccmt_record.deprn_basis_rule;
3487
3488
3489 px_asset_fin_rec_new.cost_change_flag := 'NO';
3490 px_asset_fin_rec_new.retirement_pending_flag := 'NO';
3491
3492
3493 if (p_asset_type_rec.asset_type = 'CAPITALIZED' or
3494 p_asset_type_rec.asset_type = 'CIP' or
3495 p_asset_type_rec.asset_type = 'GROUP') then
3496
3497 px_asset_fin_rec_new.capitalize_flag := 'YES';
3498 -- changed the following logic to mirror the forms
3499 -- though there discrepancies between faxfa1b.pls
3500
3501 -- SLA Uptake
3502 -- since we're taking the catchup here,
3503 -- reset flags as if no catchup is needed
3504 if ((p_asset_hdr_rec.period_of_addition = 'Y') or
3505 (p_asset_hdr_rec.period_of_addition = 'N' and
3506 p_trans_rec.transaction_type_code = 'ADDITION')) then
3507
3508 if (p_asset_deprn_rec.deprn_reserve <> 0) then -- reserve
3509 -- SLA: keeping ADD for now
3510 px_asset_fin_rec_new.adjustment_required_status := 'ADD'; -- ??? correct per detail add
3511 px_asset_fin_rec_new.annual_deprn_rounding_flag := 'RES';
3512 else
3513
3514 if (px_asset_fin_rec_new.date_placed_in_service >= p_period_rec.calendar_period_open_date and
3515 px_asset_fin_rec_new.date_placed_in_service <= p_period_rec.calendar_period_close_date) then
3516 px_asset_fin_rec_new.adjustment_required_status := 'ADD';
3517 px_asset_fin_rec_new.annual_deprn_rounding_flag := NULL;
3518 else -- not a current period addition
3519
3520 if (px_asset_fin_rec_new.date_placed_in_service >= p_period_rec.fy_start_date and
3521 px_asset_fin_rec_new.date_placed_in_service <= p_period_rec.fy_end_date ) then
3522 px_asset_fin_rec_new.adjustment_required_status := 'ADD';
3523 px_asset_fin_rec_new.annual_deprn_rounding_flag := NULL;
3524 else -- backdated addition to prior year
3525 px_asset_fin_rec_new.annual_deprn_rounding_flag := 'ADD';
3526 px_asset_fin_rec_new.adjustment_required_status := 'ADD';
3527 end if;
3528 end if;
3529
3530 -- BUG# 2522675
3531 -- when asset is set to amortize nbv, the adj_req flag must be
3532 -- set to none to avoid any additional catchup
3533 /* SLA:
3534 if ((p_trans_rec.transaction_subtype = 'AMORTIZED' and
3535 p_asset_type_rec.asset_type = 'CAPITALIZED') or
3536 (p_asset_type_rec.asset_type = 'GROUP')) then
3537 px_asset_fin_rec_new.adjustment_required_status := 'NONE';
3538 end if;
3539 */
3540
3541 -- Bug4401476: Set rounding falg to RES if it is amortize nbv
3542 -- to avoid huge catchup even though entered reserve is 0..
3543 if (p_trans_rec.transaction_subtype = 'AMORTIZED' and
3544 p_asset_type_rec.asset_type = 'CAPITALIZED') then
3545 px_asset_fin_rec_new.annual_deprn_rounding_flag := 'RES';
3546 end if;
3547 end if;
3548
3549 -- SLA: px_asset_fin_rec_new.adjustment_required_status := 'NONE';
3550
3551 else -- adjustment
3552
3553 -- BUG# 3516246
3554 -- when adjustment is performed in period of capitalization
3555 -- we need to set to NONE and avoid catchup.
3556
3557 if (p_asset_fin_rec_old.adjustment_required_status = 'ADD') then
3558 px_asset_fin_rec_new.adjustment_required_status := 'NONE';
3559 else
3560 px_asset_fin_rec_new.adjustment_required_status :=
3561 p_asset_fin_rec_old.adjustment_required_status;
3562 end if;
3563
3564 if (p_asset_fin_rec_old.adjustment_required_status = 'ADD') then
3565
3566 -- Bug#3709494
3567 -- if the asset was added with the depreciate_flag set to NO
3568 -- and this is the FIRST time that we are changing it to YES,
3569 -- then perform catchup by setting adjustment_required_status to
3570 -- ADD.
3571
3572 -- SLA: revisit this as catchup must occur at time of trx now!!!!
3573 -- ****
3574
3575 if (nvl(p_asset_fin_rec_old.depreciate_flag, 'YES') = 'NO') then
3576 --SLA: no need for flag, take catchup now
3577 -- catchup
3578 px_asset_fin_rec_new.adjustment_required_status :=
3579 p_asset_fin_rec_old.adjustment_required_status;
3580
3581 else
3582 -- No catchup
3583 px_asset_fin_rec_new.adjustment_required_status := 'NONE';
3584 end if;
3585 else
3586 px_asset_fin_rec_new.adjustment_required_status :=
3587 p_asset_fin_rec_old.adjustment_required_status;
3588 end if;
3589
3590 /* old fix - pre-sla for 3709494
3591 if ((nvl(p_asset_fin_rec_old.depreciate_flag, 'YES') = 'NO') and
3592 (nvl(px_asset_fin_rec_new.depreciate_flag, 'YES') = 'YES')) then
3593
3594 -- We confirmed that we have changed the depreciate_flag from
3595 -- NO to YES. Now we need to check if this is the asset were
3599
3596 -- originally NO, and this is the first time it was changed to YES.
3597
3598 begin
3600 select bk.depreciate_flag,
3601 bk.transaction_header_id_in
3602 into l_depreciate_flag,
3603 l_dep_flag_thid
3604 from fa_books bk,
3605 fa_transaction_headers th
3606 where th.asset_id = p_asset_hdr_rec.asset_id
3607 and th.book_type_code = p_asset_hdr_rec.book_type_code
3608 and th.transaction_type_code = 'ADDITION'
3609 and th.transaction_header_id = bk.transaction_header_id_in;
3610 exception
3611 when others then
3612 l_depreciate_flag := 'YES';
3613 end;
3614
3615 if (l_depreciate_flag = 'NO') then
3616
3617 -- The flag was originally NO. Now is this the first change?
3618 begin
3619
3620 select count(*)
3621 into l_count_dep_flag
3622 from fa_books
3623 where asset_id = p_asset_hdr_rec.asset_id
3624 and book_type_code = p_asset_hdr_rec.book_type_code
3625 and depreciate_flag = 'YES'
3626 and transaction_header_id_in >= l_dep_flag_thid;
3627
3628 exception
3629 when others then
3630 l_count_dep_flag := 1;
3631 end;
3632
3633 if (l_count_dep_flag = 0) then
3634 -- catchup
3635 px_asset_fin_rec_new.adjustment_required_status := 'ADD';
3636 end if;
3637 end if;
3638 end if;
3639 */
3640
3641
3642 -- BUG# 2678718
3643 -- removing prior logic for checking first period
3644 -- of fiscal year and always setting flag to ADJ
3645
3646 /*
3647 select count(1)
3648 into l_first_period
3649 from fa_fiscal_year fy,
3650 fa_deprn_periods dp
3651 where l_fiscal_year_name = fy.fiscal_year_name
3652 and l_current_fiscal_year = fy.fiscal_year
3653 and dp.book_type_code = p_asset_hdr_rec.book_type_code
3654 and dp.calendar_period_open_date = fy.start_date
3655 and p_trans_rec.transaction_date_entered between
3656 dp.calendar_period_open_date and
3657 dp.calendar_period_close_date
3658 and rownum < 2;
3659
3660 if (l_first_period = 0) then
3661 px_asset_fin_rec_new.annual_deprn_rounding_flag := 'ADJ';
3662 else
3663
3664 if l_rate_source_rule = 'FLAT' then
3665 px_asset_fin_rec_new.annual_deprn_rounding_flag := 'ADJ';
3666 else
3667 px_asset_fin_rec_new.annual_deprn_rounding_flag := NULL;
3668 end if;
3669
3670 end if;
3671
3672 */
3673
3674 px_asset_fin_rec_new.annual_deprn_rounding_flag := 'ADJ';
3675
3676 end if;
3677
3678 else -- expensed asset
3679
3680 px_asset_fin_rec_new.adjustment_required_status := 'NONE';
3681 px_asset_fin_rec_new.annual_deprn_rounding_flag := NULL;
3682 px_asset_fin_rec_new.capitalize_flag := 'NO';
3683
3684 end if;
3685
3686 /*
3687 -- calculate the short tax and formula info
3688 if (l_Rate_Source_Rule = 'FORMULA') then
3689
3690 -- Get current fiscal year start and end dates.
3691
3692 fa_short_tax_years_pkg.calculate_short_tax_vals(
3693 X_Asset_Id => p_asset_hdr_rec.Asset_Id,
3694 X_Book_Type_Code => p_asset_hdr_rec.Book_type_Code,
3695 -- new columns
3696 X_Short_Fiscal_Year_Flag => px_asset_fin_rec_new.Short_Fiscal_Year_Flag,
3697 X_Date_Placed_In_Service => px_asset_fin_rec_new.Date_Placed_In_Service,
3698 X_Deprn_Start_Date => px_asset_fin_rec_new.Deprn_Start_Date,
3699 X_Prorate_Date => px_asset_fin_rec_new.Prorate_Date,
3700 X_Conversion_Date => px_asset_fin_rec_new.Conversion_Date,
3701 X_Orig_Deprn_Start_Date => px_asset_fin_rec_new.Orig_Deprn_Start_Date,
3702 X_Curr_Fy_Start_Date => p_period_rec.fy_start_date,
3703 X_Curr_Fy_End_Date => p_period_rec.fy_end_date,
3704 X_Life_In_Months => px_asset_fin_rec_new.Life_In_Months,
3705 X_Rate_Source_Rule => l_Rate_Source_Rule, -- BUG# 2016824
3706 X_Remaining_Life1 => px_asset_fin_rec_new.remaining_life1,
3707 X_Remaining_Life2 => px_asset_fin_rec_new.remaining_life2,
3708 X_Success => l_sty_success,
3709 p_log_level_rec => p_log_level_rec);
3710
3711 if (l_sty_success = 'NO') then
3712 raise calc_err;
3713 end if;
3714
3715 end if;
3716 */
3717
3718 return true;
3719
3720 EXCEPTION
3721 when calc_err then
3722 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
3723 return false;
3724
3725 when others then
3726 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
3730
3727 return false;
3728
3729 END calc_flags;
3731
3732 FUNCTION calc_deprn_info
3733 (p_trans_rec IN FA_API_TYPES.trans_rec_type,
3734 p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
3735 p_asset_desc_rec IN FA_API_TYPES.asset_desc_rec_type,
3736 p_asset_cat_rec IN FA_API_TYPES.asset_cat_rec_type,
3737 p_asset_type_rec IN FA_API_TYPES.asset_type_rec_type,
3738 p_asset_fin_rec_old IN FA_API_TYPES.asset_fin_rec_type,
3739 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
3740 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
3741 p_asset_deprn_rec_adj IN FA_API_TYPES.asset_deprn_rec_type,
3742 p_asset_deprn_rec_new IN FA_API_TYPES.asset_deprn_rec_type,
3743 p_period_rec IN FA_API_TYPES.period_rec_type,
3744 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
3745 ) RETURN BOOLEAN IS
3746
3747 l_count number;
3748 l_result boolean;
3749 l_unit_of_measure FA_BOOKS.UNIT_OF_MEASURE%TYPE;
3750
3751 l_method_id number;
3752 l_rate_source_rule FA_METHODS.rate_source_rule%TYPE;
3753 l_deprn_basis_rule FA_METHODS.deprn_basis_rule%TYPE;
3754
3755 l_last_period_counter number;
3756 l_calendar_period_open_date date;
3757 l_calendar_period_close_date date;
3758 h_prod_method number; -- added this for bug 3245984
3759
3760 CURSOR unit_of_measure IS
3761 select unit_of_measure
3762 from fa_books
3763 where asset_id = p_asset_hdr_rec.asset_id
3764 and book_type_code = fa_cache_pkg.fazcbc_record.distribution_source_book
3765 and transaction_header_id_out is NULL
3766 and deprn_method_code = px_asset_fin_rec_new.deprn_method_code;
3767
3768 l_calling_fn VARCHAR2(40) := 'fa_asset_calc_pvt.calc_deprn_info';
3769 calc_err EXCEPTION;
3770
3771 BEGIN
3772
3773 l_last_period_counter := fa_cache_pkg.fazcbc_record.last_period_counter;
3774
3775 -- NOTE: moved additions defaulting to the private additions apit's init procedure
3776 -- as part of group project...
3777
3778 -- Set deprn info - "all or nothing" - this means that if you are changing the
3779 -- method you must provide the other info (life or rates for instance).
3780 -- the semi exception is production capacity which is done above based on delta
3781 if (p_asset_fin_rec_adj.deprn_method_code is not null) then
3782 px_asset_fin_rec_new.deprn_method_code := p_asset_fin_rec_adj.deprn_method_code;
3783 px_asset_fin_rec_new.life_in_months := p_asset_fin_rec_adj.life_in_months;
3784 px_asset_fin_rec_new.basic_rate := p_asset_fin_rec_adj.basic_rate;
3785 px_asset_fin_rec_new.adjusted_rate := p_asset_fin_rec_adj.adjusted_rate;
3786 px_asset_fin_rec_new.unit_of_measure := p_asset_fin_rec_adj.unit_of_measure;
3787 else
3788
3789 if (p_asset_fin_rec_adj.life_in_months is not null OR
3790 p_asset_fin_rec_adj.basic_rate is not null OR
3791 p_asset_fin_rec_adj.adjusted_rate is not null ) then
3792 -- BUG# 5441722
3793 -- nvl(p_asset_fin_rec_adj.production_capacity, 0) <> 0
3794 fa_srvr_msg.add_message(
3795 calling_fn => l_calling_fn,
3796 name => 'FA_EXP_GET_METHOD_INFO');
3797 raise calc_err;
3798 end if;
3799
3800 if (p_asset_fin_rec_old.deprn_method_code is not null) then
3801 px_asset_fin_rec_new.deprn_method_code := p_asset_fin_rec_old.deprn_method_code;
3802 px_asset_fin_rec_new.life_in_months := p_asset_fin_rec_old.life_in_months;
3803 px_asset_fin_rec_new.basic_rate := p_asset_fin_rec_old.basic_rate;
3804 px_asset_fin_rec_new.adjusted_rate := p_asset_fin_rec_old.adjusted_rate;
3805 px_asset_fin_rec_new.unit_of_measure := p_asset_fin_rec_old.unit_of_measure;
3806 end if;
3807
3808 end if;
3809
3810
3811 -- do not allow method change is unplanned has been entered
3812 -- needed to check the methods per BUG# 2435403
3813 --fix for bug no.2536674
3814 /* if (p_trans_rec.transaction_type_code <> 'ADDITION' and
3815 p_trans_rec.transaction_type_code <> 'CIP ADDITION' and
3816 p_trans_rec.transaction_type_code <> 'GROUP ADDITION' and
3817 (p_asset_fin_rec_old.deprn_method_code <>
3818 p_asset_fin_rec_adj.deprn_method_code)) then
3819 if fa_asset_val_pvt.validate_unplanned_exists
3820 (p_book => p_asset_hdr_rec.book_type_code,
3821 p_asset_id => p_asset_hdr_rec.asset_id,
3822 p_log_level_rec => p_log_level_rec) then
3823 fa_srvr_msg.add_message(
3824 calling_fn => 'l_calling_fn',
3825 name => '***FA_NO_METHOD_CHG_UNP***');
3826 raise calc_err;
3827 end if;
3828 end if;
3829 */
3830
3831 -- verify deprn information is valid by calling the method
3832 -- cache function - modified from STYR to handle all types.
3833 -- FYI: we MUST call the cache even when there is no method change
3834 -- because of potential impact of the flags on the depreciable
3835 -- basis, deprn_start_date and on adjusted_cost for nbv methods
3836 if not FA_CACHE_PKG.fazccmt(
3840 ) then
3837 X_method => px_asset_fin_rec_new.deprn_method_code,
3838 X_life => px_asset_fin_rec_new.life_in_months,
3839 p_log_level_rec => p_log_level_rec
3841 raise calc_err;
3842 end if;
3843
3844
3845 l_method_id := fa_cache_pkg.fazccmt_record.method_id;
3846 l_rate_source_rule := fa_cache_pkg.fazccmt_record.rate_source_rule;
3847 l_deprn_basis_rule := fa_cache_pkg.fazccmt_record.deprn_basis_rule;
3848
3849 -- verify that basic rate and adj_rate are valid for flat
3850 -- rate methods and that production info is correct
3851
3852 if (px_asset_fin_rec_new.deprn_method_code is not null) then
3853 if (l_rate_source_rule = 'FLAT') then
3854
3855 select count(*)
3856 into l_count
3857 from fa_flat_rates
3858 where method_id = l_method_id
3859 and basic_rate = px_asset_fin_rec_new.basic_rate
3860 and adjusted_rate = px_asset_fin_rec_new.adjusted_rate;
3861
3862 if (l_count = 0) then
3863 fa_srvr_msg.add_message(
3864 calling_fn => l_calling_fn,
3865 name => 'FA_SHARED_INVALID_METHOD_RATE');
3866 raise calc_err;
3867 else
3868 px_asset_fin_rec_new.life_in_months := NULL;
3869 px_asset_fin_rec_new.production_capacity := NULL;
3870 px_asset_fin_rec_new.unit_of_measure := NULL;
3871 end if;
3872
3873 elsif (l_rate_source_rule = 'PRODUCTION') then
3874
3875 if (px_asset_fin_rec_new.production_capacity is null) then
3876 fa_srvr_msg.add_message(
3877 calling_fn => l_calling_fn,
3878 name => 'FA_BOOKS_NULL_PROD');
3879 raise calc_err;
3880 else
3881 px_asset_fin_rec_new.life_in_months := NULL;
3882 px_asset_fin_rec_new.adjusted_rate := NULL;
3883 px_asset_fin_rec_new.basic_rate := NULL;
3884 end if;
3885
3886 -- verify corp asset is UOP and get unit of measure
3887 -- Depreciate flag may not be 'NO'
3888
3889 if (px_asset_fin_rec_new.depreciate_flag <> 'YES') then
3890 fa_srvr_msg.add_message(
3891 calling_fn => l_calling_fn,
3892 name => 'FA_BOOK_INVALID_DEPRN_FLAG');
3893 raise calc_err;
3894 end if;
3895
3896 if (fa_cache_pkg.fazcbc_record.book_class = 'TAX') then
3897 OPEN unit_of_measure;
3898 FETCH unit_of_measure INTO px_asset_fin_rec_new.unit_of_measure;
3899
3900 if (unit_of_measure%NOTFOUND) then
3901 CLOSE unit_of_measure;
3902 fa_srvr_msg.add_message(
3903 calling_fn => l_calling_fn,
3904 name => 'FA_MASSCHG_NOT_PROD_IN_CORP');
3905 raise calc_err;
3906 end if;
3907 CLOSE unit_of_measure;
3908
3909 end if;
3910
3911 elsif (l_rate_source_rule = 'TABLE') then
3912 px_asset_fin_rec_new.adjusted_rate := NULL;
3913 px_asset_fin_rec_new.basic_rate := NULL;
3914 px_asset_fin_rec_new.production_capacity := NULL;
3915 px_asset_fin_rec_new.unit_of_measure := NULL;
3916 elsif (l_rate_source_rule = 'FORMULA') then
3917 px_asset_fin_rec_new.adjusted_rate := NULL;
3918 px_asset_fin_rec_new.basic_rate := NULL;
3919
3920 -- added this for bug 3245984
3921 h_prod_method := instr (fa_cache_pkg.fazcfor_record.formula_actual,'CAPACITY');
3922 -- if the formula has 'CAPACITY' in it, then it is a Production method
3923 -- otherwise, it is a Life method.
3924 if (h_prod_method = 0) then
3925 px_asset_fin_rec_new.production_capacity := NULL;
3926 px_asset_fin_rec_new.unit_of_measure := NULL;
3927 end if;
3928
3929 else
3930 px_asset_fin_rec_new.production_capacity := NULL;
3931 px_asset_fin_rec_new.unit_of_measure := NULL;
3932 end if;
3933
3934 end if; -- new method code is not null
3935
3936 px_asset_fin_rec_new.adjusted_capacity := px_asset_fin_rec_new.production_capacity;
3937
3938
3939 -- BUG# 4676908
3940 -- make sure the proate period match the method
3941 if (fa_cache_pkg.fazccmt_record.prorate_periods_per_year is not null) then
3942 if not fa_cache_pkg.fazcct
3943 (X_calendar => fa_cache_pkg.fazcbc_record.prorate_calendar,
3944 p_log_level_rec => p_log_level_rec) then
3945 raise calc_err;
3946 end if;
3947
3948 if (fa_cache_pkg.fazccmt_record.prorate_periods_per_year <>
3949 fa_cache_pkg.fazcct_record.number_per_fiscal_year) then
3950 fa_srvr_msg.add_message(
3951 calling_fn => l_calling_fn,
3952 name => 'FA_INVALID_DEPRN_METHOD');
3953 raise calc_err;
3954 end if;
3955 end if;
3956
3957
3958 -- verify reserve and ytd = 0 for UOP
3959
3960 if (p_log_level_rec.statement_level) then
3961 fa_debug_pkg.add('calc_fin_info',
3962 'p_asset_deprn_rec_adj.deprn_reserve',
3963 p_asset_deprn_rec_adj.deprn_reserve);
3964 fa_debug_pkg.add('calc_fin_info',
3965 'p_asset_deprn_rec_adj.ytd_deprn',
3969 p_asset_deprn_rec_adj.ltd_production);
3966 p_asset_deprn_rec_adj.ytd_deprn);
3967 fa_debug_pkg.add('calc_fin_info',
3968 'p_asset_deprn_rec_adj.ltd_prod',
3970 fa_debug_pkg.add('calc_fin_info',
3971 'p_asset_deprn_rec_adj.ytd_prod',
3972 p_asset_deprn_rec_adj.ytd_production);
3973 fa_debug_pkg.add('calc_fin_info',
3974 'px_asset_fin_rec_new.short_fiscal_year_flag',
3975 px_asset_fin_rec_new.short_fiscal_year_flag);
3976 end if;
3977
3978 if (l_rate_source_rule = 'PRODUCTION') and
3979 (nvl(p_trans_rec.transaction_key, 'XX') not in ('MR', 'MS')) then
3980 if (nvl(p_asset_deprn_rec_adj.deprn_reserve,0) <> 0 OR
3981 nvl(p_asset_deprn_rec_adj.ytd_deprn,0) <> 0) then
3982 fa_srvr_msg.add_message(
3983 calling_fn => l_calling_fn,
3984 name => 'FA_NO_RESERVE_FOR_PROD');
3985 raise calc_err;
3986 end if;
3987 end if;
3988
3989 -- verify STY information is valid
3990 if not fa_asset_val_pvt.validate_short_tax_year
3991 (p_book_type_code => p_asset_hdr_rec.book_type_code,
3992 p_transaction_type_code => p_trans_rec.transaction_type_code,
3993 p_asset_type => p_asset_type_rec.asset_type,
3994 p_short_fiscal_year_flag => px_asset_fin_rec_new.short_fiscal_year_flag,
3995 p_conversion_date => px_asset_fin_rec_new.conversion_date,
3996 px_orig_deprn_start_date => px_asset_fin_rec_new.orig_deprn_start_date,
3997 p_date_placed_in_service => px_asset_fin_rec_new.date_placed_in_service,
3998 p_ytd_deprn => p_asset_deprn_rec_new.ytd_deprn,
3999 p_deprn_reserve => p_asset_deprn_rec_new.deprn_reserve,
4000 p_period_rec => p_period_rec,
4001 p_calling_fn => l_calling_fn ,
4002 p_log_level_rec => p_log_level_rec
4003 ) then
4004 raise calc_err;
4005 end if;
4006
4007 -- Check Bonus Rule
4008
4009 if (px_asset_fin_rec_new.bonus_rule IS NOT NULL) then
4010 select count(*)
4011 into l_count
4012 from fa_bonus_rules
4013 where bonus_rule = px_asset_fin_rec_new.bonus_rule;
4014
4015 if (l_count = 0) then
4016 fa_srvr_msg.add_message(
4017 calling_fn => l_calling_fn,
4018 name => 'FA_INVALID_BONUS_RULE');
4019 raise calc_err;
4020 end if;
4021 end if;
4022
4023
4024 -- check super group
4025 if (l_rate_source_rule <> 'FLAT' and
4026 px_asset_fin_rec_new.super_group_id is not null) then
4027 fa_srvr_msg.add_message(
4028 calling_fn => l_calling_fn,
4029 name => '***FA_NO_SUPER_NO_FLAT***');
4030 raise calc_err;
4031 end if;
4032
4033 return true;
4034
4035 EXCEPTION
4036 when calc_err then
4037 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
4038 return false;
4039
4040 when others then
4041 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
4042 return false;
4043
4044 END calc_deprn_info;
4045
4046
4047 FUNCTION calc_group_info
4048 (p_trans_rec IN FA_API_TYPES.trans_rec_type,
4049 p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
4050 p_asset_fin_rec_old IN FA_API_TYPES.asset_fin_rec_type,
4051 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
4052 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
4053 p_asset_deprn_rec_old IN FA_API_TYPES.asset_deprn_rec_type,
4054 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
4055 ) return boolean IS
4056
4057 CURSOR c_find_member_asset IS
4058 SELECT 'Y'
4059 FROM FA_BOOKS
4060 WHERE GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
4061 AND BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
4062 AND TRANSACTION_HEADER_ID_OUT is NULL;
4063
4064 l_calling_fn VARCHAR2(40) := 'fa_asset_calc_pvt.calc_group_info';
4065
4066 l_member_exists VARCHAR2(1) := null;
4067
4068 calc_err EXCEPTION;
4069
4070 BEGIN
4071
4072 -- this will validate/set all the new group asset flags
4073 -- note that the addition api has already defaulted the
4074 -- values if they weren't specified. here we need to
4075 -- check for changes and validate the values
4076
4077 -- +++++ Reduction Rate +++++
4078
4079 px_asset_fin_rec_new.reduction_rate :=
4080 nvl(p_asset_fin_rec_adj.reduction_rate, 0) +
4081 nvl(p_asset_fin_rec_old.reduction_rate, 0);
4082
4083 --
4084 -- Function call fazccmt is mandatory before calling this function.
4085 -- Currently fazccmt is called in calc_deprn_info and calc_flag which
4086 -- is called from calc_derived_amounts.
4087 -- If calc_deprn_info is called before this function, then I can simply use
4088 -- new so don't need this much of the code.
4089 if (p_asset_fin_rec_adj.deprn_method_code is not null) then
4090 if not fa_cache_pkg.fazccmt
4091 (X_method => p_asset_fin_rec_adj.Deprn_Method_Code,
4092 X_life => p_asset_fin_rec_adj.Life_In_Months,
4096 end if;
4093 p_log_level_rec => p_log_level_rec
4094 ) then
4095 raise calc_err;
4097 else
4098 if not fa_cache_pkg.fazccmt
4099 (X_method => p_asset_fin_rec_old.Deprn_Method_Code,
4100 X_life => p_asset_fin_rec_old.Life_In_Months,
4101 p_log_level_rec => p_log_level_rec
4102 ) then
4103 raise calc_err;
4104 end if;
4105 end if;
4106
4107 if (nvl(fa_cache_pkg.fazcdrd_record.allow_reduction_rate_flag, 'N') = 'N') then
4108 px_asset_fin_rec_new.reduction_rate := to_number(null);
4109 end if;
4110
4111
4112 FA_UTIL_PVT.load_char_value
4113 (p_char_old => p_asset_fin_rec_old.over_depreciate_option,
4114 p_char_adj => p_asset_fin_rec_adj.over_depreciate_option,
4115 x_char_new => px_asset_fin_rec_new.over_depreciate_option
4116 );
4117
4118 --
4119 -- Set Over Depreciate to 'NO'
4120 -- 1. If it is set to DEPRN and FLAT-NBV method
4121 -- 2. If it is not NO and there is some deprn limit
4122 --
4123 if (fa_cache_pkg.fazcbc_record.book_class = 'TAX') then
4124
4125 if (px_asset_fin_rec_new.over_depreciate_option =
4126 fa_std_types.FA_OVER_DEPR_DEPRN) and
4127 (fa_cache_pkg.fazccmt_record.rate_source_rule = 'FLAT' and
4128 fa_cache_pkg.fazccmt_record.deprn_basis_rule = 'NBV') then
4129 px_asset_fin_rec_new.over_depreciate_option :=
4130 fa_std_types.FA_OVER_DEPR_NO;
4131 end if;
4132
4133 end if;
4134
4135 -- +++++ Over Depreciate +++++
4136 -- Validation moved to fa_asset_val_pvt.validate_over_depreciate
4137
4138 -- +++++ Reduction Flags +++++
4139 if (px_asset_fin_rec_new.reduction_rate is null) then
4140 px_asset_fin_rec_new.reduce_addition_flag := null;
4141 px_asset_fin_rec_new.reduce_adjustment_flag := null;
4142 px_asset_fin_rec_new.reduce_retirement_flag := null;
4143 else
4144 FA_UTIL_PVT.load_char_value
4145 (p_char_old => p_asset_fin_rec_old.reduce_addition_flag,
4146 p_char_adj => p_asset_fin_rec_adj.reduce_addition_flag,
4147 x_char_new => px_asset_fin_rec_new.reduce_addition_flag
4148 );
4149 FA_UTIL_PVT.load_char_value
4150 (p_char_old => p_asset_fin_rec_old.reduce_adjustment_flag,
4151 p_char_adj => p_asset_fin_rec_adj.reduce_adjustment_flag,
4152 x_char_new => px_asset_fin_rec_new.reduce_adjustment_flag
4153 );
4154 FA_UTIL_PVT.load_char_value
4155 (p_char_old => p_asset_fin_rec_old.reduce_retirement_flag,
4156 p_char_adj => p_asset_fin_rec_adj.reduce_retirement_flag,
4157 x_char_new => px_asset_fin_rec_new.reduce_retirement_flag
4158 );
4159 end if;
4160
4161 -- +++++ Retirement and Tracking Options +++++
4162 -- From here, these values are not updateable
4163 -- once depreciation is run or first member asset
4164 -- is added.
4165
4166 if (p_asset_hdr_rec.period_of_addition = 'Y') then
4167 OPEN c_find_member_asset;
4168 FETCH c_find_member_asset INTO l_member_exists;
4169
4170 if (c_find_member_asset%NOTFOUND) then
4171 l_member_exists := 'N';
4172 end if;
4173
4174 CLOSE c_find_member_asset;
4175
4176 end if;
4177
4178 if (p_asset_hdr_rec.period_of_addition <> 'Y') or
4179 (l_member_exists = 'Y') then
4180
4181 px_asset_fin_rec_new.recognize_gain_loss :=
4182 p_asset_fin_rec_old.recognize_gain_loss;
4183
4184 px_asset_fin_rec_new.recapture_reserve_flag :=
4185 p_asset_fin_rec_old.recapture_reserve_flag;
4186
4187 px_asset_fin_rec_new.limit_proceeds_flag :=
4188 p_asset_fin_rec_old.limit_proceeds_flag;
4189
4190 px_asset_fin_rec_new.terminal_gain_loss :=
4191 p_asset_fin_rec_old.terminal_gain_loss;
4192
4193 px_asset_fin_rec_new.exclude_proceeds_from_basis :=
4194 p_asset_fin_rec_old.exclude_proceeds_from_basis;
4195
4196 px_asset_fin_rec_new.retirement_deprn_option :=
4197 p_asset_fin_rec_old.retirement_deprn_option;
4198
4199 px_asset_fin_rec_new.tracking_method :=
4200 p_asset_fin_rec_old.tracking_method;
4201
4202 px_asset_fin_rec_new.allocate_to_fully_rsv_flag :=
4203 p_asset_fin_rec_old.allocate_to_fully_rsv_flag;
4204
4205 px_asset_fin_rec_new.allocate_to_fully_ret_flag :=
4206 p_asset_fin_rec_old.allocate_to_fully_ret_flag;
4207
4208 px_asset_fin_rec_new.excess_allocation_option :=
4209 p_asset_fin_rec_old.excess_allocation_option;
4210
4211 px_asset_fin_rec_new.depreciation_option :=
4212 p_asset_fin_rec_old.depreciation_option;
4213
4214 px_asset_fin_rec_new.member_rollup_flag :=
4215 p_asset_fin_rec_old.member_rollup_flag;
4216
4217 else -- No member asset in this group and still in period of addition
4218
4219 FA_UTIL_PVT.load_char_value
4220 (p_char_old => p_asset_fin_rec_old.recognize_gain_loss,
4221 p_char_adj => p_asset_fin_rec_adj.recognize_gain_loss,
4222 x_char_new => px_asset_fin_rec_new.recognize_gain_loss
4223 );
4224
4225 FA_UTIL_PVT.load_char_value
4226 (p_char_old => p_asset_fin_rec_old.recapture_reserve_flag,
4227 p_char_adj => p_asset_fin_rec_adj.recapture_reserve_flag,
4228 x_char_new => px_asset_fin_rec_new.recapture_reserve_flag
4229 );
4230
4231 FA_UTIL_PVT.load_char_value
4232 (p_char_old => p_asset_fin_rec_old.limit_proceeds_flag,
4233 p_char_adj => p_asset_fin_rec_adj.limit_proceeds_flag,
4234 x_char_new => px_asset_fin_rec_new.limit_proceeds_flag
4235 );
4236
4237 FA_UTIL_PVT.load_char_value
4238 (p_char_old => p_asset_fin_rec_old.terminal_gain_loss,
4239 p_char_adj => p_asset_fin_rec_adj.terminal_gain_loss,
4240 x_char_new => px_asset_fin_rec_new.terminal_gain_loss
4241 );
4242
4243 FA_UTIL_PVT.load_char_value
4244 (p_char_old => p_asset_fin_rec_old.exclude_proceeds_from_basis,
4245 p_char_adj => p_asset_fin_rec_adj.exclude_proceeds_from_basis,
4246 x_char_new => px_asset_fin_rec_new.exclude_proceeds_from_basis
4247 );
4248
4249 FA_UTIL_PVT.load_char_value
4250 (p_char_old => p_asset_fin_rec_old.retirement_deprn_option,
4251 p_char_adj => p_asset_fin_rec_adj.retirement_deprn_option,
4252 x_char_new => px_asset_fin_rec_new.retirement_deprn_option
4253 );
4254
4255 --
4256 -- Retirement Option Validations
4257 --
4258 if (nvl(px_asset_fin_rec_new.recognize_gain_loss, 'XXX')
4259 not in ('NO', 'YES')) then
4260 px_asset_fin_rec_new.recognize_gain_loss := 'NO';
4261 end if;
4262
4263 if (px_asset_fin_rec_new.over_depreciate_option <>
4264 fa_std_types.FA_OVER_DEPR_NO) and
4265 (nvl(px_asset_fin_rec_new.recapture_reserve_flag, 'N') <> 'N') then
4266 px_asset_fin_rec_new.recapture_reserve_flag := 'N';
4267 elsif (nvl(px_asset_fin_rec_new.recapture_reserve_flag, 'N') not in ('N', 'Y')) then
4268 px_asset_fin_rec_new.recapture_reserve_flag := 'N';
4269 end if;
4270
4271 if (px_asset_fin_rec_new.recognize_gain_loss = 'YES') and
4272 (nvl(px_asset_fin_rec_new.limit_proceeds_flag, 'N') <> 'Y') then
4273 px_asset_fin_rec_new.limit_proceeds_flag := 'N';
4274 elsif (nvl(px_asset_fin_rec_new.limit_proceeds_flag, 'N') not in ('N', 'Y')) then
4275 px_asset_fin_rec_new.limit_proceeds_flag := 'N';
4276 end if;
4277
4278 if (nvl(px_asset_fin_rec_new.terminal_gain_loss, 'XXX')
4279 not in ('NO', 'YES', 'END_OF_YEAR')) then
4280 px_asset_fin_rec_new.terminal_gain_loss := 'YES';
4281 end if;
4282
4283 FA_UTIL_PVT.load_char_value
4284 (p_char_old => p_asset_fin_rec_old.tracking_method,
4285 p_char_adj => p_asset_fin_rec_adj.tracking_method,
4286 x_char_new => px_asset_fin_rec_new.tracking_method
4287 );
4288
4289 FA_UTIL_PVT.load_char_value
4290 (p_char_old => p_asset_fin_rec_old.allocate_to_fully_rsv_flag,
4294
4291 p_char_adj => p_asset_fin_rec_adj.allocate_to_fully_rsv_flag,
4292 x_char_new => px_asset_fin_rec_new.allocate_to_fully_rsv_flag
4293 );
4295 FA_UTIL_PVT.load_char_value
4296 (p_char_old => p_asset_fin_rec_old.allocate_to_fully_ret_flag,
4297 p_char_adj => p_asset_fin_rec_adj.allocate_to_fully_ret_flag,
4298 x_char_new => px_asset_fin_rec_new.allocate_to_fully_ret_flag
4299 );
4300
4301 FA_UTIL_PVT.load_char_value
4302 (p_char_old => p_asset_fin_rec_old.excess_allocation_option,
4303 p_char_adj => p_asset_fin_rec_adj.excess_allocation_option,
4304 x_char_new => px_asset_fin_rec_new.excess_allocation_option
4305 );
4306
4307 FA_UTIL_PVT.load_char_value
4308 (p_char_old => p_asset_fin_rec_old.depreciation_option,
4309 p_char_adj => p_asset_fin_rec_adj.depreciation_option,
4310 x_char_new => px_asset_fin_rec_new.depreciation_option
4311 );
4312
4313 FA_UTIL_PVT.load_char_value
4314 (p_char_old => p_asset_fin_rec_old.member_rollup_flag,
4315 p_char_adj => p_asset_fin_rec_adj.member_rollup_flag,
4316 x_char_new => px_asset_fin_rec_new.member_rollup_flag
4317 );
4318
4319 --
4320 -- Tracking Option Validations
4321 --HH check allow_member_tracking_flag too.
4322 --
4323 if (px_asset_fin_rec_new.tracking_method is null) OR
4324 (nvl(fa_cache_pkg.fazcbc_record.allow_member_tracking_flag,'N') <> 'Y')then
4325
4326 px_asset_fin_rec_new.allocate_to_fully_rsv_flag := null;
4327 px_asset_fin_rec_new.allocate_to_fully_ret_flag := null;
4328 px_asset_fin_rec_new.excess_allocation_option := null;
4329 px_asset_fin_rec_new.depreciation_option := null;
4330 px_asset_fin_rec_new.member_rollup_flag := null;
4331
4332 elsif (px_asset_fin_rec_new.tracking_method = 'ALLOCATE') then
4333
4334 if (px_asset_fin_rec_new.allocate_to_fully_rsv_flag = 'Y') then
4335 px_asset_fin_rec_new.allocate_to_fully_ret_flag := 'Y';
4336 px_asset_fin_rec_new.excess_allocation_option := null;
4337 elsif (px_asset_fin_rec_new.allocate_to_fully_rsv_flag = 'N') then
4338 px_asset_fin_rec_new.allocate_to_fully_ret_flag := 'N';
4339 if (nvl(px_asset_fin_rec_new.excess_allocation_option, 'XXX')
4340 not in ('REDUCE', 'DISTRIBUTE')) then
4341 px_asset_fin_rec_new.excess_allocation_option := 'REDUCE';
4342 end if;
4343 else
4344 px_asset_fin_rec_new.allocate_to_fully_rsv_flag := 'N';
4345 px_asset_fin_rec_new.allocate_to_fully_ret_flag := 'N';
4346 end if;
4347
4348 px_asset_fin_rec_new.depreciation_option := null;
4349 px_asset_fin_rec_new.member_rollup_flag := null;
4350
4351 elsif (px_asset_fin_rec_new.tracking_method = 'CALCULATE') then
4352 if (nvl(px_asset_fin_rec_new.depreciation_option, 'XXX') not in ('GROUP', 'MEMBER')) then
4353 px_asset_fin_rec_new.depreciation_option := 'MEMBER';
4354 end if;
4355
4356 if (nvl(px_asset_fin_rec_new.member_rollup_flag, 'X') not in ('Y', 'N')) then
4357 px_asset_fin_rec_new.member_rollup_flag := 'N';
4358 end if;
4359
4360 --
4361 -- Bug5032617: Following if is just to ensure to prevent
4362 -- wrong combination of group setup values. (for API)
4363 --
4364 if ((px_asset_fin_rec_new.recognize_gain_loss = 'NO') or
4365 (px_asset_fin_rec_new.terminal_gain_loss <> 'YES')) and
4366 (px_asset_fin_rec_new.member_rollup_flag = 'Y') then
4367 fa_srvr_msg.add_message(
4368 calling_fn => 'fa_asset_calc_pvt.calc_group_info',
4369 name => 'FA_INVALID_PARAMETER',
4370 token1 => 'VALUE',
4371 value1 => px_asset_fin_rec_new.recognize_gain_loss,
4372 token2 => 'PARAM',
4373 value2 => 'RECOGNIZE_GAIN_LOSS');
4374 fa_srvr_msg.add_message(
4375 calling_fn => 'fa_asset_calc_pvt.calc_group_info',
4376 name => 'FA_INVALID_PARAMETER',
4377 token1 => 'VALUE',
4378 value1 => px_asset_fin_rec_new.terminal_gain_loss,
4379 token2 => 'PARAM',
4380 value2 => 'TERMINAL_GAIN_LOSS');
4381 fa_srvr_msg.add_message(
4382 calling_fn => 'fa_asset_calc_pvt.calc_group_info',
4383 name => 'FA_INVALID_PARAMETER',
4384 token1 => 'VALUE',
4385 value1 => px_asset_fin_rec_new.member_rollup_flag,
4386 token2 => 'PARAM',
4387 value2 => 'MEMBER_ROLLUP_FLAG');
4388
4389 raise calc_err;
4390 end if;
4391
4392 px_asset_fin_rec_new.allocate_to_fully_rsv_flag := null;
4393 px_asset_fin_rec_new.allocate_to_fully_ret_flag := null;
4394 px_asset_fin_rec_new.excess_allocation_option := null;
4395
4396 else
4397 fa_srvr_msg.add_message(
4398 calling_fn => l_calling_fn,
4399 name => 'FA_INVALID_TRACKING_METHOD');
4400 raise calc_err;
4401 end if; -- (px_asset_fin_rec_new.tracking_method is null)
4402
4406 nvl(p_asset_fin_rec_adj.ytd_proceeds, 0) +
4403 end if; -- (p_asset_hdr_rec.period_of_addition = 'Y') and
4404
4405 px_asset_fin_rec_new.ytd_proceeds :=
4407 nvl(p_asset_fin_rec_old.ytd_proceeds, 0);
4408
4409 px_asset_fin_rec_new.ltd_proceeds :=
4410 nvl(p_asset_fin_rec_adj.ltd_proceeds, 0) +
4411 nvl(p_asset_fin_rec_old.ltd_proceeds, 0);
4412
4413 px_asset_fin_rec_new.eofy_reserve :=
4414 nvl(p_asset_fin_rec_adj.eofy_reserve, 0) +
4415 nvl(p_asset_fin_rec_old.eofy_reserve, 0);
4416
4417 FA_UTIL_PVT.load_char_value
4418 (p_char_old => p_asset_fin_rec_old.terminal_gain_loss_flag,
4419 p_char_adj => p_asset_fin_rec_adj.terminal_gain_loss_flag,
4420 x_char_new => px_asset_fin_rec_new.terminal_gain_loss_flag);
4421
4422
4423 if (px_asset_fin_rec_new.cost <> 0) and
4424 (p_asset_fin_rec_old.terminal_gain_loss_flag = 'Y') then
4425 px_asset_fin_rec_new.terminal_gain_loss_flag := 'N';
4426 end if;
4427
4428 if (px_asset_fin_rec_new.terminal_gain_loss_flag = 'Y') and
4429 (p_trans_rec.member_transaction_header_id is not null) then
4430 px_asset_fin_rec_new.terminal_gain_loss_flag := 'N';
4431 end if;
4432
4433 return true;
4434
4435 EXCEPTION
4436 when calc_err then
4437 if (c_find_member_asset%ISOPEN) then
4438 CLOSE c_find_member_asset;
4439 end if;
4440 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
4441 return false;
4442
4443 when others then
4444 if (c_find_member_asset%ISOPEN) then
4445 CLOSE c_find_member_asset;
4446 end if;
4447 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
4448 return false;
4449
4450 END calc_group_info;
4451
4452 FUNCTION calc_member_info
4453 (p_trans_rec IN FA_API_TYPES.trans_rec_type,
4454 p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
4455 p_asset_fin_rec_old IN FA_API_TYPES.asset_fin_rec_type,
4456 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
4457 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
4458 p_asset_deprn_rec_old IN FA_API_TYPES.asset_deprn_rec_type,
4459 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
4460 ) return boolean IS
4461
4462 CURSOR c_get_group_values IS
4463 SELECT recognize_gain_loss,
4464 recapture_reserve_flag,
4465 limit_proceeds_flag,
4466 terminal_gain_loss,
4467 exclude_proceeds_from_basis,
4468 retirement_deprn_option,
4469 tracking_method,
4470 allocate_to_fully_rsv_flag,
4471 allocate_to_fully_ret_flag,
4472 excess_allocation_option,
4473 depreciation_option,
4474 member_rollup_flag,
4475 reduction_rate,
4476 reduce_addition_flag,
4477 reduce_adjustment_flag,
4478 reduce_retirement_flag,
4479 disabled_flag, --HH
4480 over_depreciate_option -- hh
4481 FROM FA_BOOKS
4482 WHERE ASSET_ID = px_asset_fin_rec_new.group_asset_id
4483 AND BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
4484 AND transaction_header_id_out is null;
4485
4486 l_recognize_gain_loss varchar2(30);
4487 l_recapture_reserve_flag varchar2(1);
4488 l_limit_proceeds_flag varchar2(1);
4489 l_terminal_gain_loss varchar2(30);
4490 l_exclude_proceeds_from_basis varchar2(1);
4491 l_retirement_deprn_option varchar2(30);
4492 l_tracking_method varchar2(30);
4493 l_allocate_to_fully_rsv_flag varchar2(1);
4494 l_allocate_to_fully_ret_flag varchar2(1);
4495 l_excess_allocation_option varchar2(30);
4496 l_depreciation_option varchar2(30);
4497 l_member_rollup_flag varchar2(1);
4498 l_reduction_rate number;
4499 l_reduce_addition_flag varchar2(1);
4500 l_reduce_adjustment_flag varchar2(1);
4501 l_reduce_retirement_flag varchar2(1);
4502 l_disabled_flag varchar2(1); --HH
4503 l_over_depreciate_option varchar2(30); --hh
4504
4505 l_calling_fn VARCHAR2(40) := 'fa_asset_calc_pvt.calc_member_info';
4506
4507 calc_member_err EXCEPTION;
4508
4509 BEGIN
4510
4511 -- This function will copy the tracking related columns from old structure
4512 -- to new structure. And if the group assignment is changed,
4513 -- get new tracking related columns from FA_BOOKS instead of copying
4514 -- old to new.
4515
4516 -- Only when this asset is assigned to group, this module will be available.
4517
4518 if px_asset_fin_rec_new.group_asset_id is not null then
4519
4520 --
4521 -- Get group information for reduction rate and tracking related values.
4522 -- If there will be more, this can be replaced with get_asset_fin_rec.
4523 -- User cursor for now since we only need part of fa_books.
4524 --
4525 open c_get_group_values;
4526 fetch c_get_group_values into l_recognize_gain_loss,
4527 l_recapture_reserve_flag,
4528 l_limit_proceeds_flag,
4529 l_terminal_gain_loss,
4530 l_exclude_proceeds_from_basis,
4531 l_retirement_deprn_option,
4535 l_excess_allocation_option,
4532 l_tracking_method,
4533 l_allocate_to_fully_rsv_flag,
4534 l_allocate_to_fully_ret_flag,
4536 l_depreciation_option,
4537 l_member_rollup_flag,
4538 l_reduction_rate,
4539 l_reduce_addition_flag,
4540 l_reduce_adjustment_flag,
4541 l_reduce_retirement_flag,
4542 l_disabled_flag,
4543 l_over_depreciate_option;
4544
4545 --
4546 -- Set reduction rate
4547 -- If this is addition and REDUCE_ADDITION flag is Y or
4548 -- this is adjustment and REDUCE_ADJUSTMENT flag is Y, then
4549 -- set group reduction rate is no value is passed in fin_rec_adj.
4550 -- Otherwise, add fin_rec_adj reduction rate to old one.
4551 --
4552 if ((p_trans_rec.transaction_type_code = 'ADDITION') and
4553 (l_reduce_addition_flag = 'Y')) or
4554 ((p_trans_rec.transaction_type_code = 'ADJUSTMENT') and
4555 (l_reduce_adjustment_flag = 'Y')) then
4556 if (p_asset_fin_rec_adj.reduction_rate is null) and
4557 (p_asset_fin_rec_old.reduction_rate is null) then
4558 px_asset_fin_rec_new.reduction_rate := nvl(l_reduction_rate, 0);
4559 else
4560 px_asset_fin_rec_new.reduction_rate :=
4561 nvl(p_asset_fin_rec_old.reduction_rate, 0) +
4562 nvl(p_asset_fin_rec_adj.reduction_rate, 0);
4563 end if;
4564 else
4565 px_asset_fin_rec_new.reduction_rate := to_number(null);
4566 end if;
4567
4568 if px_asset_fin_rec_new.group_asset_id <>
4569 nvl(p_asset_fin_rec_old.group_asset_id,-99) then
4570
4571 -- In case the group asset is changed, need to replace with new
4572 -- tracking related columns from FA_BOOKS.
4573
4574 if c_get_group_values%NOTFOUND then
4575
4576 -- This is a case in which tracking method is not assigned to the group
4577 -- to which this member asset belongs...
4578
4579 fa_srvr_msg.add_message(
4580 calling_fn => 'fa_asset_calc_pvt.calc_member_info',
4581 name => 'FA_BOOK_INEFFECTIVE_BOOK');
4582 raise calc_member_err;
4583
4584 else
4585
4586 -- New tracking related columns will be set to new structure.
4587
4588 px_asset_fin_rec_new.recognize_gain_loss := l_recognize_gain_loss;
4589 px_asset_fin_rec_new.recapture_reserve_flag := l_recapture_reserve_flag;
4590 px_asset_fin_rec_new.limit_proceeds_flag := l_limit_proceeds_flag;
4591 px_asset_fin_rec_new.terminal_gain_loss := l_terminal_gain_loss;
4592 px_asset_fin_rec_new.exclude_proceeds_from_basis := l_exclude_proceeds_from_basis;
4593 px_asset_fin_rec_new.retirement_deprn_option := l_retirement_deprn_option;
4594 px_asset_fin_rec_new.tracking_method := l_tracking_method;
4595 px_asset_fin_rec_new.allocate_to_fully_rsv_flag := l_allocate_to_fully_rsv_flag;
4596 px_asset_fin_rec_new.allocate_to_fully_ret_flag := l_allocate_to_fully_ret_flag;
4597 px_asset_fin_rec_new.excess_allocation_option := l_excess_allocation_option;
4598 px_asset_fin_rec_new.depreciation_option := l_depreciation_option;
4599 px_asset_fin_rec_new.member_rollup_flag := l_member_rollup_flag;
4600 px_asset_fin_rec_new.disabled_flag := l_disabled_flag; --HH
4601 px_asset_fin_rec_new.over_depreciate_option := l_over_depreciate_option; --hh
4602
4603 end if;
4604
4605 else -- group assignment is not changed
4606 -- In this case, just copy from old to new.
4607
4608 px_asset_fin_rec_new.recognize_gain_loss :=
4609 p_asset_fin_rec_old.recognize_gain_loss;
4610
4611 px_asset_fin_rec_new.recapture_reserve_flag :=
4612 p_asset_fin_rec_old.recapture_reserve_flag;
4613
4614 px_asset_fin_rec_new.limit_proceeds_flag :=
4615 p_asset_fin_rec_old.limit_proceeds_flag;
4616
4617 px_asset_fin_rec_new.exclude_proceeds_from_basis :=
4618 p_asset_fin_rec_old.exclude_proceeds_from_basis;
4619
4620 px_asset_fin_rec_new.retirement_deprn_option :=
4621 p_asset_fin_rec_old.retirement_deprn_option;
4622
4623 px_asset_fin_rec_new.terminal_gain_loss :=
4624 p_asset_fin_rec_old.terminal_gain_loss;
4625
4626 px_asset_fin_rec_new.tracking_method :=
4627 p_asset_fin_rec_old.tracking_method;
4628
4629 px_asset_fin_rec_new.allocate_to_fully_rsv_flag :=
4630 p_asset_fin_rec_old.allocate_to_fully_rsv_flag;
4631
4632 px_asset_fin_rec_new.allocate_to_fully_ret_flag :=
4633 p_asset_fin_rec_old.allocate_to_fully_ret_flag;
4634
4635 px_asset_fin_rec_new.excess_allocation_option :=
4636 p_asset_fin_rec_old.excess_allocation_option;
4637
4638 px_asset_fin_rec_new.depreciation_option :=
4639 p_asset_fin_rec_old.depreciation_option;
4640
4641 px_asset_fin_rec_new.member_rollup_flag :=
4642 p_asset_fin_rec_old.member_rollup_flag;
4646 --make sure there is a value here for cost sign change function
4643 --HH
4644 px_asset_fin_rec_new.disabled_flag :=
4645 p_asset_fin_rec_old.disabled_flag;
4647 px_asset_fin_rec_new.over_depreciate_option :=
4648 nvl(p_asset_fin_rec_old.over_depreciate_option, l_over_depreciate_option);
4649 --End HH
4650 end if; -- px_asset_fin_rec_new.group_asset_id <> nvl(p_asset_f.....
4651
4652 close c_get_group_values;
4653
4654 end if; -- px_asset_fin_rec_new.group_asset_id is not null;
4655
4656 if p_asset_hdr_rec.period_of_addition = 'Y' then
4657 px_asset_fin_rec_new.eofy_reserve := nvl(p_asset_deprn_rec_old.deprn_reserve, 0) -
4658 nvl(p_asset_deprn_rec_old.ytd_deprn, 0);
4659 else
4660 px_asset_fin_rec_new.eofy_reserve :=
4661 nvl(p_asset_fin_rec_adj.eofy_reserve, 0) +
4662 nvl(p_asset_fin_rec_old.eofy_reserve, 0);
4663 end if;
4664
4665 return true;
4666
4667 EXCEPTION
4668 when calc_member_err then
4669 if (c_get_group_values%ISOPEN) then
4670 CLOSE c_get_group_values;
4671 end if;
4672
4673 return false;
4674
4675 when others then
4676 if (c_get_group_values%ISOPEN) then
4677 CLOSE c_get_group_values;
4678 end if;
4679 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
4680 return false;
4681
4682 END calc_member_info;
4683
4684
4685 --RELOCATED
4686 --RELOCATED Relocated to FAVAMRTB.pls
4687 --RELOCATED
4688 --RELOCATED FUNCTION calc_raf_adj_cost
4689 --RELOCATED (p_trans_rec IN FA_API_TYPES.trans_rec_type,
4690 --RELOCATED p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
4691 --RELOCATED p_asset_desc_rec IN FA_API_TYPES.asset_desc_rec_type,
4692 --RELOCATED p_asset_type_rec IN FA_API_TYPES.asset_type_rec_type,
4693 --RELOCATED p_asset_fin_rec_old IN FA_API_TYPES.asset_fin_rec_type,
4694 --RELOCATED px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
4695 --RELOCATED p_asset_deprn_rec_adj IN FA_API_TYPES.asset_deprn_rec_type,
4696 --RELOCATED p_asset_deprn_rec_new IN FA_API_TYPES.asset_deprn_rec_type,
4697 --RELOCATED p_period_rec IN FA_API_TYPES.period_rec_type,
4698 --RELOCATED p_mrc_sob_type_code IN VARCHAR2
4699 --RELOCATED ) RETURN BOOLEAN IS
4700 --RELOCATED
4701 --RELOCATED
4702 --RELOCATED BEGIN
4703 --RELOCATED
4704 --RELOCATED return true;
4705 --RELOCATED
4706 --RELOCATED END calc_raf_adj_cost;
4707 --RELOCATED
4708
4709
4710 FUNCTION calc_standalone_info
4711 (p_asset_hdr_rec IN FA_API_TYPES.asset_Hdr_rec_type,
4712 p_asset_fin_rec_old IN FA_API_TYPES.asset_fin_rec_type,
4713 p_asset_fin_rec_adj IN FA_API_TYPES.asset_fin_rec_type,
4714 px_asset_fin_rec_new IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
4715 p_asset_deprn_rec_new IN FA_API_TYPES.asset_deprn_rec_type,
4716 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null
4717 ) return boolean IS
4718
4719 l_calling_fn VARCHAR2(40) := 'fa_asset_calc_pvt.calc_standalone_info';
4720
4721 BEGIN
4722
4723 --
4724 -- Setting Group Related variables
4725 px_asset_fin_rec_new.reduction_rate := null;
4726 px_asset_fin_rec_new.reduce_addition_flag := null;
4727 px_asset_fin_rec_new.reduce_adjustment_flag := null;
4728 px_asset_fin_rec_new.reduce_retirement_flag := null;
4729
4730 px_asset_fin_rec_new.recognize_gain_loss := null;
4731 px_asset_fin_rec_new.recapture_reserve_flag := null;
4732 px_asset_fin_rec_new.limit_proceeds_flag := null;
4733 px_asset_fin_rec_new.terminal_gain_loss := null;
4734 px_asset_fin_rec_new.exclude_proceeds_from_basis := null;
4735 px_asset_fin_rec_new.retirement_deprn_option := null;
4736
4737 px_asset_fin_rec_new.tracking_method := null;
4738 px_asset_fin_rec_new.allocate_to_fully_rsv_flag := null;
4739 px_asset_fin_rec_new.allocate_to_fully_ret_flag := null;
4740 px_asset_fin_rec_new.excess_allocation_option := null;
4741 px_asset_fin_rec_new.depreciation_option := null;
4742 px_asset_fin_rec_new.member_rollup_flag := null;
4743 px_asset_fin_rec_new.super_group_id := null;
4744 px_asset_fin_rec_new.over_depreciate_option := null;
4745 px_asset_fin_rec_new.ytd_proceeds := null;
4746 px_asset_fin_rec_new.ltd_proceeds := null;
4747 px_asset_fin_rec_new.ltd_cost_of_removal := null;
4748 px_asset_fin_rec_new.exclude_fully_rsv_flag := null;
4749 px_asset_fin_rec_new.terminal_gain_loss_flag := null;
4750
4751 if p_asset_hdr_rec.period_of_addition = 'Y' then
4752 px_asset_fin_rec_new.eofy_reserve := nvl(p_asset_deprn_rec_new.deprn_reserve, 0) -
4753 nvl(p_asset_deprn_rec_new.ytd_deprn, 0);
4754 else
4755 px_asset_fin_rec_new.eofy_reserve :=
4756 nvl(p_asset_fin_rec_adj.eofy_reserve, 0) +
4757 nvl(p_asset_fin_rec_old.eofy_reserve, 0);
4758 end if;
4759
4760 return true;
4761
4762 EXCEPTION
4763 when others then
4764 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
4765 return false;
4766
4767 END calc_standalone_info;
4768
4769
4770
4771 END FA_ASSET_CALC_PVT;