DBA Data[Home] [Help]

PACKAGE BODY: APPS.FA_ADDITION_PVT

Source


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