DBA Data[Home] [Help]

PACKAGE BODY: APPS.FA_RETIREMENT_ADJUSTMENT_PUB

Source


1 PACKAGE BODY FA_RETIREMENT_ADJUSTMENT_PUB AS
2 /* $Header: FAPRADJB.pls 120.24.12020000.3 2012/11/30 13:44:46 spooyath ship $ */
3 
4 
5 --*********************** Global constants ******************************--
6 
7 G_PKG_NAME      CONSTANT   varchar2(30) := 'FA_ADJUSTMENT_PUB';
8 G_API_NAME      CONSTANT   varchar2(30) := 'Adjustment API';
9 G_API_VERSION   CONSTANT   number       := 1.0;
10 
11 g_log_level_rec fa_api_types.log_level_rec_type;
12 
13 --*********************** Private functions ******************************--
14 -- This private function calls fa_asset_val_pvt.validate_over_depreciate
15 -- to determine this retirement adjustment is valid or not
16 FUNCTION validate_over_depreciate
17    (p_asset_hdr_rec                   FA_API_TYPES.asset_hdr_rec_type,
18     p_asset_type_rec                  FA_API_TYPES.asset_type_rec_type,
19     p_asset_fin_rec                   FA_API_TYPES.asset_fin_rec_type,
20     p_asset_deprn_rec                 FA_API_TYPES.asset_deprn_rec_type,
21     p_proceeds_of_sale                NUMBER,
22     p_cost_of_removal                 NUMBER,
23     p_log_level_rec                IN fa_api_types.log_level_rec_type
24 ) RETURN BOOLEAN;
25 
26 FUNCTION do_all_books
27    (px_trans_rec               IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
28     px_asset_hdr_rec           IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
29     p_cost_of_removal          IN     NUMBER,
30     p_proceeds                 IN     NUMBER,
31     p_cost_of_removal_ccid     IN     NUMBER,
32     p_proceeds_ccid            IN     NUMBER,
33     p_log_level_rec            IN     fa_api_types.log_level_rec_type
34 ) RETURN BOOLEAN;
35 
36 
37 --*********************** Public procedures ******************************--
38 
39 
40 PROCEDURE do_retirement_adjustment
41    (p_api_version              IN     NUMBER,
42     p_init_msg_list            IN     VARCHAR2 := FND_API.G_FALSE,
43     p_commit                   IN     VARCHAR2 := FND_API.G_FALSE,
44     p_validation_level         IN     NUMBER   := FND_API.G_VALID_LEVEL_FULL,
45     p_calling_fn               IN     VARCHAR2,
46     x_return_status               OUT NOCOPY VARCHAR2,
47     x_msg_count                   OUT NOCOPY NUMBER,
48     x_msg_data                    OUT NOCOPY VARCHAR2,
49 
50     px_trans_rec               IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
51     px_asset_hdr_rec           IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
52     p_cost_of_removal          IN     NUMBER,
53     p_proceeds                 IN     NUMBER,
54     p_cost_of_removal_ccid     IN     NUMBER DEFAULT NULL,
55     p_proceeds_ccid            IN     NUMBER DEFAULT NULL
56 ) IS
57 
58    l_reporting_flag          varchar2(1);
59 
60    l_calling_fn              VARCHAR2(35) := 'fa_ret_adj_pub.do_ret_adj';
61    ret_adj_err               EXCEPTION;
62 
63 BEGIN
64 
65    SAVEPOINT do_retirement_adjustment;
66 
67    if (not g_log_level_rec.initialized) then
68       if (NOT fa_util_pub.get_log_level_rec (
69                 x_log_level_rec =>  g_log_level_rec
70       )) then
71          raise ret_adj_err;
72       end if;
73    end if;
74 
75    -- Initialize message list if p_init_msg_list is set to TRUE.
76    if (fnd_api.to_boolean(p_init_msg_list)) then
77         -- initialize error message stack.
78         fa_srvr_msg.init_server_message;
79 
80         -- initialize debug message stack.
81         fa_debug_pkg.initialize;
82    end if;
83 
84    -- Check version of the API
85    -- Standard call to check for API call compatibility.
86    if NOT fnd_api.compatible_api_call (
87           G_API_VERSION,
88           p_api_version,
89           G_API_NAME,
90           G_PKG_NAME
91          ) then
92       x_return_status := FND_API.G_RET_STS_ERROR;
93       raise ret_adj_err;
94    end if;
95 
96    -- call the cache for the primary transaction book
97    if NOT fa_cache_pkg.fazcbc
98             (X_book => px_asset_hdr_rec.book_type_code,
99              p_log_level_rec => g_log_level_rec) then
100       raise ret_adj_err;
101    end if;
102 
103    -- verify the asset exists in the book already
104    if not FA_ASSET_VAL_PVT.validate_asset_book
105               (p_transaction_type_code      => 'ADJUSTMENT',
106                p_book_type_code             => px_asset_hdr_rec.book_type_code,
107                p_asset_id                   => px_asset_hdr_rec.asset_id,
108                p_calling_fn                 => l_calling_fn,
109                p_log_level_rec              => g_log_level_rec
110               ) then
111       raise ret_adj_err;
112    end if;
113 
114    -- Validate asset_type is Group
115    if not FA_ASSET_VAL_PVT.validate_group_asset_id
116               (p_asset_id                   => px_asset_hdr_rec.asset_id,
117                p_log_level_rec => g_log_level_rec) then
118       raise ret_adj_err;
119    end if;
120 
121    -- Account for transaction submitted from a responsibility
122    -- that is not tied to a SOB_ID by getting the value from
123    -- the book struct
124 
125    -- Get the book type code P,R or N
126    if not fa_cache_pkg.fazcsob
127       (X_set_of_books_id   => fa_cache_pkg.fazcbc_record.set_of_books_id,
128        X_mrc_sob_type_code => l_reporting_flag,
129        p_log_level_rec     => g_log_level_rec) then
130       raise ret_adj_err;
131    end if;
132 
133    --  Error out if the program is submitted from the Reporting Responsibility
134    --  No transaction permitted directly on reporting books.
135 
136    IF l_reporting_flag = 'R' THEN
137       fa_srvr_msg.add_message
138           (calling_fn => l_calling_fn,
139            name => 'MRC_OSP_INVALID_BOOK_TYPE',
140            p_log_level_rec => g_log_level_rec);
141       raise ret_adj_err;
142    END IF;
143 
144    -- end initial MRC validation
145 
146 
147    -- call the mrc wrapper for the transaction book
148 
149    if not do_all_books
150       (px_asset_hdr_rec        => px_asset_hdr_rec,
151        px_trans_rec            => px_trans_rec,
152        p_cost_of_removal       => p_cost_of_removal,
153        p_proceeds              => p_proceeds,
154        p_cost_of_removal_ccid  => p_cost_of_removal_ccid,
155        p_proceeds_ccid         => p_proceeds_ccid,
156        p_log_level_rec         => g_log_level_rec
157       )then
158       raise ret_adj_err;
159    end if;
160 
161    -- no auto-copy / cip in tax for group reclass transactions
162 
163    -- commit if p_commit is TRUE.
164    if (fnd_api.to_boolean (p_commit)) then
165         COMMIT WORK;
166    end if;
167 
168    x_return_status :=  FND_API.G_RET_STS_SUCCESS;
169 
170 EXCEPTION
171 
172    when ret_adj_err then
173       ROLLBACK TO do_retirement_adjustment;
174 
175       fa_srvr_msg.add_message
176         (calling_fn => l_calling_fn,
177          p_log_level_rec => g_log_level_rec);
178 
179       -- do not retrieve / clear messaging when this is being called
180       -- from reclass api - allow calling util to dump them
181 
182       FND_MSG_PUB.count_and_get (
183             p_count => x_msg_count,
184             p_data  => x_msg_data
185          );
186       x_return_status :=  FND_API.G_RET_STS_ERROR;
187 
188    when others then
189       ROLLBACK TO do_retirement_adjustment;
190 
191       fa_srvr_msg.add_sql_error
192         (calling_fn => l_calling_fn,
193          p_log_level_rec => g_log_level_rec);
194 
195       -- do not retrieve / clear messaging when this is being called
196       -- from reclass api - allow calling util to dump them
197       FND_MSG_PUB.count_and_get (
198             p_count => x_msg_count,
199             p_data  => x_msg_data
200          );
201 
202       x_return_status :=  FND_API.G_RET_STS_ERROR;
203 
204 END do_retirement_adjustment;
205 
206 -----------------------------------------------------------------------------
207 
208 -- Books (MRC) Wrapper - called from public API above
209 --
210 -- For non mrc books, this just calls the private API with provided params
211 -- For MRC, it processes the primary and then loops through each reporting
212 -- book calling the private api for each.
213 
214 
215 FUNCTION do_all_books
216    (px_trans_rec               IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
217     px_asset_hdr_rec           IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
218     p_cost_of_removal          IN     NUMBER,
219     p_proceeds                 IN     NUMBER,
220     p_cost_of_removal_ccid     IN     NUMBER,
221     p_proceeds_ccid            IN     NUMBER,
222     p_log_level_rec            IN     fa_api_types.log_level_rec_type
223 ) RETURN BOOLEAN IS
224 
225 
226    -- used for new source asset
227    l_asset_hdr_rec          fa_api_types.asset_hdr_rec_type;
228    l_mrc_asset_hdr_rec      fa_api_types.asset_hdr_rec_type;
229    l_asset_desc_rec         fa_api_types.asset_desc_rec_type;
230    l_asset_type_rec         fa_api_types.asset_type_rec_type;
231    l_asset_cat_rec          fa_api_types.asset_cat_rec_type;
232    l_asset_fin_rec_old      fa_api_types.asset_fin_rec_type;
233    l_asset_fin_rec_new      fa_api_types.asset_fin_rec_type;
234    l_asset_deprn_rec_old    fa_api_types.asset_deprn_rec_type;
235    l_asset_deprn_rec_new    fa_api_types.asset_deprn_rec_type;
236 
237    l_proceeds                   number;
238    l_cost_of_removal            number;
239 
240    l_primary_cost               number;   -- ??? use ???
241 
242    l_period_rec                 FA_API_TYPES.period_rec_type;
243    l_rsob_tbl                   FA_CACHE_PKG.fazcrsob_sob_tbl_type;
244    l_reporting_flag             varchar2(1);
245 
246    l_exchange_rate              number;
247    l_avg_rate                   number;
248 
249    l_rowid                      varchar2(40);
250    l_return_status              boolean;
251 
252    l_calling_fn                 VARCHAR2(35) := 'fa_ret_adj_pub.do_all_books';
253    ret_adj_err                  exception;
254 
255    --Secondary Chnages
256    l_secondary_asset_hdr_rec          fa_api_types.asset_hdr_rec_type;
257    l_secondary_trans_rec                 FA_API_TYPES.trans_rec_type;
258    l_secondary_sob_id                     number;
259 
260 BEGIN
261 
262    -- load the initial values in structs
263    px_asset_hdr_rec.set_of_books_id    := fa_cache_pkg.fazcbc_record.set_of_books_id;
264 
265    l_asset_hdr_rec       := px_asset_hdr_rec;
266 
267    px_trans_rec.transaction_type_code := 'GROUP ADJUSTMENT';  -- **** ??? ****
268    px_trans_rec.transaction_subtype   := 'AMORTIZED';
269    px_trans_rec.transaction_key       := 'GR';
270 
271    -- we need the thid first for inserting clearing into adjustments
272    select fa_transaction_headers_s.nextval
273      into px_trans_rec.transaction_header_id
274      from dual;
275 
276    -- Bug 15877517 : Reinitialize who_info as well
277    px_trans_rec.who_info.creation_date := sysdate;
278    px_trans_rec.who_info.last_update_date := sysdate;
279 
280    -- load the period struct for current period info
281    if not FA_UTIL_PVT.get_period_rec
282           (p_book           => l_asset_hdr_rec.book_type_code,
283            p_effective_date => NULL,
284            x_period_rec     => l_period_rec,
285            p_log_level_rec  => p_log_level_rec
286           ) then
287       raise ret_adj_err;
288    end if;
289 
290    -- note that we need to investigate / determine transaction subtype and track member impacts!!!!
291    -- how to handle amort start / trx_date , etc on the member in all three scenarios
292 
293    px_trans_rec.transaction_date_entered :=
294       greatest(l_period_rec.calendar_period_open_date,
295                least(sysdate,l_period_rec.calendar_period_close_date));
296 
297    if p_cost_of_removal_ccid is not null then
298       if not FA_ASSET_VAL_PVT.validate_ccid(p_book_type_code => fa_cache_pkg.fazcbc_record.book_type_code,
299                 p_ccid                   => p_cost_of_removal_ccid,
300                 p_gl_chart_id            => fa_cache_pkg.fazcbc_record.accounting_flex_structure,
301 		p_ledger_id              => px_asset_hdr_rec.set_of_books_id,
302 		p_validation_date        => px_trans_rec.transaction_date_entered,
303                 p_calling_fn             => l_calling_fn,
304                 p_log_level_rec          => p_log_level_rec
305                ) then
306                return false;
307       end if;
308    end if;
309    if p_proceeds_ccid is not null then
310       if not FA_ASSET_VAL_PVT.validate_ccid(p_book_type_code => fa_cache_pkg.fazcbc_record.book_type_code,
311                 p_ccid                   => p_proceeds_ccid,
312                 p_gl_chart_id            => fa_cache_pkg.fazcbc_record.accounting_flex_structure,
313 		p_ledger_id              => px_asset_hdr_rec.set_of_books_id,
314 		p_validation_date        => px_trans_rec.transaction_date_entered,
315                 p_calling_fn             => l_calling_fn,
316                 p_log_level_rec          => p_log_level_rec
317                ) then
318                return false;
319       end if;
320    end if;
321    -- call transaction approval for source asset
322    if not FA_TRX_APPROVAL_PKG.faxcat
323           (X_book              => px_asset_hdr_rec.book_type_code,
324            X_asset_id          => px_asset_hdr_rec.asset_id,
325            X_trx_type          => px_trans_rec.transaction_type_code,
326            X_trx_date          => px_trans_rec.transaction_date_entered,
327            X_init_message_flag => 'NO',
328            p_log_level_rec     => p_log_level_rec
329           ) then
330       raise ret_adj_err;
331    end if;
332 
333 
334    -- also check if this is the period of addition - use absolute mode for adjustments
335    -- we will only clear cost outside period of addition
336    if not FA_ASSET_VAL_PVT.validate_period_of_addition
337              (p_asset_id            => l_asset_hdr_rec.asset_id,
338               p_book                => l_asset_hdr_rec.book_type_code,
339               p_mode                => 'ABSOLUTE',
340               px_period_of_addition => l_asset_hdr_rec.period_of_addition,
341               p_log_level_rec       => p_log_level_rec
342              ) then
343       raise ret_adj_err;
344    end if;
345 
346 
347    -- pop the structs for the non-fin information needed for trx
348    -- source
349    if not FA_UTIL_PVT.get_asset_desc_rec
350           (p_asset_hdr_rec          => l_asset_hdr_rec,
351            px_asset_desc_rec        => l_asset_desc_rec,
352            p_log_level_rec          => p_log_level_rec
353           ) then
354       raise ret_adj_err;
355    end if;
356 
357    if not FA_UTIL_PVT.get_asset_cat_rec
358           (p_asset_hdr_rec          => l_asset_hdr_rec,
359            px_asset_cat_rec         => l_asset_cat_rec,
360            p_date_effective         => null,
361            p_log_level_rec          => p_log_level_rec
362           ) then
363       raise ret_adj_err;
364    end if;
365 
366    if not FA_UTIL_PVT.get_asset_type_rec
367           (p_asset_hdr_rec         => l_asset_hdr_rec,
368            px_asset_type_rec       => l_asset_type_rec,
369            p_date_effective        => null,
370            p_log_level_rec         => p_log_level_rec
371           ) then
372       raise ret_adj_err;
373    end if;
374 
375    -- Call the reporting books cache to get rep books.
376    if (NOT fa_cache_pkg.fazcrsob (
377              x_book_type_code => l_asset_hdr_rec.book_type_code,
378              x_sob_tbl        => l_rsob_tbl,
379              p_log_level_rec  => p_log_level_rec
380             )) then
381        raise ret_adj_err;
382    end if;
383 
384    if not FA_XLA_EVENTS_PVT.create_transaction_event
385             (p_asset_hdr_rec          => px_asset_hdr_rec,
386              p_asset_type_rec         => l_asset_type_rec,
387              px_trans_rec             => px_trans_rec,
388              p_event_status           => NULL,
389              p_calling_fn             => l_calling_fn,
390              p_log_level_rec          => p_log_level_rec
391             ) then
392       raise ret_adj_err;
393    end if;
394 
395    fa_transaction_headers_pkg.insert_row
396       (x_rowid                    => l_rowid,
397        x_transaction_header_id    => px_trans_rec.transaction_header_id,
398        x_book_type_code           => px_asset_hdr_rec.book_type_code,
399        x_asset_id                 => px_asset_hdr_rec.asset_id,
400        x_transaction_type_code    => px_trans_rec.transaction_type_code,
401        x_transaction_date_entered => px_trans_rec.transaction_date_entered,
402        x_date_effective           => px_trans_rec.who_info.last_update_date,
403        x_last_update_date         => px_trans_rec.who_info.last_update_date,
404        x_last_updated_by          => px_trans_rec.who_info.last_updated_by,
405        x_transaction_name         => px_trans_rec.transaction_name,
406        x_last_update_login        => px_trans_rec.who_info.last_update_login,
407        x_transaction_key          => px_trans_rec.transaction_key,
408        x_transaction_subtype      => px_trans_rec.transaction_subtype,
409        x_amortization_start_date  => px_trans_rec.amortization_start_date,
410        x_calling_interface        => px_trans_rec.calling_interface,
411        x_mass_transaction_id      => px_trans_rec.mass_transaction_id,
412        x_trx_reference_id         => px_trans_rec.trx_reference_id,
413        x_event_id                 => px_trans_rec.event_id,
414        x_return_status            => l_return_status,
415        x_calling_fn               => l_calling_fn,
416        p_log_level_rec            => p_log_level_rec);
417 
418    for l_mrc_index in 0..l_rsob_tbl.COUNT loop
419 
420       l_mrc_asset_hdr_rec  := l_asset_hdr_rec;
421 
422       if (l_mrc_index  = 0) then
423          l_mrc_asset_hdr_rec.set_of_books_id  := fa_cache_pkg.fazcbc_record.set_of_books_id;
424          l_reporting_flag := 'P';
425       else
426          l_mrc_asset_hdr_rec.set_of_books_id  := l_rsob_tbl(l_mrc_index);
427          l_reporting_flag := 'R';
428       end if;
429 
430       -- Need to always call fazcbcs
431       if (NOT fa_cache_pkg.fazcbcs (
432                 X_book => l_mrc_asset_hdr_rec.book_type_code,
433                 X_set_of_books_id => l_mrc_asset_hdr_rec.set_of_books_id,
434                 p_log_level_rec => p_log_level_rec
435                )) then
436          raise ret_adj_err;
437       end if;
438 
439       -- get the old fin and deprn information
440       if not FA_UTIL_PVT.get_asset_fin_rec
441               (p_asset_hdr_rec         => l_mrc_asset_hdr_rec,
442                px_asset_fin_rec        => l_asset_fin_rec_old,
443                p_transaction_header_id => NULL,
444                p_mrc_sob_type_code     => l_reporting_flag,
445                p_log_level_rec         => p_log_level_rec
446               ) then
447          raise ret_adj_err;
448       end if;
449 
450       --HH validate disabled_flag
451       if not FA_ASSET_VAL_PVT.validate_disabled_flag
452                   (p_group_asset_id => l_mrc_asset_hdr_rec.asset_id,
453                    p_book_type_code => l_mrc_asset_hdr_rec.book_type_code,
454                    p_old_flag       => l_asset_fin_rec_old.disabled_flag,
455                    p_new_flag       => l_asset_fin_rec_old.disabled_flag,
456                    p_log_level_rec  => p_log_level_rec
457                   ) then
458          raise ret_adj_err;
459       end if; -- end HH
460 
461       if not FA_UTIL_PVT.get_asset_deprn_rec
462               (p_asset_hdr_rec         => l_mrc_asset_hdr_rec ,
463                px_asset_deprn_rec      => l_asset_deprn_rec_old,
464                p_period_counter        => NULL,
465                p_mrc_sob_type_code     => l_reporting_flag,
466                p_log_level_rec         => p_log_level_rec
467               ) then
468          raise ret_adj_err;
469       end if;
470 
471       -- in order to derive the transfer amount for the reporting
472       -- books, we will use a ratio of the primary amount / primary cost
473       -- for the source asset
474 
475       if (l_mrc_index = 0) then
476          l_proceeds        := p_proceeds;
477          l_cost_of_removal := p_cost_of_removal;
478          l_primary_cost    := l_asset_fin_rec_old.cost;
479       else
480          if (l_primary_cost <> 0) then
481             l_proceeds        := p_proceeds        * (l_asset_fin_rec_old.cost / l_primary_cost);
482             l_cost_of_removal := p_cost_of_removal * (l_asset_fin_rec_old.cost / l_primary_cost);
483          else
484             -- get the latest average rate (used conditionally in some cases below)
485             if not fa_mc_util_pvt.get_latest_rate
486                    (p_asset_id            => l_mrc_asset_hdr_rec.asset_id,
487                     p_book_type_code      => l_mrc_asset_hdr_rec.book_type_code,
488                     p_set_of_books_id     => l_mrc_asset_hdr_rec.set_of_books_id,
489                     px_rate               => l_exchange_rate,
490                     px_avg_exchange_rate  => l_avg_rate,
491                     p_log_level_rec       => p_log_level_rec
492                    ) then
493                raise ret_adj_err;
494             end if;
495 
496             l_proceeds        := p_proceeds        * l_avg_rate;
497             l_cost_of_removal := p_cost_of_removal * l_avg_rate;
498 
499          end if;
500       end if;
501 
502       if not validate_over_depreciate
503              (p_asset_hdr_rec         => l_mrc_asset_hdr_rec,
504               p_asset_type_rec        => l_asset_type_rec,
505               p_asset_fin_rec         => l_asset_fin_rec_old,
506               p_asset_deprn_rec       => l_asset_deprn_rec_old,
507               p_proceeds_of_sale      => l_proceeds,
508               p_cost_of_removal       => l_cost_of_removal,
509               p_log_level_rec         => p_log_level_rec
510              ) then
511          raise ret_adj_err;
512       end if;
513 
514       -- now call the private api to do the processing
515 
516       if not FA_RETIREMENT_ADJUSTMENT_PVT.do_retirement_adjustment
517                (px_trans_rec              => px_trans_rec,
518                 px_asset_hdr_rec          => l_mrc_asset_hdr_rec,
519                 p_asset_desc_rec          => l_asset_desc_rec,
520                 p_asset_type_rec          => l_asset_type_rec,
521                 p_asset_cat_rec           => l_asset_cat_rec,
522                 p_asset_fin_rec_old       => l_asset_fin_rec_old,
523                 x_asset_fin_rec_new       => l_asset_fin_rec_new,
524                 p_asset_deprn_rec_old     => l_asset_deprn_rec_old,
525                 x_asset_deprn_rec_new     => l_asset_deprn_rec_new,
526                 p_period_rec              => l_period_rec,
527                 p_mrc_sob_type_code       => l_reporting_flag,
528                 p_cost_of_removal         => l_cost_of_removal,
529                 p_proceeds                => l_proceeds,
530                 p_cost_of_removal_ccid    => p_cost_of_removal_ccid,
531                 p_proceeds_ccid           => p_proceeds_ccid,
532                 p_log_level_rec           => p_log_level_rec
533                ) then
534          raise ret_adj_err;
535       end if; -- do_adjustment
536       l_secondary_sob_id := FA_XLA_EVENTS_PVT.get_secondary_sob_id(px_asset_hdr_rec.book_type_code);
537       if(l_reporting_flag = 'R') and (fa_cache_pkg.fazcbc_record.set_of_books_id <> l_mrc_asset_hdr_rec.set_of_books_id) and (l_secondary_sob_id = l_mrc_asset_hdr_rec.set_of_books_id) then
538            l_secondary_asset_hdr_rec                         := px_asset_hdr_rec;
539             l_secondary_trans_rec                               := px_trans_rec;
540            l_secondary_asset_hdr_rec.set_of_books_id :=  l_mrc_asset_hdr_rec.set_of_books_id;
541            if not FA_XLA_EVENTS_PVT.create_transaction_event
542                     (p_asset_hdr_rec          => l_secondary_asset_hdr_rec,
543                      p_asset_type_rec         => l_asset_type_rec,
544                      px_trans_rec             => l_secondary_trans_rec,
545                      p_event_status           => NULL,
546                      p_calling_fn             => l_calling_fn,
547                      p_log_level_rec          => p_log_level_rec
548                     ) then
549               raise ret_adj_err;
550            end if;
551       end if;
552    end loop;
553 
554    return true;
555 
556 EXCEPTION
557 
558    WHEN ret_adj_err THEN
559       fa_srvr_msg.add_message
560         (calling_fn => l_calling_fn,
561          p_log_level_rec => p_log_level_rec);
562       return FALSE;
563 
564    WHEN OTHERS THEN
565       fa_srvr_msg.add_sql_error
566         (calling_fn => l_calling_fn,
567          p_log_level_rec => p_log_level_rec);
568       return FALSE;
569 
570 
571 end do_all_books;
572 
573 FUNCTION validate_over_depreciate
574    (p_asset_hdr_rec                   FA_API_TYPES.asset_hdr_rec_type,
575     p_asset_type_rec                  FA_API_TYPES.asset_type_rec_type,
576     p_asset_fin_rec                   FA_API_TYPES.asset_fin_rec_type,
577     p_asset_deprn_rec                 FA_API_TYPES.asset_deprn_rec_type,
578     p_proceeds_of_sale                NUMBER,
579     p_cost_of_removal                 NUMBER,
580     p_log_level_rec                IN fa_api_types.log_level_rec_type) RETURN BOOLEAN IS
581 
582    l_deprn_reserve_new  NUMBER := 0;
583 BEGIN
584 
585    l_deprn_reserve_new := nvl(p_asset_deprn_rec.deprn_reserve, 0) +
586                           nvl(p_proceeds_of_sale, 0) -
587                           nvl(p_cost_of_removal, 0);
588 
589    if (not fa_asset_val_pvt.validate_over_depreciate(
590               p_asset_hdr_rec              => p_asset_hdr_rec,
591               p_asset_type                 => p_asset_type_rec.asset_type,
592               p_over_depreciate_option     => p_asset_fin_rec.over_depreciate_option,
593               p_adjusted_recoverable_cost  => p_asset_fin_rec.adjusted_recoverable_cost,
594               p_recoverable_cost           => p_asset_fin_rec.recoverable_cost,
595               p_deprn_reserve_new          => l_deprn_reserve_new,
596               p_log_level_rec              => p_log_level_rec)) then
597 
598       return false;
599    end if;
600 
601    return TRUE;
602 
603 END validate_over_depreciate;
604 
605 END FA_RETIREMENT_ADJUSTMENT_PUB ;