[Home] [Help]
PACKAGE BODY: APPS.FA_ADDITION_PVT
Source
1 PACKAGE BODY FA_ADDITION_PVT AS
2 /* $Header: FAVADDB.pls 120.64.12020000.5 2013/04/08 09:40:01 gigupta ship $ */
3
4 g_release number := fa_cache_pkg.fazarel_release;
5
6 function initialize (
7 -- Transaction Object --
8 px_trans_rec IN OUT NOCOPY fa_api_types.trans_rec_type,
9 px_dist_trans_rec IN OUT NOCOPY fa_api_types.trans_rec_type,
10 -- Asset Object --
11 px_asset_hdr_rec IN OUT NOCOPY fa_api_types.asset_hdr_rec_type,
12 px_asset_desc_rec IN OUT NOCOPY fa_api_types.asset_desc_rec_type,
13 px_asset_type_rec IN OUT NOCOPY fa_api_types.asset_type_rec_type,
14 px_asset_cat_rec IN OUT NOCOPY fa_api_types.asset_cat_rec_type,
15 px_asset_hierarchy_rec IN OUT NOCOPY fa_api_types.asset_hierarchy_rec_type,
16 px_asset_fin_rec IN OUT NOCOPY fa_api_types.asset_fin_rec_type,
17 px_asset_deprn_rec IN OUT NOCOPY fa_api_types.asset_deprn_rec_type,
18 px_asset_dist_tbl IN OUT NOCOPY fa_api_types.asset_dist_tbl_type,
19 -- Invoice Object --
20 px_inv_tbl IN OUT NOCOPY fa_api_types.inv_tbl_type,
21 x_return_status OUT NOCOPY VARCHAR2,
22 p_calling_fn IN VARCHAR2
23 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type) return boolean as
24
25 l_return_status boolean;
26 l_distribution_count number;
27
28 l_period_rec fa_api_types.period_rec_type;
29
30 -- Category information
31 l_category_chart_id number;
32 l_num_segs number;
33 l_delimiter varchar2(1);
34 l_segment_array FND_FLEX_EXT.SEGMENTARRAY;
35 l_concat_string varchar2(210);
36
37 init_err EXCEPTION;
38
39 --Bug# 7715087
40 cursor c_get_context_date(c_book_type_code varchar2) is
41 select greatest(calendar_period_open_date,
42 least(sysdate, calendar_period_close_date))
43 from fa_deprn_periods
44 where book_type_code = c_book_type_code
45 and period_close_date is null;
46
47 l_trx_date date;
48 --Bug# 7715087 end
49
50
51 --Bug# 8630874 - to default value of group options from category defaults for group type asset.
52 l_recognize_gain_loss varchar2(30);
53 l_terminal_gain_loss varchar2(30);
54 l_tracking_method varchar2(30);
55 l_excess_allocation_option varchar2(30);
56 l_allocate_to_fully_rsv_flag varchar2(30);
57 l_recapture_reserve_flag varchar2(1);
58 l_limit_proceeds_flag varchar2(1);
59 l_depreciation_option varchar2(30);
60 l_member_rollup_flag varchar2(1);
61
62 cursor c_get_group_defaults(c_book_type_code px_asset_hdr_rec.book_type_code%type,c_category_id px_asset_cat_rec.category_id%type,c_date_placed_in_service px_asset_fin_rec.date_placed_in_service%type) is
63 select
64 nvl(cbd.recognize_gain_loss,'NO'),
65 nvl(cbd.terminal_gain_loss,'YES'),
66 cbd.tracking_method,
67 cbd.excess_allocation_option,
68 cbd.allocate_to_fully_rsv_flag,
69 cbd.Recapture_Reserve_Flag,
70 decode(nvl(cbd.recognize_gain_loss,'NO'),'NO',cbd.LIMIT_PROCEEDS_FLAG,NULL),
71 cbd.depreciation_option,
72 cbd.member_rollup_flag
73 FROM
74 fa_categories cat,
75 fa_category_book_defaults cbd,
76 fa_methods mth,
77 fa_deprn_periods dp,
78 fa_deprn_basis_rules dbr
79 WHERE
80 dp.book_type_code = c_book_type_code and
81 dp.period_close_date is null
82 AND
83 cbd.category_id = c_category_id and
84 cbd.book_type_code = c_book_type_code and
85 nvl(c_date_placed_in_service,
86 greatest(dp.calendar_period_open_date,
87 least(sysdate,
88 nvl(dp.calendar_period_close_date,sysdate))))
89 >= cbd.start_dpis and
90 nvl(c_date_placed_in_service,
91 greatest(dp.calendar_period_open_date,
92 least(sysdate,
93 nvl(dp.calendar_period_close_date,sysdate))))
94 <= nvl(cbd.end_dpis,greatest(dp.calendar_period_open_date,
95 least(sysdate, dp.calendar_period_close_date))) and
96 cat.category_id = c_category_id and
97 mth.method_code = cbd.deprn_method and
98 decode(mth.rate_source_rule,'PRODUCTION','PROD',
99 'FLAT','FLAT',mth.life_in_months)
100 = decode(mth.rate_source_rule,
101 'PRODUCTION','PROD',
102 'FLAT','FLAT',cbd.life_in_months) and
103 mth.deprn_basis_rule_id = dbr.deprn_basis_rule_id(+);
104 --Bug# 8630874 end
105
106 begin
107
108 -- For Addition transactions, the period_of_addition flag
109 -- should be 'Y'
110 px_asset_hdr_rec.period_of_addition := 'Y';
111 px_asset_deprn_rec.reval_loss_balance := 0;
112
113 if (NOT FA_UTIL_PVT.get_period_rec (
114 p_book => px_asset_hdr_rec.book_type_code,
115 p_effective_date => NULL,
116 x_period_rec => l_period_rec
117 , p_log_level_rec => p_log_level_rec)) then
118 raise init_err;
119 end if;
120
121
122 -- may need to modify for group addition !!!
123
124
125 -- Default transaction_subtype if needed.
126 if (px_trans_rec.amortization_start_date is not null) then
127 px_trans_rec.transaction_subtype := 'AMORTIZED';
128 px_trans_rec.amortization_start_date :=
129 to_date(to_char(px_trans_rec.amortization_start_date,'DD/MM/YYYY'),'DD/MM/YYYY');
130 elsif ((px_trans_rec.amortization_start_date is null) AND
131 (px_trans_rec.transaction_subtype is not null)) then
132
133 fa_srvr_msg.add_message(
134 calling_fn => 'fa_addition_pvt.initialize',
135 name => 'FA_INVALID_PARAMETER',
136 token1 => 'VALUE',
137 value1 => px_trans_rec.transaction_subtype,
138 token2 => 'PARAM',
139 value2 => 'TRANSACTION_SUBTYPE', p_log_level_rec => p_log_level_rec);
140
141 fa_srvr_msg.add_message(
142 calling_fn => 'fa_addition_pvt.initialize',
143 name => 'FA_INVALID_PARAMETER',
144 token1 => 'VALUE',
145 value1 => 'NULL',
146 token2 => 'PARAM',
147 value2 => 'AMORTIZATION_START_DATE', p_log_level_rec => p_log_level_rec);
148
149 raise init_err;
150
151 end if;
152
153 -- Fix for Bug #2515034. Derive current_units rather than
154 -- accept value from user.
155 l_distribution_count := px_asset_dist_tbl.COUNT;
156 px_asset_desc_rec.current_units := 0;
157
158 for i in 1..l_distribution_count loop
159 px_asset_desc_rec.current_units := px_asset_desc_rec.current_units +
160 px_asset_dist_tbl(i).units_assigned;
161 end loop;
162
163 -- For corporate books, default the following info if its null
164 if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
165
166 if (px_asset_hdr_rec.asset_id is null) then
167 -- Pop the asset_id
168 select fa_additions_s.nextval
169 into px_asset_hdr_rec.asset_id
170 from dual;
171 end if;
172
173 -- Get defaults from the category.
174 if not fa_cache_pkg.fazcat (
175 X_cat_id => px_asset_cat_rec.category_id
176 , p_log_level_rec => p_log_level_rec) then
177 raise init_err;
178 end if;
179
180 -- Set Appropriate values to defaults if user did not provide them.
181 if (px_asset_desc_rec.asset_number = FND_API.G_MISS_CHAR) then
182 px_asset_desc_rec.asset_number := NULL;
183 end if;
184
185 if (px_asset_desc_rec.description = FND_API.G_MISS_CHAR) then
186 px_asset_desc_rec.description := NULL;
187 end if;
188
189 if (px_asset_desc_rec.tag_number = FND_API.G_MISS_CHAR) then
190 px_asset_desc_rec.tag_number := NULL;
191 end if;
192
193 if (px_asset_desc_rec.serial_number = FND_API.G_MISS_CHAR) then
194 px_asset_desc_rec.serial_number := NULL;
195 end if;
196
197 if (px_asset_desc_rec.asset_key_ccid = FND_API.G_MISS_NUM) then
198 px_asset_desc_rec.asset_key_ccid := NULL;
199 end if;
200
201 if (px_asset_desc_rec.parent_asset_id = FND_API.G_MISS_NUM) then
202 px_asset_desc_rec.parent_asset_id := NULL;
203 end if;
204
205 if (px_asset_desc_rec.manufacturer_name = FND_API.G_MISS_CHAR) then
206 px_asset_desc_rec.manufacturer_name := NULL;
207 end if;
208
209 if (px_asset_desc_rec.model_number = FND_API.G_MISS_CHAR) then
210 px_asset_desc_rec.model_number := NULL;
211 end if;
212
213 if (px_asset_desc_rec.warranty_id = FND_API.G_MISS_NUM) then
214 px_asset_desc_rec.warranty_id := NULL;
215 end if;
216
217 if (px_asset_desc_rec.lease_id = FND_API.G_MISS_NUM) then
218 px_asset_desc_rec.lease_id := NULL;
219 end if;
220
221 if (px_asset_desc_rec.in_use_flag = FND_API.G_MISS_CHAR or
222 px_asset_desc_rec.in_use_flag is null) then
223 px_asset_desc_rec.in_use_flag := 'YES';
224 end if;
225
226 if (px_asset_desc_rec.inventorial = FND_API.G_MISS_CHAR or
227 px_asset_desc_rec.inventorial is null) then
228 px_asset_desc_rec.inventorial :=
229 fa_cache_pkg.fazcat_record.inventorial;
230 end if;
231
232 if (px_asset_desc_rec.property_type_code = FND_API.G_MISS_CHAR or
233 px_asset_desc_rec.property_type_code is null) then
234 px_asset_desc_rec.property_type_code :=
235 fa_cache_pkg.fazcat_record.property_type_code;
236 end if;
237
238 if (px_asset_desc_rec.property_1245_1250_code = FND_API.G_MISS_CHAR or
239 px_asset_desc_rec.property_1245_1250_code is null) then
240 px_asset_desc_rec.property_1245_1250_code :=
241 fa_cache_pkg.fazcat_record.property_1245_1250_code;
242 end if;
243
244 if (px_asset_desc_rec.owned_leased = FND_API.G_MISS_CHAR or
245 px_asset_desc_rec.owned_leased is null) then
246 px_asset_desc_rec.owned_leased :=
247 fa_cache_pkg.fazcat_record.owned_leased;
248 end if;
249
250 if (px_asset_desc_rec.new_used = FND_API.G_MISS_CHAR or
251 px_asset_desc_rec.new_used is null) then
252 px_asset_desc_rec.new_used := 'NEW';
253 end if;
254
255 if (px_asset_desc_rec.unit_adjustment_flag = FND_API.G_MISS_CHAR or
256 px_asset_desc_rec.unit_adjustment_flag is null) then
257 px_asset_desc_rec.unit_adjustment_flag := 'NO';
258 end if;
259
260 if (px_asset_desc_rec.add_cost_je_flag = FND_API.G_MISS_CHAR or
261 px_asset_desc_rec.add_cost_je_flag is null) then
262 px_asset_desc_rec.add_cost_je_flag := 'NO';
263 end if;
264
265 if (px_asset_desc_rec.status = FND_API.G_MISS_CHAR) then
266 px_asset_desc_rec.status := NULL;
267 end if;
268
269 -- Bug:8240522
270 if (px_asset_fin_rec.contract_id = FND_API.G_MISS_NUM) then
271 px_asset_fin_rec.contract_id := NULL;
272 end if;
273
274 if (px_asset_fin_rec.itc_amount_id = FND_API.G_MISS_NUM) then
275 px_asset_fin_rec.itc_amount_id := NULL;
276 end if;
277
278 if (px_asset_fin_rec.ceiling_name = FND_API.G_MISS_CHAR) then
279 px_asset_fin_rec.ceiling_name := NULL;
280 end if;
281
282 if (px_asset_fin_rec.capitalize_flag = NULL) then
283 px_asset_fin_rec.capitalize_flag :=
284 fa_cache_pkg.fazcat_record.capitalize_flag;
285 end if;
286
287 if (px_asset_fin_rec.global_attribute1 = FND_API.G_MISS_CHAR) then
288 px_asset_fin_rec.global_attribute1 := NULL;
289 end if;
290
291 if (px_asset_fin_rec.global_attribute2 = FND_API.G_MISS_CHAR) then
292 px_asset_fin_rec.global_attribute2 := NULL;
293 end if;
294
295 if (px_asset_fin_rec.global_attribute3 = FND_API.G_MISS_CHAR) then
296 px_asset_fin_rec.global_attribute3 := NULL;
297 end if;
298
299 if (px_asset_fin_rec.global_attribute4 = FND_API.G_MISS_CHAR) then
300 px_asset_fin_rec.global_attribute4 := NULL;
301 end if;
302
303 if (px_asset_fin_rec.global_attribute5 = FND_API.G_MISS_CHAR) then
304 px_asset_fin_rec.global_attribute5 := NULL;
305 end if;
306
307 if (px_asset_fin_rec.global_attribute6 = FND_API.G_MISS_CHAR) then
308 px_asset_fin_rec.global_attribute6 := NULL;
309 end if;
310
311 if (px_asset_fin_rec.global_attribute7 = FND_API.G_MISS_CHAR) then
312 px_asset_fin_rec.global_attribute7 := NULL;
313 end if;
314
315 if (px_asset_fin_rec.global_attribute8 = FND_API.G_MISS_CHAR) then
316 px_asset_fin_rec.global_attribute8 := NULL;
317 end if;
318
319 if (px_asset_fin_rec.global_attribute9 = FND_API.G_MISS_CHAR) then
320 px_asset_fin_rec.global_attribute9 := NULL;
321 end if;
322
323 if (px_asset_fin_rec.global_attribute10 = FND_API.G_MISS_CHAR) then
324 px_asset_fin_rec.global_attribute10 := NULL;
325 end if;
326
327 if (px_asset_fin_rec.global_attribute11 = FND_API.G_MISS_CHAR) then
328 px_asset_fin_rec.global_attribute11 := NULL;
329 end if;
330
331 if (px_asset_fin_rec.global_attribute12 = FND_API.G_MISS_CHAR) then
332 px_asset_fin_rec.global_attribute12 := NULL;
333 end if;
334
335 if (px_asset_fin_rec.global_attribute13 = FND_API.G_MISS_CHAR) then
336 px_asset_fin_rec.global_attribute13 := NULL;
337 end if;
338
339 if (px_asset_fin_rec.global_attribute14 = FND_API.G_MISS_CHAR) then
340 px_asset_fin_rec.global_attribute14 := NULL;
341 end if;
342
343 if (px_asset_fin_rec.global_attribute15 = FND_API.G_MISS_CHAR) then
344 px_asset_fin_rec.global_attribute15 := NULL;
345 end if;
346
347 if (px_asset_fin_rec.global_attribute16 = FND_API.G_MISS_CHAR) then
348 px_asset_fin_rec.global_attribute16 := NULL;
349 end if;
350
351 if (px_asset_fin_rec.global_attribute17 = FND_API.G_MISS_CHAR) then
352 px_asset_fin_rec.global_attribute17 := NULL;
353 end if;
354
355 if (px_asset_fin_rec.global_attribute18 = FND_API.G_MISS_CHAR) then
356 px_asset_fin_rec.global_attribute18 := NULL;
357 end if;
358
359 if (px_asset_fin_rec.global_attribute19 = FND_API.G_MISS_CHAR) then
360 px_asset_fin_rec.global_attribute19 := NULL;
361 end if;
362
363 if (px_asset_fin_rec.global_attribute20 = FND_API.G_MISS_CHAR) then
364 px_asset_fin_rec.global_attribute20 := NULL;
365 end if;
366
367 if (px_asset_fin_rec.global_attribute_category = FND_API.G_MISS_CHAR) then
368 px_asset_fin_rec.global_attribute_category := NULL;
369 end if;
370
371 if (px_asset_cat_rec.desc_flex.attribute_category_code is null) then
372
373 l_return_status := fa_cache_pkg.fazsys(p_log_level_rec);
374
375 if not (l_return_status) then
376 raise init_err;
377 else
378 l_category_chart_id :=
379 fa_cache_pkg.fazsys_record.category_flex_structure;
380 end if;
381
382 l_return_status := fa_flex_pvt.get_concat_segs (
383 p_ccid => px_asset_cat_rec.category_id,
384 p_application_short_name => 'OFA',
385 p_flex_code => 'CAT#',
386 p_flex_num => l_category_chart_id,
387 p_num_segs => l_num_segs,
388 p_delimiter => l_delimiter,
389 p_segment_array => l_segment_array,
390 p_concat_string => l_concat_string
391 , p_log_level_rec => p_log_level_rec);
392
393 if not (l_return_status) then
394 raise init_err;
395 end if;
396
397 px_asset_cat_rec.desc_flex.attribute_category_code :=
398 l_concat_string;
399
400 end if;
401 /*Bug# 9941662 - Added call to globalization hook to get correct context value.
402 Bug# 10180243 - Need to call only when called from mass additions interface */
403 if px_asset_desc_rec.global_desc_flex.attribute_category_code is not null and
404 px_trans_rec.calling_interface = 'FAMAPT'then
405 l_return_status := JG_GLOBE_FLEX_VAL.reassign_context_code(px_asset_desc_rec.global_desc_flex.attribute_category_code);
406 if not (l_return_status) then
407 fa_srvr_msg.add_message(calling_fn => 'fa_addition_pvt.initialize'
408 ,name => 'FA_NOT_VALID_GDF'
409 ,token1 => 'ASSET_NUMBER',
410 value1 => px_asset_hdr_rec.asset_id
411 ,p_log_level_rec => p_log_level_rec);
412 raise init_err;
413 end if;
414 end if;
415 -- Removing condition due to bug 5211950
416 /* if (px_asset_cat_rec.desc_flex.context is null) then
417 px_asset_cat_rec.desc_flex.context :=
418 px_asset_cat_rec.desc_flex.attribute_category_code;
419 end if;
420 */
421 else -- tax book
422
423 -- Default cost/dpis in Tax to cost in corp if needed.
424 if (px_asset_fin_rec.cost is null or
425 px_asset_fin_rec.date_placed_in_service is null) then
426
427 select nvl(px_asset_fin_rec.cost, cost),
428 nvl(px_asset_fin_rec.date_placed_in_service, date_placed_in_service)
429 into px_asset_fin_rec.cost,
430 px_asset_fin_rec.date_placed_in_service
431 from fa_books bks
432 where book_type_code =
433 fa_cache_pkg.fazcbc_record.distribution_source_book
434 and asset_id = px_asset_hdr_rec.asset_id
435 and transaction_header_id_out is null;
436 end if;
437
438 -- load the shared structs
439 if not FA_UTIL_PVT.get_asset_desc_rec
440 (p_asset_hdr_rec => px_asset_hdr_rec,
441 px_asset_desc_rec => px_asset_desc_rec
442 , p_log_level_rec => p_log_level_rec) then
443 raise init_err;
444 end if;
445
446 if not FA_UTIL_PVT.get_asset_cat_rec
447 (p_asset_hdr_rec => px_asset_hdr_rec,
448 px_asset_cat_rec => px_asset_cat_rec,
449 p_date_effective => null
450 , p_log_level_rec => p_log_level_rec) then
451 raise init_err;
452 end if;
453
454 if not FA_UTIL_PVT.get_asset_type_rec
455 (p_asset_hdr_rec => px_asset_hdr_rec,
456 px_asset_type_rec => px_asset_type_rec,
457 p_date_effective => null
458 , p_log_level_rec => p_log_level_rec) then
459 raise init_err;
460 end if;
461
462
463 -- remove and items in the distribution table as they are
464 -- irrelevant to tax
465 px_asset_dist_tbl.delete;
466
467 end if; -- corp or tax
468
469
470 -- Determine defaults for transaction_date_entered and
471 -- date_placed_in_service - dpis is populated abiove for tax
472
473
474 if ((px_trans_rec.transaction_date_entered is null) and
475 (px_asset_fin_rec.date_placed_in_service is null)) then
476
477 if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
478 -- Default to last day of the period
479 px_asset_fin_rec.date_placed_in_service :=
480 l_period_rec.calendar_period_close_date;
481 end if;
482
483 px_trans_rec.transaction_date_entered :=
484 px_asset_fin_rec.date_placed_in_service;
485
486 elsif ((px_trans_rec.transaction_date_entered is null) and
487 (px_asset_fin_rec.date_placed_in_service is not null)) then
488
489 px_trans_rec.transaction_date_entered :=
490 px_asset_fin_rec.date_placed_in_service;
491
492 elsif ((px_trans_rec.transaction_date_entered is not null) and
493 (px_asset_fin_rec.date_placed_in_service is null)) then
494
495 px_asset_fin_rec.date_placed_in_service :=
496 px_trans_rec.transaction_date_entered;
497
498 elsif (px_trans_rec.transaction_date_entered <>
499 px_asset_fin_rec.date_placed_in_service) then
500
501 fa_srvr_msg.add_message(
502 calling_fn => NULL,
503 name => 'FA_WHATIF_ASSET_CHK_TRX_DATE',
504 token1 => 'ASSET_ID',
505 value1 => to_char(px_asset_hdr_rec.asset_id),
506 p_log_level_rec => p_log_level_rec);
507
508 raise init_err;
509 end if;
510
511 -- BUG# 3549470
512 -- remove time stamp if provided
513
514 px_trans_rec.transaction_date_entered :=
515 to_date(to_char(px_trans_rec.transaction_date_entered,'DD/MM/YYYY'),'DD/MM/YYYY');
516
517 px_asset_fin_rec.date_placed_in_service :=
518 to_date(to_char(px_asset_fin_rec.date_placed_in_service,'DD/MM/YYYY'),'DD/MM/YYYY');
519
520 -- Derive the transaction type - needs to be done after the
521 -- asset type is derived for tax assets
522
523 if (px_asset_type_rec.asset_type = 'CIP') then
524 px_trans_rec.transaction_type_code := 'CIP ADDITION';
525 elsif (px_asset_type_rec.asset_type = 'GROUP') then
526 px_trans_rec.transaction_type_code := 'GROUP ADDITION';
527 else
528 px_trans_rec.transaction_type_code := 'ADDITION';
529 end if;
530
531 if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
532 -- Set the default values for the distribution trans rec if corp book
533 px_dist_trans_rec.transaction_type_code := 'TRANSFER IN';
534
535 px_dist_trans_rec.transaction_date_entered :=
536 px_trans_rec.transaction_date_entered;
537
538 px_dist_trans_rec.source_transaction_header_id := NULL;
539
540 px_dist_trans_rec.mass_reference_id := px_trans_rec.mass_reference_id;
541
542 px_dist_trans_rec.transaction_subtype := NULL;
543
544 px_dist_trans_rec.transaction_key := NULL;
545
546 px_dist_trans_rec.amortization_start_date := NULL;
547
548 px_dist_trans_rec.who_info := px_trans_rec.who_info;
549 --9413081
550 px_dist_trans_rec.event_id := NULL;
551 end if;
552
553 -- Default values in inv_rec
554 for i in 1 .. px_inv_tbl.COUNT loop
555 if (px_inv_tbl(i).deleted_flag is NULL) then
556 px_inv_tbl(i).deleted_flag := 'NO';
557 end if;
558 end loop;
559
560 -- *****************************
561 -- begin changes for group deprn
562 -- *****************************
563 if (px_asset_type_rec.asset_type = 'GROUP') then
564 px_asset_fin_rec.cost := 0;
565 end if;
566
567
568
569 -- following section is for setting various defaults from the category
570 -- if needed - this code used to reside in the calculation engine
571 -- but has grown complex and easier to place it here.
572
573 if not fa_cache_pkg.fazccbd (X_book => px_asset_hdr_rec.book_type_code,
574 X_cat_id => px_asset_cat_rec.category_id,
575 X_jdpis => to_number(to_char(px_asset_fin_rec.date_placed_in_service, 'J')),
576 p_log_level_rec => p_log_level_rec) then
577 raise init_err;
578 end if;
579
580 -- for period of addition, if deprn info is not populated, then first
581 -- default from the parent rules (if applicable) or from the category
582
583 if (px_asset_fin_rec.deprn_method_code is null) then
584
585 px_asset_fin_rec.deprn_method_code := fa_cache_pkg.fazccbd_record.deprn_method;
586 px_asset_fin_rec.life_in_months := fa_cache_pkg.fazccbd_record.life_in_months;
587 px_asset_fin_rec.basic_rate := fa_cache_pkg.fazccbd_record.basic_rate;
588 px_asset_fin_rec.adjusted_rate := fa_cache_pkg.fazccbd_record.adjusted_rate;
589
590 -- BUG# 2417520 - mass additions can send in prod capacity only, so allow this
591 px_asset_fin_rec.production_capacity := nvl(px_asset_fin_rec.production_capacity,
592 fa_cache_pkg.fazccbd_record.production_capacity);
593
594 -- BUG# 3066139 - need to default UOP as well
595 px_asset_fin_rec.unit_of_measure := nvl(px_asset_fin_rec.unit_of_measure,
596 fa_cache_pkg.fazccbd_record.unit_of_measure);
597
598 if (nvl(fa_cache_pkg.fazccbd_record.subcomponent_life_rule, 'NULL') <> 'NULL' and
599 nvl(px_asset_desc_rec.parent_asset_id, -99) <> -99) then
600
601 if not FA_ASSET_CALC_PVT.calc_subcomp_life
602 (p_trans_rec => px_trans_rec,
603 p_asset_hdr_rec => px_asset_hdr_rec,
604 p_asset_cat_rec => px_asset_cat_rec,
605 p_asset_desc_rec => px_asset_desc_rec,
606 p_period_rec => l_period_rec,
607 px_asset_fin_rec => px_asset_fin_rec,
608 p_calling_fn => 'fa_ddition_pvt.initialize'
609 , p_log_level_rec => p_log_level_rec) then
610 raise init_err;
611 end if;
612 end if;
613 end if;
614
615
616
617 /*Bug# 7715087 -to default amortization start date for energy if not provided.
618 Initialize the cache first*/
619 if not fa_cache_pkg.fazccmt
620 (X_method => px_asset_fin_rec.deprn_method_code,
621 X_life => px_asset_fin_rec.life_in_months, p_log_level_rec => p_log_level_rec) then
622 raise init_err;
623 end if;
624 if( fa_cache_pkg.fazccmt_record.rate_source_rule = 'PRODUCTION'
625 AND fa_cache_pkg.fazcdrd_record.rule_name = 'ENERGY PERIOD END BALANCE') then
626 open c_get_context_date(px_asset_hdr_rec.book_type_code);
627 fetch c_get_context_date into l_trx_date ;
628 close c_get_context_date;
629 if( px_trans_rec.amortization_start_date is null ) then
630 px_trans_rec.amortization_start_date := to_date(to_char(l_trx_date,'DD/MM/YYYY'),'DD/MM/YYYY');
631 px_trans_rec.transaction_subtype := 'AMORTIZED';
632 end if;
633 end if;
634 --Bug# 7715087 end
635 /*bug#15897249 starts*/
636 if( fa_cache_pkg.fazccmt_record.deprn_basis_rule = 'NBV'
637 AND fa_cache_pkg.fazcdrd_record.rule_name = 'YEAR END BALANCE WITH POSITIVE REDUCTION AMOUNT'
638 AND px_asset_type_rec.asset_type = 'GROUP'
639 AND px_asset_fin_rec.tracking_method = 'CALCULATE'
640 AND px_asset_fin_rec.member_rollup_flag = 'Y'
641 AND px_asset_fin_rec.exclude_proceeds_from_basis is null
642 ) then
643 px_asset_fin_rec.exclude_proceeds_from_basis := 'Y';
644 end if;
645 /*bug#15897249 ends */
646
647 if (px_asset_fin_rec.bonus_rule is null) then
648 px_asset_fin_rec.bonus_rule :=
649 fa_cache_pkg.fazccbd_record.bonus_rule;
650 elsif (px_asset_fin_rec.bonus_rule = FND_API.G_MISS_CHAR) then
651 px_asset_fin_rec.bonus_rule := NULL;
652 end if;
653
654 if (px_asset_fin_rec.ceiling_name is null) then
655 px_asset_fin_rec.ceiling_name :=
656 fa_cache_pkg.fazccbd_record.ceiling_name;
657 elsif (px_asset_fin_rec.ceiling_name = FND_API.G_MISS_CHAR) then
658 px_asset_fin_rec.ceiling_name := NULL;
659 end if;
660
661 -- this is where we would allow for multi-tier group
662 -- associations if we ever offer it and in the if
663 -- condition surrounding the load_miss call below
664 if px_asset_type_rec.asset_type <> 'GROUP' then
665 if (px_asset_fin_rec.group_asset_id is null) then
666 --Call validate disabled_flag to confirm default group is not disabled
667 if NOT FA_ASSET_VAL_PVT.validate_group_info
668 (p_group_asset_id => fa_cache_pkg.fazccbd_record.group_asset_id,
669 p_book_type_code => px_asset_hdr_rec.book_type_code,
670 p_calling_fn => 'fa_addition_pvt.initialize', p_log_level_rec => p_log_level_rec) then
671 fa_srvr_msg.add_message(calling_fn => 'fa_addition_pvt.initialize',
672 name => 'FA_DISABLED_DEFAULT_GROUP', p_log_level_rec => p_log_level_rec);
673 raise init_err;
674 end if;
675 --HH do this check for conditional group defaulting
676 if (px_asset_type_rec.asset_type <> 'CIP') OR
677 ((px_asset_type_rec.asset_type = 'CIP') AND
678 (fa_cache_pkg.fazcbc_record.allow_cip_member_flag = 'Y')) then
679 px_asset_fin_rec.group_asset_id := fa_cache_pkg.fazccbd_record.group_asset_id;
680 else
681 px_asset_fin_rec.group_asset_id := NULL;
682 /* fa_srvr_msg.add_message(calling_fn => 'fa_addition_pvt.initialize',
683 name => 'FA_CIP_MEMBER_NOT_ALLOWED', p_log_level_rec => p_log_level_rec);
684 raise init_err; */
685 end if; --end HH -- conditional group defaulting
686 elsif (px_asset_fin_rec.group_asset_id = FND_API.G_MISS_NUM) then
687 px_asset_fin_rec.group_asset_id := NULL;
688 end if; --group asset_id null
689 else
690 px_asset_fin_rec.group_asset_id := null;
691 end if; --<>Group
692
693 -- percent salvage - this is where we should derive
694 -- the various copy options (NO/YES/PER) for tax books
695 -- during mass copy and autocopy. we will try to
696 -- determine user intent first by looking at the
697 -- type then by looking at the values
698
699 if (px_asset_fin_rec.salvage_type is null) then
700 if (px_asset_fin_rec.percent_salvage_value is null and
701 px_asset_fin_rec.salvage_value is null) then
702 if (fa_cache_pkg.fazcbc_record.book_class = 'TAX' and
703 px_trans_rec.source_transaction_header_id is not null and
704 fa_cache_pkg.fazcbc_record.copy_salvage_value_flag = 'YES') then
705 -- get the primary corp book value from source transaction
706 -- using this and then converting in case mrc is anabled on tax
707 -- books but not on corp
708
709 if (px_asset_fin_rec.cost <> 0) then
710 select nvl(salvage_value, 0)
711 into px_asset_fin_rec.salvage_value
712 from fa_books
713 where transaction_header_id_in = px_trans_rec.source_transaction_header_id;
714 else
715 px_asset_fin_rec.salvage_value := 0;
716 end if;
717 else -- corp, manual tax, or no copy salvage
718 px_asset_fin_rec.percent_salvage_value :=
719 fa_cache_pkg.fazccbd_record.percent_salvage_value;
720 end if;
721 end if;
722
723 if (px_asset_fin_rec.percent_salvage_value is null) then
724 if (px_asset_type_rec.asset_type = 'GROUP') then
725 px_asset_fin_rec.salvage_type := 'PCT';
726 px_asset_fin_rec.salvage_value := 0;
727 else
728 px_asset_fin_rec.salvage_type := 'AMT';
729 end if;
730 else
731 px_asset_fin_rec.salvage_type := 'PCT';
732 end if;
733
734 elsif (px_asset_fin_rec.salvage_type = 'PCT' and
735 px_asset_fin_rec.percent_salvage_value is null) then
736 px_asset_fin_rec.percent_salvage_value := nvl(fa_cache_pkg.fazccbd_record.percent_salvage_value, 0);
737 elsif (px_asset_fin_rec.salvage_type = 'AMT' and
738 px_asset_fin_rec.salvage_value is null) then
739 px_asset_fin_rec.salvage_value := 0;
740 elsif (px_asset_fin_rec.salvage_type <> 'PCT' and
741 px_asset_fin_rec.salvage_type <> 'AMT' and
742 px_asset_fin_rec.salvage_type <> 'SUM') then
743 fa_srvr_msg.add_message(
744 calling_fn => 'fa_addition_pvt.initialize',
745 name => 'FA_INVALID_PARAMETER',
746 token1 => 'VALUE',
747 value1 => px_asset_fin_rec.salvage_type,
748 token2 => 'PARAM',
749 value2 => 'SALVAGE_TYPE', p_log_level_rec => p_log_level_rec); raise init_err;
750 end if;
751
752 -- note that if after the following logic the deprn_limit type
753 -- is not NONE and the amount and percentage remain null, we will error
754 -- but this is caught inside the calculation engine.
755
756 if (px_asset_fin_rec.deprn_limit_type is null) then
757 if (px_asset_fin_rec.allowed_deprn_limit_amount is null and
758 px_asset_fin_rec.allowed_deprn_limit is null) then
759 if (fa_cache_pkg.fazccbd_record.use_deprn_limits_flag = 'YES') then
760 px_asset_fin_rec.allowed_deprn_limit :=
761 fa_cache_pkg.fazccbd_record.allowed_deprn_limit;
762 px_asset_fin_rec.allowed_deprn_limit_amount :=
763 fa_cache_pkg.fazccbd_record.special_deprn_limit_amount;
764 end if;
765 end if;
766
767 if (px_asset_fin_rec.allowed_deprn_limit is not null) then
768 px_asset_fin_rec.deprn_limit_type := 'PCT';
769 elsif (px_asset_fin_rec.allowed_deprn_limit_amount is not null) then
770 px_asset_fin_rec.deprn_limit_type := 'AMT';
771 else
772 px_asset_fin_rec.deprn_limit_type := 'NONE';
773 end if;
774
775 elsif (px_asset_fin_rec.deprn_limit_type = 'PCT' and
776 px_asset_fin_rec.allowed_deprn_limit is null) then
777 px_asset_fin_rec.allowed_deprn_limit:=
778 fa_cache_pkg.fazccbd_record.allowed_deprn_limit;
779 if (px_asset_fin_rec.allowed_deprn_limit is null) then
780 fa_srvr_msg.add_message(
781 calling_fn => 'fa_addition_pvt.initialize',
782 name => '***FA_MUST_SPECIFY_LIMIT***',
783 p_log_level_rec => p_log_level_rec);
784 raise init_err;
785 end if;
786 elsif (px_asset_fin_rec.deprn_limit_type = 'AMT' and
787 px_asset_fin_rec.allowed_deprn_limit_amount is null) then
788 px_asset_fin_rec.allowed_deprn_limit_amount:=
789 fa_cache_pkg.fazccbd_record.special_deprn_limit_amount;
790 if (px_asset_fin_rec.allowed_deprn_limit_amount is null) then
791 fa_srvr_msg.add_message(
792 calling_fn => 'fa_addition_pvt.initialize',
793 name => '***FA_MUST_SPECIFY_LIMIT***',
794 p_log_level_rec => p_log_level_rec);
795 raise init_err;
796 end if;
797 elsif (px_asset_fin_rec.deprn_limit_type = 'NONE') then
798 px_asset_fin_rec.allowed_deprn_limit := null;
799 px_asset_fin_rec.allowed_deprn_limit_amount := null;
800 elsif (px_asset_fin_rec.deprn_limit_type <> 'PCT' and
801 px_asset_fin_rec.deprn_limit_type <> 'AMT' and
802 px_asset_fin_rec.deprn_limit_type <> 'SUM' and
803 px_asset_fin_rec.deprn_limit_type <> 'NONE') then
804 fa_srvr_msg.add_message(
805 calling_fn => 'fa_addition_pvt.initialize',
806 name => 'FA_INVALID_PARAMETER',
807 token1 => 'VALUE',
808 value1 => px_asset_fin_rec.deprn_limit_type,
809 token2 => 'PARAM',
810 value2 => 'DEPRN_LIMIT_TYPE', p_log_level_rec => p_log_level_rec);
811 raise init_err;
812 end if;
813
814 -- end category defaulting
815
816 -- begin group defaulting
817 if (px_asset_type_rec.asset_type = 'GROUP') then
818
819 if (p_log_level_rec.statement_level) then
820 fa_debug_pkg.add('add',
821 'entering group flag defaulting',
822 'X', p_log_level_rec => p_log_level_rec);
823 fa_debug_pkg.add('add',
824 'px_asset_fin_rec.over_depreciate_option',
825 px_asset_fin_rec.over_depreciate_option, p_log_level_rec => p_log_level_rec);
826 end if;
827
828 --Bug# 8630874 Group option defaulting from category group default
829 open c_get_group_defaults(px_asset_hdr_rec.book_type_code,px_asset_cat_rec.category_id,px_asset_fin_rec.date_placed_in_service);
830 fetch c_get_group_defaults into l_recognize_gain_loss,
831 l_terminal_gain_loss,
832 l_tracking_method,
833 l_excess_allocation_option,
834 l_allocate_to_fully_rsv_flag,
835 l_recapture_reserve_flag,
836 l_limit_proceeds_flag,
837 l_depreciation_option,
838 l_member_rollup_flag;
839
840 if (px_asset_fin_rec.recognize_gain_loss is null) then
841 px_asset_fin_rec.recognize_gain_loss := l_recognize_gain_loss;
842 end if;
843
844 if (px_asset_fin_rec.tracking_method is null) then
845 px_asset_fin_rec.tracking_method := l_tracking_method;
846 end if;
847
848 if (px_asset_fin_rec.allocate_to_fully_rsv_flag is null) then
849 px_asset_fin_rec.allocate_to_fully_rsv_flag := l_allocate_to_fully_rsv_flag;
850 end if;
851 if (px_asset_fin_rec.terminal_gain_loss is null) then
852 px_asset_fin_rec.terminal_gain_loss := l_terminal_gain_loss;
853 end if;
854
855 if (px_asset_fin_rec.excess_allocation_option is null) then
856 px_asset_fin_rec.excess_allocation_option := l_excess_allocation_option;
857 end if;
858
859 if (px_asset_fin_rec.recapture_reserve_flag is null) then
860 px_asset_fin_rec.recapture_reserve_flag := l_recapture_reserve_flag;
861 end if;
862
863 if (px_asset_fin_rec.limit_proceeds_flag is null) then
864 px_asset_fin_rec.limit_proceeds_flag := l_limit_proceeds_flag;
865 end if;
866
867 if (px_asset_fin_rec.depreciation_option is null) then
868 px_asset_fin_rec.depreciation_option := l_depreciation_option;
869 end if;
870
871 if (not (l_recognize_gain_loss = 'NO') or (l_terminal_gain_loss <> 'YES')) and
872 px_asset_fin_rec.member_rollup_flag is null then
873 px_asset_fin_rec.member_rollup_flag := l_member_rollup_flag;
874 end if;
875 --Bug8630874 end
876
877 if (px_asset_fin_rec.over_depreciate_option is null) then
878 px_asset_fin_rec.over_depreciate_option :=
879 fa_std_types.FA_OVER_DEPR_NO;
880 end if;
881
882 if (p_log_level_rec.statement_level) then
883 fa_debug_pkg.add('add',
884 'px_asset_fin_rec.over_depreciate_option',
885 px_asset_fin_rec.over_depreciate_option, p_log_level_rec => p_log_level_rec);
886 end if;
887
888 if not fa_cache_pkg.fazccmt
889 (X_method => px_asset_fin_rec.deprn_method_code,
890 X_life => px_asset_fin_rec.life_in_months, p_log_level_rec => p_log_level_rec) then
891 raise init_err;
892 end if;
893
894 if (nvl(fa_cache_pkg.fazcdrd_record.allow_reduction_rate_flag, 'N') = 'N') then
895 px_asset_fin_rec.reduction_rate := to_number(null);
896 px_asset_fin_rec.reduce_addition_flag := null;
897 px_asset_fin_rec.reduce_adjustment_flag := null;
898 px_asset_fin_rec.reduce_adjustment_flag := null;
899 else
900 if (px_asset_fin_rec.reduction_rate is null) then
901 px_asset_fin_rec.reduction_rate := 0;
902 end if;
903
904 if (px_asset_fin_rec.reduce_addition_flag is null) then
905 px_asset_fin_rec.reduce_addition_flag := 'N';
906 end if;
907
908 if (px_asset_fin_rec.reduce_adjustment_flag is null) then
909 px_asset_fin_rec.reduce_adjustment_flag := 'N';
910 end if;
911
912 if (px_asset_fin_rec.reduce_retirement_flag is null) then
913 px_asset_fin_rec.reduce_retirement_flag := 'N';
914 end if;
915
916 end if;
917
918 --
919 -- Bug5032617: Following if is just to ensure to prevent
920 -- wrong combination of group setup values. (for API)
921 -- If member_rollup_flag is given and Y, then set
922 -- retirement option accordingly if they are null.
923 --
924 if (px_asset_fin_rec.member_rollup_flag = 'Y') then
925 if (px_asset_fin_rec.recognize_gain_loss is null) then
926 px_asset_fin_rec.recognize_gain_loss := 'YES';
927 end if;
928 if (px_asset_fin_rec.terminal_gain_loss is null) then
929 px_asset_fin_rec.terminal_gain_loss := 'YES';
930 end if;
931 end if;
932
933 if (px_asset_fin_rec.recognize_gain_loss is null) then
934 px_asset_fin_rec.recognize_gain_loss := 'NO';
935 px_asset_fin_rec.limit_proceeds_flag := 'N';
936 px_asset_fin_rec.terminal_gain_loss := 'YES';
937 else
938 if (px_asset_fin_rec.limit_proceeds_flag is null) then
939 px_asset_fin_rec.limit_proceeds_flag := 'N';
940 end if;
941 if (px_asset_fin_rec.terminal_gain_loss is null) then
942 px_asset_fin_rec.terminal_gain_loss := 'YES';
943 end if;
944 end if;
945
946 --
947 -- Bug5032617: Following if is just to ensure to prevent
948 -- wrong combination of group setup values. (for API)
949 --
950 /*bug#15897249 modified if statement */
951 if ((px_asset_fin_rec.recognize_gain_loss = 'NO') or
952 (px_asset_fin_rec.terminal_gain_loss <> 'YES')) and
953 ((px_asset_fin_rec.member_rollup_flag = 'Y' and
954 nvl(fa_cache_pkg.fazcdrd_record.rule_name,'ZZ') <> 'YEAR END BALANCE WITH POSITIVE REDUCTION AMOUNT')
955 ) then
956 fa_srvr_msg.add_message(
957 calling_fn => 'fa_addition_pvt.initialize',
958 name => 'FA_INVALID_PARAMETER',
959 token1 => 'VALUE',
960 value1 => px_asset_fin_rec.recognize_gain_loss,
961 token2 => 'PARAM',
962 value2 => 'RECOGNIZE_GAIN_LOSS', p_log_level_rec => p_log_level_rec);
963 fa_srvr_msg.add_message(
964 calling_fn => 'fa_addition_pvt.initialize',
965 name => 'FA_INVALID_PARAMETER',
966 token1 => 'VALUE',
967 value1 => px_asset_fin_rec.terminal_gain_loss,
968 token2 => 'PARAM',
969 value2 => 'TERMINAL_GAIN_LOSS', p_log_level_rec => p_log_level_rec);
970 fa_srvr_msg.add_message(
971 calling_fn => 'fa_addition_pvt.initialize',
972 name => 'FA_INVALID_PARAMETER',
973 token1 => 'VALUE',
974 value1 => px_asset_fin_rec.member_rollup_flag,
975 token2 => 'PARAM',
976 value2 => 'MEMBER_ROLLUP_FLAG', p_log_level_rec => p_log_level_rec);
977
978 raise init_err;
979 end if;
980
981 if (px_asset_fin_rec.recapture_reserve_flag is null) then
982 px_asset_fin_rec.recapture_reserve_flag := 'N';
983 end if;
984
985 if (px_asset_fin_rec.tracking_method is null or
986 px_asset_fin_rec.tracking_method = FND_API.G_MISS_CHAR) then
987 px_asset_fin_rec.tracking_method := null;
988 px_asset_fin_rec.allocate_to_fully_rsv_flag := null;
989 px_asset_fin_rec.allocate_to_fully_ret_flag := null;
990 px_asset_fin_rec.excess_allocation_option := null;
991 px_asset_fin_rec.depreciation_option := null;
992 px_asset_fin_rec.member_rollup_flag := null;
993 else
994 if (px_asset_fin_rec.tracking_method = 'ALLOCATE') then
995 if (px_asset_fin_rec.allocate_to_fully_rsv_flag is null) then
996 px_asset_fin_rec.allocate_to_fully_rsv_flag := 'N';
997 end if;
998 if (px_asset_fin_rec.allocate_to_fully_ret_flag is null) then
999 px_asset_fin_rec.allocate_to_fully_ret_flag := 'N';
1000 end if;
1001 if (px_asset_fin_rec.excess_allocation_option is null) then
1002 px_asset_fin_rec.excess_allocation_option := 'REDUCE';
1003 end if;
1004 px_asset_fin_rec.depreciation_option := null;
1005 px_asset_fin_rec.member_rollup_flag := null;
1006 elsif (px_asset_fin_rec.tracking_method = 'CALCULATE') then
1007 px_asset_fin_rec.allocate_to_fully_rsv_flag := null;
1008 px_asset_fin_rec.allocate_to_fully_ret_flag := null;
1009 px_asset_fin_rec.excess_allocation_option := null;
1010
1011 if (px_asset_fin_rec.depreciation_option is null) then
1012 px_asset_fin_rec.depreciation_option := 'GROUP';
1013 end if;
1014 if (px_asset_fin_rec.member_rollup_flag is null) then
1015 px_asset_fin_rec.member_rollup_flag := 'N';
1016 end if;
1017 end if;
1018 end if;
1019
1020 end if;
1021 -- end group defaulting
1022
1023 return TRUE;
1024
1025 exception
1026 when init_err then
1027 fa_srvr_msg.add_message(
1028 calling_fn => 'fa_addition_pvt.initialize', p_log_level_rec => p_log_level_rec);
1029 x_return_status := FND_API.G_RET_STS_ERROR;
1030 return FALSE;
1031
1032 when others then
1033 fa_srvr_msg.add_sql_error(
1034 calling_fn => 'fa_addition_pvt.initialize', p_log_level_rec => p_log_level_rec);
1035 x_return_status := FND_API.G_RET_STS_ERROR;
1036 return FALSE;
1037
1038 end initialize;
1039
1040 function insert_asset (
1041 p_trans_rec IN OUT NOCOPY fa_api_types.trans_rec_type,
1042 p_dist_trans_rec IN fa_api_types.trans_rec_type,
1043 p_asset_hdr_rec IN fa_api_types.asset_hdr_rec_type,
1044 p_asset_desc_rec IN fa_api_types.asset_desc_rec_type,
1045 p_asset_type_rec IN fa_api_types.asset_type_rec_type,
1046 p_asset_cat_rec IN fa_api_types.asset_cat_rec_type,
1047 p_asset_hierarchy_rec IN fa_api_types.asset_hierarchy_rec_type,
1048 p_asset_fin_rec IN OUT NOCOPY fa_api_types.asset_fin_rec_type,
1049 p_asset_deprn_rec IN fa_api_types.asset_deprn_rec_type,
1050 px_asset_dist_tbl IN OUT NOCOPY fa_api_types.asset_dist_tbl_type,
1051 p_inv_trans_rec IN fa_api_types.inv_trans_rec_type,
1052 p_primary_cost IN NUMBER,
1053 p_exchange_rate IN NUMBER,
1054 x_return_status OUT NOCOPY VARCHAR2,
1055 p_mrc_sob_type_code IN VARCHAR2,
1056 p_period_rec IN fa_api_types.period_rec_type,
1057 p_calling_fn IN VARCHAR2
1058 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type) return boolean as
1059
1060 l_rowid ROWID;
1061 l_asset_id NUMBER(15);
1062 l_asset_number VARCHAR2(15);
1063
1064 l_transaction_header_id NUMBER(15);
1065 l_trans_in_header_id NUMBER(15);
1066 l_return_status BOOLEAN;
1067
1068 l_date_effective DATE;
1069
1070 l_distribution_id NUMBER(15);
1071 l_distribution_count NUMBER := 0;
1072
1073 l_deprn_run_date DATE;
1074 l_period_counter NUMBER(15);
1075 l_bonus_rate NUMBER;
1076
1077 -- For merging primary/mrc and amort nbv logic
1078 l_status BOOLEAN;
1079 l_deprn_exp NUMBER;
1080 l_bonus_deprn_exp NUMBER;
1081 l_impairment_exp NUMBER;
1082 l_ann_adj_deprn_exp NUMBER;
1083 l_ann_adj_bonus_deprn_exp NUMBER;
1084
1085 l_clearing NUMBER := 0;
1086 l_ds_rowid ROWID;
1087
1088 l_new_adjusted_cost NUMBER := p_asset_fin_rec.adjusted_cost;
1089 l_new_adjusted_capacity NUMBER := p_asset_fin_rec.adjusted_capacity;
1090 l_rate_adjustment_factor NUMBER := 1;
1091 l_reval_amortization_basis NUMBER
1092 := p_asset_fin_rec.reval_amortization_basis;
1093 l_formula_factor NUMBER := p_asset_fin_rec.formula_factor;
1094
1095 deprn_override_flag_default varchar2(1);
1096
1097 l_period_rec fa_api_types.period_rec_type;
1098 l_capitalized_flag VARCHAR2(1);
1099 l_fully_reserved_flag VARCHAR2(1);
1100 l_fully_retired_flag VARCHAR2(1);
1101 l_life_complete_flag VARCHAR2(1);
1102
1103 mrc_check_error EXCEPTION;
1104 general_error EXCEPTION;
1105
1106 l_asset_fin_rec_null FA_API_TYPES.asset_fin_rec_type;
1107
1108 --bug3548724
1109 l_asset_deprn_rec_adj fa_api_types.asset_deprn_rec_type;
1110
1111
1112 -- Bug:5930979:Japan Tax Reform Project
1113 l_method_type NUMBER := 0;
1114 l_success INTEGER;
1115 l_rate_in_use NUMBER;
1116 l_revised_count NUMBER := 0;
1117
1118 l_original_Rate NUMBER;
1119 l_Revised_Rate NUMBER;
1120 l_Guaranteed_Rate NUMBER;
1121 l_is_revised_rate NUMBER;
1122
1123 -- sla
1124 l_adj fa_adjust_type_pkg.fa_adj_row_struct;
1125
1126
1127 TYPE num_tbl IS TABLE OF number;
1128
1129 l_payables_cost_tbl num_tbl;
1130 l_payables_ccid_tbl num_tbl;
1131 l_source_line_id_tbl num_tbl;
1132 l_asset_invoice_id_tbl num_tbl;
1133
1134 --Secondary Changes
1135 l_secondary_trans_rec FA_API_TYPES.trans_rec_type;
1136 l_secondary_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
1137 l_secondary_sob_id number;
1138
1139 cursor c_invoices
1140 (p_asset_id number,
1141 p_invoice_transaction_id number) is
1142 select source_line_id,
1143 asset_invoice_id,
1144 payables_cost,
1145 nvl(payables_code_combination_id, 0)
1146 from fa_asset_invoices
1147 where asset_id = p_asset_id
1148 and invoice_transaction_id_in = p_invoice_transaction_id
1149 and nvl(payables_cost, 0) <> 0;
1150
1151
1152 cursor c_mc_invoices
1153 (p_asset_id number,
1154 p_invoice_transaction_id number) is
1155 select source_line_id,
1156 asset_invoice_id,
1157 payables_cost,
1158 nvl(payables_code_combination_id, 0)
1159 from fa_mc_asset_invoices
1160 where asset_id = p_asset_id
1161 and invoice_transaction_id_in = p_invoice_transaction_id
1162 and nvl(payables_cost, 0) <> 0
1163 and set_of_books_id = p_asset_hdr_rec.set_of_books_id;
1164
1165 /*Bug 16463079 */
1166 cursor c_mc_invoices_sec
1167 (p_asset_id number,
1168 p_invoice_transaction_id number) is
1169 select mai.source_line_id,
1170 mai.asset_invoice_id,
1171 mai.payables_cost,
1172 nvl(mai.payables_code_combination_id, 0)
1173 from fa_mc_asset_invoices mai,
1174 gl_ledgers gltr,
1175 fa_mc_book_controls mcbc,
1176 gl_ledgers glcr
1177 where mai.asset_id = p_asset_id
1178 and mai.invoice_transaction_id_in = p_invoice_transaction_id
1179 and nvl(mai.payables_cost, 0) <> 0
1180 and mai.set_of_books_id = glcr.ledger_id
1181 and gltr.ledger_id = p_asset_hdr_rec.set_of_books_id
1182 and gltr.currency_code = glcr.currency_code
1183 and gltr.chart_of_accounts_id = glcr.chart_of_accounts_id
1184 and gltr.ledger_id <> glcr.ledger_id
1185 and mcbc.book_type_code = fa_cache_pkg.fazcbc_record.distribution_source_book
1186 and glcr.ledger_id = mcbc.set_of_books_id;
1187 begin
1188
1189 l_period_counter := fa_cache_pkg.fazcbc_record.last_period_counter;
1190
1191 l_rowid := NULL;
1192 l_transaction_header_id := p_trans_rec.transaction_header_id;
1193 l_trans_in_header_id := p_dist_trans_rec.transaction_header_id;
1194 l_date_effective := p_trans_rec.who_info.last_update_date;
1195 l_deprn_run_date := p_trans_rec.who_info.last_update_date;
1196
1197 deprn_override_flag_default:= fa_std_types.FA_NO_OVERRIDE;
1198
1199 if (p_mrc_sob_type_code <> 'R') then
1200
1201 if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
1202
1203 -- Insert into fa_additions.
1204 l_rowid := NULL;
1205 l_asset_id := p_asset_hdr_rec.asset_id;
1206 l_asset_number := upper(p_asset_desc_rec.asset_number);
1207
1208 -- for bug no. 3643781. made the serial number case sensitive.
1209
1210 fa_additions_pkg.insert_row (
1211 X_Rowid => l_rowid,
1212 X_Asset_Id => l_asset_id,
1213 X_Asset_Number => l_asset_number,
1214 X_Asset_Key_Ccid => p_asset_desc_rec.asset_key_ccid,
1215 X_Current_Units => p_asset_desc_rec.current_units,
1216 X_Asset_Type => upper(p_asset_type_rec.asset_type),
1217 X_Tag_Number => upper(p_asset_desc_rec.tag_number),
1218 X_Description => p_asset_desc_rec.description,
1219 X_Asset_Category_Id => p_asset_cat_rec.category_id,
1220 X_Parent_Asset_Id => p_asset_desc_rec.parent_asset_id,
1221 X_Manufacturer_Name => p_asset_desc_rec.manufacturer_name,
1222 X_Serial_Number => p_asset_desc_rec.serial_number,
1223 X_Model_Number => p_asset_desc_rec.model_number,
1224 X_Property_Type_Code => upper(p_asset_desc_rec.property_type_code),
1225 X_Property_1245_1250_Code
1226 =>
1227 p_asset_desc_rec.property_1245_1250_code,
1228 X_In_Use_Flag => upper(p_asset_desc_rec.in_use_flag),
1229 X_Owned_Leased => upper(p_asset_desc_rec.owned_leased),
1230 X_New_Used => upper(p_asset_desc_rec.new_used),
1231 X_Unit_Adjustment_Flag => upper(p_asset_desc_rec.unit_adjustment_flag),
1232 X_Add_Cost_Je_Flag => upper(p_asset_desc_rec.add_cost_je_flag),
1233 X_attribute1 => p_asset_cat_rec.desc_flex.attribute1,
1234 X_attribute2 => p_asset_cat_rec.desc_flex.attribute2,
1235 X_attribute3 => p_asset_cat_rec.desc_flex.attribute3,
1236 X_attribute4 => p_asset_cat_rec.desc_flex.attribute4,
1237 X_attribute5 => p_asset_cat_rec.desc_flex.attribute5,
1238 X_attribute6 => p_asset_cat_rec.desc_flex.attribute6,
1239 X_attribute7 => p_asset_cat_rec.desc_flex.attribute7,
1240 X_attribute8 => p_asset_cat_rec.desc_flex.attribute8,
1241 X_attribute9 => p_asset_cat_rec.desc_flex.attribute9,
1242 X_attribute10 => p_asset_cat_rec.desc_flex.attribute10,
1243 X_attribute11 => p_asset_cat_rec.desc_flex.attribute11,
1244 X_attribute12 => p_asset_cat_rec.desc_flex.attribute12,
1245 X_attribute13 => p_asset_cat_rec.desc_flex.attribute13,
1246 X_attribute14 => p_asset_cat_rec.desc_flex.attribute14,
1247 X_attribute15 => p_asset_cat_rec.desc_flex.attribute15,
1248 X_attribute16 => p_asset_cat_rec.desc_flex.attribute16,
1249 X_attribute17 => p_asset_cat_rec.desc_flex.attribute17,
1250 X_attribute18 => p_asset_cat_rec.desc_flex.attribute18,
1251 X_attribute19 => p_asset_cat_rec.desc_flex.attribute19,
1252 X_attribute20 => p_asset_cat_rec.desc_flex.attribute20,
1253 X_attribute21 => p_asset_cat_rec.desc_flex.attribute21,
1254 X_attribute22 => p_asset_cat_rec.desc_flex.attribute22,
1255 X_attribute23 => p_asset_cat_rec.desc_flex.attribute23,
1256 X_attribute24 => p_asset_cat_rec.desc_flex.attribute24,
1257 X_attribute25 => p_asset_cat_rec.desc_flex.attribute25,
1258 X_attribute26 => p_asset_cat_rec.desc_flex.attribute26,
1259 X_attribute27 => p_asset_cat_rec.desc_flex.attribute27,
1260 X_attribute28 => p_asset_cat_rec.desc_flex.attribute28,
1261 X_attribute29 => p_asset_cat_rec.desc_flex.attribute29,
1262 X_attribute30 => p_asset_cat_rec.desc_flex.attribute30,
1263 X_attribute_Category_Code
1264 =>
1265 p_asset_cat_rec.desc_flex.attribute_category_code,
1266 X_gf_attribute1 =>
1267 p_asset_desc_rec.global_desc_flex.attribute1,
1268 X_gf_attribute2 =>
1269 p_asset_desc_rec.global_desc_flex.attribute2,
1270 X_gf_attribute3 =>
1271 p_asset_desc_rec.global_desc_flex.attribute3,
1272 X_gf_attribute4 =>
1273 p_asset_desc_rec.global_desc_flex.attribute4,
1274 X_gf_attribute5 =>
1275 p_asset_desc_rec.global_desc_flex.attribute5,
1276 X_gf_attribute6 =>
1277 p_asset_desc_rec.global_desc_flex.attribute6,
1278 X_gf_attribute7 =>
1279 p_asset_desc_rec.global_desc_flex.attribute7,
1280 X_gf_attribute8 =>
1281 p_asset_desc_rec.global_desc_flex.attribute8,
1282 X_gf_attribute9 =>
1283 p_asset_desc_rec.global_desc_flex.attribute9,
1284 X_gf_attribute10 =>
1285 p_asset_desc_rec.global_desc_flex.attribute10,
1286 X_gf_attribute11 =>
1287 p_asset_desc_rec.global_desc_flex.attribute11,
1288 X_gf_attribute12 =>
1289 p_asset_desc_rec.global_desc_flex.attribute12,
1290 X_gf_attribute13 =>
1291 p_asset_desc_rec.global_desc_flex.attribute13,
1292 X_gf_attribute14 =>
1293 p_asset_desc_rec.global_desc_flex.attribute14,
1294 X_gf_attribute15 =>
1295 p_asset_desc_rec.global_desc_flex.attribute15,
1296 X_gf_attribute16 =>
1297 p_asset_desc_rec.global_desc_flex.attribute16,
1298 X_gf_attribute17 =>
1299 p_asset_desc_rec.global_desc_flex.attribute17,
1300 X_gf_attribute18 =>
1301 p_asset_desc_rec.global_desc_flex.attribute18,
1302 X_gf_attribute19 =>
1303 p_asset_desc_rec.global_desc_flex.attribute19,
1304 X_gf_attribute20 =>
1305 p_asset_desc_rec.global_desc_flex.attribute20,
1306 X_gf_attribute_Category_Code
1307 =>
1308 p_asset_desc_rec.global_desc_flex.attribute_category_code,
1309 X_Context => p_asset_cat_rec.desc_flex.context,
1310 X_Lease_Id => p_asset_desc_rec.lease_id,
1311 X_Inventorial => upper(p_asset_desc_rec.inventorial),
1312 X_Commitment => p_asset_desc_rec.commitment,
1313 X_Investment_Law => p_asset_desc_rec.investment_law,
1314 X_Status => upper(p_asset_desc_rec.status),
1315 X_Last_Update_Date => p_trans_rec.who_info.last_update_date,
1316 X_Last_Updated_By => p_trans_rec.who_info.last_updated_by,
1317 X_Created_By => p_trans_rec.who_info.created_by,
1318 X_Creation_Date => p_trans_rec.who_info.creation_date,
1319 X_Last_Update_Login => p_trans_rec.who_info.last_update_login,
1320 X_Calling_Fn => 'fa_addition_pvt.insert_asset'
1321 , p_log_level_rec => p_log_level_rec);
1322
1323 -- Should only update the lease desc flex if modified.
1324 -- Probably need to change later to use table handler.
1325 if (p_asset_desc_rec.lease_id is not null) and
1326 (p_trans_rec.mass_reference_id is null) then -- Bug 7445419
1327
1328 UPDATE fa_leases
1329 SET
1330 last_update_date = p_trans_rec.who_info.last_update_date,
1331 last_updated_by = p_trans_rec.who_info.last_updated_by,
1332 last_update_login = p_trans_rec.who_info.last_update_login,
1333 attribute1 = p_asset_desc_rec.lease_desc_flex.attribute1,
1334 attribute2 = p_asset_desc_rec.lease_desc_flex.attribute2,
1335 attribute3 = p_asset_desc_rec.lease_desc_flex.attribute3,
1336 attribute4 = p_asset_desc_rec.lease_desc_flex.attribute4,
1337 attribute5 = p_asset_desc_rec.lease_desc_flex.attribute5,
1338 attribute6 = p_asset_desc_rec.lease_desc_flex.attribute6,
1339 attribute7 = p_asset_desc_rec.lease_desc_flex.attribute7,
1340 attribute8 = p_asset_desc_rec.lease_desc_flex.attribute8,
1341 attribute9 = p_asset_desc_rec.lease_desc_flex.attribute9,
1342 attribute10 = p_asset_desc_rec.lease_desc_flex.attribute10,
1343 attribute11 = p_asset_desc_rec.lease_desc_flex.attribute11,
1344 attribute12 = p_asset_desc_rec.lease_desc_flex.attribute12,
1345 attribute13 = p_asset_desc_rec.lease_desc_flex.attribute13,
1346 attribute14 = p_asset_desc_rec.lease_desc_flex.attribute14,
1347 attribute15 = p_asset_desc_rec.lease_desc_flex.attribute15,
1348 attribute_category_code
1349 =
1350 p_asset_desc_rec.lease_desc_flex.attribute_category_code
1351 WHERE lease_id = p_asset_desc_rec.lease_id;
1352 end if;
1353
1354 -- Add warranty if applicable.
1355 -- Should probably use table handler.
1356 if (p_asset_desc_rec.warranty_id is not null) then
1357 INSERT INTO fa_add_warranties (
1358 warranty_id,
1359 asset_id,
1360 date_effective,
1361 last_update_date,
1362 last_updated_by,
1363 created_by,
1364 creation_date,
1365 last_update_login
1366 ) VALUES (
1367 p_asset_desc_rec.warranty_id,
1368 p_asset_hdr_rec.asset_id,
1369 l_date_effective,
1370 p_trans_rec.who_info.last_update_date,
1371 p_trans_rec.who_info.last_updated_by,
1372 p_trans_rec.who_info.created_by,
1373 p_trans_rec.who_info.creation_date,
1374 p_trans_rec.who_info.last_update_login
1375 );
1376 end if;
1377 end if; -- end corporate
1378
1379 -- SLA UPTAKE
1380 -- assign an event for the transaction
1381 -- at this point key info asset/book/trx info is known from initialize
1382 -- call and the above code (i.e. trx_type, etc)
1383 if not FA_XLA_EVENTS_PVT.create_transaction_event
1384 (p_asset_hdr_rec => p_asset_hdr_rec,
1385 p_asset_type_rec => p_asset_type_rec,
1386 px_trans_rec => p_trans_rec,
1387 p_event_status => NULL,
1388 p_calling_fn => 'fa_addition_pvt.insert_asset',
1389 p_log_level_rec => p_log_level_rec) then
1390 raise general_error;
1391 end if;
1392 /*=================================================================
1393 Secondary Changes Start
1394 If primary and secondary sob_id is different then we need to
1395 create event for secondary ledger*/
1396 l_secondary_sob_id := FA_XLA_EVENTS_PVT.get_secondary_sob_id(p_asset_hdr_rec.book_type_code);
1397
1398 if(l_secondary_sob_id is not null)then
1399 l_secondary_trans_rec := p_trans_rec;
1400 l_secondary_asset_hdr_rec := p_asset_hdr_rec;
1401 l_secondary_asset_hdr_rec.set_of_books_id := l_secondary_sob_id;
1402 if not fa_xla_events_pvt.create_transaction_event
1403 (p_asset_hdr_rec => l_secondary_asset_hdr_rec,
1404 p_asset_type_rec=> p_asset_type_rec,
1405 px_trans_rec => l_secondary_trans_rec,
1406 p_event_status => NULL,
1407 p_calling_fn => 'fa_addition_pvt.insert_asset'
1408 ,p_log_level_rec => p_log_level_rec) then
1409 raise general_error;
1410 end if;
1411 end if;
1412 /*Secondary Changes End
1413 ==================================================================*/
1414 -- Insert into fa_transaction_headers.
1415 l_rowid := NULL;
1416
1417 fa_transaction_headers_pkg.insert_row (
1418 X_Rowid => l_rowid,
1419 X_Transaction_header_Id => l_transaction_header_id,
1420 X_Book_Type_Code => p_asset_hdr_rec.book_type_code,
1421 X_Asset_Id => p_asset_hdr_rec.asset_id,
1422 X_Transaction_Type_Code => p_trans_rec.transaction_type_code,
1423 X_Transaction_Date_Entered => p_trans_rec.transaction_date_entered,
1424 X_Date_Effective => l_date_effective,
1425 X_Last_Update_Date => p_trans_rec.who_info.last_update_date,
1426 X_Last_Updated_By => p_trans_rec.who_info.last_updated_by,
1427 X_Transaction_Name => p_trans_rec.transaction_name,
1428 X_Invoice_Transaction_Id => p_inv_trans_rec.invoice_transaction_id,
1429 X_Source_Transaction_Header_Id
1430 => p_trans_rec.source_transaction_header_id,
1431 X_Mass_Reference_Id => p_trans_rec.mass_reference_id,
1432 X_Last_Update_Login => p_trans_rec.who_info.last_update_login,
1433 X_Transaction_Subtype => p_trans_rec.transaction_subtype,
1434 X_attribute1 => p_trans_rec.desc_flex.attribute1,
1435 X_attribute2 => p_trans_rec.desc_flex.attribute2,
1436 X_attribute3 => p_trans_rec.desc_flex.attribute3,
1437 X_attribute4 => p_trans_rec.desc_flex.attribute4,
1438 X_attribute5 => p_trans_rec.desc_flex.attribute5,
1439 X_attribute6 => p_trans_rec.desc_flex.attribute6,
1440 X_attribute7 => p_trans_rec.desc_flex.attribute7,
1441 X_attribute8 => p_trans_rec.desc_flex.attribute8,
1442 X_attribute9 => p_trans_rec.desc_flex.attribute9,
1443 X_attribute10 => p_trans_rec.desc_flex.attribute10,
1444 X_attribute11 => p_trans_rec.desc_flex.attribute11,
1445 X_attribute12 => p_trans_rec.desc_flex.attribute12,
1446 X_attribute13 => p_trans_rec.desc_flex.attribute13,
1447 X_attribute14 => p_trans_rec.desc_flex.attribute14,
1448 X_attribute15 => p_trans_rec.desc_flex.attribute15,
1449 X_attribute_Category_Code =>
1450 p_trans_rec.desc_flex.attribute_category_code,
1451 X_Transaction_Key => p_trans_rec.transaction_key,
1452 X_Amortization_Start_Date => p_trans_rec.amortization_start_date,
1453 X_Calling_Interface => p_trans_rec.calling_interface,
1454 X_Mass_Transaction_ID => p_trans_rec.mass_transaction_id,
1455 X_Trx_Reference_Id => p_trans_rec.trx_reference_id,
1456 X_Event_Id => p_trans_rec.event_id,
1457 X_Return_Status => l_return_status,
1458 X_Calling_Fn => 'fa_addition_pvt.insert_asset'
1459 , p_log_level_rec => p_log_level_rec);
1460
1461 if not (l_return_status) then
1462 raise general_error;
1463 end if;
1464
1465 l_rowid := NULL;
1466
1467 if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
1468
1469 fa_transaction_headers_pkg.insert_row (
1470 X_Rowid => l_rowid,
1471 X_Transaction_Header_Id => l_trans_in_header_id,
1472 X_Book_Type_Code => p_asset_hdr_rec.book_type_code,
1473 X_Asset_Id => p_asset_hdr_rec.asset_id,
1474 X_Transaction_Type_Code => p_dist_trans_rec.transaction_type_code,
1475 X_Transaction_Date_Entered
1476 => p_dist_trans_rec.transaction_date_entered,
1477 X_Date_Effective => l_date_effective,
1478 X_Last_Update_Date =>
1479 p_dist_trans_rec.who_info.last_update_date,
1480 X_Last_Updated_By => p_dist_trans_rec.who_info.last_updated_by,
1481 X_Transaction_Name => p_dist_trans_rec.transaction_name,
1482 X_Invoice_Transaction_Id
1483 => p_inv_trans_rec.invoice_transaction_id,
1484 X_Source_Transaction_Header_Id
1485 =>
1486 p_dist_trans_rec.source_transaction_header_id,
1487 X_Mass_Reference_Id => p_dist_trans_rec.mass_reference_id,
1488 X_Last_Update_Login =>
1489 p_dist_trans_rec.who_info.last_update_login,
1490 X_Transaction_Subtype => p_dist_trans_rec.transaction_subtype,
1491 X_attribute1 => p_dist_trans_rec.desc_flex.attribute1,
1492 X_attribute2 => p_dist_trans_rec.desc_flex.attribute2,
1493 X_attribute3 => p_dist_trans_rec.desc_flex.attribute3,
1494 X_attribute4 => p_dist_trans_rec.desc_flex.attribute4,
1495 X_attribute5 => p_dist_trans_rec.desc_flex.attribute5,
1496 X_attribute6 => p_dist_trans_rec.desc_flex.attribute6,
1497 X_attribute7 => p_dist_trans_rec.desc_flex.attribute7,
1498 X_attribute8 => p_dist_trans_rec.desc_flex.attribute8,
1499 X_attribute9 => p_dist_trans_rec.desc_flex.attribute9,
1500 X_attribute10 => p_dist_trans_rec.desc_flex.attribute10,
1501 X_attribute11 => p_dist_trans_rec.desc_flex.attribute11,
1502 X_attribute12 => p_dist_trans_rec.desc_flex.attribute12,
1503 X_attribute13 => p_dist_trans_rec.desc_flex.attribute13,
1504 X_attribute14 => p_dist_trans_rec.desc_flex.attribute14,
1505 X_attribute15 => p_dist_trans_rec.desc_flex.attribute15,
1506 X_attribute_Category_Code
1507 =>
1508 p_dist_trans_rec.desc_flex.attribute_category_code,
1509 X_Transaction_Key => p_dist_trans_rec.transaction_key,
1510 X_Amortization_Start_Date
1511 => p_dist_trans_rec.amortization_start_date,
1512 X_Calling_Interface => p_dist_trans_rec.calling_interface,
1513 X_Mass_Transaction_ID => p_trans_rec.mass_transaction_id,
1514 X_Trx_Reference_Id => p_trans_rec.trx_reference_id,
1515 X_Event_Id => p_dist_trans_rec.event_id, --9413081
1516 X_Return_Status => l_return_status,
1517 X_Calling_Fn => 'fa_addition_pvt.insert_asset'
1518 , p_log_level_rec => p_log_level_rec);
1519
1520 if not (l_return_status) then
1521 raise general_error;
1522 end if;
1523 end if; -- end corporate
1524 end if; -- end primary book
1525
1526 -- Insert into fa_books.
1527 l_rowid := NULL;
1528 ---Added by Satish Byreddy In order to cater the Japan tax Reforms Migration Requirements
1529
1530 IF p_asset_fin_rec.period_counter_life_complete IS NULL AND p_asset_fin_rec.period_counter_fully_reserved IS NOT NULL THEN
1531 p_asset_fin_rec.period_counter_life_complete := p_asset_fin_rec.period_counter_fully_reserved;
1532 END IF;
1533
1534 -- End OF Additions
1535
1536 fa_books_pkg.insert_row (
1537 X_Rowid => l_rowid,
1538 X_Book_Type_Code => p_asset_hdr_rec.book_type_code,
1539 X_Asset_Id => p_asset_hdr_rec.asset_id,
1540 X_Date_Placed_In_Service => p_asset_fin_rec.date_placed_in_service,
1541 X_Date_Effective => l_date_effective,
1542 X_Deprn_Start_Date => p_asset_fin_rec.deprn_start_date,
1543 X_Deprn_Method_Code => p_asset_fin_rec.deprn_method_code,
1544 X_Life_In_Months => p_asset_fin_rec.life_in_months,
1545 X_Rate_Adjustment_Factor => p_asset_fin_rec.rate_adjustment_factor,
1546 X_Adjusted_Cost => p_asset_fin_rec.adjusted_cost,
1547 X_Cost => p_asset_fin_rec.cost,
1548 X_Original_Cost => p_asset_fin_rec.original_cost,
1549 X_Salvage_Value => p_asset_fin_rec.salvage_value,
1550 X_Prorate_Convention_Code => p_asset_fin_rec.prorate_convention_code,
1551 X_Prorate_Date => p_asset_fin_rec.prorate_date,
1552 X_Cost_Change_Flag => p_asset_fin_rec.cost_change_flag,
1553 X_Adjustment_Required_Status => p_asset_fin_rec.adjustment_required_status,
1554 X_Capitalize_Flag => p_asset_fin_rec.capitalize_flag,
1555 X_Retirement_Pending_Flag => p_asset_fin_rec.retirement_pending_flag,
1556 X_Depreciate_Flag => p_asset_fin_rec.depreciate_flag,
1557 X_Disabled_Flag => p_asset_fin_rec.disabled_flag,--HH
1558 X_Last_Update_Date => p_trans_rec.who_info.last_update_date,
1559 X_Last_Updated_By => p_trans_rec.who_info.last_updated_by,
1560 X_Date_Ineffective => NULL,
1561 X_Transaction_Header_Id_In => p_trans_rec.transaction_header_id,
1562 X_Transaction_Header_Id_Out => NULL,
1563 X_Itc_Amount_Id => p_asset_fin_rec.itc_amount_id,
1564 X_Itc_Amount => p_asset_fin_rec.itc_amount,
1565 X_Retirement_Id => p_asset_fin_rec.retirement_id,
1566 X_Tax_Request_Id => p_asset_fin_rec.tax_request_id,
1567 X_Itc_Basis => p_asset_fin_rec.itc_basis,
1568 X_Basic_Rate => p_asset_fin_rec.basic_rate,
1569 X_Adjusted_Rate => p_asset_fin_rec.adjusted_rate,
1570 X_Bonus_Rule => p_asset_fin_rec.bonus_rule,
1571 X_Ceiling_Name => p_asset_fin_rec.ceiling_name,
1572 X_Recoverable_Cost => p_asset_fin_rec.recoverable_cost,
1573 X_Last_Update_Login => p_trans_rec.who_info.last_update_login,
1574 X_Adjusted_Capacity => p_asset_fin_rec.adjusted_capacity,
1575 X_Fully_Rsvd_Revals_Counter => p_asset_fin_rec.period_counter_capitalized,
1576 X_PC_Fully_Reserved => p_asset_fin_rec.period_counter_fully_reserved,
1577 X_Period_Counter_Fully_Retired => p_asset_fin_rec.period_counter_fully_retired,
1578 X_Production_Capacity => p_asset_fin_rec.production_capacity,
1579 X_Reval_Amortization_Basis => p_asset_fin_rec.reval_amortization_basis,
1580 X_Reval_Ceiling => p_asset_fin_rec.reval_ceiling,
1581 X_Unit_Of_Measure => p_asset_fin_rec.unit_of_measure,
1582 X_Unrevalued_Cost => p_asset_fin_rec.unrevalued_cost,
1583 X_Annual_Deprn_Rounding_Flag => p_asset_fin_rec.annual_deprn_rounding_flag,
1584 X_Percent_Salvage_Value => p_asset_fin_rec.percent_salvage_value,
1585 X_Allowed_Deprn_Limit => p_asset_fin_rec.allowed_deprn_limit,
1586 X_Allowed_Deprn_Limit_Amount => p_asset_fin_rec.allowed_deprn_limit_amount,
1587 X_Period_Counter_Life_Complete => p_asset_fin_rec.period_counter_life_complete,
1588 X_Adjusted_Recoverable_Cost => p_asset_fin_rec.adjusted_recoverable_cost,
1589 X_Short_Fiscal_Year_Flag => p_asset_fin_rec.short_fiscal_year_flag,
1590 X_Conversion_Date => p_asset_fin_rec.conversion_date,
1591 X_Orig_Deprn_Start_Date => p_asset_fin_rec.orig_deprn_start_date,
1592 X_Remaining_Life1 => p_asset_fin_rec.remaining_life1,
1593 X_Remaining_Life2 => p_asset_fin_rec.remaining_life2,
1594 X_Old_Adj_Cost => p_asset_fin_rec.old_adjusted_cost,
1595 X_Formula_Factor => p_asset_fin_rec.formula_factor,
1596 X_gf_attribute1 => p_asset_fin_rec.global_attribute1,
1597 X_gf_attribute2 => p_asset_fin_rec.global_attribute2,
1598 X_gf_attribute3 => p_asset_fin_rec.global_attribute3,
1599 X_gf_attribute4 => p_asset_fin_rec.global_attribute4,
1600 X_gf_attribute5 => p_asset_fin_rec.global_attribute5,
1601 X_gf_attribute6 => p_asset_fin_rec.global_attribute6,
1602 X_gf_attribute7 => p_asset_fin_rec.global_attribute7,
1603 X_gf_attribute8 => p_asset_fin_rec.global_attribute8,
1604 X_gf_attribute9 => p_asset_fin_rec.global_attribute9,
1605 X_gf_attribute10 => p_asset_fin_rec.global_attribute10,
1606 X_gf_attribute11 => p_asset_fin_rec.global_attribute11,
1607 X_gf_attribute12 => p_asset_fin_rec.global_attribute12,
1608 X_gf_attribute13 => p_asset_fin_rec.global_attribute13,
1609 X_gf_attribute14 => p_asset_fin_rec.global_attribute14,
1610 X_gf_attribute15 => p_asset_fin_rec.global_attribute15,
1611 X_gf_attribute16 => p_asset_fin_rec.global_attribute16,
1612 X_gf_attribute17 => p_asset_fin_rec.global_attribute17,
1613 X_gf_attribute18 => p_asset_fin_rec.global_attribute18,
1614 X_gf_attribute19 => p_asset_fin_rec.global_attribute19,
1615 X_gf_attribute20 => p_asset_fin_rec.global_attribute20,
1616 X_global_attribute_category => p_asset_fin_rec.global_attribute_category,
1617 X_group_asset_id => p_asset_fin_rec.group_asset_id,
1618 X_salvage_type => p_asset_fin_rec.salvage_type,
1619 X_deprn_limit_type => p_asset_fin_rec.deprn_limit_type,
1620 X_over_depreciate_option => p_asset_fin_rec.over_depreciate_option,
1621 X_super_group_id => p_asset_fin_rec.super_group_id,
1622 X_reduction_rate => p_asset_fin_rec.reduction_rate,
1623 X_reduce_addition_flag => p_asset_fin_rec.reduce_addition_flag,
1624 X_reduce_adjustment_flag => p_asset_fin_rec.reduce_adjustment_flag,
1625 X_reduce_retirement_flag => p_asset_fin_rec.reduce_retirement_flag,
1626 X_recognize_gain_loss => p_asset_fin_rec.recognize_gain_loss,
1627 X_recapture_reserve_flag => p_asset_fin_rec.recapture_reserve_flag,
1628 X_limit_proceeds_flag => p_asset_fin_rec.limit_proceeds_flag,
1629 X_terminal_gain_loss => p_asset_fin_rec.terminal_gain_loss,
1630 X_exclude_proceeds_from_basis => p_asset_fin_rec.exclude_proceeds_from_basis,
1631 X_retirement_deprn_option => p_asset_fin_rec.retirement_deprn_option,
1632 X_tracking_method => p_asset_fin_rec.tracking_method,
1633 X_allocate_to_fully_rsv_flag => p_asset_fin_rec.allocate_to_fully_rsv_flag,
1634 X_allocate_to_fully_ret_flag => p_asset_fin_rec.allocate_to_fully_ret_flag,
1635 X_exclude_fully_rsv_flag => p_asset_fin_rec.exclude_fully_rsv_flag,
1636 X_excess_allocation_option => p_asset_fin_rec.excess_allocation_option,
1637 X_depreciation_option => p_asset_fin_rec.depreciation_option,
1638 X_member_rollup_flag => p_asset_fin_rec.member_rollup_flag,
1639 X_ytd_proceeds => p_asset_fin_rec.ytd_proceeds,
1640 X_ltd_proceeds => p_asset_fin_rec.ltd_proceeds,
1641 X_eofy_reserve => p_asset_fin_rec.eofy_reserve,
1642 X_terminal_gain_loss_amount => p_asset_fin_rec.terminal_gain_loss_amount,
1643 X_ltd_cost_of_removal => p_asset_fin_rec.ltd_cost_of_removal,
1644 X_cip_cost => p_asset_fin_rec.cip_cost,
1645 X_contract_id => p_asset_fin_rec.contract_id, -- Bug:8240522
1646 X_cash_generating_unit_id => p_asset_fin_rec.cash_generating_unit_id,
1647 X_mrc_sob_type_code => p_mrc_sob_type_code,
1648 X_set_of_books_id => p_asset_hdr_rec.set_of_books_id,
1649 X_Return_Status => l_return_status,
1650 X_Calling_Fn => 'fa_addition_pvt.insert_asset' ,
1651 X_nbv_at_switch => p_asset_fin_rec.nbv_at_switch , -- Changes made as per the ER No.s 6606548 and 6606552 by Sbyreddy Start
1652 X_prior_deprn_limit_type => p_asset_fin_rec.prior_deprn_limit_type ,
1653 X_prior_deprn_limit_amount => p_asset_fin_rec.prior_deprn_limit_amount,
1654 X_prior_deprn_limit => p_asset_fin_rec.prior_deprn_limit ,
1655 X_period_counter_fully_rsrved => p_asset_fin_rec.period_counter_fully_reserved ,
1656 X_extended_depreciation_period => p_asset_fin_rec.extended_depreciation_period ,
1657 X_prior_deprn_method => p_asset_fin_rec.prior_deprn_method ,
1658 X_prior_life_in_months => p_asset_fin_rec.prior_life_in_months ,
1659 X_prior_basic_rate => p_asset_fin_rec.prior_basic_rate ,
1660 X_prior_adjusted_rate => p_asset_fin_rec.prior_adjusted_rate ,
1661 X_extended_deprn_flag => p_asset_fin_rec.extended_deprn_flag
1662 -- Changes made as per the ER No.s 6606548 and 6606552 by Sbyreddy End
1663 , p_log_level_rec => p_log_level_rec);
1664
1665 if not (l_return_status) then
1666 raise general_error;
1667 end if;
1668
1669 if ( p_mrc_sob_type_code <> 'R') then
1670 if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
1671
1672 -- Insert into fa_asset_history.
1673 l_rowid := NULL;
1674
1675 fa_asset_history_pkg.insert_row (
1676 X_Rowid => l_rowid,
1677 X_Asset_Id => p_asset_hdr_rec.asset_id,
1678 X_Category_Id => p_asset_cat_rec.category_id,
1679 X_Asset_Type => upper(p_asset_type_rec.asset_type),
1680 X_Units => p_asset_desc_rec.current_units,
1681 X_Date_Effective => l_date_effective,
1682 X_Transaction_Header_Id_In
1683 => p_trans_rec.transaction_header_id,
1684 X_Transaction_Header_Id_Out
1685 => NULL,
1686 X_Last_Update_Date => p_trans_rec.who_info.last_update_date,
1687 X_Last_Updated_By => p_trans_rec.who_info.last_updated_by,
1688 X_Last_Update_Login => p_trans_rec.who_info.last_update_login,
1689 X_Return_Status => l_return_status,
1690 X_Calling_Fn => 'fa_addition_pvt.insert_asset'
1691 , p_log_level_rec => p_log_level_rec);
1692
1693 if not (l_return_status) then
1694 raise general_error;
1695 end if;
1696
1697 -- Insert into fa_distributions.
1698 l_distribution_count := px_asset_dist_tbl.COUNT;
1699
1700 for i in 1..l_distribution_count loop
1701 l_rowid := NULL;
1702 l_distribution_id := NULL;
1703
1704 fa_distribution_history_pkg.insert_row (
1705 X_Rowid => l_rowid,
1706 X_Distribution_Id => l_distribution_id,
1707 X_Book_Type_Code => p_asset_hdr_rec.book_type_code,
1708 X_Asset_Id => p_asset_hdr_rec.asset_id,
1709 X_Units_Assigned => px_asset_dist_tbl(i).units_assigned,
1710 X_Date_Effective => l_date_effective,
1711 X_Code_Combination_Id => px_asset_dist_tbl(i).expense_ccid,
1712 X_Location_Id => px_asset_dist_tbl(i).location_ccid,
1713 X_Transaction_Header_Id_In
1714 => p_dist_trans_rec.transaction_header_id,
1715 X_Last_Update_Date =>
1716 p_dist_trans_rec.who_info.last_update_date,
1717 X_Last_Updated_By =>
1718 p_dist_trans_rec.who_info.last_updated_by,
1719 X_Date_Ineffective => NULL,
1720 X_Assigned_To => px_asset_dist_tbl(i).assigned_to,
1721 X_Transaction_Header_Id_Out
1722 => NULL,
1723 X_Transaction_Units => NULL,
1724 X_Retirement_Id => p_asset_fin_rec.retirement_id,
1725 X_Last_Update_Login =>
1726 p_dist_trans_rec.who_info.last_update_login,
1727 X_Calling_Fn => 'fa_addition_pvt.insert_asset'
1728 , p_log_level_rec => p_log_level_rec);
1729
1730 px_asset_dist_tbl(i).distribution_id := l_distribution_id;
1731
1732 end loop;
1733 end if; -- end corporate
1734 end if; -- end primary book
1735
1736 l_ds_rowid := NULL;
1737
1738 -- Insert into fa_deprn_summary
1739 fa_deprn_summary_pkg.insert_row (
1740 X_Rowid => l_ds_rowid,
1741 X_Book_Type_Code => p_asset_hdr_rec.book_type_code,
1742 X_Asset_Id => p_asset_hdr_rec.asset_id,
1743 X_Deprn_Run_Date => l_deprn_run_date,
1744 X_Deprn_Amount => nvl(p_asset_deprn_rec.deprn_amount,0),
1745 X_Ytd_Deprn => nvl(p_asset_deprn_rec.ytd_deprn,0),
1746 X_Deprn_Reserve => nvl(p_asset_deprn_rec.deprn_reserve,0),
1747 X_Deprn_Source_Code => 'BOOKS',
1748 X_Adjusted_Cost => nvl(p_asset_fin_rec.adjusted_cost,0),
1749 X_Bonus_Rate => l_bonus_rate,
1750 X_Ltd_Production => p_asset_deprn_rec.ltd_production,
1751 X_Period_Counter => l_period_counter,
1752 X_Production => p_asset_deprn_rec.production,
1753 X_Reval_Amortization => p_asset_deprn_rec.reval_amortization,
1754 X_Reval_Amortization_Basis
1755 => p_asset_deprn_rec.reval_amortization_basis,
1756 X_Reval_Deprn_Expense => p_asset_deprn_rec.reval_deprn_expense,
1757 X_Reval_Reserve => p_asset_deprn_rec.reval_deprn_reserve,
1758 X_Reval_loss_balance => p_asset_deprn_rec.reval_loss_balance,
1759 X_Ytd_Production => p_asset_deprn_rec.ytd_production,
1760 X_Ytd_Reval_Deprn_Expense
1761 => p_asset_deprn_rec.reval_ytd_deprn,
1762 X_Bonus_Deprn_Amount => p_asset_deprn_rec.bonus_deprn_amount,
1763 X_Bonus_Ytd_Deprn => p_asset_deprn_rec.bonus_ytd_deprn,
1764 X_Bonus_Deprn_Reserve => p_asset_deprn_rec.bonus_deprn_reserve,
1765 X_Impairment_Amount => p_asset_deprn_rec.impairment_amount,
1766 X_Ytd_Impairment => p_asset_deprn_rec.ytd_impairment,
1767 X_impairment_reserve => p_asset_deprn_rec.impairment_reserve,
1768 X_mrc_sob_type_code => p_mrc_sob_type_code,
1769 X_set_of_books_id => p_asset_hdr_rec.set_of_books_id,
1770 X_Calling_Fn => 'fa_addition_pvt.insert_asset'
1771 , p_log_level_rec => p_log_level_rec);
1772
1773 -- Insert into fa_deprn_detail
1774 -- br: changed to use faxindd which automatically handles multi-dist
1775 l_status := FA_INS_DETAIL_PKG.FAXINDD (
1776 X_book_type_code => p_asset_hdr_rec.book_type_code,
1777 X_asset_id => p_asset_hdr_rec.asset_id,
1778 X_mrc_sob_type_code => p_mrc_sob_type_code,
1779 X_set_of_books_id => p_asset_hdr_rec.set_of_books_id
1780 , p_log_level_rec => p_log_level_rec);
1781
1782 if not (l_status) then
1783 raise general_error;
1784 end if;
1785
1786
1787 -- BUG# 2115343 need to reset the cache to the active book after faxindd
1788
1789 l_status := fa_cache_pkg.fazcbc (
1790 X_book => p_asset_hdr_rec.book_type_code
1791 , p_log_level_rec => p_log_level_rec);
1792
1793 if not (l_status) then
1794 raise general_error;
1795 end if;
1796
1797 -- Insert into fa_books_summary if polish rule
1798 if not fa_cache_pkg.fazccmt
1799 (X_method => p_asset_fin_rec.deprn_method_code,
1800 X_life => p_asset_fin_rec.life_in_months, p_log_level_rec => p_log_level_rec) then
1801 raise general_error;
1802 end if;
1803
1804 if (p_asset_type_rec.asset_type <> 'GROUP') then
1805 l_rowid := NULL;
1806
1807 if (NOT FA_UTIL_PVT.get_period_rec (
1808 p_book => p_asset_hdr_rec.book_type_code,
1809 p_effective_date => NULL,
1810 x_period_rec => l_period_rec
1811 , p_log_level_rec => p_log_level_rec)) then
1812 raise general_error;
1813 end if;
1814
1815 if (p_asset_fin_rec.period_counter_capitalized is null) then
1816 l_capitalized_flag := 'N';
1817 else
1818 l_capitalized_flag := 'Y';
1819 end if;
1820
1821 if (p_asset_fin_rec.period_counter_fully_reserved is null) then
1822 l_fully_reserved_flag := 'N';
1823 else
1824 l_fully_reserved_flag := 'Y';
1825 end if;
1826
1827 if (p_asset_fin_rec.period_counter_fully_retired is null) then
1828 l_fully_retired_flag := 'N';
1829 else
1830 l_fully_retired_flag := 'Y';
1831 end if;
1832
1833 if (p_asset_fin_rec.period_counter_life_complete is null) then
1834 l_life_complete_flag := 'N';
1835 else
1836 l_life_complete_flag := 'Y';
1837 end if;
1838
1839 -- Insert into current period DEPRN row
1840 fa_books_summary_pkg.insert_row (
1841 X_Rowid => l_rowid,
1842 X_Book_Type_Code => p_asset_hdr_rec.book_type_code,
1843 X_Asset_Id => p_asset_hdr_rec.asset_id,
1844 X_Period_Counter => l_period_counter + 1,
1845 X_Calendar_Period_Open_Date =>
1846 l_period_rec.calendar_period_open_date,
1847 X_Calendar_Period_Close_Date =>
1848 l_period_rec.calendar_period_close_date,
1849 X_Reset_Adjusted_Cost_Flag => 'Y',
1850 X_Change_In_Cost => 0,
1851 X_Change_In_Additions_Cost => 0,
1852 X_Change_In_Adjustments_Cost => 0,
1853 X_Change_In_Retirements_Cost => 0,
1854 X_Change_In_Group_Rec_Cost => 0,
1855 X_Change_In_CIP_Cost => 0,
1856 X_Cost => p_asset_fin_rec.cost,
1857 X_CIP_Cost => p_asset_fin_rec.cip_cost,
1858 X_Salvage_Type => p_asset_fin_rec.salvage_type,
1859 X_Percent_Salvage_Value => p_asset_fin_rec.percent_salvage_value,
1860 X_Salvage_Value => p_asset_fin_rec.salvage_value,
1861 X_Member_Salvage_Value => 0,
1862 X_Recoverable_Cost => p_asset_fin_rec.recoverable_cost,
1863 X_Deprn_Limit_Type => p_asset_fin_rec.deprn_limit_type,
1864 X_Allowed_Deprn_Limit => p_asset_fin_rec.allowed_deprn_limit,
1865 X_Allowed_Deprn_Limit_Amount =>
1866 p_asset_fin_rec.allowed_deprn_limit_amount,
1867 X_Member_Deprn_Limit_Amount => 0,
1868 X_Adjusted_Recoverable_Cost =>
1869 p_asset_fin_rec.adjusted_recoverable_cost,
1870 X_Adjusted_Cost => p_asset_fin_rec.adjusted_cost,
1871 X_Depreciate_Flag => p_asset_fin_rec.depreciate_flag,
1872 X_Disabled_Flag => p_asset_fin_rec.disabled_flag,
1873 X_Date_Placed_In_Service => p_asset_fin_rec.date_placed_in_service,
1874 X_Deprn_Method_Code => p_asset_fin_rec.deprn_method_code,
1875 X_Life_In_Months => p_asset_fin_rec.life_in_months,
1876 X_Rate_Adjustment_Factor => p_asset_fin_rec.rate_adjustment_factor,
1877 X_Adjusted_Rate => p_asset_fin_rec.adjusted_rate,
1878 X_Bonus_Rule => p_asset_fin_rec.bonus_rule,
1879 X_Adjusted_Capacity => p_asset_fin_rec.adjusted_capacity,
1880 X_Production_Capacity => p_asset_fin_rec.production_capacity,
1881 X_Unit_Of_Measure => p_asset_fin_rec.unit_of_measure,
1882 X_Remaining_Life1 => p_asset_fin_rec.remaining_life1,
1883 X_Remaining_Life2 => p_asset_fin_rec.remaining_life2,
1884 X_Formula_Factor => p_asset_fin_rec.formula_factor,
1885 X_Unrevalued_Cost => p_asset_fin_rec.unrevalued_cost,
1886 X_Reval_Amortization_Basis =>
1887 p_asset_fin_rec.reval_amortization_basis,
1888 X_Reval_Ceiling => p_asset_fin_rec.reval_ceiling,
1889 X_Ceiling_Name => p_asset_fin_rec.ceiling_name,
1890 X_Eofy_Adj_Cost => nvl(p_asset_fin_rec.eofy_adj_cost, 0),
1891 X_Eofy_Formula_Factor =>
1892 nvl(p_asset_fin_rec.eofy_formula_factor, 1),
1893 X_Eofy_Reserve => nvl(p_asset_fin_rec.eofy_reserve, 0),
1894 X_Eop_Adj_Cost => nvl(p_asset_fin_rec.eop_adj_cost, 0),
1895 X_Eop_Formula_Factor =>
1896 nvl(p_asset_fin_rec.eop_formula_factor, 1),
1897 X_Short_Fiscal_Year_Flag => p_asset_fin_rec.short_fiscal_year_flag,
1898 X_Group_Asset_ID => p_asset_fin_rec.group_asset_id,
1899 X_Super_Group_ID => p_asset_fin_rec.super_group_id,
1900 X_Over_Depreciate_Option => p_asset_fin_rec.over_depreciate_option,
1901 X_Fully_Rsvd_Revals_Counter =>
1902 p_asset_fin_rec.period_counter_capitalized,
1903 X_Capitalized_Flag => l_capitalized_flag,
1904 X_Fully_Reserved_Flag => l_fully_reserved_flag,
1905 X_Fully_Retired_Flag => l_fully_retired_flag,
1906 X_Life_Complete_Flag => l_life_complete_flag,
1907 X_Terminal_Gain_Loss_Amount =>
1908 nvl(p_asset_fin_rec.terminal_gain_loss_amount, 0),
1909 X_Terminal_Gain_Loss_Flag =>
1910 nvl(p_asset_fin_rec.terminal_gain_loss_flag, 'N'),
1911 X_Deprn_Amount => nvl(p_asset_deprn_rec.deprn_amount,0),
1912 X_Ytd_Deprn => nvl(p_asset_deprn_rec.ytd_deprn,0),
1913 X_Deprn_Reserve => nvl(p_asset_deprn_rec.deprn_reserve,0),
1914 X_Bonus_Deprn_Amount => p_asset_deprn_rec.bonus_deprn_amount,
1915 X_Bonus_Ytd_Deprn => p_asset_deprn_rec.bonus_ytd_deprn,
1916 X_Bonus_Deprn_Reserve => p_asset_deprn_rec.bonus_deprn_reserve,
1917 X_Bonus_Rate => l_bonus_rate,
1918 X_Impairment_Amount => p_asset_deprn_rec.impairment_amount,
1919 X_Ytd_Impairment => p_asset_deprn_rec.ytd_impairment,
1920 X_impairment_reserve => p_asset_deprn_rec.impairment_reserve,
1921 X_Ltd_Production => p_asset_deprn_rec.ltd_production,
1922 X_Ytd_Production => p_asset_deprn_rec.ytd_production,
1923 X_Production => p_asset_deprn_rec.production,
1924 X_Reval_Amortization => p_asset_deprn_rec.reval_amortization,
1925 X_Reval_Deprn_Expense => p_asset_deprn_rec.reval_deprn_expense,
1926 X_Reval_Reserve => p_asset_deprn_rec.reval_deprn_reserve,
1927 X_Ytd_Reval_Deprn_Expense => p_asset_deprn_rec.reval_ytd_deprn,
1928 X_Deprn_Override_Flag => deprn_override_flag_default,
1929 X_System_Deprn_Amount => 0,
1930 X_System_Bonus_Deprn_Amount => 0,
1931 X_Ytd_Proceeds_Of_Sale => p_asset_fin_rec.ytd_proceeds,
1932 X_Ltd_Proceeds_Of_Sale => p_asset_fin_rec.ltd_proceeds,
1933 X_Ytd_Cost_Of_Removal => 0,
1934 X_Ltd_Cost_Of_Removal =>
1935 nvl(p_asset_fin_rec.ltd_cost_of_removal, 0),
1936 X_Deprn_Adjustment_Amount => 0,
1937 X_Expense_Adjustment_Amount => 0,
1938 X_Unplanned_Amount => 0,
1939 X_Reserve_Adjustment_Amount => 0,
1940 X_Last_Update_Date => p_trans_rec.who_info.last_update_date,
1941 X_Last_Updated_By => p_trans_rec.who_info.last_updated_by,
1942 X_Created_By => p_trans_rec.who_info.created_by,
1943 X_Creation_Date => p_trans_rec.who_info.creation_date,
1944 X_Last_Update_Login => p_trans_rec.who_info.last_update_login,
1945 X_Change_In_Eofy_Reserve => 0,
1946 X_Switch_Code => NULL, -- derived at depreciation
1947 X_mrc_sob_type_code => p_mrc_sob_type_code,
1948 X_set_of_books_id => p_asset_hdr_rec.set_of_books_id,
1949 X_Return_Status => l_return_status,
1950 X_Calling_Fn => 'fa_addition_pvt.insert_asset', p_log_level_rec => p_log_level_rec);
1951
1952 if not (l_return_status) then
1953 raise general_error;
1954 end if;
1955 end if;
1956
1957 -- br: moved this from the main code so that primary and reporting
1958 -- books are processed
1959
1960 -- br: moved this from the main code so that primary and reporting
1961 -- books are processed
1962
1963 -- SLA Uptake, do catchup if applicable...
1964 if (p_log_level_rec.statement_level) then
1965 fa_debug_pkg.add('fa_addition_pvt.insert_asset', 'trx_subtype',
1966 p_trans_rec.transaction_subtype
1967 ,p_log_level_rec => p_log_level_rec);
1968 fa_debug_pkg.add('fa_addition_pvt.insert_asset', 'asset_type',
1969 p_asset_type_rec.asset_type
1970 ,p_log_level_rec => p_log_level_rec);
1971 fa_debug_pkg.add('fa_addition_pvt.insert_asset', 'group asset id',
1972 p_asset_fin_rec.group_asset_id
1973 ,p_log_level_rec => p_log_level_rec);
1974 fa_debug_pkg.add('fa_addition_pvt.insert_asset', 'annaul round flag',
1975 p_asset_fin_rec.annual_deprn_rounding_flag
1976 ,p_log_level_rec => p_log_level_rec);
1977 fa_debug_pkg.add('fa_addition_pvt.insert_asset',
1978 'p_trans_rec.transaction_date_entered', p_trans_rec.transaction_date_entered
1979 ,p_log_level_rec => p_log_level_rec);
1980 fa_debug_pkg.add('fa_addition_pvt.insert_asset',
1981 'p_period_rec.calendar_period_open_date', p_period_rec.calendar_period_open_date
1982 ,p_log_level_rec => p_log_level_rec);
1983
1984 end if;
1985
1986 -- Bug no 4704128 spooyath
1987 -- added nvl checking for p_asset_fin_rec.annual_deprn_rounding_flag
1988 -- its value is null for assets added with DPIS not in current fiscal year
1989
1990 -- Bug 4739563 call the catchup logic only when the addition is a
1991 -- backdated one
1992 -- added the check on p_trans_rec.transaction_date_entered and
1993 -- p_period_rec.calendar_period_open_date
1994
1995 --bug7228041 Added the 'OR' condition in following IF condition.
1996 --so that correct catch-up is calculated in case of 'START OF YEAR prorate convention
1997
1998 -- R12 conditional handling
1999 if (G_release <> 11 and
2000 (nvl(p_trans_rec.transaction_subtype, 'EXPENSED') <> 'AMORTIZED') and
2001 (p_asset_type_rec.asset_type = 'CAPITALIZED') and
2002 (p_asset_fin_rec.group_asset_id is null) and
2003 (nvl(p_asset_fin_rec.annual_deprn_rounding_flag,'ADD') <> 'RES') and
2004 ((p_trans_rec.transaction_date_entered < p_period_rec.calendar_period_open_date)
2005 or (p_asset_fin_rec.prorate_date < p_period_rec.calendar_period_open_date))) then
2006
2007 if not FA_EXP_PVT.faxexp
2008 (px_trans_rec => p_trans_rec,
2009 p_asset_hdr_rec => p_asset_hdr_rec,
2010 p_asset_desc_rec => p_asset_desc_rec,
2011 p_asset_cat_rec => p_asset_cat_rec,
2012 p_asset_type_rec => p_asset_type_rec,
2013 p_asset_fin_rec_old => l_asset_fin_rec_null,
2014 px_asset_fin_rec_new => p_asset_fin_rec,
2015 p_asset_deprn_rec => p_asset_deprn_rec,
2016 p_period_rec => p_period_rec,
2017 p_mrc_sob_type_code => p_mrc_sob_type_code,
2018 p_running_mode => fa_std_types.FA_DPR_NORMAL,
2019 p_used_by_revaluation => null,
2020 x_deprn_exp => l_deprn_exp,
2021 x_bonus_deprn_exp => l_bonus_deprn_exp,
2022 x_impairment_exp => l_impairment_exp,
2023 x_ann_adj_deprn_exp => l_ann_adj_deprn_exp,
2024 x_ann_adj_bonus_deprn_exp => l_ann_adj_bonus_deprn_exp,
2025 p_log_level_rec => p_log_level_rec) then
2026 raise general_error;
2027 end if;
2028
2029 if (p_log_level_rec.statement_level) then
2030 fa_debug_pkg.add('fa_addition_pvt.insert_asset', 'l_deprn_exp after faxexp',
2031 l_deprn_exp, p_log_level_rec => p_log_level_rec);
2032 fa_debug_pkg.add('fa_addition_pvt.insert_asset', 'l_bonus_deprn_exp after faxexp',
2033 l_bonus_deprn_exp, p_log_level_rec =>
2034 p_log_level_rec);
2035 fa_debug_pkg.add('fa_addition_pvt.insert_asset', 'Calling fa_books_pkg.update_row',
2036 'after calling faxexp', p_log_level_rec => p_log_level_rec);
2037 end if;
2038
2039 --
2040 -- Bug4439895: Reflect post catch-up info to fa_books
2041 --
2042 fa_books_pkg.update_row
2043 (X_asset_id => p_asset_hdr_rec.asset_id,
2044 X_book_type_code => p_asset_hdr_rec.book_type_code,
2045 X_rate_adjustment_factor => p_asset_fin_rec.rate_adjustment_factor,
2046 X_reval_amortization_basis => p_asset_fin_rec.reval_amortization_basis,
2047 X_adjusted_cost => p_asset_fin_rec.adjusted_cost,
2048 X_adjusted_capacity => p_asset_fin_rec.adjusted_capacity,
2049 X_formula_factor => p_asset_fin_rec.formula_factor,
2050 X_eofy_reserve => p_asset_fin_rec.eofy_reserve,
2051 X_mrc_sob_type_code => p_mrc_sob_type_code,
2052 X_set_of_books_id => p_asset_hdr_rec.set_of_books_id,
2053 X_calling_fn => 'fa_addition_pvt.insert_asset',
2054 p_log_level_rec => p_log_level_rec);
2055
2056 -- Bug:5701095
2057 FA_DEPRN_SUMMARY_PKG.Update_Row (
2058 X_Rowid => l_ds_rowid,
2059 X_Book_Type_Code => p_asset_hdr_rec.book_type_code,
2060 X_Asset_Id => p_asset_hdr_rec.asset_id,
2061 X_Deprn_Run_Date => p_trans_rec.who_info.last_update_date,
2062 X_Deprn_Amount => p_asset_deprn_rec.deprn_amount,
2063 X_Ytd_Deprn => p_asset_deprn_rec.ytd_deprn,
2064 X_Deprn_Reserve => p_asset_deprn_rec.deprn_reserve,
2065 X_Deprn_Source_Code => 'BOOKS',
2066 X_Adjusted_Cost => p_asset_fin_rec.adjusted_cost,
2067 X_Bonus_Rate => NULL,
2068 X_Ltd_Production => NULL,
2069 X_Period_Counter => l_period_counter,
2070 X_Production => NULL,
2071 X_Reval_Amortization => p_asset_deprn_rec.reval_amortization,
2072 X_Reval_Amortization_Basis => l_reval_amortization_basis,
2073 X_Reval_Deprn_Expense => p_asset_deprn_rec.reval_deprn_expense,
2074 X_Reval_Reserve => p_asset_deprn_rec.reval_deprn_reserve,
2075 X_Ytd_Production => NULL,
2076 X_Ytd_Reval_Deprn_Expense => p_asset_deprn_rec.reval_ytd_deprn,
2077 X_mrc_sob_type_code => p_mrc_sob_type_code,
2078 X_set_of_books_id => p_asset_hdr_rec.set_of_books_id,
2079 X_Calling_Fn => 'fa_addition_pvt.insert_asset',
2080 p_log_level_rec => p_log_level_rec);
2081
2082 elsif ((p_trans_rec.transaction_subtype = 'AMORTIZED') and
2083 (p_asset_type_rec.asset_type = 'CAPITALIZED') and
2084 ((p_asset_fin_rec.group_asset_id is null) or
2085 (p_asset_fin_rec.group_asset_id is not null and
2086 nvl(p_asset_fin_rec.tracking_method, 'OTHER') = 'CALCULATE'))) then
2087 --bug3548724
2088 l_asset_deprn_rec_adj.deprn_reserve := p_asset_deprn_rec.deprn_reserve;
2089 l_asset_deprn_rec_adj.ytd_deprn := p_asset_deprn_rec.ytd_deprn; -- Bug 9231768
2090
2091 if not FA_AMORT_PVT.faxama
2092 (px_trans_rec => p_trans_rec,
2093 p_asset_hdr_rec => p_asset_hdr_rec,
2094 p_asset_desc_rec => p_asset_desc_rec,
2095 p_asset_cat_rec => p_asset_cat_rec,
2096 p_asset_type_rec => p_asset_type_rec,
2097 p_asset_fin_rec_old => p_asset_fin_rec,
2098 px_asset_fin_rec_new => p_asset_fin_rec,
2099 p_asset_deprn_rec => p_asset_deprn_rec,
2100 p_asset_deprn_rec_adj => l_asset_deprn_rec_adj, --bug3548724
2101 p_period_rec => p_period_rec,
2102 p_mrc_sob_type_code => p_mrc_sob_type_code,
2103 p_running_mode => fa_std_types.FA_DPR_NORMAL,
2104 p_used_by_revaluation => null,
2105 x_deprn_exp => l_deprn_exp,
2106 x_bonus_deprn_exp => l_bonus_deprn_exp,
2107 x_impairment_exp => l_impairment_exp
2108 , p_log_level_rec => p_log_level_rec) then raise general_error;
2109 end if;
2110
2111 if not (l_status) then
2112 raise general_error;
2113 end if;
2114
2115 -- R12 conditional handling
2116 -- SLA: removing original faxiat call from here as we now call for all
2117
2118 if (G_release = 11) then
2119 -- insert all the amounts
2120 if not FA_INS_ADJ_PVT.faxiat
2121 (p_trans_rec => p_trans_rec,
2122 p_asset_hdr_rec => p_asset_hdr_rec,
2123 p_asset_desc_rec => p_asset_desc_rec,
2124 p_asset_cat_rec => p_asset_cat_rec,
2125 p_asset_type_rec => p_asset_type_rec,
2126 p_cost => 0,
2127 p_clearing => 0,
2128 p_deprn_expense => l_deprn_exp,
2129 p_bonus_expense => l_bonus_deprn_exp,
2130 p_impair_expense => l_impairment_exp,
2131 p_ann_adj_amt => 0,
2132 p_mrc_sob_type_code => p_mrc_sob_type_code,
2133 p_calling_fn => 'fa_addition_pvt.insert_asset'
2134 , p_log_level_rec => p_log_level_rec) then raise general_error;
2135 end if;
2136
2137 end if;
2138
2139 fa_books_pkg.update_row
2140 (X_asset_id => p_asset_hdr_rec.asset_id,
2141 X_book_type_code => p_asset_hdr_rec.book_type_code,
2142 X_rate_adjustment_factor => p_asset_fin_rec.rate_adjustment_factor,
2143 X_reval_amortization_basis => p_asset_fin_rec.reval_amortization_basis,
2144 X_adjusted_cost => p_asset_fin_rec.adjusted_cost,
2145 X_adjusted_capacity => p_asset_fin_rec.adjusted_capacity,
2146 X_formula_factor => p_asset_fin_rec.formula_factor,
2147 X_eofy_reserve => p_asset_fin_rec.eofy_reserve,
2148 X_mrc_sob_type_code => p_mrc_sob_type_code,
2149 X_set_of_books_id => p_asset_hdr_rec.set_of_books_id,
2150 X_calling_fn => 'fa_addition_pvt.insert_asset', p_log_level_rec => p_log_level_rec);
2151
2152 -- now update the primary or reporting amounts accordingly
2153 if (p_mrc_sob_type_code <> 'R') then
2154
2155 delete from fa_adjustments
2156 where asset_id = p_asset_hdr_rec.asset_id
2157 and book_type_code = p_asset_hdr_rec.book_type_code
2158 and adjustment_type in ('COST', 'COST CLEARING');
2159
2160 else
2161
2162 delete from fa_mc_adjustments
2163 where asset_id = p_asset_hdr_rec.asset_id
2164 and book_type_code = p_asset_hdr_rec.book_type_code
2165 and adjustment_type in ('COST', 'COST CLEARING')
2166 and set_of_books_id = p_asset_hdr_rec.set_of_books_id;
2167
2168 end if;
2169
2170 FA_DEPRN_SUMMARY_PKG.Update_Row (
2171 X_Rowid => l_ds_rowid,
2172 X_Book_Type_Code => p_asset_hdr_rec.book_type_code,
2173 X_Asset_Id => p_asset_hdr_rec.asset_id,
2174 X_Deprn_Run_Date => p_trans_rec.who_info.last_update_date,
2175 X_Deprn_Amount => p_asset_deprn_rec.deprn_amount,
2176 X_Ytd_Deprn => p_asset_deprn_rec.ytd_deprn,
2177 X_Deprn_Reserve => p_asset_deprn_rec.deprn_reserve,
2178 X_Deprn_Source_Code => 'BOOKS',
2179 X_Adjusted_Cost => p_asset_fin_rec.adjusted_cost,
2180 X_Bonus_Rate => NULL,
2181 X_Ltd_Production => NULL,
2182 X_Period_Counter => l_period_counter,
2183 X_Production => NULL,
2184 X_Reval_Amortization => p_asset_deprn_rec.reval_amortization,
2185 X_Reval_Amortization_Basis => l_reval_amortization_basis,
2186 X_Reval_Deprn_Expense => p_asset_deprn_rec.reval_deprn_expense,
2187 X_Reval_Reserve => p_asset_deprn_rec.reval_deprn_reserve,
2188 X_Ytd_Production => NULL,
2189 X_Ytd_Reval_Deprn_Expense => p_asset_deprn_rec.reval_ytd_deprn,
2190 X_mrc_sob_type_code => p_mrc_sob_type_code,
2191 X_set_of_books_id => p_asset_hdr_rec.set_of_books_id,
2192 X_Calling_Fn => 'fa_addition_pvt.insert_asset'
2193 , p_log_level_rec => p_log_level_rec);
2194 end if; -- end amort nbv
2195
2196 -- R12 conditonal handling
2197 if (G_release <> 11) then
2198
2199 if (p_inv_trans_rec.invoice_transaction_id is not null) then
2200
2201 l_adj.transaction_header_id := p_trans_rec.transaction_header_id;
2202 l_adj.asset_id := p_asset_hdr_rec.asset_id;
2203 l_adj.book_type_code := p_asset_hdr_rec.book_type_code;
2204 l_adj.period_counter_created := fa_cache_pkg.fazcbc_record.last_period_counter + 1;
2205 l_adj.period_counter_adjusted := fa_cache_pkg.fazcbc_record.last_period_counter + 1;
2206 l_adj.current_units := p_asset_desc_rec.current_units ;
2207 l_adj.selection_mode := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
2208 l_adj.selection_thid := 0;
2209 l_adj.selection_retid := 0;
2210 l_adj.leveling_flag := TRUE;
2211 l_adj.last_update_date := p_trans_rec.who_info.last_update_date;
2212
2213 l_adj.flush_adj_flag := FALSE;
2214 l_adj.gen_ccid_flag := FALSE;
2215 l_adj.annualized_adjustment := 0;
2216 l_adj.distribution_id := 0;
2217
2218 l_adj.adjustment_type := 'COST CLEARING';
2219 l_adj.source_type_code := p_trans_rec.transaction_type_code;
2220
2221 if l_adj.source_type_code = 'CIP ADJUSTMENT' then
2222 l_adj.account_type := 'CIP_CLEARING_ACCT';
2223 else
2224 l_adj.account_type := 'ASSET_CLEARING_ACCT';
2225 end if;
2226
2227 if (p_mrc_sob_type_code <> 'R') then
2228
2229 OPEN c_invoices(p_asset_id => p_asset_hdr_rec.asset_id,
2230 p_invoice_transaction_id => p_inv_trans_rec.invoice_transaction_id);
2231 FETCH c_invoices bulk collect
2232 into l_source_line_id_tbl,
2233 l_asset_invoice_id_tbl,
2234 l_payables_cost_tbl,
2235 l_payables_ccid_tbl;
2236 close c_invoices;
2237
2238 for i in 1..l_payables_cost_tbl.count loop
2239
2240 -- SLA changes
2241 l_adj.source_line_id := l_source_line_id_tbl(i);
2242 l_adj.code_combination_id := l_payables_ccid_tbl(i);
2243 l_adj.asset_invoice_id := l_asset_invoice_id_tbl(i);
2244
2245 if l_payables_cost_tbl(i) > 0 then
2246 l_adj.debit_credit_flag := 'CR';
2247 l_adj.adjustment_amount := l_payables_cost_tbl(i);
2248 else
2249 l_adj.debit_credit_flag := 'DR';
2250 l_adj.adjustment_amount := -l_payables_cost_tbl(i);
2251 end if;
2252
2253 l_adj.mrc_sob_type_code := 'P';
2254 l_adj.set_of_books_id := p_asset_hdr_rec.set_of_books_id;
2255
2256 if not FA_INS_ADJUST_PKG.faxinaj
2257 (l_adj,
2258 p_trans_rec.who_info.last_update_date,
2259 p_trans_rec.who_info.last_updated_by,
2260 p_trans_rec.who_info.last_update_login,
2261 p_log_level_rec => p_log_level_rec) then
2262 raise general_error;
2263 end if;
2264
2265 l_clearing := l_clearing + l_payables_cost_tbl(i);
2266 end loop;
2267
2268 else
2269
2270 open c_mc_invoices(p_asset_id => p_asset_hdr_rec.asset_id,
2271 p_invoice_transaction_id => p_inv_trans_rec.invoice_transaction_id);
2272
2273 FETCH c_mc_invoices bulk collect
2274 into l_source_line_id_tbl,
2275 l_asset_invoice_id_tbl,
2276 l_payables_cost_tbl,
2277 l_payables_ccid_tbl;
2278 close c_mc_invoices;
2279 /*Bug 16463079 */
2280 if fa_cache_pkg.fazcbc_record.book_class = 'TAX' and l_payables_cost_tbl.count = 0 then
2281 open c_mc_invoices_sec(p_asset_id => p_asset_hdr_rec.asset_id,
2282 p_invoice_transaction_id => p_inv_trans_rec.invoice_transaction_id);
2283 FETCH c_mc_invoices_sec bulk collect
2284 into l_source_line_id_tbl,
2285 l_asset_invoice_id_tbl,
2286 l_payables_cost_tbl,
2287 l_payables_ccid_tbl;
2288 close c_mc_invoices_sec;
2289 end if;
2290 for i in 1..l_payables_cost_tbl.count loop
2291
2292 -- SLA changes
2293 l_adj.source_line_id := l_source_line_id_tbl(i);
2294 l_adj.code_combination_id := l_payables_ccid_tbl(i);
2295 l_adj.asset_invoice_id := l_asset_invoice_id_tbl(i);
2296
2297 if l_payables_cost_tbl(i) > 0 then
2298 l_adj.debit_credit_flag := 'CR';
2299 l_adj.adjustment_amount := l_payables_cost_tbl(i);
2300 else
2301 l_adj.debit_credit_flag := 'DR';
2302 l_adj.adjustment_amount := -l_payables_cost_tbl(i);
2303 end if;
2304
2305 l_adj.mrc_sob_type_code := 'R';
2306 l_adj.set_of_books_id := p_asset_hdr_rec.set_of_books_id;
2307
2308 if not FA_INS_ADJUST_PKG.faxinaj
2309 (l_adj,
2310 p_trans_rec.who_info.last_update_date,
2311 p_trans_rec.who_info.last_updated_by,
2312 p_trans_rec.who_info.last_update_login
2313 ,p_log_level_rec => p_log_level_rec) then
2314 raise general_error;
2315 end if;
2316
2317 l_clearing := l_clearing + l_payables_cost_tbl(i);
2318
2319 end loop;
2320
2321 end if;
2322
2323 end if;
2324
2325 -- flush them
2326 l_adj.transaction_header_id := 0;
2327 l_adj.flush_adj_flag := TRUE;
2328 l_adj.leveling_flag := TRUE;
2329
2330 if not FA_INS_ADJUST_PKG.faxinaj
2331 (l_adj,
2332 p_trans_rec.who_info.last_update_date,
2333 p_trans_rec.who_info.last_updated_by,
2334 p_trans_rec.who_info.last_update_login,
2335 p_log_level_rec => p_log_level_rec) then
2336 raise general_error;
2337 end if;
2338
2339 -- need to reset this after each flush
2340 l_adj.transaction_header_id := p_trans_rec.transaction_header_id;
2341
2342
2343 -- insert all the amounts
2344 -- SLA: include catchup/amort nbv/cost and clearing now
2345
2346 if not FA_INS_ADJ_PVT.faxiat
2347 (p_trans_rec => p_trans_rec,
2348 p_asset_hdr_rec => p_asset_hdr_rec,
2349 p_asset_desc_rec => p_asset_desc_rec,
2350 p_asset_cat_rec => p_asset_cat_rec,
2351 p_asset_type_rec => p_asset_type_rec,
2352 p_cost => p_asset_fin_rec.cost,
2353 p_clearing => p_asset_fin_rec.cost - l_clearing,
2354 p_deprn_expense => l_deprn_exp,
2355 p_bonus_expense => l_bonus_deprn_exp,
2356 p_ann_adj_amt => l_ann_adj_deprn_exp, --0,
2357 p_mrc_sob_type_code => p_mrc_sob_type_code,
2358 p_calling_fn => 'fa_addition_pvt.insert_asset',
2359 p_log_level_rec => p_log_level_rec) then raise general_error;
2360 end if;
2361
2362 end if;
2363
2364 -- Bug:5930979:Japan Tax Reform Project (Start)
2365 -- Modified below code for Japan enhancement 6606548 (Backdated Asset Addition for JP-250DB methods)
2366 if nvl(fa_cache_pkg.fazccmt_record.guarantee_rate_method_flag,'NO') = 'YES' then
2367
2368 p_asset_fin_rec.nbv_at_switch := nvl(p_asset_fin_rec.nbv_at_switch,0); -- Changes made as per the ER No.s 6606548 and 6606552 by Sbyreddy Start
2369
2370 -- deprn reserve not entered and nbv_at_switch entered
2371 if (p_asset_deprn_rec.deprn_reserve = 0 and p_asset_fin_rec.nbv_at_switch <> 0) then
2372 fa_srvr_msg.add_message(calling_fn => 'fa_addition_pvt.insert_asset',
2373 name => 'FA_ADD_SWITCH_NBV_WITHOUT_RSV', p_log_level_rec => p_log_level_rec); -- Changes made as per the ER No.s 6606548 and 6606552 by Sbyreddy End
2374 raise general_error;
2375 end if;
2376
2377 FA_CDE_PKG.faxgfr (X_Book_Type_Code => p_asset_hdr_rec.book_type_code,
2378 X_Asset_Id => p_asset_hdr_rec.asset_id,
2379 X_Short_Fiscal_Year_Flag => p_asset_fin_rec.short_fiscal_year_flag,
2380 X_Conversion_Date => p_asset_fin_rec.conversion_date,
2381 X_Prorate_Date => p_asset_fin_rec.prorate_date,
2382 X_Orig_Deprn_Start_Date => p_asset_fin_rec.orig_deprn_start_date,
2383 C_Prorate_Date => NULL,
2384 C_Conversion_Date => NULL,
2385 C_Orig_Deprn_Start_Date => NULL,
2386 X_Method_Code => p_asset_fin_rec.deprn_method_code,
2387 X_Life_In_Months => p_asset_fin_rec.life_in_months,
2388 X_Fiscal_Year => -99,
2389 X_Current_Period => l_period_rec.period_counter,
2390 X_calling_interface => 'ADDITION',
2391 X_Rate => l_rate_in_use,
2392 X_Method_Type => l_method_type,
2393 X_Success => l_success, p_log_level_rec => p_log_level_rec);
2394
2395 if (l_success <= 0) then
2396 fa_srvr_msg.add_message(calling_fn => 'fa_addition_pvt.insert_asset', p_log_level_rec => p_log_level_rec);
2397 raise general_error;
2398 end if;
2399
2400
2401 -- Fix for Bug #6334489. Do not allow addition of asset with
2402 -- revised rate.
2403 select count(*)
2404 into l_revised_count
2405 from fa_methods mt,
2406 fa_formulas f
2407 where mt.method_code = p_asset_fin_rec.deprn_method_code
2408 and mt.life_in_months = p_asset_fin_rec.life_in_months
2409 and mt.method_id = f.method_id
2410 and f.revised_rate = l_rate_in_use;
2411
2412 -- revised rate with nbv_at_switch not entered -- Changes made as per the ER No.s 6606548 and 6606552 by Sbyreddy Start
2413
2414 -- Fix for Bug #7109596 . The NBV_AT_SWITCH can be ZERO ( = 0) for Zero value Assets. Hence Commenting the below Piece of Code
2415
2416 /* if (l_revised_count > 0) and (p_asset_fin_rec.nbv_at_switch = 0) then
2417 fa_srvr_msg.add_message(calling_fn => 'fa_addition_pvt.insert_asset',
2418 name => 'FA_ADD_REVISED_WITHOUT_SWITCH', p_log_level_rec => p_log_level_rec);
2419 raise general_error;
2420
2421 els*/
2422 ----End of the Comment for the Bug 7109596
2423 -- original rate with nbv_at_switch entered
2424 if (l_revised_count = 0) and (p_asset_fin_rec.nbv_at_switch <> 0) then
2425 fa_srvr_msg.add_message(calling_fn => 'fa_addition_pvt.insert_asset',
2426 name => 'FA_ADD_SWITCH_NBV_ORIGINAL_RAT', p_log_level_rec => p_log_level_rec);
2427 raise general_error;
2428 end if; -- Changes made as per the ER No.s 6606548 and 6606552 by Sbyreddy End
2429
2430 if (l_revised_count > 0) and -- Changes made as per the ER No.s 6606548 and 6606552 by Sbyreddy Start
2431 (p_asset_deprn_rec.deprn_reserve > 0) then
2432
2433 UPDATE FA_BOOKS
2434 SET adjusted_cost = p_asset_fin_rec.nbv_at_switch
2435 WHERE book_type_code = p_asset_hdr_rec.book_type_code
2436 AND asset_id = p_asset_hdr_rec.asset_id
2437 AND date_ineffective is null;
2438
2439 UPDATE FA_DEPRN_SUMMARY
2440 SET adjusted_cost = p_asset_fin_rec.nbv_at_switch
2441 WHERE book_type_code = p_asset_hdr_rec.book_type_code
2442 AND asset_id = p_asset_hdr_rec.asset_id
2443 AND DEPRN_SOURCE_CODE = 'BOOKS';
2444
2445 /*fa_srvr_msg.add_message(calling_fn => 'fa_addition_pvt.initialize',
2446 name => 'FA_ADDITION_REVISED_RATE', p_log_level_rec => p_log_level_rec);
2447 raise general_error; */
2448 end if; -- Changes made as per the ER No.s 6606548 and 6606552 by Sbyreddy End
2449
2450 BEGIN
2451 SELECT FF.original_rate
2452 , FF.revised_rate
2453 , FF.guarantee_rate
2454 INTO l_original_Rate
2455 , l_Revised_Rate
2456 , l_Guaranteed_Rate
2457 FROM FA_FORMULAS FF
2458 , FA_METHODS FM
2459 WHERE FF.METHOD_ID = FM.METHOD_ID
2460 AND FM.METHOD_CODE = p_asset_fin_rec.deprn_method_code;
2461 EXCEPTION
2462 WHEN OTHERS THEN
2463 l_original_Rate := 0;
2464 l_Revised_Rate := 0;
2465 l_Guaranteed_Rate := 0;
2466 l_is_revised_rate := 0;
2467 END;
2468
2469 /* Bug 7626457 Modified the below IF condition to correcly calculate the state of Asset */
2470 /* Bug 16197219 changed to cost from original cost */
2471 IF (TRUNC(p_asset_fin_rec.cost * l_Guaranteed_Rate)) >
2472 (TRUNC((p_asset_fin_rec.cost - (p_asset_deprn_rec.deprn_reserve -
2473 p_asset_deprn_rec.ytd_deprn))* l_original_Rate)) THEN
2474 l_rate_in_use := l_Revised_Rate;
2475 END IF;
2476
2477 UPDATE FA_BOOKS
2478 SET rate_in_use = l_rate_in_use
2479 WHERE book_type_code = p_asset_hdr_rec.book_type_code
2480 AND asset_id = p_asset_hdr_rec.asset_id
2481 AND date_ineffective is null;
2482 end if;
2483 -- Bug:5930979:Japan Tax Reform Project (End)
2484
2485 if (p_mrc_sob_type_code = 'R') then
2486
2487 -- insert the books_rates record
2488 mc_fa_utilities_pkg.insert_books_rates (
2489 p_set_of_books_id => p_asset_hdr_rec.set_of_books_id,
2490 p_asset_id => p_asset_hdr_rec.asset_id,
2491 p_book_type_code => p_asset_hdr_rec.book_type_code,
2492 p_transaction_header_id => p_trans_rec.transaction_header_id,
2493 p_invoice_transaction_id => p_inv_trans_rec.invoice_transaction_id,
2494 p_exchange_date => p_trans_rec.transaction_date_entered,
2495 p_cost => p_primary_cost,
2496 p_exchange_rate => p_exchange_rate,
2497 p_avg_exchange_rate => p_exchange_rate,
2498 p_last_updated_by => p_trans_rec.who_info.last_updated_by,
2499 p_last_update_date => p_trans_rec.who_info.last_update_date,
2500 p_last_update_login => p_trans_rec.who_info.last_update_login,
2501 p_complete => 'Y',
2502 p_trigger => 'fa_addition_pvt.insert_asset',
2503 p_currency_code => to_char(p_asset_hdr_rec.set_of_books_id),
2504 p_log_level_rec => p_log_level_rec
2505 );
2506 end if;
2507
2508 x_return_status := FND_API.G_RET_STS_SUCCESS;
2509 return TRUE;
2510
2511 EXCEPTION
2512 when mrc_check_error then
2513 fa_srvr_msg.add_message(
2514 calling_fn => 'fa_addition_pvt.insert_asset', p_log_level_rec => p_log_level_rec);
2515 x_return_status := FND_API.G_RET_STS_ERROR;
2516 return FALSE;
2517
2518 when general_error then
2519 fa_srvr_msg.add_message(
2520 calling_fn => 'fa_addition_pvt.insert_asset', p_log_level_rec => p_log_level_rec);
2521 x_return_status := FND_API.G_RET_STS_ERROR;
2522 return FALSE;
2523
2524 when others then
2525 fa_srvr_msg.add_sql_error(
2526 calling_fn => 'fa_addition_pvt.insert_asset', p_log_level_rec => p_log_level_rec);
2527 x_return_status := FND_API.G_RET_STS_ERROR;
2528 return FALSE;
2529
2530 end insert_asset;
2531 -- Bug 13022905
2532 function initialize_jp (
2533 -- Transaction Object --
2534 px_trans_rec IN OUT NOCOPY fa_api_types.trans_rec_type,
2535 px_asset_hdr_rec IN OUT NOCOPY fa_api_types.asset_hdr_rec_type,
2536 px_asset_fin_rec IN OUT NOCOPY fa_api_types.asset_fin_rec_type,
2537 px_asset_deprn_rec IN OUT NOCOPY fa_api_types.asset_deprn_rec_type,
2538 p_calling_fn IN VARCHAR2
2539 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type) return boolean as
2540
2541 -- Bug# 7698326 start
2542 l_fiscal_year number;
2543 l_number_per_fiscal_year number;
2544 l_period_num number;
2545 l_period_counter_extd number;
2546 ln_limit_amt number;
2547
2548 cursor lcu_period_info(p_book_type_code in varchar2,
2549 p_period in varchar2 ) is
2550 select ffy.fiscal_year
2551 ,fcp.period_num
2552 ,fct.number_per_fiscal_year
2553 from fa_fiscal_year ffy
2554 ,fa_book_controls fbc
2555 ,fa_calendar_periods fcp
2556 ,fa_calendar_types fct
2557 where ffy.fiscal_year_name = fbc.fiscal_year_name
2558 and ffy.fiscal_year_name = fct.fiscal_year_name
2559 and fbc.book_type_code = p_book_type_code
2560 and fcp.calendar_type = fct.calendar_type
2561 and fct.calendar_type = fbc.deprn_calendar
2562 and fcp.start_date >= ffy.start_date
2563 and fcp.end_date <= ffy.end_date
2564 and upper(fcp.period_name) = upper(p_period);
2565
2566 --Bug#7698326 End
2567 Begin
2568 l_fiscal_year := null;
2569 l_period_num := null;
2570 l_number_per_fiscal_year := null;
2571 if px_asset_fin_rec.period_full_reserve is not null AND
2572 px_asset_fin_rec.period_counter_fully_reserved is null then
2573 open lcu_period_info(p_book_type_code => px_asset_hdr_rec.book_type_code
2574 ,p_period => px_asset_fin_rec.period_full_reserve
2575 );
2576 fetch lcu_period_info
2577 into l_fiscal_year,
2578 l_period_num,
2579 l_number_per_fiscal_year;
2580 if lcu_period_info%found then
2581 px_asset_fin_rec.period_counter_fully_reserved := ( NVL(l_fiscal_year,0)* NVL(l_number_per_fiscal_year,0) ) + NVL(l_period_num,0);
2582 else
2583 px_asset_fin_rec.period_counter_fully_reserved := null;
2584 end if;
2585 close lcu_period_info;
2586 end if;
2587 l_fiscal_year := null;
2588 l_period_num := null;
2589 l_number_per_fiscal_year := null;
2590 l_period_counter_extd := null;
2591
2592 if px_asset_fin_rec.period_extd_deprn is not null AND
2593 px_asset_fin_rec.extended_depreciation_period is null then
2594 open lcu_period_info(p_book_type_code => px_asset_hdr_rec.book_type_code
2595 ,p_period => px_asset_fin_rec.period_extd_deprn
2596 );
2597 fetch lcu_period_info
2598 into l_fiscal_year,
2599 l_period_num,
2600 l_number_per_fiscal_year;
2601 if lcu_period_info%found then
2602 px_asset_fin_rec.extended_depreciation_period := ( NVL(l_fiscal_year,0)*NVL(l_number_per_fiscal_year,0) ) + NVL(l_period_num,0);
2603 else
2604 px_asset_fin_rec.extended_depreciation_period := null;
2605 end if;
2606 close lcu_period_info;
2607 end if;
2608 if px_asset_fin_rec.allowed_deprn_limit_amount is null AND
2609 px_asset_fin_rec.allowed_deprn_limit IS NOT NULL then
2610 px_asset_fin_rec.allowed_deprn_limit_amount := nvl(px_asset_fin_rec.cost,0) - nvl(px_asset_fin_rec.cost,0)* NVL(px_asset_fin_rec.allowed_deprn_limit,0);
2611 /* Bug 8590070*/
2612 FA_ROUND_PKG.fa_ceil
2613 (X_amount => px_asset_fin_rec.allowed_deprn_limit_amount,
2614 X_book => px_asset_hdr_rec.book_type_code
2615 );
2616 end if;
2617 /*Bug 8590070
2618 px_asset_fin_rec.period_counter_fully_reserved := l_period_counter_rsv;
2619 px_asset_fin_rec.period_counter_life_complete := l_period_counter_rsv;
2620 px_asset_fin_rec.extended_depreciation_period := l_period_counter_extd;*/
2621 px_asset_fin_rec.period_counter_life_complete := px_asset_fin_rec.period_counter_fully_reserved;
2622
2623 -- End of Japan profile option value
2624
2625 -- if px_asset_fin_rec.deprn_method_code like 'JP%250DB%' then
2626 -- JP_TAX_2012
2627 if nvl(fa_cache_pkg.fazccmt_record.guarantee_rate_method_flag,'NO') = 'YES' then
2628 px_asset_fin_rec.prior_deprn_limit_type := null;
2629 px_asset_fin_rec.prior_deprn_limit_amount := null;
2630 px_asset_fin_rec.prior_deprn_limit := null;
2631 px_asset_fin_rec.extended_depreciation_period := null;
2632 px_asset_fin_rec.prior_deprn_method := null;
2633 px_asset_fin_rec.prior_life_in_months := null;
2634 px_asset_fin_rec.prior_basic_rate := null;
2635 px_asset_fin_rec.prior_adjusted_rate := null;
2636 px_asset_fin_rec.period_full_reserve := null;
2637 px_asset_fin_rec.period_extd_deprn := null;
2638 elsif px_asset_fin_rec.deprn_method_code = 'JP-STL-EXTND' then
2639 ln_limit_amt := null;
2640 px_asset_fin_rec.nbv_at_switch := null;
2641 -- bug#9118540
2642 if (px_asset_fin_rec.extended_deprn_flag is null) then
2643 px_asset_fin_rec.extended_deprn_flag := 'Y';
2644 end if;
2645 if px_asset_fin_rec.prior_deprn_limit_type = 'AMT' then
2646 px_asset_fin_rec.prior_deprn_limit := null;
2647 elsif px_asset_fin_rec.prior_deprn_limit_type = 'PCT' then
2648 ln_limit_amt := (px_asset_fin_rec.prior_deprn_limit)*nvl(px_asset_fin_rec.cost,0);
2649 ln_limit_amt := nvl(px_asset_fin_rec.cost,0) - ln_limit_amt;
2650 -- Bug 8520695
2651 if ln_limit_amt <> 0 then
2652 FA_ROUND_PKG.fa_ceil
2653 (X_amount => ln_limit_amt,
2654 X_book => px_asset_hdr_rec.book_type_code
2655 );
2656 end if;
2657 -- End Bug 8520695
2658 px_asset_fin_rec.prior_deprn_limit_amount := ln_limit_amt;
2659 else
2660 px_asset_fin_rec.prior_deprn_limit_amount := null;
2661 px_asset_fin_rec.prior_deprn_limit := null;
2662 end if;
2663 else
2664 /*Bug 8590070
2665 if px_asset_fin_rec.deprn_method_code <> 'JP-STL-EXTND' then
2666 IF nvl(px_asset_fin_rec.cost,0) - NVL(px_asset_deprn_rec.deprn_reserve,0) - NVL(px_asset_fin_rec.allowed_deprn_limit_amount,0) = 0 THEN
2667 px_asset_fin_rec.period_counter_fully_reserved := px_asset_fin_rec.period_counter_fully_reserved;
2668 px_asset_fin_rec.period_counter_life_complete := px_asset_fin_rec.period_counter_fully_reserved;
2669 ELSE
2670 px_asset_fin_rec.period_counter_fully_reserved := NULL;
2671 px_asset_fin_rec.period_counter_life_complete := NULL;
2672 END IF;
2673 end if;*/
2674 px_asset_fin_rec.nbv_at_switch := null;
2675 px_asset_fin_rec.prior_deprn_limit_type := null;
2676 px_asset_fin_rec.prior_deprn_limit_amount := null;
2677 px_asset_fin_rec.prior_deprn_limit := null;
2678 px_asset_fin_rec.extended_depreciation_period := null;
2679 px_asset_fin_rec.prior_deprn_method := null;
2680 px_asset_fin_rec.prior_life_in_months := null;
2681 px_asset_fin_rec.prior_basic_rate := null;
2682 px_asset_fin_rec.prior_adjusted_rate := null;
2683 px_asset_fin_rec.period_full_reserve := null;
2684 px_asset_fin_rec.period_extd_deprn := null;
2685 px_asset_fin_rec.extended_deprn_flag := null;
2686 end if;
2687 return TRUE;
2688 -- Bug#7698326 End
2689 exception
2690 when others then
2691 fa_srvr_msg.add_sql_error(
2692 calling_fn => 'fa_addition_pvt.initialize_jp', p_log_level_rec => p_log_level_rec);
2693 return FALSE;
2694
2695 end initialize_jp;
2696
2697 END FA_ADDITION_PVT;