DBA Data[Home] [Help]

PACKAGE BODY: APPS.FA_CIP_PVT

Source


1 PACKAGE BODY FA_CIP_PVT as
2 /* $Header: FAVCIPB.pls 120.21.12010000.4 2008/12/19 17:09:13 hhafid ship $   */
3 
4 g_print_debug   boolean := fa_cache_pkg.fa_print_debug;
5 g_cap_event_id  number;
6 g_cap_thid      number;
7 g_event_status  varchar2(1);
8 
9 FUNCTION do_validation
10    (p_trans_rec               IN     FA_API_TYPES.trans_rec_type,
11     p_asset_hdr_rec           IN     FA_API_TYPES.asset_hdr_rec_type,
12     p_asset_fin_rec           IN     FA_API_TYPES.asset_fin_rec_type,
13     p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN;
14 
15 FUNCTION do_cap_rev
16    (px_trans_rec              IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
17     p_asset_hdr_rec           IN     FA_API_TYPES.asset_hdr_rec_type,
18     p_asset_desc_rec          IN     FA_API_TYPES.asset_desc_rec_type,
19     p_asset_cat_rec           IN     FA_API_TYPES.asset_cat_rec_type,
20     px_asset_type_rec         IN OUT NOCOPY FA_API_TYPES.asset_type_rec_type,
21     p_asset_fin_rec_old       IN     FA_API_TYPES.asset_fin_rec_type,
22     px_asset_fin_rec          IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
23     p_period_rec              IN     FA_API_TYPES.period_rec_type,
24     p_mrc_sob_type_code       IN     VARCHAR2,
25     p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN IS
26 
27    l_asset_type_rec           FA_API_TYPES.asset_type_rec_type;
28    l_asset_fin_rec_old        FA_API_TYPES.asset_fin_rec_type;
29    l_asset_fin_rec_adj        FA_API_TYPES.asset_fin_rec_type;
30    l_asset_fin_rec_new        FA_API_TYPES.asset_fin_rec_type;
31    l_asset_deprn_rec_old      FA_API_TYPES.asset_deprn_rec_type;
32    l_asset_deprn_rec_adj      FA_API_TYPES.asset_deprn_rec_type;
33    l_asset_deprn_rec_new      FA_API_TYPES.asset_deprn_rec_type;
34    l_inv_trans_rec            FA_API_TYPES.inv_trans_rec_type;
35 
36 
37    l_old_transaction_type_code varchar2(30);
38    l_group_reclass_options_rec FA_API_TYPES.group_reclass_options_rec_type;
39 
40    l_rowid                    rowid;
41    l_status                   boolean;
42    l_ret_status               varchar2(1);
43    l_calling_fn               varchar2(30) := 'fa_cip_pvt.do_cap_rev';
44    l_amount_inserted          number;
45 
46    l_adj                      fa_adjust_type_pkg.fa_adj_row_struct;
47    l_clear_adj                fa_adjust_type_pkg.fa_adj_row_struct;
48 
49 --   l_cap_event_id             number;
50 --   l_cap_thid                 number;
51 --   l_event_status             varchar2(1);
52    l_cap_source_info          XLA_EVENTS_PUB_PKG.t_event_source_info;
53    l_security_context         XLA_EVENTS_PUB_PKG.t_security;
54 
55    cap_rev_err                exception;
56 
57    l_adj_row_rec              FA_ADJUSTMENTS%rowtype;
58 
59    CURSOR c_mrc_adjustments (p_thid number) IS
60    SELECT code_combination_id    ,
61           distribution_id        ,
62           debit_credit_flag      ,
63           adjustment_amount      ,
64           adjustment_type
65      FROM fa_adjustments_mrc_v
66     WHERE transaction_header_id = p_thid;
67 
68    CURSOR c_adjustments (p_thid number) IS
69    SELECT code_combination_id    ,
70           distribution_id        ,
71           debit_credit_flag      ,
72           adjustment_amount      ,
73           adjustment_type
74      FROM fa_adjustments
75     WHERE transaction_header_id = p_thid;
76 
77 BEGIN
78 
79    if (p_log_level_rec.statement_level) then
80       fa_debug_pkg.add(l_calling_fn,
81                        'calling do val', ''
82 			,p_log_level_rec => p_log_level_rec);
83    end if;
84 
85    -- do validation is this is the primary book
86    if (p_mrc_sob_type_code <> 'R') then
87       if not do_validation
88              (p_trans_rec            => px_trans_rec,
89               p_asset_hdr_rec        => p_asset_hdr_rec,
90               p_asset_fin_rec        => px_asset_fin_rec
91               ,p_log_level_rec => p_log_level_rec) then
92          raise cap_rev_err;
93       end if;
94    end if;
95 
96    -- SLA uptake
97    -- need the thid before calc engine
98    if (p_mrc_sob_type_code <> 'R') then
99       select fa_transaction_headers_s.nextval
100         into px_trans_rec.transaction_header_id
101         from dual;
102    end if;
103 
104    if (p_log_level_rec.statement_level) then
105       fa_debug_pkg.add(l_calling_fn,
106                        'calling get_fin_info', ''
107 			,p_log_level_rec => p_log_level_rec);
108    end if;
109 
110    -- for reverse, set the new fin info = the old
111    -- for capitalizing, call calculation engine which will handle differences
112    -- in redefaults due to reverse/cap (i.e. ccbd/salvage)
113    -- including the life derivation for child assets
114    --   (baiscally reversals are untouched caps are recalculated)
115    --
116    -- period of addition has been set using absolute mode
117    -- meaning is this the period in which asset was first added
118 
119    if (p_log_level_rec.statement_level) then
120       fa_debug_pkg.add(l_calling_fn,
121                        'calling calc engine', ''
122 			,p_log_level_rec => p_log_level_rec);
123    end if;
124 
125    l_asset_fin_rec_old := p_asset_fin_rec_old;
126 
127    if (px_trans_rec.transaction_type_code = 'ADDITION') then
128 
129       -- the calculation engine needs info in the adj struct (esp for additions)
130       -- initialize only the not derived values
131 
132       l_asset_fin_rec_adj.date_placed_in_service := px_asset_fin_rec.date_placed_in_service;
133 
134 -- BUG 4553782
135       l_asset_fin_rec_adj.deprn_method_code       := px_asset_fin_rec.deprn_method_code;
136       l_asset_fin_rec_adj.life_in_months          := px_asset_fin_rec.life_in_months;
137       l_asset_fin_rec_adj.basic_rate              := px_asset_fin_rec.basic_rate;
138       l_asset_fin_rec_adj.adjusted_rate           := px_asset_fin_rec.adjusted_rate;
139       l_asset_fin_rec_adj.prorate_convention_code := px_asset_fin_rec.prorate_convention_code;
140       l_asset_fin_rec_adj.depreciate_flag         := px_asset_fin_rec.depreciate_flag;
141       l_asset_fin_rec_adj.bonus_rule              := px_asset_fin_rec.bonus_rule;
142       l_asset_fin_rec_adj.ceiling_name            := px_asset_fin_rec.ceiling_name;
143       l_asset_fin_rec_adj.production_capacity     := px_asset_fin_rec.production_capacity;
144       l_asset_fin_rec_adj.unit_of_measure         := px_asset_fin_rec.unit_of_measure;
145 -- END BUG
146 
147       -- null out the old struct before calc call
148       -- defaulting within calc engine has been removed for group
149       --  values are passed to adj_struct in public api
150       --
151       -- l_asset_fin_rec_old := NULL;
152 
153       -- SLA Uptake
154       -- as with FAPADDB.pls, we need to insure prior fy expense is 0
155       -- not null to get catchup
156 
157       -- should be ok with following:
158       --  l_asset_deprn_rec_old.prior_fy_expense := 0;
159 
160       if not FA_UTIL_PVT.get_asset_deprn_rec
161               (p_asset_hdr_rec         => p_asset_hdr_rec ,
162                px_asset_deprn_rec      => l_asset_deprn_rec_old,
163                p_period_counter        => NULL,
164                p_mrc_sob_type_code     => p_mrc_sob_type_code
165                ,p_log_level_rec => p_log_level_rec) then raise cap_rev_err;
166       end if;
167 
168 
169       -- SLA Uptake - sense new asset type to calc engine to
170       -- force catchup from faxexp
171 
172       l_asset_type_rec.asset_type := 'CAPITALIZED';
173 
174       if not FA_ASSET_CALC_PVT.calc_fin_info
175                  (px_trans_rec              => px_trans_rec,
176                   p_inv_trans_rec           => l_inv_trans_rec,
177                   p_asset_hdr_rec           => p_asset_hdr_rec ,
178                   p_asset_desc_rec          => p_asset_desc_rec,
179                   p_asset_type_rec          => l_asset_type_rec,
180                   p_asset_cat_rec           => p_asset_cat_rec,
181                   p_asset_fin_rec_old       => l_asset_fin_rec_old,
182                   p_asset_fin_rec_adj       => l_asset_fin_rec_adj,
183                   px_asset_fin_rec_new      => l_asset_fin_rec_new,
184                   p_asset_deprn_rec_old     => l_asset_deprn_rec_old,
185                   p_asset_deprn_rec_adj     => l_asset_deprn_rec_adj,
186                   px_asset_deprn_rec_new    => l_asset_deprn_rec_new,
187                   p_period_rec              => p_period_rec,
188                   p_mrc_sob_type_code       => p_mrc_sob_type_code,
189 		  p_group_reclass_options_rec => l_group_reclass_options_rec,
190                   p_calling_fn              => l_calling_fn
191                   ,p_log_level_rec => p_log_level_rec) then raise cap_rev_err;
192       end if;
193 
194       if (p_log_level_rec.statement_level) then
195          fa_debug_pkg.add(l_calling_fn,
196                           'after calc_engine, cost', l_asset_fin_rec_new.cost
197 				,p_log_level_rec => p_log_level_rec);
198       end if;
199 
200       -- insure original cost is reset
201       l_asset_fin_rec_new.original_cost              := l_asset_fin_rec_new.cost;
202       l_asset_fin_rec_new.period_counter_capitalized := p_period_rec.period_counter;
203 
204       /*
205       --Bug 7300699:
206       --Ensure subcomponent life is correctly derived.
207       --fazccbd should have been called in the public api.
208       --Contrary to comments above, child life is not derived in calc_fin_info
209       --and it does not make sense to do it there for this purpose anyway.
210      */
211       if (nvl(fa_cache_pkg.fazccbd_record.subcomponent_life_rule, 'NULL') <> 'NULL' and
212             nvl(p_asset_desc_rec.parent_asset_id, -99) <> -99) then
213 
214            if not FA_ASSET_CALC_PVT.calc_subcomp_life
215                     (p_trans_rec                => px_trans_rec,
216                      p_asset_hdr_rec            => p_asset_hdr_rec,
217                      p_asset_cat_rec            => p_asset_cat_rec,
218                      p_asset_desc_rec           => p_asset_desc_rec,
219                      p_period_rec               => p_period_rec,
220                      px_asset_fin_rec           => l_asset_fin_rec_new,
221                      p_calling_fn               => l_calling_fn,
222                      p_log_level_rec            => p_log_level_rec
223                     ) then
224               raise cap_rev_err;
225            end if;
226       end if; -- (nvl(fa_cache_pkg.fazccbd_recor ...
227 
228       if (p_log_level_rec.statement_level) then
229          fa_debug_pkg.add(l_calling_fn, 'after calc_subcomp_life', l_asset_fin_rec_new.life_in_months
230                            ,p_log_level_rec => p_log_level_rec);
231       end if;
232 
233    else -- reverse
234 
235       l_asset_fin_rec_new                            := l_asset_fin_rec_old;
236       l_asset_fin_rec_new.annual_deprn_rounding_flag := NULL;
237       l_asset_fin_rec_new.period_counter_capitalized := NULL;
238 
239    end if;
240 
241    if (p_log_level_rec.statement_level) then
242       fa_debug_pkg.add(l_calling_fn,
243                        'period_of_addition', p_asset_hdr_rec.period_of_addition
244 			,p_log_level_rec => p_log_level_rec);
245    end if;
246 
247 
248    -- SLA uptake - this is obsolete, handle period of addition the same way
249 
250       if (p_log_level_rec.statement_level) then
251          fa_debug_pkg.add(l_calling_fn,
252                           'in prior period logic',''
253 				,p_log_level_rec => p_log_level_rec);
254       end if;
255 
256       if (p_mrc_sob_type_code <> 'R') then
257 
258          -- trx_types are already set correctly
259          if (px_trans_rec.transaction_type_code = 'CIP REVERSE') then
260             px_asset_type_rec.asset_type := 'CIP';
261          else
262             px_asset_type_rec.asset_type := 'CAPITALIZED';
263             px_trans_rec.transaction_date_entered := px_asset_fin_rec.date_placed_in_service;
264          end if;
265 
266          if (px_trans_rec.transaction_type_code = 'CIP REVERSE') then
267 
268              if (p_log_level_rec.statement_level) then
269                fa_debug_pkg.add(l_calling_fn,
270                                 'checking','event status'
271 				,p_log_level_rec => p_log_level_rec);
272              end if;
273 
274              select event_id,
275                     transaction_header_id
276                into g_cap_event_id,
277                     g_cap_thid
278                from fa_transaction_headers
279               where asset_id              = p_asset_hdr_rec.asset_id
280                 and book_type_code        = p_asset_hdr_rec.book_type_code
281                 and transaction_type_code = 'ADDITION';
282 
283              if (g_cap_event_id is not null) then
284                 l_cap_source_info.application_id        := 140;
285                 l_cap_source_info.ledger_id             := p_asset_hdr_rec.set_of_books_id;
286                 l_cap_source_info.source_id_int_1       := g_cap_thid ;
287                 l_cap_source_info.entity_type_code      := 'TRANSACTIONS';
288 
289                 if (p_log_level_rec.statement_level) then
290                    fa_debug_pkg.add(l_calling_fn, 'calling get event status for
291 event ', g_cap_event_id
292 			,p_log_level_rec => p_log_level_rec);
293                 end if;
294 
295                 -- check the event status
296                 g_event_status := XLA_EVENTS_PUB_PKG.get_event_status
297                         (p_event_source_info            => l_cap_source_info,
298                          p_event_id                     => g_cap_event_id,
299                          p_valuation_method             => p_asset_hdr_rec.book_type_code,
300                          p_security_context             => l_security_context);
301 
302                 if (p_log_level_rec.statement_level) then
303                    fa_debug_pkg.add(l_calling_fn, 'event status ', g_event_status
304                                       ,p_log_level_rec => p_log_level_rec);
305                 end if;
306 
307              end if;
308 
309          end if;
310 
311 
312          -- SLA UPTAKE
313          -- assign an event for the transaction
314          -- always for cap, only if not deleting for rev
315 
316          if ((px_trans_rec.transaction_type_code = 'CIP REVERSE' and
317               g_event_status = XLA_EVENTS_PUB_PKG.C_EVENT_PROCESSED) OR
318              px_trans_rec.transaction_type_code <> 'CIP REVERSE') then
319 
320             if not fa_xla_events_pvt.create_transaction_event
321                  (p_asset_hdr_rec => p_asset_hdr_rec,
322                   p_asset_type_rec=> px_asset_type_rec,
323                   px_trans_rec    => px_trans_rec,
324                   p_event_status  => NULL,
325                   p_calling_fn    => l_calling_fn
326                   ,p_log_level_rec => p_log_level_rec) then
327                raise cap_rev_err;
328             end if;
329 
330          elsif (px_trans_rec.transaction_type_code = 'CIP REVERSE' and
331                  g_event_status <> XLA_EVENTS_PUB_PKG.C_EVENT_PROCESSED) then
332 
333             if (p_log_level_rec.statement_level) then
334                fa_debug_pkg.add(l_calling_fn,
335                                 'deleting capitalization event',
336                                 g_cap_thid
337                                 ,p_log_level_rec => p_log_level_rec);
338             end if;
339 
340             -- now handle event impacts
341             -- create the event for the transaction
342 
343             if not fa_xla_events_pvt.delete_transaction_event
344               (p_ledger_id             => fa_cache_pkg.fazcbc_record.set_of_books_id,
345                p_transaction_header_id => g_cap_thid,
346                p_book_type_code        => p_asset_hdr_rec.book_type_code,
347                p_calling_fn            => l_calling_fn
348                ,p_log_level_rec => p_log_level_rec) then
349                raise cap_rev_err;
350             end if;
351 
352             if (p_log_level_rec.statement_level) then
353                fa_debug_pkg.add(l_calling_fn,
354                                 'deleting accounting impacts for cap thid',
355                                 g_cap_thid
356                                 ,p_log_level_rec => p_log_level_rec);
357             end if;
358 
359             update fa_transaction_headers
360                set event_id = NULL
361              where transaction_header_id = g_cap_thid;
362 
363          end if;
364 
365          if (p_log_level_rec.statement_level) then
366             fa_debug_pkg.add(l_calling_fn,
367                              'calling trx insert_row',''
368 				,p_log_level_rec => p_log_level_rec);
369          end if;
370 
371          FA_TRANSACTION_HEADERS_PKG.Insert_Row
372                       (X_Rowid                          => l_rowid,
373                        X_Transaction_Header_Id          => px_trans_rec.transaction_header_id,
374                        X_Book_Type_Code                 => p_asset_hdr_rec.book_type_code,
375                        X_Asset_Id                       => p_asset_hdr_rec.asset_id,
376                        X_Transaction_Type_Code          => px_trans_rec.transaction_type_code,
377                        X_Transaction_Date_Entered       => px_trans_rec.transaction_date_entered,
378                        X_Date_Effective                 => px_trans_rec.who_info.creation_date,
379                        X_Last_Update_Date               => px_trans_rec.who_info.last_update_date,
380                        X_Last_Updated_By                => px_trans_rec.who_info.last_updated_by,
381                        X_Transaction_Name               => px_trans_rec.transaction_name,
382                        X_Invoice_Transaction_Id         => null,
383                        X_Source_Transaction_Header_Id   => px_trans_rec.Source_Transaction_Header_Id,
384                        X_Mass_Reference_Id              => px_trans_rec.mass_reference_id,
385                        X_Last_Update_Login              => px_trans_rec.who_info.last_update_login,
386                        X_Transaction_Subtype            => null,
387                        X_Attribute1                     => px_trans_rec.desc_flex.attribute1,
388                        X_Attribute2                     => px_trans_rec.desc_flex.attribute2,
389                        X_Attribute3                     => px_trans_rec.desc_flex.attribute3,
390                        X_Attribute4                     => px_trans_rec.desc_flex.attribute4,
391                        X_Attribute5                     => px_trans_rec.desc_flex.attribute5,
392                        X_Attribute6                     => px_trans_rec.desc_flex.attribute6,
393                        X_Attribute7                     => px_trans_rec.desc_flex.attribute7,
394                        X_Attribute8                     => px_trans_rec.desc_flex.attribute8,
395                        X_Attribute9                     => px_trans_rec.desc_flex.attribute9,
396                        X_Attribute10                    => px_trans_rec.desc_flex.attribute10,
397                        X_Attribute11                    => px_trans_rec.desc_flex.attribute11,
398                        X_Attribute12                    => px_trans_rec.desc_flex.attribute12,
399                        X_Attribute13                    => px_trans_rec.desc_flex.attribute13,
400                        X_Attribute14                    => px_trans_rec.desc_flex.attribute14,
401                        X_Attribute15                    => px_trans_rec.desc_flex.attribute15,
402                        X_Attribute_Category_Code        => px_trans_rec.desc_flex.attribute_category_code,
403                        X_Transaction_Key                => null,
404                        X_Amortization_Start_Date        => null,
405                        X_Calling_Interface              => px_trans_rec.calling_interface,
406                        X_Mass_Transaction_ID            => px_trans_rec.mass_transaction_id,
407                        X_Trx_Reference_Id               => px_trans_rec.trx_reference_id,
408                        X_Event_Id                       => px_trans_rec.event_id,
409                        X_Return_Status                  => l_status,
410                        X_Calling_Fn                     => l_calling_fn
411                        ,p_log_level_rec => p_log_level_rec);
412 
413          if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
414 
415             if (p_log_level_rec.statement_level) then
416                fa_debug_pkg.add(l_calling_fn,
417                                 'calling ah update_row, thid out',px_trans_rec.transaction_header_id
418 				,p_log_level_rec => p_log_level_rec);
419             end if;
420 
421             fa_asset_history_pkg.update_row
422                (X_asset_id                  => p_asset_hdr_rec.asset_id,
423                 X_transaction_header_id_out => px_trans_rec.transaction_header_id,
424                 X_date_ineffective          => px_trans_rec.who_info.last_update_date,
425                 X_last_update_date          => px_trans_rec.who_info.last_update_date,
426                 X_last_updated_by           => px_trans_rec.who_info.last_updated_by,
427                 X_Return_Status             => l_status,
428                 X_calling_fn                => l_calling_fn
429                 ,p_log_level_rec => p_log_level_rec);
430 
431             if (p_log_level_rec.statement_level) then
432                fa_debug_pkg.add(l_calling_fn,
433                                 'calling ah insert_row',''
434 				,p_log_level_rec => p_log_level_rec);
435             end if;
436 
437             fa_asset_history_pkg.insert_row(
438                 X_Rowid                     => l_rowid,
439                 X_Asset_Id                  => p_asset_hdr_rec.asset_id,
440                 X_Category_Id               => p_asset_cat_rec.category_id,
441                 X_Asset_Type                => px_asset_type_rec.asset_type,
442                 X_Units                     => p_asset_desc_rec.current_units,
443                 X_Date_Effective            => px_trans_rec.who_info.last_update_date,
444                 X_Date_Ineffective          => null,
445                 X_Transaction_Header_Id_In  => px_trans_rec.transaction_header_id,
446                 X_Transaction_Header_Id_Out => null,
447                 X_Last_Update_Date          => px_trans_rec.who_info.last_update_date,
448                 X_Last_Updated_By           => px_trans_rec.who_info.last_updated_by,
449                 X_Last_Update_Login         => px_trans_rec.who_info.last_update_login,
450                 X_Return_Status             => l_status,
451                 X_Calling_Fn                => l_calling_fn
452                 ,p_log_level_rec => p_log_level_rec);
453 
454          end if;
455       end if;
456 
457       if (p_log_level_rec.statement_level) then
458          fa_debug_pkg.add(l_calling_fn,
459                           'calling bk deactivate_row',''
460 				,p_log_level_rec => p_log_level_rec);
461       end if;
462 
463       -- use table handler for mrc
464       fa_books_pkg.deactivate_row
465         (X_asset_id                  => p_asset_hdr_rec.asset_id,
466          X_book_type_code            => p_asset_hdr_rec.book_type_code,
467          X_transaction_header_id_out => px_trans_rec.transaction_header_id,
468          X_date_ineffective          => px_trans_rec.who_info.last_update_date,
469          X_mrc_sob_type_code              => p_mrc_sob_type_code,
470          X_Calling_Fn                => l_calling_fn
471          ,p_log_level_rec => p_log_level_rec);
472 
473       if (p_log_level_rec.statement_level) then
474          fa_debug_pkg.add(l_calling_fn,
475                           'calling bk insert_row',''
476 				,p_log_level_rec => p_log_level_rec);
477       end if;
478 
479       fa_books_pkg.insert_row
480          (X_Rowid                        => l_rowid,
481           X_Book_Type_Code               => p_asset_hdr_rec.book_type_code,
482           X_Asset_Id                     => p_asset_hdr_rec.asset_id,
483           X_Date_Placed_In_Service       => l_asset_fin_rec_new.date_placed_in_service,
484           X_Date_Effective               => px_trans_rec.who_info.last_update_date,
485           X_Deprn_Start_Date             => l_asset_fin_rec_new.deprn_start_date,
486           X_Deprn_Method_Code            => l_asset_fin_rec_new.deprn_method_code,
487           X_Life_In_Months               => l_asset_fin_rec_new.life_in_months,
488           X_Rate_Adjustment_Factor       => l_asset_fin_rec_new.rate_adjustment_factor,
489           X_Adjusted_Cost                => l_asset_fin_rec_new.adjusted_cost,
490           X_Cost                         => l_asset_fin_rec_new.cost,
491           X_Original_Cost                => l_asset_fin_rec_new.original_cost,
492           X_Salvage_Value                => l_asset_fin_rec_new.salvage_value,
493           X_Prorate_Convention_Code      => l_asset_fin_rec_new.prorate_convention_code,
494           X_Prorate_Date                 => l_asset_fin_rec_new.prorate_date,
495           X_Cost_Change_Flag             => l_asset_fin_rec_new.cost_change_flag,
496           X_Adjustment_Required_Status   => l_asset_fin_rec_new.adjustment_required_status,
497           X_Capitalize_Flag              => l_asset_fin_rec_new.capitalize_flag,
498           X_Retirement_Pending_Flag      => l_asset_fin_rec_new.retirement_pending_flag,
499           X_Depreciate_Flag              => l_asset_fin_rec_new.depreciate_flag,
500           X_Disabled_Flag                => l_asset_fin_rec_new.disabled_flag,--HH
501           X_Last_Update_Date             => px_trans_rec.who_info.last_update_date,
502           X_Last_Updated_By              => px_trans_rec.who_info.last_updated_by,
503           X_Date_Ineffective             => NULL,
504           X_Transaction_Header_Id_In     => px_trans_rec.transaction_header_id,
505           X_Transaction_Header_Id_Out    => NULL,
506           X_Itc_Amount_Id                => l_asset_fin_rec_new.itc_amount_id,
507           X_Itc_Amount                   => l_asset_fin_rec_new.itc_amount,
508           X_Retirement_Id                => l_asset_fin_rec_new.retirement_id,
509           X_Tax_Request_Id               => l_asset_fin_rec_new.tax_request_id,
510           X_Itc_Basis                    => l_asset_fin_rec_new.itc_basis,
511           X_Basic_Rate                   => l_asset_fin_rec_new.basic_rate,
512           X_Adjusted_Rate                => l_asset_fin_rec_new.adjusted_rate,
513           X_Bonus_Rule                   => l_asset_fin_rec_new.bonus_rule,
514           X_Ceiling_Name                 => l_asset_fin_rec_new.ceiling_name,
515           X_Recoverable_Cost             => l_asset_fin_rec_new.recoverable_cost,
516           X_Last_Update_Login            => px_trans_rec.who_info.last_update_login,
517           X_Adjusted_Capacity            => l_asset_fin_rec_new.adjusted_capacity,
518           X_Fully_Rsvd_Revals_Counter    => l_asset_fin_rec_new.fully_rsvd_revals_counter,
519           X_Idled_Flag                   => l_asset_fin_rec_new.idled_flag,
520           X_Period_Counter_Capitalized   => l_asset_fin_rec_new.period_counter_capitalized,
521           X_PC_Fully_Reserved            => l_asset_fin_rec_new.period_counter_fully_reserved,
522           X_Period_Counter_Fully_Retired => l_asset_fin_rec_new.period_counter_fully_retired,
523           X_Production_Capacity          => l_asset_fin_rec_new.production_capacity,
524           X_Reval_Amortization_Basis     => l_asset_fin_rec_new.reval_amortization_basis,
525           X_Reval_Ceiling                => l_asset_fin_rec_new.reval_ceiling,
526           X_Unit_Of_Measure              => l_asset_fin_rec_new.unit_of_measure,
527           X_Unrevalued_Cost              => l_asset_fin_rec_new.unrevalued_cost,
528           X_Annual_Deprn_Rounding_Flag   => l_asset_fin_rec_new.annual_deprn_rounding_flag,
529           X_Percent_Salvage_Value        => l_asset_fin_rec_new.percent_salvage_value,
530           X_Allowed_Deprn_Limit          => l_asset_fin_rec_new.allowed_deprn_limit,
531           X_Allowed_Deprn_Limit_Amount   => l_asset_fin_rec_new.allowed_deprn_limit_amount,
532           X_Period_Counter_Life_Complete => l_asset_fin_rec_new.period_counter_life_complete,
533           X_Adjusted_Recoverable_Cost    => l_asset_fin_rec_new.adjusted_recoverable_cost,
534           X_Short_Fiscal_Year_Flag       => l_asset_fin_rec_new.short_fiscal_year_flag,
535           X_Conversion_Date              => l_asset_fin_rec_new.conversion_date,
536           X_Orig_Deprn_Start_Date        => l_asset_fin_rec_new.orig_deprn_start_date,
537           X_Remaining_Life1              => l_asset_fin_rec_new.remaining_life1,
538           X_Remaining_Life2              => l_asset_fin_rec_new.remaining_life2,
539           X_Old_Adj_Cost                 => l_asset_fin_rec_new.old_adjusted_cost,
540           X_Formula_Factor               => l_asset_fin_rec_new.formula_factor,
541           X_gf_Attribute1                => l_asset_fin_rec_new.global_attribute1,
542           X_gf_Attribute2                => l_asset_fin_rec_new.global_attribute2,
543           X_gf_Attribute3                => l_asset_fin_rec_new.global_attribute3,
544           X_gf_Attribute4                => l_asset_fin_rec_new.global_attribute4,
545           X_gf_Attribute5                => l_asset_fin_rec_new.global_attribute5,
546           X_gf_Attribute6                => l_asset_fin_rec_new.global_attribute6,
547           X_gf_Attribute7                => l_asset_fin_rec_new.global_attribute7,
548           X_gf_Attribute8                => l_asset_fin_rec_new.global_attribute8,
549           X_gf_Attribute9                => l_asset_fin_rec_new.global_attribute9,
550           X_gf_Attribute10               => l_asset_fin_rec_new.global_attribute10,
551           X_gf_Attribute11               => l_asset_fin_rec_new.global_attribute11,
552           X_gf_Attribute12               => l_asset_fin_rec_new.global_attribute12,
553           X_gf_Attribute13               => l_asset_fin_rec_new.global_attribute13,
554           X_gf_Attribute14               => l_asset_fin_rec_new.global_attribute14,
555           X_gf_Attribute15               => l_asset_fin_rec_new.global_attribute15,
556           X_gf_Attribute16               => l_asset_fin_rec_new.global_attribute16,
557           X_gf_Attribute17               => l_asset_fin_rec_new.global_attribute17,
558           X_gf_Attribute18               => l_asset_fin_rec_new.global_attribute18,
559           X_gf_Attribute19               => l_asset_fin_rec_new.global_attribute19,
560           X_gf_Attribute20               => l_asset_fin_rec_new.global_attribute20,
561           X_global_attribute_category    => l_asset_fin_rec_new.global_attribute_category,
562           X_group_asset_id               => l_asset_fin_rec_new.group_asset_id,
563           X_salvage_type                 => l_asset_fin_rec_new.salvage_type,
564           X_deprn_limit_type             => l_asset_fin_rec_new.deprn_limit_type,
565           X_over_depreciate_option       => l_asset_fin_rec_new.over_depreciate_option,
566           X_super_group_id               => l_asset_fin_rec_new.super_group_id,
567           X_reduction_rate               => l_asset_fin_rec_new.reduction_rate,
568           X_reduce_addition_flag         => l_asset_fin_rec_new.reduce_addition_flag,
569           X_reduce_adjustment_flag       => l_asset_fin_rec_new.reduce_adjustment_flag,
570           X_reduce_retirement_flag       => l_asset_fin_rec_new.reduce_retirement_flag,
571           X_recognize_gain_loss          => l_asset_fin_rec_new.recognize_gain_loss,
572           X_recapture_reserve_flag       => l_asset_fin_rec_new.recapture_reserve_flag,
573           X_limit_proceeds_flag          => l_asset_fin_rec_new.limit_proceeds_flag,
574           X_terminal_gain_loss           => l_asset_fin_rec_new.terminal_gain_loss,
575           X_tracking_method              => l_asset_fin_rec_new.tracking_method,
576           X_allocate_to_fully_rsv_flag   => l_asset_fin_rec_new.allocate_to_fully_rsv_flag,
577           X_allocate_to_fully_ret_flag   => l_asset_fin_rec_new.allocate_to_fully_ret_flag,
578           X_exclude_fully_rsv_flag       => l_asset_fin_rec_new.exclude_fully_rsv_flag,
579           X_excess_allocation_option     => l_asset_fin_rec_new.excess_allocation_option,
580           X_depreciation_option          => l_asset_fin_rec_new.depreciation_option,
581           X_member_rollup_flag           => l_asset_fin_rec_new.member_rollup_flag,
582           X_ytd_proceeds                 => l_asset_fin_rec_new.ytd_proceeds,
583           X_ltd_proceeds                 => l_asset_fin_rec_new.ltd_proceeds,
584           X_eofy_reserve                 => l_asset_fin_rec_new.eofy_reserve,
585           X_cip_cost                     => l_asset_fin_rec_new.cip_cost,
586           X_terminal_gain_loss_amount    => l_asset_fin_rec_new.terminal_gain_loss_amount,
587           X_ltd_cost_of_removal          => l_asset_fin_rec_new.ltd_cost_of_removal,
588           X_mrc_sob_type_code            => p_mrc_sob_type_code,
589           X_Return_Status                => l_status,
590           X_Calling_Fn                   => l_calling_fn
591           ,p_log_level_rec => p_log_level_rec);
592 
593 
594     /* Code added for 6748832 */
595 
596       if (p_log_level_rec.statement_level) then
597          fa_debug_pkg.add(l_calling_fn,'calling deprn summary update_row',''
598 				,p_log_level_rec => p_log_level_rec);
599       end if;
600 
601 
602       if (p_asset_hdr_rec.period_of_addition = 'Y') then
603 
604 	                FA_DEPRN_SUMMARY_PKG.Update_Row
605 	                                     (X_Book_Type_Code => p_asset_hdr_rec.book_type_code,
606 	                                      X_Asset_Id      => p_asset_hdr_rec.asset_id,
607 	                                      		X_Deprn_Run_Date => px_trans_rec.who_info.last_update_date,
608 	                                      		X_Adjusted_Cost  => l_asset_fin_rec_new.adjusted_cost,
609 	                                      		X_Period_Counter => p_period_rec.period_counter-1,
610 	                                      		X_mrc_sob_type_code => p_mrc_sob_type_code,
611 	                                      		X_Calling_Fn  => l_calling_fn
612 	                                      		,p_log_level_rec => p_log_level_rec);
613       end if;
614 
615     /* Code added for 6748832 */
616 
617       if (p_mrc_sob_type_code <> 'R') then
618 
619          if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
620 
621             if (p_log_level_rec.statement_level) then
622                fa_debug_pkg.add(l_calling_fn,
623                                 'calling ad update_row',''
624 				,p_log_level_rec => p_log_level_rec);
625             end if;
626 
627             fa_additions_pkg.update_row
628                (X_asset_id          => p_asset_hdr_rec.asset_id,
629                 X_asset_type        => px_asset_type_rec.asset_type,
630                 X_last_update_date  => px_trans_rec.who_info.last_update_date,
631                 X_last_updated_by   => px_trans_rec.who_info.last_updated_by,
632                 X_last_update_login => px_trans_rec.who_info.last_update_login,
633                 X_Return_Status     => l_status,
634                 X_Calling_Fn        => l_calling_fn
635                 ,p_log_level_rec => p_log_level_rec);
636 
637          end if; -- corp
638       end if;    -- primary
639 
640       if (px_trans_rec.transaction_type_code = 'CIP REVERSE') then
641 
642          if (p_mrc_sob_type_code <> 'R') then
643 
644              if (p_log_level_rec.statement_level) then
645                fa_debug_pkg.add(l_calling_fn,
646                                 'calling th update trx type',''
647 				,p_log_level_rec => p_log_level_rec);
648              end if;
649 
650              -- SLA: keeping this
651              FA_TRANSACTION_HEADERS_PKG.Update_Trx_Type
652                        (X_Book_Type_Code                => p_asset_hdr_rec.book_type_code,
653                         X_Asset_Id                      => p_asset_hdr_rec.asset_id,
654                         X_Transaction_Type_Code         => 'ADDITION',
655                         X_New_Transaction_Type          => 'ADDITION/VOID',
656                         X_Return_Status                 => l_status,
657                         X_Calling_Fn                    => l_calling_fn
658                         ,p_log_level_rec => p_log_level_rec);
659          end if;
660 
661          -- SLA conditionally delete / reverse depending on event status
662 
663          if (g_event_status = XLA_EVENTS_PUB_PKG.C_EVENT_PROCESSED) then
664 
665             if (p_log_level_rec.statement_level) then
666                fa_debug_pkg.add(l_calling_fn,
667                                 'reversing accounting impacts for cap',
668                                 'from fa_adjustments'
669 				,p_log_level_rec => p_log_level_rec);
670             end if;
671 
672             if (p_mrc_sob_type_code = 'R') then
673               open c_mrc_adjustments(p_thid => g_cap_thid);
674             else
675               open c_adjustments(p_thid => g_cap_thid);
676             end if;
677 
678             loop
679                if (p_mrc_sob_type_code = 'R') then
680                   fetch c_mrc_adjustments
681                    into l_adj_row_rec.code_combination_id    ,
682                         l_adj_row_rec.distribution_id        ,
683                         l_adj_row_rec.debit_credit_flag      ,
684                         l_adj_row_rec.adjustment_amount      ,
685                         l_adj_row_rec.adjustment_type;
686                else
687                   fetch c_adjustments
688                    into l_adj_row_rec.code_combination_id    ,
689                         l_adj_row_rec.distribution_id        ,
690                         l_adj_row_rec.debit_credit_flag      ,
691                         l_adj_row_rec.adjustment_amount      ,
692                         l_adj_row_rec.adjustment_type;
693                end if;
694 
695                if (p_mrc_sob_type_code = 'R') then
696                   EXIT WHEN c_mrc_adjustments%NOTFOUND;
697                else
698                   EXIT WHEN c_adjustments%NOTFOUND;
699                end if;
700 
701 
702                l_adj.transaction_header_id    := px_trans_rec.transaction_header_id;
703                l_adj.asset_id                 := p_asset_hdr_rec.asset_id;
704                l_adj.book_type_code           := p_asset_hdr_rec.book_type_code;
705                l_adj.period_counter_created   := p_period_rec.period_counter;
706                l_adj.period_counter_adjusted  := p_period_rec.period_counter;
707                l_adj.current_units            := p_asset_desc_rec.current_units ;
708                l_adj.selection_mode           := FA_ADJUST_TYPE_PKG.FA_AJ_SINGLE;
709                l_adj.selection_thid           := 0;
710                l_adj.selection_retid          := 0;
711                l_adj.leveling_flag            := FALSE;
712                l_adj.last_update_date         := px_trans_rec.who_info.last_update_date;
713 
714                l_adj.gen_ccid_flag            := FALSE;
715                l_adj.annualized_adjustment    := 0;
716                l_adj.asset_invoice_id         := 0;
717                l_adj.code_combination_id      := l_adj_row_rec.code_combination_id;
718                l_adj.distribution_id          := l_adj_row_rec.distribution_id;
719 
720                l_adj.adjustment_amount        := l_adj_row_rec.adjustment_amount;
721                l_adj.flush_adj_flag           := FALSE;
722                l_adj.adjustment_type          := l_adj_row_rec.adjustment_type;
723 
724                if (l_adj_row_rec.debit_credit_flag = 'DR') then
725                   l_adj.debit_credit_flag     := 'CR';
726                else
727                   l_adj.debit_credit_flag     := 'DR';
728                end if;
729 
730                l_adj.account                  := NULL;
731 
732                if (l_adj_row_rec.adjustment_type = 'COST') then
733                   l_adj.account_type             := 'ASSET_COST_ACCT';
734                   l_adj.source_type_code         := 'ADDITION';
735                elsif (l_adj_row_rec.adjustment_type = 'CIP COST') then
736                   l_adj.account_type             := 'CIP_COST_ACCT';
737                   l_adj.source_type_code         := 'ADDITION';
738                elsif (l_adj_row_rec.adjustment_type = 'EXPENSE') then
739                   l_adj.account_type             := 'DEPRN_EXPENSE_ACCT';
740                   l_adj.source_type_code         := 'DEPRECIATION';
741                -- Bug:6404609
742 			   elsif (l_adj_row_rec.adjustment_type = 'COST CLEARING') then
743                   l_adj.adjustment_type          := 'CIP COST';
744                   l_adj.account_type             := 'CIP_COST_ACCT';
745                   l_adj.source_type_code         := 'CIP ADDITION';
746 			   else
747                   l_adj.account_type             := 'BONUS_DEPRN_EXPENSE_ACCT';
748                   l_adj.source_type_code         := 'DEPRECIATION';
749                end if;
750 
751                l_adj.mrc_sob_type_code        := p_mrc_sob_type_code;
752 
753                if not FA_INS_ADJUST_PKG.faxinaj
754                         (l_adj,
755                          px_trans_rec.who_info.last_update_date,
756                          px_trans_rec.who_info.last_updated_by,
757                          px_trans_rec.who_info.last_update_login
758                          ,p_log_level_rec => p_log_level_rec) then
759                   raise cap_rev_err;
760                end if;
761 
762             end loop;
763 
764             -- now flush the rows to db
765             l_adj.transaction_header_id := 0;
766             l_adj.flush_adj_flag        := TRUE;
767             l_adj.leveling_flag         := TRUE;
768 
769             if not FA_INS_ADJUST_PKG.faxinaj
770                      (l_adj,
771                       px_trans_rec.who_info.last_update_date,
772                       px_trans_rec.who_info.last_updated_by,
773                       px_trans_rec.who_info.last_update_login
774                       ,p_log_level_rec => p_log_level_rec) then
775                raise cap_rev_err;
776             end if;
777 
778             if (p_mrc_sob_type_code = 'R') then
779               close c_mrc_adjustments;
780             else
781               close c_adjustments;
782             end if;
783 
784          else
785 
786             if (p_log_level_rec.statement_level) then
787                fa_debug_pkg.add(l_calling_fn,
788                                 'deleting accounting impacts for cap thid',
789                                 g_cap_thid
790                                 ,p_log_level_rec => p_log_level_rec);
791             end if;
792 
793             if (p_mrc_sob_type_code <> 'R') then
794 
795                delete from fa_adjustments
796                 where transaction_header_id = g_cap_thid;
797 
798             else
799 
800                delete from fa_adjustments_mrc_v
801                 where transaction_header_id = g_cap_thid;
802 
803             end if;
804 
805          end if;
806 
807       else  -- capitalizing
808 
809          -- now insert adjustments via faxinaj (when outside period of add)
810          -- period of add flag has been set in absolute mode
811 
812          -- converted to use faxinaj instead of faxinadj for mrc
813 
814          if (p_log_level_rec.statement_level) then
815             fa_debug_pkg.add(l_calling_fn,
816                              'calling faxinaj',''
817 				,p_log_level_rec => p_log_level_rec);
818             fa_debug_pkg.add(l_calling_fn,
819                              'calling faxinaj - adj_amount', l_asset_fin_rec_new.cost
820 				,p_log_level_rec => p_log_level_rec);
821          end if;
822 
823          l_adj.transaction_header_id    := px_trans_rec.transaction_header_id;
824          l_adj.asset_id                 := p_asset_hdr_rec.asset_id;
825          l_adj.book_type_code           := p_asset_hdr_rec.book_type_code;
826          l_adj.period_counter_created   := p_period_rec.period_counter;
827          l_adj.period_counter_adjusted  := p_period_rec.period_counter;
828          l_adj.current_units            := p_asset_desc_rec.current_units ;
829          l_adj.selection_mode           := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
830          l_adj.selection_thid           := 0;
831          l_adj.selection_retid          := 0;
832          l_adj.leveling_flag            := FALSE;
833          l_adj.last_update_date         := px_trans_rec.who_info.last_update_date;
834 
835          l_adj.gen_ccid_flag            := TRUE;
836          l_adj.annualized_adjustment    := 0;
837          l_adj.asset_invoice_id         := 0;
838          l_adj.code_combination_id      := 0;
839          l_adj.distribution_id          := 0;
840 
841          l_adj.adjustment_amount        := l_asset_fin_rec_new.cost;
842          l_adj.source_type_code         := 'ADDITION';
843 
844 
845          -- cost first
846          l_adj.flush_adj_flag           := TRUE;   -- ??
847          l_adj.adjustment_type          := 'COST';
848          l_adj.debit_credit_flag        := 'DR';
849          l_adj.account                  := fa_cache_pkg.fazccb_record.asset_cost_acct;
850          l_adj.account_type             := 'ASSET_COST_ACCT';
851          l_adj.mrc_sob_type_code        := p_mrc_sob_type_code;
852 
853          if not FA_INS_ADJUST_PKG.faxinaj
854                 (l_adj,
855                  px_trans_rec.who_info.last_update_date,
856                  px_trans_rec.who_info.last_updated_by,
857                  px_trans_rec.who_info.last_update_login
858                  ,p_log_level_rec => p_log_level_rec) then
859             raise cap_rev_err;
860          end if;
861 
862          -- cip cost next
863          l_adj.flush_adj_flag           := TRUE;
864          l_adj.adjustment_type          := 'CIP COST';
865          l_adj.debit_credit_flag        := 'CR';
866          l_adj.account                  := fa_cache_pkg.fazccb_record.cip_cost_acct;
867          l_adj.account_type             := 'CIP_COST_ACCT';
868 
869          if not FA_INS_ADJUST_PKG.faxinaj
870                 (l_adj,
871                  px_trans_rec.who_info.last_update_date,
872                  px_trans_rec.who_info.last_updated_by,
873                  px_trans_rec.who_info.last_update_login
874                  ,p_log_level_rec => p_log_level_rec) then
875             raise cap_rev_err;
876          end if;
877 
878       end if; -- reverse/cap
879 
880    -- return the full fin struct back to public api for mrc rate insertion
881    px_asset_fin_rec := l_asset_fin_rec_new;
882 
883 
884    return TRUE;  -- all good
885 
886 exception
887    when cap_rev_err then
888       fa_srvr_msg.add_message(calling_fn => l_calling_fn
889             ,p_log_level_rec => p_log_level_rec);
890       return false;
891 
892    when others then
893       fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
894             ,p_log_level_rec => p_log_level_rec);
895       return false;
896 
897 
898 end do_cap_rev;
899 
900 -------------------------------------------------------------------------
901 
902 function do_validation
903     (p_trans_rec      IN   FA_API_TYPES.trans_rec_type,
904      p_asset_hdr_rec  IN   FA_API_TYPES.asset_hdr_rec_type,
905      p_asset_fin_rec  IN   FA_API_TYPES.asset_fin_rec_type,
906      p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null) return boolean is
907 
908    l_count                 number;
909    l_period_of_addition    varchar2(1);
910    l_calling_fn            varchar2(30) := 'fa_cip_pvt.do_validation';
911    val_err                 exception;
912 
913 begin
914 
915    if (p_trans_rec.transaction_type_code = 'ADDITION') then
916 
917       -- validate dpis
918       if not fa_asset_val_pvt.validate_dpis
919               (p_transaction_type_code    => p_trans_rec.transaction_type_code,
920                p_book_type_code           => p_asset_hdr_rec.book_type_code,
921                p_date_placed_in_service   =>
922                   p_asset_fin_rec.date_placed_in_service,
923                p_prorate_convention_code  =>
924                   p_asset_fin_rec.prorate_convention_code,
925                p_calling_fn               => l_calling_fn
926                ,p_log_level_rec => p_log_level_rec) then
927           raise val_err;
928       end if;
929 
930    else
931 
932       -- check addition (don't allow after period of capitalization)
933       if not fa_asset_val_pvt.validate_period_of_addition
934               (p_asset_id            => p_asset_hdr_rec.asset_id,
935                p_book                => p_asset_hdr_rec.book_type_code,
936                p_mode                => 'CAPITALIZED',
937                px_period_of_addition => l_period_of_addition
938                ,p_log_level_rec => p_log_level_rec) then
939           raise val_err;
940       end if;
941 
942       if (p_log_level_rec.statement_level) then
943          fa_debug_pkg.add(l_calling_fn,
944                           'cap period_of_addition', l_period_of_addition
945 				,p_log_level_rec => p_log_level_rec);
946       end if;
947 
948       if (l_period_of_addition = 'N') then
949          fa_srvr_msg.add_message
950               (calling_fn => l_calling_fn,
951                name       => 'FA_CWA_NOT_ADDED_THIS_PERIOD'
952                ,p_log_level_rec => p_log_level_rec);
953          raise val_err;
954       end if;
955 
956       -- chk trx after add (don't allow if any trx after capitalization)
957       if (p_log_level_rec.statement_level) then
958          fa_debug_pkg.add(l_calling_fn,
959                           'checking subsequent trxs', ''
960 				,p_log_level_rec => p_log_level_rec);
961       end if;
962 
963       select count(*)
964         into l_count
965         from fa_transaction_headers th_add,
966              fa_transaction_headers th_other
967        where th_add.asset_id              = p_asset_hdr_rec.asset_id
968          and th_add.book_type_code        = p_asset_hdr_rec.book_type_code
969          and th_add.transaction_type_code = 'ADDITION'
970          and th_other.asset_id            = p_asset_hdr_rec.asset_id
971          and th_other.book_type_code      = p_asset_hdr_rec.book_type_code
972          and th_other.date_effective      > th_add.date_effective;
973 
974       if (l_count <> 0) then
975          fa_srvr_msg.add_message
976               (calling_fn => l_calling_fn,
977                name       => 'FA_CWA_TRX_AFTER_ADDITION'
978                ,p_log_level_rec => p_log_level_rec);
979          raise val_err;
980       end if;
981 
982       -- BUG# 4609532
983       -- removing the following validation due to the fact that
984       -- we now allow cip revaluations
985       -- check invoices cost for corp only
986 
987    end if;  -- capitalize / reverse
988 
989 
990    -- check retirements (pending / full)
991 
992    if (p_log_level_rec.statement_level) then
993       fa_debug_pkg.add(l_calling_fn,
994                        'checking fully ret', ''
995 			,p_log_level_rec => p_log_level_rec);
996    end if;
997 
998    if fa_asset_val_pvt.validate_fully_retired
999       (p_asset_id            => p_asset_hdr_rec.asset_id,
1000        p_book                => p_asset_hdr_rec.book_type_code
1001        ,p_log_level_rec => p_log_level_rec)  then
1002       fa_srvr_msg.add_message
1003          (name       => 'FA_REC_RETIRED',
1004           calling_fn => l_calling_fn
1005           ,p_log_level_rec => p_log_level_rec);
1006       raise val_err;
1007    end if;
1008 
1009    if (p_log_level_rec.statement_level) then
1010       fa_debug_pkg.add(l_calling_fn,
1011                        'checking ret pending', ''
1012 			,p_log_level_rec => p_log_level_rec);
1013    end if;
1014 
1015    if fa_asset_val_pvt.validate_ret_rst_pending
1016       (p_asset_id            => p_asset_hdr_rec.asset_id,
1017        p_book                => p_asset_hdr_rec.book_type_code
1018        ,p_log_level_rec => p_log_level_rec)  then
1019        raise val_err;
1020    end if;
1021 
1022    return true;
1023 
1024 exception
1025    when val_err then
1026       fa_srvr_msg.add_message(calling_fn => l_calling_fn
1027             ,p_log_level_rec => p_log_level_rec);
1028       return false;
1029 
1030    when others then
1031       fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
1032             ,p_log_level_rec => p_log_level_rec);
1033       return false;
1034 
1035 end do_validation;
1036 
1037 ------------------------------------------------------------------------
1038 
1039 END FA_CIP_PVT;