[Home] [Help]
PACKAGE BODY: APPS.FA_INS_ADJ_PVT
Source
1 PACKAGE BODY FA_INS_ADJ_PVT AS
2 /* $Header: FAVIATB.pls 120.12 2011/01/04 12:45:55 gigupta ship $ */
3
4 Function faxiat
5 (p_trans_rec IN FA_API_TYPES.trans_rec_type,
6 p_asset_hdr_rec IN FA_API_TYPES.asset_hdr_rec_type,
7 p_asset_desc_rec IN FA_API_TYPES.asset_desc_rec_type,
8 p_asset_cat_rec IN FA_API_TYPES.asset_cat_rec_type,
9 p_asset_type_rec IN FA_API_TYPES.asset_type_rec_type,
10 p_cost IN number DEFAULT 0,
11 p_clearing IN number DEFAULT 0,
12 p_deprn_expense IN number DEFAULT 0,
13 p_bonus_expense IN number DEFAULT 0,
14 p_impair_expense IN number DEFAULT 0,
15 p_deprn_reserve IN number DEFAULT 0,
16 p_bonus_reserve IN number DEFAULT 0,
17 p_ann_adj_amt IN number DEFAULT 0,
18 p_track_member_flag IN varchar2 DEFAULT NULL,
19 p_mrc_sob_type_code IN VARCHAR2,
20 p_calling_fn IN VARCHAR2
21 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type) return boolean is
22
23 l_adj fa_adjust_type_pkg.fa_adj_row_struct;
24 l_clear_adj fa_adjust_type_pkg.fa_adj_row_struct;
25
26 l_mesg_name varchar2(30);
27 l_action_buf varchar2(30);
28 l_calling_fn varchar2(35) := 'FA_INS_ADJ_PVT.faxiat';
29
30 l_cost_acct Varchar2(240);
31 l_clearing_acct Varchar2(240);
32 l_cost_acct_type Varchar2(240);
33 l_clearing_acct_type Varchar2(240);
34 l_source Varchar2(240);
35 l_tracking_method Varchar2(30);
36 l_member_rollup_flag Varchar2(1);
37
38 i number := 0;
39 inv number := 0;
40 l_bool_dummy boolean;
41 error_found exception;
42
43 begin
44
45 if not fa_cache_pkg.fazcct(fa_cache_pkg.fazcbc_record.deprn_calendar, p_log_level_rec => p_log_level_rec) then
46 raise error_found;
47 end if;
48
49 l_adj.transaction_header_id := p_trans_rec.transaction_header_id;
50 l_adj.asset_id := p_asset_hdr_rec.asset_id;
51 l_adj.book_type_code := p_asset_hdr_rec.book_type_code;
52 l_adj.period_counter_created := fa_cache_pkg.fazcbc_record.last_period_counter + 1;
53 l_adj.period_counter_adjusted := fa_cache_pkg.fazcbc_record.last_period_counter + 1;
54 l_adj.current_units := p_asset_desc_rec.current_units ;
55 l_adj.selection_mode := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
56 l_adj.selection_thid := 0;
57 l_adj.selection_retid := 0;
58 l_adj.leveling_flag := TRUE;
59 l_adj.last_update_date := p_trans_rec.who_info.last_update_date;
60
61 l_adj.flush_adj_flag := FALSE;
62 l_adj.gen_ccid_flag := TRUE;
63 l_adj.annualized_adjustment := 0;
64 l_adj.asset_invoice_id := 0;
65 l_adj.code_combination_id := 0;
66 l_adj.distribution_id := 0;
67
68 l_adj.deprn_override_flag:= '';
69
70 if not fa_cache_pkg.fazccb
71 (p_asset_hdr_rec.book_type_code,
72 p_asset_cat_rec.category_id , p_log_level_rec => p_log_level_rec) then
73 raise error_found;
74 end if;
75
76
77 l_source := p_trans_rec.transaction_type_code;
78
79 --BUG FIX 5410699
80 if(substr(l_source,1,5) = 'GROUP')then
81 l_source := substr(l_source,7,length(l_source));
82 end if;
83
84
85 if p_asset_type_rec.asset_type = 'CIP' then
86 l_cost_acct_type := 'CIP_COST_ACCT';
87 l_clearing_acct_type := 'CIP_CLEARING_ACCT';
88 l_cost_acct := fa_cache_pkg.fazccb_record.CIP_COST_ACCT;
89 l_clearing_acct := fa_cache_pkg.fazccb_record.CIP_CLEARING_ACCT;
90 else
91 l_cost_acct_type := 'ASSET_COST_ACCT';
92 l_clearing_acct_type := 'ASSET_CLEARING_ACCT';
93 l_cost_acct := fa_cache_pkg.fazccb_record.ASSET_COST_ACCT;
94 l_clearing_acct := fa_cache_pkg.fazccb_record.ASSET_CLEARING_ACCT;
95 end if;
96
97 -- first, process the COST row
98
99 if (p_cost <> 0 and p_asset_type_rec.asset_type <> 'GROUP') then
100
101 l_adj.source_type_code := l_source;
102 l_adj.adjustment_type := 'COST';
103 l_adj.account := l_cost_acct;
104 l_adj.account_type := l_cost_acct_type;
105
106 if p_cost > 0 then
107 l_adj.debit_credit_flag := 'DR';
108 l_adj.adjustment_amount := p_cost;
109 else
110 l_adj.debit_credit_flag := 'CR';
111 l_adj.adjustment_amount := -p_cost;
112 end if;
113
114 l_adj.mrc_sob_type_code := p_mrc_sob_type_code;
115 l_adj.set_of_books_id := p_asset_hdr_rec.set_of_books_id;
116
117 if not FA_INS_ADJUST_PKG.faxinaj
118 (l_adj,
119 p_trans_rec.who_info.last_update_date,
120 p_trans_rec.who_info.last_updated_by,
121 p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
122 raise error_found;
123 end if;
124
125 end if;
126
127
128 -- clear the difference between the cleared payables and total cost
129 -- to the account built using category accounts
130
131 if (p_clearing <> 0 and p_asset_type_rec.asset_type <> 'GROUP') then
132
133 l_adj.source_type_code := l_source;
134 l_adj.adjustment_type := 'COST CLEARING';
135 l_adj.account := l_clearing_acct;
136 l_adj.account_type := l_clearing_acct_type;
137
138 if p_clearing > 0 then
139 l_adj.debit_credit_flag := 'CR';
140 l_adj.adjustment_amount := p_clearing;
141 else
142 l_adj.debit_credit_flag := 'DR';
143 l_adj.adjustment_amount := -p_clearing;
144 end if;
145
146 l_adj.mrc_sob_type_code := p_mrc_sob_type_code;
147 l_adj.set_of_books_id := p_asset_hdr_rec.set_of_books_id;
148
149 if not FA_INS_ADJUST_PKG.faxinaj
150 (l_adj,
151 p_trans_rec.who_info.last_update_date,
152 p_trans_rec.who_info.last_updated_by,
153 p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
154 raise error_found;
155 end if;
156 end if;
157
158 l_adj.annualized_adjustment := nvl(p_ann_adj_amt, 0);
159
160 -- insert the depreciation expense
161 if p_deprn_expense <> 0 then
162
163 l_adj.source_type_code := 'DEPRECIATION';
164 l_adj.adjustment_type := 'EXPENSE';
165 l_adj.debit_credit_flag := 'DR';
166 l_adj.account_type := 'DEPRN_EXPENSE_ACCT';
167 l_adj.account := FA_CACHE_PKG.fazccb_record.deprn_expense_acct;
168 l_adj.adjustment_amount := p_deprn_expense;
169
170 -- manual override
171 FA_DEBUG_PKG.ADD
172 (fname => 'FA_AMORT_PKG.faxiat',
173 element => 'faxiat: deprn_override_flag',
174 value => p_trans_rec.deprn_override_flag, p_log_level_rec => p_log_level_rec);
175
176 if p_trans_rec.deprn_override_flag in (fa_std_types.FA_OVERRIDE_DPR,
177 fa_std_types.FA_OVERRIDE_BONUS,
178 fa_std_types.FA_OVERRIDE_DPR_BONUS) then
179 l_adj.deprn_override_flag:= 'Y';
180 else
181 l_adj.deprn_override_flag:= '';
182 end if;
183 -- End of Manual Override
184
185 if nvl(p_track_member_flag, 'N') = 'Y' then
186 l_adj.track_member_flag := 'Y';
187 else
188 l_adj.track_member_flag := null;
189 end if;
190
191 l_adj.mrc_sob_type_code := p_mrc_sob_type_code;
192 l_adj.set_of_books_id := p_asset_hdr_rec.set_of_books_id;
193
194 if not FA_INS_ADJUST_PKG.faxinaj
195 (l_adj,
196 p_trans_rec.who_info.last_update_date,
197 p_trans_rec.who_info.last_updated_by,
198 p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
199 raise error_found;
200 end if;
201
202 /* Bug 6666666 : Added for SORP Compliance (via Bug 7590545) */
203 /* Creating SORP Neutralizing entries */
204 if FA_CACHE_PKG.fazcbc_record.sorp_enabled_flag = 'Y' then
205 if not FA_SORP_UTIL_PVT.create_sorp_neutral_acct (
206 p_amount => p_deprn_expense,
207 p_reversal => 'N',
208 p_adj => l_adj,
209 p_created_by => NULL,
210 p_creation_date => NULL,
211 p_last_update_date => p_trans_rec.who_info.last_update_date,
212 p_last_updated_by => p_trans_rec.who_info.last_updated_by,
213 p_last_update_login => p_trans_rec.who_info.last_update_login,
214 p_who_mode => 'UPDATE'
215 , p_log_level_rec => p_log_level_rec) then
216 raise error_found;
217 end if;
218 end if;
219 /*End of Bug 6666666 */
220 end if;
221
222
223 -- insert the bonus expense
224 if p_bonus_expense <> 0 then
225
226 l_adj.source_type_code := 'DEPRECIATION';
227 l_adj.adjustment_type := 'BONUS EXPENSE';
228 l_adj.debit_credit_flag := 'DR';
229 l_adj.account_type := 'BONUS_DEPRN_EXPENSE_ACCT';
230 l_adj.account := FA_CACHE_PKG.fazccb_record.bonus_deprn_expense_acct;
231 l_adj.adjustment_amount := p_bonus_expense;
232
233 -- Manual Override
234 if p_trans_rec.deprn_override_flag in (fa_std_types.FA_OVERRIDE_BONUS,
235 fa_std_types.FA_OVERRIDE_DPR_BONUS) then
236 l_adj.deprn_override_flag:= 'Y';
237 else
238 l_adj.deprn_override_flag:= '';
239 end if;
240 -- End of Manual Override
241
242 l_adj.mrc_sob_type_code := p_mrc_sob_type_code;
243 l_adj.set_of_books_id := p_asset_hdr_rec.set_of_books_id;
244
245 if not FA_INS_ADJUST_PKG.faxinaj
246 (l_adj,
247 p_trans_rec.who_info.last_update_date,
248 p_trans_rec.who_info.last_updated_by,
249 p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
250 raise error_found;
251 end if;
252 end if;
253
254 if p_impair_expense <> 0 then
255
256 l_adj.source_type_code := 'DEPRECIATION';
257 l_adj.adjustment_type := 'IMPAIR EXPENSE';
258 l_adj.debit_credit_flag := 'DR';
259 l_adj.account_type := 'IMPAIR_EXPENSE_ACCT';
260 l_adj.account := FA_CACHE_PKG.fazccb_record.impair_expense_acct;
261 l_adj.adjustment_amount := p_impair_expense;
262
263 -- Manual Override
264 if p_trans_rec.deprn_override_flag in (fa_std_types.FA_OVERRIDE_IMPAIR,
265 fa_std_types.FA_OVERRIDE_DPR_IMPAIR) then
266
267 l_adj.deprn_override_flag:= 'Y';
268 else
269 l_adj.deprn_override_flag:= '';
270 end if;
271 -- End of Manual Override
272
273 l_adj.mrc_sob_type_code := p_mrc_sob_type_code;
274 l_adj.set_of_books_id := p_asset_hdr_rec.set_of_books_id;
275
276 if not FA_INS_ADJUST_PKG.faxinaj
277 (l_adj,
278 p_trans_rec.who_info.last_update_date,
279 p_trans_rec.who_info.last_updated_by,
280 p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
281 raise error_found;
282 end if;
283 /*For 8520733 during 10160292 to create neutralization entries */
284 if FA_CACHE_PKG.fazcbc_record.sorp_enabled_flag = 'Y' then
285 if not FA_SORP_UTIL_PVT.create_sorp_neutral_acct (
286 p_amount => p_impair_expense,
287 p_reversal => 'N',
288 p_adj => l_adj,
289 p_created_by => NULL,
290 p_creation_date => NULL,
291 p_last_update_date => p_trans_rec.who_info.last_update_date,
292 p_last_updated_by => p_trans_rec.who_info.last_updated_by,
293 p_last_update_login => p_trans_rec.who_info.last_update_login,
294 p_who_mode => 'UPDATE'
295 , p_log_level_rec => p_log_level_rec) then
296 raise error_found;
297 end if;
298 end if;
299 end if;
300
301 -- insert the reserve
302 if p_deprn_reserve <> 0 then
303
304 l_adj.source_type_code := l_source;
305 l_adj.adjustment_type := 'RESERVE';
306 l_adj.account_type := 'DEPRN_RESERVE_ACCT';
307 l_adj.account := FA_CACHE_PKG.fazccb_record.deprn_reserve_acct;
308
309 if p_deprn_reserve > 0 then
310 l_adj.debit_credit_flag := 'CR';
311 l_adj.adjustment_amount := p_deprn_reserve;
312 else
313 l_adj.debit_credit_flag := 'DR';
314 l_adj.adjustment_amount := -p_deprn_reserve;
315 end if;
316
317 l_adj.mrc_sob_type_code := p_mrc_sob_type_code;
318 l_adj.set_of_books_id := p_asset_hdr_rec.set_of_books_id;
319
320 if not FA_INS_ADJUST_PKG.faxinaj
321 (l_adj,
322 p_trans_rec.who_info.last_update_date,
323 p_trans_rec.who_info.last_updated_by,
324 p_trans_rec.who_info.last_update_login
325 ,p_log_level_rec => p_log_level_rec) then
326 raise error_found;
327 end if;
328 end if;
329
330 -- insert the bonus reserve
331 if p_bonus_reserve <> 0 then
332
333 l_adj.source_type_code := l_source;
334 l_adj.adjustment_type := 'BONUS RESERVE';
335 l_adj.account_type := 'BONUS_DEPRN_RESERVE_ACCT';
336 l_adj.account := FA_CACHE_PKG.fazccb_record.bonus_deprn_reserve_acct;
337
338 if p_bonus_reserve > 0 then
339 l_adj.debit_credit_flag := 'CR';
340 l_adj.adjustment_amount := p_bonus_reserve;
341 else
342 l_adj.debit_credit_flag := 'DR';
343 l_adj.adjustment_amount := -p_bonus_reserve;
344 end if;
345
346 l_adj.mrc_sob_type_code := p_mrc_sob_type_code;
347 l_adj.set_of_books_id := p_asset_hdr_rec.set_of_books_id;
348
349 if not FA_INS_ADJUST_PKG.faxinaj
350 (l_adj,
351 p_trans_rec.who_info.last_update_date,
352 p_trans_rec.who_info.last_updated_by,
353 p_trans_rec.who_info.last_update_login
354 ,p_log_level_rec => p_log_level_rec) then
355 raise error_found;
356 end if;
357 end if;
358
359 -- flush fa_adjustments
360 l_adj.transaction_header_id := 0;
361 l_adj.flush_adj_flag := TRUE;
362 l_adj.leveling_flag := TRUE;
363
364 if not FA_INS_ADJUST_PKG.faxinaj
365 (l_adj,
366 p_trans_rec.who_info.last_update_date,
367 p_trans_rec.who_info.last_updated_by,
368 p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
369 raise error_found;
370 end if;
371
372 return true;
373
374 EXCEPTION
375 WHEN error_found THEN
376 fa_srvr_msg.add_message(
377 calling_fn => l_calling_fn, p_log_level_rec => p_log_level_rec);
378 return (FALSE);
379
380 WHEN others THEN
381 fa_srvr_msg.add_sql_error
382 (calling_fn => l_calling_fn, p_log_level_rec => p_log_level_rec);
383 return (FALSE);
384
385 end faxiat;
386
387 End FA_INS_ADJ_PVT;