[Home] [Help]
PACKAGE BODY: APPS.XLA_00707_AAD_S_000007_BC_PKG
Source
1 PACKAGE BODY XLA_00707_AAD_S_000007_BC_PKG AS
2 --
3 /*======================================================================+
4 | Copyright (c) 1997 Oracle Corporation |
5 | Redwood Shores, CA, USA |
6 | All rights reserved. |
7 +=======================================================================+
8 | Package Name |
9 | XLA_00707_AAD_S_000007_BC_PKG |
10 | |
11 | DESCRIPTION |
12 | Package generated From Product Accounting Definition |
13 | Name : Federal Costing Application Accounting Definition |
14 | Code : FV_CST_AAD |
15 | Owner : PRODUCT |
16 | Version : |
17 | AMB Context Code: DEFAULT |
18 | HISTORY |
19 | Generated at 30-03-2009 at 05:03:33 by user ANONYMOUS |
20 +=======================================================================*/
21 --
22 --
23 TYPE t_rec_array_event IS RECORD
24 (array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
25 ,array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
26 ,array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L
27 ,array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
28 ,array_event_id xla_number_array_type --XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
29 ,array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L
30 ,array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L
31 ,array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
32 ,array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
33 ,array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
34 ,array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
35 ,array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
36 ,array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
37 ,array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
38 ,array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
39 ,array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
40 ,array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
41 ,array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
42 ,array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
43 ,array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
44 ,array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
45 ,array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L
46 );
47 --
48 type t_array_value_num is table of number index by varchar2(30);
49 type t_array_value_char is table of varchar2(240) index by varchar2(30);
50 type t_array_value_date is table of date index by varchar2(30);
51
52 type t_rec_value is record
53 (array_value_num t_array_value_num
54 ,array_value_char t_array_value_char
55 ,array_value_date t_array_value_date);
56
57 type t_array_event is table of t_rec_value index by binary_integer;
58
59 g_array_event t_array_event;
60
61 --=============================================================================
62 -- *********** Diagnostics **********
63 --=============================================================================
64
65 g_diagnostics_mode VARCHAR2(1);
66 g_last_hdr_idx NUMBER; -- 4262811 MPA
67 g_hdr_extract_count PLS_INTEGER;
68
69 --=============================================================================
70 -- *********** Local Trace Routine **********
71 --=============================================================================
72
73 C_LEVEL_STATEMENT CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
74 C_LEVEL_PROCEDURE CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
75 C_LEVEL_EVENT CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
76 C_LEVEL_EXCEPTION CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
77 C_LEVEL_ERROR CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
78 C_LEVEL_UNEXPECTED CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
79
80 C_LEVEL_LOG_DISABLED CONSTANT NUMBER := 99;
81 C_DEFAULT_MODULE CONSTANT VARCHAR2(240) := 'xla.plsql.XLA_00707_AAD_S_000007_BC_PKG';
82
83 C_CHAR CONSTANT VARCHAR2(30) := fnd_global.local_chr(12); -- 4219869 Business flow
84 C_NUM CONSTANT NUMBER := 9.99E125; -- 4219869 Business flow
85
86 g_log_level NUMBER;
87 g_log_enabled BOOLEAN;
88
89 PROCEDURE trace
90 (p_msg IN VARCHAR2
91 ,p_level IN NUMBER
92 ,p_module IN VARCHAR2 ) IS
93 BEGIN
94 ----------------------------------------------------------------------------
95 -- Following is for FND log.
96 ----------------------------------------------------------------------------
97 IF (p_msg IS NULL AND p_level >= g_log_level) THEN
98 fnd_log.message(p_level, p_module);
99 ELSIF p_level >= g_log_level THEN
100 fnd_log.string(p_level, p_module, p_msg);
101 END IF;
102
103 EXCEPTION
104 WHEN xla_exceptions_pkg.application_exception THEN
105 RAISE;
106 WHEN OTHERS THEN
107 xla_exceptions_pkg.raise_message
108 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.trace');
109 END trace;
110
111 --
112 --+============================================+
113 --| |
114 --| PRIVATE PROCEDURES/FUNCTIONS |
115 --| |
116 --+============================================+
117 --
118
119 --
120 /*======================================================================+
121 | |
122 | Private Function |
123 | ValidateLookupMeaning |
124 | |
125 +======================================================================*/
126 FUNCTION ValidateLookupMeaning(
127 p_meaning IN VARCHAR2
128 , p_lookup_code IN VARCHAR2
129 , p_lookup_type IN VARCHAR2
130 , p_source_code IN VARCHAR2
131 , p_source_type_code IN VARCHAR2
132 , p_source_application_id IN INTEGER
133 )
134 RETURN VARCHAR2
135 IS
136 l_log_module VARCHAR2(240);
137 BEGIN
138 IF g_log_enabled THEN
139 l_log_module := C_DEFAULT_MODULE||'.ValidateLookupMeaning';
140 END IF;
141 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
142 trace
143 (p_msg => 'BEGIN of ValidateLookupMeaning'
144 ,p_level => C_LEVEL_PROCEDURE
145 ,p_module => l_log_module);
146 END IF;
147 --
148 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
149 trace
150 (p_msg => 'p_source_code = '|| p_source_code||
151 ' - p_source_type_code = '|| p_source_type_code||
152 ' - p_source_application_id = '|| p_source_application_id||
153 ' - p_lookup_code = '|| p_lookup_code||
154 ' - p_lookup_type = '|| p_lookup_type||
155 ' - p_meaning = '|| p_meaning
156 ,p_level => C_LEVEL_PROCEDURE
157 ,p_module => l_log_module);
158
159 END IF;
160
161 IF p_lookup_code IS NOT NULL AND p_meaning IS NULL THEN
162 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
163 xla_accounting_err_pkg. build_message
164 (p_appli_s_name => 'XLA'
165 ,p_msg_name => 'XLA_AP_NO_LOOKUP_MEANING'
166 ,p_token_1 => 'SOURCE_NAME'
167 ,p_value_1 => xla_ae_sources_pkg.GetSourceName(
168 p_source_code
169 , p_source_type_code
170 , p_source_application_id
171 )
172 ,p_token_2 => 'LOOKUP_CODE'
173 ,p_value_2 => p_lookup_code
174 ,p_token_3 => 'LOOKUP_TYPE'
175 ,p_value_3 => p_lookup_type
176 ,p_token_4 => 'PRODUCT_NAME'
177 ,p_value_4 => xla_ae_journal_entry_pkg.g_cache_event.application_name
178 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
179 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
180 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
181 );
182
183 IF (C_LEVEL_ERROR >= g_log_level) THEN
184 trace
185 (p_msg => 'ERROR: XLA_AP_NO_LOOKUP_MEANING'
186 ,p_level => C_LEVEL_ERROR
187 ,p_module => l_log_module);
188 END IF;
189 END IF;
190
191 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
192 trace
193 (p_msg => 'END of ValidateLookupMeaning'
194 ,p_level => C_LEVEL_PROCEDURE
195 ,p_module => l_log_module);
196 END IF;
197 RETURN p_meaning;
198 EXCEPTION
199 WHEN xla_exceptions_pkg.application_exception THEN
200 RETURN p_meaning;
201 WHEN OTHERS THEN
202 xla_exceptions_pkg.raise_message
203 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.ValidateLookupMeaning');
204 --
205 END ValidateLookupMeaning;
206 --
207 --
208
209 FUNCTION GetMeaning (
210 p_flex_value_set_id IN INTEGER
211 , p_flex_value IN VARCHAR2
212 , p_source_code IN VARCHAR2
213 , p_source_type_code IN VARCHAR2
214 , p_source_application_id IN INTEGER
215 )
216 RETURN VARCHAR2
217 IS
218 BEGIN
219 --
220 RETURN NULL ;
221 --
222 EXCEPTION
223 WHEN xla_exceptions_pkg.application_exception THEN
224 RAISE;
225 WHEN OTHERS THEN
226 xla_exceptions_pkg.raise_message
227 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.GetMeaning');
228 END GetMeaning;
229 --
230
231 ---------------------------------------
232 --
233 -- PRIVATE FUNCTION
234 -- AcctDerRule_1
235 --
236 ---------------------------------------
237 FUNCTION AcctDerRule_1 (
238 p_application_id IN NUMBER
239 , p_ae_header_id IN NUMBER
240 , p_side IN VARCHAR2
241 , p_override_seg_flag IN VARCHAR2
242 , x_transaction_coa_id OUT NOCOPY NUMBER
243 , x_accounting_coa_id OUT NOCOPY NUMBER
244 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
245 , x_flex_value_set_id OUT NOCOPY NUMBER
246 , x_value_type_code OUT NOCOPY VARCHAR2
247 , x_value_combination_id OUT NOCOPY NUMBER
248 , x_value_segment_code OUT NOCOPY VARCHAR2
249 )
250 RETURN VARCHAR2
251 IS
252 l_component_type VARCHAR2(80) ;
253 l_component_code VARCHAR2(30) ;
254 l_component_type_code VARCHAR2(1) ;
255 l_component_appl_id INTEGER ;
256 l_amb_context_code VARCHAR2(30) ;
257 l_log_module VARCHAR2(240) ;
258 l_output_value VARCHAR2(30) ;
259 BEGIN
260 IF g_log_enabled THEN
261 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_1';
262 END IF;
263 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
264
265 trace
266 (p_msg => 'BEGIN of AcctDerRule_1'
267 ,p_level => C_LEVEL_PROCEDURE
268 ,p_module => l_log_module);
269
270 END IF;
271
272 l_component_type := 'AMB_ADR';
273 l_component_code := 'FV_310701';
274 l_component_type_code := 'S';
275 l_component_appl_id := 707;
276 l_amb_context_code := 'DEFAULT';
277 x_transaction_coa_id := null;
278 x_accounting_coa_id := null;
279 x_flexfield_segment_code := null;
280 x_flex_value_set_id := 1009988 ;
281
282
283 --
284 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
285
286 trace
287 (p_msg => 'END of AcctDerRule_1'
288 ,p_level => C_LEVEL_PROCEDURE
289 ,p_module => l_log_module);
290
291 END IF;
292 x_value_combination_id := null ;
293 x_value_segment_code := null ;
294 x_value_type_code := 'C';
295 l_output_value := '310701';
296 RETURN l_output_value;
297
298
299 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
300
301 trace
302 (p_msg => 'END of AcctDerRule_1(invalid)'
303 ,p_level => C_LEVEL_PROCEDURE
304 ,p_module => l_log_module);
305
306 END IF;
307
308 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
309 x_value_combination_id := null;
310 x_value_segment_code := null;
311 x_value_type_code := null;
312 l_output_value := null;
313 xla_accounting_err_pkg.build_message
314 (p_appli_s_name => 'XLA'
315 ,p_msg_name => 'XLA_AP_INVALID_ADR'
316 ,p_token_1 => 'COMPONENT_NAME'
317 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
318 l_component_type
319 , l_component_code
320 , l_component_type_code
321 , l_component_appl_id
322 , l_amb_context_code
323 )
324 ,p_token_2 => 'OWNER'
325 ,p_value_2 => xla_lookups_pkg.get_meaning(
326 'XLA_OWNER_TYPE'
327 ,l_component_type_code
328 )
329 ,p_token_3 => 'PAD_NAME'
330 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
331 ,p_token_4 => 'PAD_OWNER'
332 ,p_value_4 => xla_lookups_pkg.get_meaning(
333 'XLA_OWNER_TYPE'
334 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
335 )
336 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
337 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
338 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
339 ,p_ae_header_id => NULL
340 );
341 RETURN l_output_value;
342 EXCEPTION
343 WHEN xla_exceptions_pkg.application_exception THEN
344 RAISE;
345 WHEN OTHERS THEN
346 xla_exceptions_pkg.raise_message
347 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctDerRule_1');
348 END AcctDerRule_1;
349 --
350
351 ---------------------------------------
352 --
353 -- PRIVATE FUNCTION
354 -- AcctDerRule_2
355 --
356 ---------------------------------------
357 FUNCTION AcctDerRule_2 (
358 p_application_id IN NUMBER
359 , p_ae_header_id IN NUMBER
360 , p_side IN VARCHAR2
361 , p_override_seg_flag IN VARCHAR2
362 , x_transaction_coa_id OUT NOCOPY NUMBER
363 , x_accounting_coa_id OUT NOCOPY NUMBER
364 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
365 , x_flex_value_set_id OUT NOCOPY NUMBER
366 , x_value_type_code OUT NOCOPY VARCHAR2
367 , x_value_combination_id OUT NOCOPY NUMBER
368 , x_value_segment_code OUT NOCOPY VARCHAR2
369 )
370 RETURN VARCHAR2
371 IS
372 l_component_type VARCHAR2(80) ;
373 l_component_code VARCHAR2(30) ;
374 l_component_type_code VARCHAR2(1) ;
375 l_component_appl_id INTEGER ;
376 l_amb_context_code VARCHAR2(30) ;
377 l_log_module VARCHAR2(240) ;
378 l_output_value VARCHAR2(30) ;
379 BEGIN
380 IF g_log_enabled THEN
381 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_2';
382 END IF;
383 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
384
385 trace
386 (p_msg => 'BEGIN of AcctDerRule_2'
387 ,p_level => C_LEVEL_PROCEDURE
388 ,p_module => l_log_module);
389
390 END IF;
391
392 l_component_type := 'AMB_ADR';
393 l_component_code := 'FV_431002';
394 l_component_type_code := 'S';
395 l_component_appl_id := 707;
396 l_amb_context_code := 'DEFAULT';
397 x_transaction_coa_id := null;
398 x_accounting_coa_id := null;
399 x_flexfield_segment_code := null;
400 x_flex_value_set_id := 1009988 ;
401
402
403 --
404 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
405
406 trace
407 (p_msg => 'END of AcctDerRule_2'
408 ,p_level => C_LEVEL_PROCEDURE
409 ,p_module => l_log_module);
410
411 END IF;
412 x_value_combination_id := null ;
413 x_value_segment_code := null ;
414 x_value_type_code := 'C';
415 l_output_value := '431002';
416 RETURN l_output_value;
417
418
419 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
420
421 trace
422 (p_msg => 'END of AcctDerRule_2(invalid)'
423 ,p_level => C_LEVEL_PROCEDURE
424 ,p_module => l_log_module);
425
426 END IF;
427
428 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
429 x_value_combination_id := null;
430 x_value_segment_code := null;
431 x_value_type_code := null;
432 l_output_value := null;
433 xla_accounting_err_pkg.build_message
434 (p_appli_s_name => 'XLA'
435 ,p_msg_name => 'XLA_AP_INVALID_ADR'
436 ,p_token_1 => 'COMPONENT_NAME'
437 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
438 l_component_type
439 , l_component_code
440 , l_component_type_code
441 , l_component_appl_id
442 , l_amb_context_code
443 )
444 ,p_token_2 => 'OWNER'
445 ,p_value_2 => xla_lookups_pkg.get_meaning(
446 'XLA_OWNER_TYPE'
447 ,l_component_type_code
448 )
449 ,p_token_3 => 'PAD_NAME'
450 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
451 ,p_token_4 => 'PAD_OWNER'
452 ,p_value_4 => xla_lookups_pkg.get_meaning(
453 'XLA_OWNER_TYPE'
454 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
455 )
456 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
457 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
458 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
459 ,p_ae_header_id => NULL
460 );
461 RETURN l_output_value;
462 EXCEPTION
463 WHEN xla_exceptions_pkg.application_exception THEN
464 RAISE;
465 WHEN OTHERS THEN
466 xla_exceptions_pkg.raise_message
467 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctDerRule_2');
468 END AcctDerRule_2;
469 --
470
471 ---------------------------------------
472 --
473 -- PRIVATE FUNCTION
474 -- AcctDerRule_3
475 --
476 ---------------------------------------
477 FUNCTION AcctDerRule_3 (
478 p_application_id IN NUMBER
479 , p_ae_header_id IN NUMBER
480 , p_side IN VARCHAR2
481 , p_override_seg_flag IN VARCHAR2
482 , x_transaction_coa_id OUT NOCOPY NUMBER
483 , x_accounting_coa_id OUT NOCOPY NUMBER
484 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
485 , x_flex_value_set_id OUT NOCOPY NUMBER
486 , x_value_type_code OUT NOCOPY VARCHAR2
487 , x_value_combination_id OUT NOCOPY NUMBER
488 , x_value_segment_code OUT NOCOPY VARCHAR2
489 )
490 RETURN VARCHAR2
491 IS
492 l_component_type VARCHAR2(80) ;
493 l_component_code VARCHAR2(30) ;
494 l_component_type_code VARCHAR2(1) ;
495 l_component_appl_id INTEGER ;
496 l_amb_context_code VARCHAR2(30) ;
497 l_log_module VARCHAR2(240) ;
498 l_output_value VARCHAR2(30) ;
499 BEGIN
500 IF g_log_enabled THEN
501 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_3';
502 END IF;
503 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
504
505 trace
506 (p_msg => 'BEGIN of AcctDerRule_3'
507 ,p_level => C_LEVEL_PROCEDURE
508 ,p_module => l_log_module);
509
510 END IF;
511
512 l_component_type := 'AMB_ADR';
513 l_component_code := 'FV_445002';
514 l_component_type_code := 'S';
515 l_component_appl_id := 707;
516 l_amb_context_code := 'DEFAULT';
517 x_transaction_coa_id := null;
518 x_accounting_coa_id := null;
519 x_flexfield_segment_code := null;
520 x_flex_value_set_id := 1009988 ;
521
522
523 --
524 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
525
526 trace
527 (p_msg => 'END of AcctDerRule_3'
528 ,p_level => C_LEVEL_PROCEDURE
529 ,p_module => l_log_module);
530
531 END IF;
532 x_value_combination_id := null ;
533 x_value_segment_code := null ;
534 x_value_type_code := 'C';
535 l_output_value := '445002';
536 RETURN l_output_value;
537
538
539 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
540
541 trace
542 (p_msg => 'END of AcctDerRule_3(invalid)'
543 ,p_level => C_LEVEL_PROCEDURE
544 ,p_module => l_log_module);
545
546 END IF;
547
548 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
549 x_value_combination_id := null;
550 x_value_segment_code := null;
551 x_value_type_code := null;
552 l_output_value := null;
553 xla_accounting_err_pkg.build_message
554 (p_appli_s_name => 'XLA'
555 ,p_msg_name => 'XLA_AP_INVALID_ADR'
556 ,p_token_1 => 'COMPONENT_NAME'
557 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
558 l_component_type
559 , l_component_code
560 , l_component_type_code
561 , l_component_appl_id
562 , l_amb_context_code
563 )
564 ,p_token_2 => 'OWNER'
565 ,p_value_2 => xla_lookups_pkg.get_meaning(
566 'XLA_OWNER_TYPE'
567 ,l_component_type_code
568 )
569 ,p_token_3 => 'PAD_NAME'
570 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
571 ,p_token_4 => 'PAD_OWNER'
572 ,p_value_4 => xla_lookups_pkg.get_meaning(
573 'XLA_OWNER_TYPE'
574 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
575 )
576 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
577 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
578 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
579 ,p_ae_header_id => NULL
580 );
581 RETURN l_output_value;
582 EXCEPTION
583 WHEN xla_exceptions_pkg.application_exception THEN
584 RAISE;
585 WHEN OTHERS THEN
586 xla_exceptions_pkg.raise_message
587 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctDerRule_3');
588 END AcctDerRule_3;
589 --
590
591 ---------------------------------------
592 --
593 -- PRIVATE FUNCTION
594 -- AcctDerRule_4
595 --
596 ---------------------------------------
597 FUNCTION AcctDerRule_4 (
598 p_application_id IN NUMBER
599 , p_ae_header_id IN NUMBER
600 , p_side IN VARCHAR2
601 , p_override_seg_flag IN VARCHAR2
602 --Federal Fund Expired Status
603 , p_source_1 IN VARCHAR2
604 --Federal Fund Category
605 , p_source_2 IN VARCHAR2
606 , x_transaction_coa_id OUT NOCOPY NUMBER
607 , x_accounting_coa_id OUT NOCOPY NUMBER
608 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
609 , x_flex_value_set_id OUT NOCOPY NUMBER
610 , x_value_type_code OUT NOCOPY VARCHAR2
611 , x_value_combination_id OUT NOCOPY NUMBER
612 , x_value_segment_code OUT NOCOPY VARCHAR2
613 )
614 RETURN VARCHAR2
615 IS
616 l_component_type VARCHAR2(80) ;
617 l_component_code VARCHAR2(30) ;
618 l_component_type_code VARCHAR2(1) ;
619 l_component_appl_id INTEGER ;
620 l_amb_context_code VARCHAR2(30) ;
621 l_log_module VARCHAR2(240) ;
622 l_output_value VARCHAR2(30) ;
623 BEGIN
624 IF g_log_enabled THEN
625 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_4';
626 END IF;
627 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
628
629 trace
630 (p_msg => 'BEGIN of AcctDerRule_4'
631 ,p_level => C_LEVEL_PROCEDURE
632 ,p_module => l_log_module);
633
634 END IF;
635
636 l_component_type := 'AMB_ADR';
637 l_component_code := 'FV_46X002';
638 l_component_type_code := 'S';
639 l_component_appl_id := 707;
640 l_amb_context_code := 'DEFAULT';
641 x_transaction_coa_id := null;
642 x_accounting_coa_id := null;
643 x_flexfield_segment_code := null;
644 x_flex_value_set_id := 1009988 ;
645
646
647 IF NVL(p_source_1,'
648 ') = 'Expired'
649 THEN
650 --
651 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
652
653 trace
654 (p_msg => 'END of AcctDerRule_4'
655 ,p_level => C_LEVEL_PROCEDURE
656 ,p_module => l_log_module);
657
658 END IF;
659 x_value_combination_id := null ;
660 x_value_segment_code := null ;
661 x_value_type_code := 'C';
662 l_output_value := '465002';
663 RETURN l_output_value;
664
665 ELSIF (NVL(p_source_1,'
666 ') = 'Unexpired') AND
667 (NVL(p_source_2,'
668 ') = 'A' OR
669 NVL(p_source_2,'
670 ') = 'B' OR
671 NVL(p_source_2,'
672 ') = 'S' OR
673 NVL(p_source_2,'
674 ') = 'T')
675 THEN
676 --
677 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
678
679 trace
680 (p_msg => 'END of AcctDerRule_4'
681 ,p_level => C_LEVEL_PROCEDURE
682 ,p_module => l_log_module);
683
684 END IF;
685 x_value_combination_id := null ;
686 x_value_segment_code := null ;
687 x_value_type_code := 'C';
688 l_output_value := '461002';
689 RETURN l_output_value;
690
691 ELSIF (NVL(p_source_1,'
692 ') = 'Unexpired') AND
693 (NVL(p_source_2,'
694 ') = 'C' OR
695 NVL(p_source_2,'
696 ') = 'R')
697 THEN
698 --
699 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
700
701 trace
702 (p_msg => 'END of AcctDerRule_4'
703 ,p_level => C_LEVEL_PROCEDURE
704 ,p_module => l_log_module);
705
706 END IF;
707 x_value_combination_id := null ;
708 x_value_segment_code := null ;
709 x_value_type_code := 'C';
710 l_output_value := '462002';
711 RETURN l_output_value;
712
713 ELSE
714 IF p_override_seg_flag = 'Y' THEN
715 RETURN '#$NO_OVERRIDE#$';
716 END IF;
717 END IF;
718
719 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
720
721 trace
722 (p_msg => 'END of AcctDerRule_4(invalid)'
723 ,p_level => C_LEVEL_PROCEDURE
724 ,p_module => l_log_module);
725
726 END IF;
727
728 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
729 x_value_combination_id := null;
730 x_value_segment_code := null;
731 x_value_type_code := null;
732 l_output_value := null;
733 xla_accounting_err_pkg.build_message
734 (p_appli_s_name => 'XLA'
735 ,p_msg_name => 'XLA_AP_INVALID_ADR'
736 ,p_token_1 => 'COMPONENT_NAME'
737 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
738 l_component_type
739 , l_component_code
740 , l_component_type_code
741 , l_component_appl_id
742 , l_amb_context_code
743 )
744 ,p_token_2 => 'OWNER'
745 ,p_value_2 => xla_lookups_pkg.get_meaning(
746 'XLA_OWNER_TYPE'
747 ,l_component_type_code
748 )
749 ,p_token_3 => 'PAD_NAME'
750 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
751 ,p_token_4 => 'PAD_OWNER'
752 ,p_value_4 => xla_lookups_pkg.get_meaning(
753 'XLA_OWNER_TYPE'
754 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
755 )
756 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
757 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
758 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
759 ,p_ae_header_id => NULL
760 );
761 RETURN l_output_value;
762 EXCEPTION
763 WHEN xla_exceptions_pkg.application_exception THEN
764 RAISE;
765 WHEN OTHERS THEN
766 xla_exceptions_pkg.raise_message
767 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctDerRule_4');
768 END AcctDerRule_4;
769 --
770
771 ---------------------------------------
772 --
773 -- PRIVATE FUNCTION
774 -- AcctDerRule_5
775 --
776 ---------------------------------------
777 FUNCTION AcctDerRule_5 (
778 p_application_id IN NUMBER
779 , p_ae_header_id IN NUMBER
780 , p_side IN VARCHAR2
781 , p_override_seg_flag IN VARCHAR2
782 , x_transaction_coa_id OUT NOCOPY NUMBER
783 , x_accounting_coa_id OUT NOCOPY NUMBER
784 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
785 , x_flex_value_set_id OUT NOCOPY NUMBER
786 , x_value_type_code OUT NOCOPY VARCHAR2
787 , x_value_combination_id OUT NOCOPY NUMBER
788 , x_value_segment_code OUT NOCOPY VARCHAR2
789 )
790 RETURN VARCHAR2
791 IS
792 l_component_type VARCHAR2(80) ;
793 l_component_code VARCHAR2(30) ;
794 l_component_type_code VARCHAR2(1) ;
795 l_component_appl_id INTEGER ;
796 l_amb_context_code VARCHAR2(30) ;
797 l_log_module VARCHAR2(240) ;
798 l_output_value VARCHAR2(30) ;
799 BEGIN
800 IF g_log_enabled THEN
801 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_5';
802 END IF;
803 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
804
805 trace
806 (p_msg => 'BEGIN of AcctDerRule_5'
807 ,p_level => C_LEVEL_PROCEDURE
808 ,p_module => l_log_module);
809
810 END IF;
811
812 l_component_type := 'AMB_ADR';
813 l_component_code := 'FV_480101';
814 l_component_type_code := 'S';
815 l_component_appl_id := 707;
816 l_amb_context_code := 'DEFAULT';
817 x_transaction_coa_id := null;
818 x_accounting_coa_id := null;
819 x_flexfield_segment_code := null;
820 x_flex_value_set_id := 1009988 ;
821
822
823 --
824 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
825
826 trace
827 (p_msg => 'END of AcctDerRule_5'
828 ,p_level => C_LEVEL_PROCEDURE
829 ,p_module => l_log_module);
830
831 END IF;
832 x_value_combination_id := null ;
833 x_value_segment_code := null ;
834 x_value_type_code := 'C';
835 l_output_value := '480101';
836 RETURN l_output_value;
837
838
839 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
840
841 trace
842 (p_msg => 'END of AcctDerRule_5(invalid)'
843 ,p_level => C_LEVEL_PROCEDURE
844 ,p_module => l_log_module);
845
846 END IF;
847
848 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
849 x_value_combination_id := null;
850 x_value_segment_code := null;
851 x_value_type_code := null;
852 l_output_value := null;
853 xla_accounting_err_pkg.build_message
854 (p_appli_s_name => 'XLA'
855 ,p_msg_name => 'XLA_AP_INVALID_ADR'
856 ,p_token_1 => 'COMPONENT_NAME'
857 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
858 l_component_type
859 , l_component_code
860 , l_component_type_code
861 , l_component_appl_id
862 , l_amb_context_code
863 )
864 ,p_token_2 => 'OWNER'
865 ,p_value_2 => xla_lookups_pkg.get_meaning(
866 'XLA_OWNER_TYPE'
867 ,l_component_type_code
868 )
869 ,p_token_3 => 'PAD_NAME'
870 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
871 ,p_token_4 => 'PAD_OWNER'
872 ,p_value_4 => xla_lookups_pkg.get_meaning(
873 'XLA_OWNER_TYPE'
874 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
875 )
876 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
877 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
878 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
879 ,p_ae_header_id => NULL
880 );
881 RETURN l_output_value;
882 EXCEPTION
883 WHEN xla_exceptions_pkg.application_exception THEN
884 RAISE;
885 WHEN OTHERS THEN
886 xla_exceptions_pkg.raise_message
887 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctDerRule_5');
888 END AcctDerRule_5;
889 --
890
891 ---------------------------------------
892 --
893 -- PRIVATE FUNCTION
894 -- AcctDerRule_6
895 --
896 ---------------------------------------
897 FUNCTION AcctDerRule_6 (
898 p_application_id IN NUMBER
899 , p_ae_header_id IN NUMBER
900 , p_side IN VARCHAR2
901 , p_override_seg_flag IN VARCHAR2
902 , x_transaction_coa_id OUT NOCOPY NUMBER
903 , x_accounting_coa_id OUT NOCOPY NUMBER
904 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
905 , x_flex_value_set_id OUT NOCOPY NUMBER
906 , x_value_type_code OUT NOCOPY VARCHAR2
907 , x_value_combination_id OUT NOCOPY NUMBER
908 , x_value_segment_code OUT NOCOPY VARCHAR2
909 )
910 RETURN VARCHAR2
911 IS
912 l_component_type VARCHAR2(80) ;
913 l_component_code VARCHAR2(30) ;
914 l_component_type_code VARCHAR2(1) ;
915 l_component_appl_id INTEGER ;
916 l_amb_context_code VARCHAR2(30) ;
917 l_log_module VARCHAR2(240) ;
918 l_output_value VARCHAR2(30) ;
919 BEGIN
920 IF g_log_enabled THEN
921 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_6';
922 END IF;
923 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
924
925 trace
926 (p_msg => 'BEGIN of AcctDerRule_6'
927 ,p_level => C_LEVEL_PROCEDURE
928 ,p_module => l_log_module);
929
930 END IF;
931
932 l_component_type := 'AMB_ADR';
933 l_component_code := 'FV_480201';
934 l_component_type_code := 'S';
935 l_component_appl_id := 707;
936 l_amb_context_code := 'DEFAULT';
937 x_transaction_coa_id := null;
938 x_accounting_coa_id := null;
939 x_flexfield_segment_code := null;
940 x_flex_value_set_id := 1009988 ;
941
942
943 --
944 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
945
946 trace
947 (p_msg => 'END of AcctDerRule_6'
948 ,p_level => C_LEVEL_PROCEDURE
949 ,p_module => l_log_module);
950
951 END IF;
952 x_value_combination_id := null ;
953 x_value_segment_code := null ;
954 x_value_type_code := 'C';
955 l_output_value := '480201';
956 RETURN l_output_value;
957
958
959 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
960
961 trace
962 (p_msg => 'END of AcctDerRule_6(invalid)'
963 ,p_level => C_LEVEL_PROCEDURE
964 ,p_module => l_log_module);
965
966 END IF;
967
968 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
969 x_value_combination_id := null;
970 x_value_segment_code := null;
971 x_value_type_code := null;
972 l_output_value := null;
973 xla_accounting_err_pkg.build_message
974 (p_appli_s_name => 'XLA'
975 ,p_msg_name => 'XLA_AP_INVALID_ADR'
976 ,p_token_1 => 'COMPONENT_NAME'
977 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
978 l_component_type
979 , l_component_code
980 , l_component_type_code
981 , l_component_appl_id
982 , l_amb_context_code
983 )
984 ,p_token_2 => 'OWNER'
985 ,p_value_2 => xla_lookups_pkg.get_meaning(
986 'XLA_OWNER_TYPE'
987 ,l_component_type_code
988 )
989 ,p_token_3 => 'PAD_NAME'
990 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
991 ,p_token_4 => 'PAD_OWNER'
992 ,p_value_4 => xla_lookups_pkg.get_meaning(
993 'XLA_OWNER_TYPE'
994 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
995 )
996 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
997 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
998 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
999 ,p_ae_header_id => NULL
1000 );
1001 RETURN l_output_value;
1002 EXCEPTION
1003 WHEN xla_exceptions_pkg.application_exception THEN
1004 RAISE;
1005 WHEN OTHERS THEN
1006 xla_exceptions_pkg.raise_message
1007 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctDerRule_6');
1008 END AcctDerRule_6;
1009 --
1010
1011 ---------------------------------------
1012 --
1013 -- PRIVATE FUNCTION
1014 -- AcctDerRule_7
1015 --
1016 ---------------------------------------
1017 FUNCTION AcctDerRule_7 (
1018 p_application_id IN NUMBER
1019 , p_ae_header_id IN NUMBER
1020 , p_side IN VARCHAR2
1021 , p_override_seg_flag IN VARCHAR2
1022 , x_transaction_coa_id OUT NOCOPY NUMBER
1023 , x_accounting_coa_id OUT NOCOPY NUMBER
1024 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1025 , x_flex_value_set_id OUT NOCOPY NUMBER
1026 , x_value_type_code OUT NOCOPY VARCHAR2
1027 , x_value_combination_id OUT NOCOPY NUMBER
1028 , x_value_segment_code OUT NOCOPY VARCHAR2
1029 )
1030 RETURN VARCHAR2
1031 IS
1032 l_component_type VARCHAR2(80) ;
1033 l_component_code VARCHAR2(30) ;
1034 l_component_type_code VARCHAR2(1) ;
1035 l_component_appl_id INTEGER ;
1036 l_amb_context_code VARCHAR2(30) ;
1037 l_log_module VARCHAR2(240) ;
1038 l_output_value VARCHAR2(30) ;
1039 BEGIN
1040 IF g_log_enabled THEN
1041 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_7';
1042 END IF;
1043 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1044
1045 trace
1046 (p_msg => 'BEGIN of AcctDerRule_7'
1047 ,p_level => C_LEVEL_PROCEDURE
1048 ,p_module => l_log_module);
1049
1050 END IF;
1051
1052 l_component_type := 'AMB_ADR';
1053 l_component_code := 'FV_487101';
1054 l_component_type_code := 'S';
1055 l_component_appl_id := 707;
1056 l_amb_context_code := 'DEFAULT';
1057 x_transaction_coa_id := null;
1058 x_accounting_coa_id := null;
1059 x_flexfield_segment_code := null;
1060 x_flex_value_set_id := 1009988 ;
1061
1062
1063 --
1064 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1065
1066 trace
1067 (p_msg => 'END of AcctDerRule_7'
1068 ,p_level => C_LEVEL_PROCEDURE
1069 ,p_module => l_log_module);
1070
1071 END IF;
1072 x_value_combination_id := null ;
1073 x_value_segment_code := null ;
1074 x_value_type_code := 'C';
1075 l_output_value := '487101';
1076 RETURN l_output_value;
1077
1078
1079 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1080
1081 trace
1082 (p_msg => 'END of AcctDerRule_7(invalid)'
1083 ,p_level => C_LEVEL_PROCEDURE
1084 ,p_module => l_log_module);
1085
1086 END IF;
1087
1088 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1089 x_value_combination_id := null;
1090 x_value_segment_code := null;
1091 x_value_type_code := null;
1092 l_output_value := null;
1093 xla_accounting_err_pkg.build_message
1094 (p_appli_s_name => 'XLA'
1095 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1096 ,p_token_1 => 'COMPONENT_NAME'
1097 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1098 l_component_type
1099 , l_component_code
1100 , l_component_type_code
1101 , l_component_appl_id
1102 , l_amb_context_code
1103 )
1104 ,p_token_2 => 'OWNER'
1105 ,p_value_2 => xla_lookups_pkg.get_meaning(
1106 'XLA_OWNER_TYPE'
1107 ,l_component_type_code
1108 )
1109 ,p_token_3 => 'PAD_NAME'
1110 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1111 ,p_token_4 => 'PAD_OWNER'
1112 ,p_value_4 => xla_lookups_pkg.get_meaning(
1113 'XLA_OWNER_TYPE'
1114 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1115 )
1116 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1117 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1118 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1119 ,p_ae_header_id => NULL
1120 );
1121 RETURN l_output_value;
1122 EXCEPTION
1123 WHEN xla_exceptions_pkg.application_exception THEN
1124 RAISE;
1125 WHEN OTHERS THEN
1126 xla_exceptions_pkg.raise_message
1127 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctDerRule_7');
1128 END AcctDerRule_7;
1129 --
1130
1131 ---------------------------------------
1132 --
1133 -- PRIVATE FUNCTION
1134 -- AcctDerRule_8
1135 --
1136 ---------------------------------------
1137 FUNCTION AcctDerRule_8 (
1138 p_application_id IN NUMBER
1139 , p_ae_header_id IN NUMBER
1140 , p_side IN VARCHAR2
1141 , p_override_seg_flag IN VARCHAR2
1142 , x_transaction_coa_id OUT NOCOPY NUMBER
1143 , x_accounting_coa_id OUT NOCOPY NUMBER
1144 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1145 , x_flex_value_set_id OUT NOCOPY NUMBER
1146 , x_value_type_code OUT NOCOPY VARCHAR2
1147 , x_value_combination_id OUT NOCOPY NUMBER
1148 , x_value_segment_code OUT NOCOPY VARCHAR2
1149 )
1150 RETURN VARCHAR2
1151 IS
1152 l_component_type VARCHAR2(80) ;
1153 l_component_code VARCHAR2(30) ;
1154 l_component_type_code VARCHAR2(1) ;
1155 l_component_appl_id INTEGER ;
1156 l_amb_context_code VARCHAR2(30) ;
1157 l_log_module VARCHAR2(240) ;
1158 l_output_value VARCHAR2(30) ;
1159 BEGIN
1160 IF g_log_enabled THEN
1161 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_8';
1162 END IF;
1163 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1164
1165 trace
1166 (p_msg => 'BEGIN of AcctDerRule_8'
1167 ,p_level => C_LEVEL_PROCEDURE
1168 ,p_module => l_log_module);
1169
1170 END IF;
1171
1172 l_component_type := 'AMB_ADR';
1173 l_component_code := 'FV_488101';
1174 l_component_type_code := 'S';
1175 l_component_appl_id := 707;
1176 l_amb_context_code := 'DEFAULT';
1177 x_transaction_coa_id := null;
1178 x_accounting_coa_id := null;
1179 x_flexfield_segment_code := null;
1180 x_flex_value_set_id := 1009988 ;
1181
1182
1183 --
1184 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1185
1186 trace
1187 (p_msg => 'END of AcctDerRule_8'
1188 ,p_level => C_LEVEL_PROCEDURE
1189 ,p_module => l_log_module);
1190
1191 END IF;
1192 x_value_combination_id := null ;
1193 x_value_segment_code := null ;
1194 x_value_type_code := 'C';
1195 l_output_value := '488101';
1196 RETURN l_output_value;
1197
1198
1199 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1200
1201 trace
1202 (p_msg => 'END of AcctDerRule_8(invalid)'
1203 ,p_level => C_LEVEL_PROCEDURE
1204 ,p_module => l_log_module);
1205
1206 END IF;
1207
1208 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1209 x_value_combination_id := null;
1210 x_value_segment_code := null;
1211 x_value_type_code := null;
1212 l_output_value := null;
1213 xla_accounting_err_pkg.build_message
1214 (p_appli_s_name => 'XLA'
1215 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1216 ,p_token_1 => 'COMPONENT_NAME'
1217 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1218 l_component_type
1219 , l_component_code
1220 , l_component_type_code
1221 , l_component_appl_id
1222 , l_amb_context_code
1223 )
1224 ,p_token_2 => 'OWNER'
1225 ,p_value_2 => xla_lookups_pkg.get_meaning(
1226 'XLA_OWNER_TYPE'
1227 ,l_component_type_code
1228 )
1229 ,p_token_3 => 'PAD_NAME'
1230 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1231 ,p_token_4 => 'PAD_OWNER'
1232 ,p_value_4 => xla_lookups_pkg.get_meaning(
1233 'XLA_OWNER_TYPE'
1234 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1235 )
1236 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1237 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1238 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1239 ,p_ae_header_id => NULL
1240 );
1241 RETURN l_output_value;
1242 EXCEPTION
1243 WHEN xla_exceptions_pkg.application_exception THEN
1244 RAISE;
1245 WHEN OTHERS THEN
1246 xla_exceptions_pkg.raise_message
1247 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctDerRule_8');
1248 END AcctDerRule_8;
1249 --
1250
1251 ---------------------------------------
1252 --
1253 -- PRIVATE FUNCTION
1254 -- AcctDerRule_9
1255 --
1256 ---------------------------------------
1257 FUNCTION AcctDerRule_9 (
1258 p_application_id IN NUMBER
1259 , p_ae_header_id IN NUMBER
1260 , p_side IN VARCHAR2
1261 , p_override_seg_flag IN VARCHAR2
1262 , x_transaction_coa_id OUT NOCOPY NUMBER
1263 , x_accounting_coa_id OUT NOCOPY NUMBER
1264 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1265 , x_flex_value_set_id OUT NOCOPY NUMBER
1266 , x_value_type_code OUT NOCOPY VARCHAR2
1267 , x_value_combination_id OUT NOCOPY NUMBER
1268 , x_value_segment_code OUT NOCOPY VARCHAR2
1269 )
1270 RETURN VARCHAR2
1271 IS
1272 l_component_type VARCHAR2(80) ;
1273 l_component_code VARCHAR2(30) ;
1274 l_component_type_code VARCHAR2(1) ;
1275 l_component_appl_id INTEGER ;
1276 l_amb_context_code VARCHAR2(30) ;
1277 l_log_module VARCHAR2(240) ;
1278 l_output_value VARCHAR2(30) ;
1279 BEGIN
1280 IF g_log_enabled THEN
1281 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_9';
1282 END IF;
1283 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1284
1285 trace
1286 (p_msg => 'BEGIN of AcctDerRule_9'
1287 ,p_level => C_LEVEL_PROCEDURE
1288 ,p_module => l_log_module);
1289
1290 END IF;
1291
1292 l_component_type := 'AMB_ADR';
1293 l_component_code := 'FV_490101';
1294 l_component_type_code := 'S';
1295 l_component_appl_id := 707;
1296 l_amb_context_code := 'DEFAULT';
1297 x_transaction_coa_id := null;
1298 x_accounting_coa_id := null;
1299 x_flexfield_segment_code := null;
1300 x_flex_value_set_id := 1009988 ;
1301
1302
1303 --
1304 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1305
1306 trace
1307 (p_msg => 'END of AcctDerRule_9'
1308 ,p_level => C_LEVEL_PROCEDURE
1309 ,p_module => l_log_module);
1310
1311 END IF;
1312 x_value_combination_id := null ;
1313 x_value_segment_code := null ;
1314 x_value_type_code := 'C';
1315 l_output_value := '490101';
1316 RETURN l_output_value;
1317
1318
1319 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1320
1321 trace
1322 (p_msg => 'END of AcctDerRule_9(invalid)'
1323 ,p_level => C_LEVEL_PROCEDURE
1324 ,p_module => l_log_module);
1325
1326 END IF;
1327
1328 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1329 x_value_combination_id := null;
1330 x_value_segment_code := null;
1331 x_value_type_code := null;
1332 l_output_value := null;
1333 xla_accounting_err_pkg.build_message
1334 (p_appli_s_name => 'XLA'
1335 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1336 ,p_token_1 => 'COMPONENT_NAME'
1337 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1338 l_component_type
1339 , l_component_code
1340 , l_component_type_code
1341 , l_component_appl_id
1342 , l_amb_context_code
1343 )
1344 ,p_token_2 => 'OWNER'
1345 ,p_value_2 => xla_lookups_pkg.get_meaning(
1346 'XLA_OWNER_TYPE'
1347 ,l_component_type_code
1348 )
1349 ,p_token_3 => 'PAD_NAME'
1350 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1351 ,p_token_4 => 'PAD_OWNER'
1352 ,p_value_4 => xla_lookups_pkg.get_meaning(
1353 'XLA_OWNER_TYPE'
1354 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1355 )
1356 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1357 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1358 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1359 ,p_ae_header_id => NULL
1360 );
1361 RETURN l_output_value;
1362 EXCEPTION
1363 WHEN xla_exceptions_pkg.application_exception THEN
1364 RAISE;
1365 WHEN OTHERS THEN
1366 xla_exceptions_pkg.raise_message
1367 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctDerRule_9');
1368 END AcctDerRule_9;
1369 --
1370
1371 ---------------------------------------
1372 --
1373 -- PRIVATE FUNCTION
1374 -- AcctDerRule_10
1375 --
1376 ---------------------------------------
1377 FUNCTION AcctDerRule_10 (
1378 p_application_id IN NUMBER
1379 , p_ae_header_id IN NUMBER
1380 , p_side IN VARCHAR2
1381 , p_override_seg_flag IN VARCHAR2
1382 , x_transaction_coa_id OUT NOCOPY NUMBER
1383 , x_accounting_coa_id OUT NOCOPY NUMBER
1384 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1385 , x_flex_value_set_id OUT NOCOPY NUMBER
1386 , x_value_type_code OUT NOCOPY VARCHAR2
1387 , x_value_combination_id OUT NOCOPY NUMBER
1388 , x_value_segment_code OUT NOCOPY VARCHAR2
1389 )
1390 RETURN VARCHAR2
1391 IS
1392 l_component_type VARCHAR2(80) ;
1393 l_component_code VARCHAR2(30) ;
1394 l_component_type_code VARCHAR2(1) ;
1395 l_component_appl_id INTEGER ;
1396 l_amb_context_code VARCHAR2(30) ;
1397 l_log_module VARCHAR2(240) ;
1398 l_output_value VARCHAR2(30) ;
1399 BEGIN
1400 IF g_log_enabled THEN
1401 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_10';
1402 END IF;
1403 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1404
1405 trace
1406 (p_msg => 'BEGIN of AcctDerRule_10'
1407 ,p_level => C_LEVEL_PROCEDURE
1408 ,p_module => l_log_module);
1409
1410 END IF;
1411
1412 l_component_type := 'AMB_ADR';
1413 l_component_code := 'FV_570001';
1414 l_component_type_code := 'S';
1415 l_component_appl_id := 707;
1416 l_amb_context_code := 'DEFAULT';
1417 x_transaction_coa_id := null;
1418 x_accounting_coa_id := null;
1419 x_flexfield_segment_code := null;
1420 x_flex_value_set_id := 1009988 ;
1421
1422
1423 --
1424 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1425
1426 trace
1427 (p_msg => 'END of AcctDerRule_10'
1428 ,p_level => C_LEVEL_PROCEDURE
1429 ,p_module => l_log_module);
1430
1431 END IF;
1432 x_value_combination_id := null ;
1433 x_value_segment_code := null ;
1434 x_value_type_code := 'C';
1435 l_output_value := '570001';
1436 RETURN l_output_value;
1437
1438
1439 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1440
1441 trace
1442 (p_msg => 'END of AcctDerRule_10(invalid)'
1443 ,p_level => C_LEVEL_PROCEDURE
1444 ,p_module => l_log_module);
1445
1446 END IF;
1447
1448 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1449 x_value_combination_id := null;
1450 x_value_segment_code := null;
1451 x_value_type_code := null;
1452 l_output_value := null;
1453 xla_accounting_err_pkg.build_message
1454 (p_appli_s_name => 'XLA'
1455 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1456 ,p_token_1 => 'COMPONENT_NAME'
1457 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1458 l_component_type
1459 , l_component_code
1460 , l_component_type_code
1461 , l_component_appl_id
1462 , l_amb_context_code
1463 )
1464 ,p_token_2 => 'OWNER'
1465 ,p_value_2 => xla_lookups_pkg.get_meaning(
1466 'XLA_OWNER_TYPE'
1467 ,l_component_type_code
1468 )
1469 ,p_token_3 => 'PAD_NAME'
1470 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1471 ,p_token_4 => 'PAD_OWNER'
1472 ,p_value_4 => xla_lookups_pkg.get_meaning(
1473 'XLA_OWNER_TYPE'
1474 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1475 )
1476 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1477 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1478 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1479 ,p_ae_header_id => NULL
1480 );
1481 RETURN l_output_value;
1482 EXCEPTION
1483 WHEN xla_exceptions_pkg.application_exception THEN
1484 RAISE;
1485 WHEN OTHERS THEN
1486 xla_exceptions_pkg.raise_message
1487 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctDerRule_10');
1488 END AcctDerRule_10;
1489 --
1490
1491 ---------------------------------------
1492 --
1493 -- PRIVATE FUNCTION
1494 -- AcctDerRule_11
1495 --
1496 ---------------------------------------
1497 FUNCTION AcctDerRule_11 (
1498 p_application_id IN NUMBER
1499 , p_ae_header_id IN NUMBER
1500 , p_side IN VARCHAR2
1501 --PO Budget Account
1502 , p_source_3 IN NUMBER
1503 , x_transaction_coa_id OUT NOCOPY NUMBER
1504 , x_accounting_coa_id OUT NOCOPY NUMBER
1505 , x_value_type_code OUT NOCOPY VARCHAR2
1506 )
1507 RETURN NUMBER
1508 IS
1509 l_component_type VARCHAR2(80) ;
1510 l_component_code VARCHAR2(30) ;
1511 l_component_type_code VARCHAR2(1) ;
1512 l_component_appl_id INTEGER ;
1513 l_amb_context_code VARCHAR2(30) ;
1514 l_log_module VARCHAR2(240) ;
1515 l_output_value NUMBER ;
1516 BEGIN
1517 IF g_log_enabled THEN
1518 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_11';
1519 END IF;
1520 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1521 trace
1522 (p_msg => 'BEGIN of AcctDerRule_11'
1523 ,p_level => C_LEVEL_PROCEDURE
1524 ,p_module => l_log_module);
1525 END IF;
1526 --
1527 l_component_type := 'AMB_ADR';
1528 l_component_code := 'FV_PO_BUDGET_ACCOUNT';
1529 l_component_type_code := 'S';
1530 l_component_appl_id := 707;
1531 l_amb_context_code := 'DEFAULT';
1532 x_transaction_coa_id := null;
1533 x_accounting_coa_id := null;
1534 --
1535
1536 --
1537 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1538 trace
1539 (p_msg => 'END of AcctDerRule_11'
1540 ,p_level => C_LEVEL_PROCEDURE
1541 ,p_module => l_log_module);
1542 END IF;
1543 x_value_type_code := 'S';
1544 l_output_value := TO_NUMBER(TO_NUMBER(p_source_3));
1545 RETURN l_output_value;
1546
1547 --
1548 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1549 trace
1550 (p_msg => 'END of AcctDerRule_11(invalid)'
1551 ,p_level => C_LEVEL_PROCEDURE
1552 ,p_module => l_log_module);
1553 END IF;
1554 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1555 x_value_type_code := null;
1556 l_output_value := null;
1557 xla_accounting_err_pkg.build_message
1558 (p_appli_s_name => 'XLA'
1559 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1560 ,p_token_1 => 'COMPONENT_NAME'
1561 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1562 l_component_type
1563 , l_component_code
1564 , l_component_type_code
1565 , l_component_appl_id
1566 , l_amb_context_code
1567 )
1568 ,p_token_2 => 'OWNER'
1569 ,p_value_2 => xla_lookups_pkg.get_meaning(
1570 'XLA_OWNER_TYPE'
1571 ,l_component_type_code
1572 )
1573 ,p_token_3 => 'PAD_NAME'
1574 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1575 ,p_token_4 => 'PAD_OWNER'
1576 ,p_value_4 => xla_lookups_pkg.get_meaning(
1577 'XLA_OWNER_TYPE'
1578 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1579 )
1580 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1581 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1582 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1583 ,p_ae_header_id => NULL
1584 );
1585 RETURN l_output_value;
1586 EXCEPTION
1587 WHEN xla_exceptions_pkg.application_exception THEN
1588 RAISE;
1589 WHEN OTHERS THEN
1590 xla_exceptions_pkg.raise_message
1591 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctDerRule_11');
1592 END AcctDerRule_11;
1593 --
1594
1595 ---------------------------------------
1596 --
1597 -- PRIVATE FUNCTION
1598 -- AcctLineType_12
1599 --
1600 ---------------------------------------
1601 PROCEDURE AcctLineType_12 (
1602 p_application_id IN NUMBER
1603 ,p_event_id IN NUMBER
1604 ,p_calculate_acctd_flag IN VARCHAR2
1605 ,p_calculate_g_l_flag IN VARCHAR2
1606 ,p_actual_flag IN OUT VARCHAR2
1607 ,p_balance_type_code OUT VARCHAR2
1608 ,p_gain_or_loss_ref OUT VARCHAR2
1609
1610 --PO Budget Account
1611 , p_source_3 IN NUMBER
1612 --Federal Prior Year Flag
1613 , p_source_5 IN VARCHAR2
1614 --Receiving Accounting Line Type
1615 , p_source_6 IN VARCHAR2
1616 --Applied to Application ID
1617 , p_source_7 IN NUMBER
1618 --Applied to Distribution Link Type
1619 , p_source_8 IN VARCHAR2
1620 --Applied to Entity Code
1621 , p_source_9 IN VARCHAR2
1622 --PO_DISTRIBUTION_ID
1623 , p_source_10 IN NUMBER
1624 --Applied To Purchase Document Identifier
1625 , p_source_11 IN NUMBER
1626 --DISTRIBUTION_IDENTIFIER
1627 , p_source_12 IN NUMBER
1628 --Distribution Type
1629 , p_source_13 IN VARCHAR2
1630 , p_source_13_meaning IN VARCHAR2
1631 --Encumbrance Reversal Amount Entered
1632 , p_source_14 IN NUMBER
1633 --Entered Currency Code
1634 , p_source_15 IN VARCHAR2
1635 --Transaction Encumbrance Reversal Amount
1636 , p_source_16 IN NUMBER
1637 --Costing Encumbrance Upgrade Option
1638 , p_source_17 IN VARCHAR2
1639 --Federal Anticipated Amt
1640 , p_source_18 IN NUMBER
1641 --Currency Conversion Date
1642 , p_source_19 IN DATE
1643 --Currency Conversion Rate
1644 , p_source_20 IN NUMBER
1645 --Currency Conversion Type
1646 , p_source_21 IN VARCHAR2
1647 --Purchasing Encumbrance Type Identifier
1648 , p_source_22 IN NUMBER
1649 )
1650 IS
1651
1652 l_component_type VARCHAR2(80);
1653 l_component_code VARCHAR2(30);
1654 l_component_type_code VARCHAR2(1);
1655 l_component_appl_id INTEGER;
1656 l_amb_context_code VARCHAR2(30);
1657 l_entity_code VARCHAR2(30);
1658 l_event_class_code VARCHAR2(30);
1659 l_ae_header_id NUMBER;
1660 l_event_type_code VARCHAR2(30);
1661 l_line_definition_code VARCHAR2(30);
1662 l_line_definition_owner_code VARCHAR2(1);
1663 --
1664 -- adr variables
1665 l_segment VARCHAR2(30);
1666 l_ccid NUMBER;
1667 l_adr_transaction_coa_id NUMBER;
1668 l_adr_accounting_coa_id NUMBER;
1669 l_adr_flexfield_segment_code VARCHAR2(30);
1670 l_adr_flex_value_set_id NUMBER;
1671 l_adr_value_type_code VARCHAR2(30);
1672 l_adr_value_combination_id NUMBER;
1673 l_adr_value_segment_code VARCHAR2(30);
1674
1675 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
1676 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
1677 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
1678 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
1679
1680 -- 4262811 Variables ------------------------------------------------------------------------------------------
1681 l_entered_amt_idx NUMBER;
1682 l_accted_amt_idx NUMBER;
1683 l_acc_rev_flag VARCHAR2(1);
1684 l_accrual_line_num NUMBER;
1685 l_tmp_amt NUMBER;
1686 l_acc_rev_natural_side_code VARCHAR2(1);
1687
1688 l_num_entries NUMBER;
1689 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
1690 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
1691 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
1692 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
1693 l_recog_line_1 NUMBER;
1694 l_recog_line_2 NUMBER;
1695
1696 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
1697 l_bflow_applied_to_amt NUMBER; -- 5132302
1698 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
1699
1700 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
1701
1702 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
1703 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
1704
1705 ---------------------------------------------------------------------------------------------------------------
1706
1707
1708 --
1709 -- bulk performance
1710 --
1711 l_balance_type_code VARCHAR2(1);
1712 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
1713 l_log_module VARCHAR2(240);
1714
1715 --
1716 -- Upgrade strategy
1717 --
1718 l_actual_upg_option VARCHAR2(1);
1719 l_enc_upg_option VARCHAR2(1);
1720
1721 --
1722 BEGIN
1723 --
1724 IF g_log_enabled THEN
1725 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_12';
1726 END IF;
1727 --
1728 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1729
1730 trace
1731 (p_msg => 'BEGIN of AcctLineType_12'
1732 ,p_level => C_LEVEL_PROCEDURE
1733 ,p_module => l_log_module);
1734
1735 END IF;
1736 --
1737 l_component_type := 'AMB_JLT';
1738 l_component_code := 'FV_DOWNWARD_ANTICIPATED_CR';
1739 l_component_type_code := 'S';
1740 l_component_appl_id := 707;
1741 l_amb_context_code := 'DEFAULT';
1742 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
1743 l_event_class_code := 'DELIVER_EXPENSE';
1744 l_event_type_code := 'DELIVER_EXPENSE_ALL';
1745 l_line_definition_owner_code := 'S';
1746 l_line_definition_code := 'FV_RETURN_TO_RECEIVING';
1747 --
1748 l_balance_type_code := 'A';
1749 l_segment := NULL;
1750 l_ccid := NULL;
1751 l_adr_transaction_coa_id := NULL;
1752 l_adr_accounting_coa_id := NULL;
1753 l_adr_flexfield_segment_code := NULL;
1754 l_adr_flex_value_set_id := NULL;
1755 l_adr_value_type_code := NULL;
1756 l_adr_value_combination_id := NULL;
1757 l_adr_value_segment_code := NULL;
1758
1759 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
1760 l_bflow_class_code := ''; -- 4219869 Business Flow
1761 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
1762 l_budgetary_control_flag := 'Y';
1763
1764 l_bflow_applied_to_amt_idx := NULL; -- 5132302
1765 l_bflow_applied_to_amt := NULL; -- 5132302
1766 l_entered_amt_idx := NULL; -- 4262811
1767 l_accted_amt_idx := NULL; -- 4262811
1768 l_acc_rev_flag := NULL; -- 4262811
1769 l_accrual_line_num := NULL; -- 4262811
1770 l_tmp_amt := NULL; -- 4262811
1771 --
1772
1773 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
1774 l_balance_type_code <> 'B' THEN
1775 IF NVL(
1776 xla_ae_sources_pkg.GetSystemSourceChar(
1777 p_source_code => 'XLA_EVENT_TYPE_CODE'
1778 , p_source_type_code => 'Y'
1779 , p_source_application_id => 602
1780 ),'
1781 ') = 'RETURN_TO_RECEIVING' AND
1782 NVL(p_source_5,'
1783 ') = 'Y' AND
1784 NVL(p_source_6,'
1785 ') = 'Charge'
1786 THEN
1787
1788 --
1789 XLA_AE_LINES_PKG.SetNewLine;
1790
1791 p_balance_type_code := l_balance_type_code;
1792 -- set the flag so later we will know whether the gain loss line needs to be created
1793
1794 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
1795 p_actual_flag :='A';
1796 END IF;
1797
1798 --
1799 -- bulk performance
1800 --
1801 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
1802 p_header_num => 0); -- 4262811
1803 --
1804 -- set accounting line options
1805 --
1806 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
1807 p_natural_side_code => 'C'
1808 , p_gain_or_loss_flag => 'N'
1809 , p_gl_transfer_mode_code => 'S'
1810 , p_acct_entry_type_code => 'A'
1811 , p_switch_side_flag => 'N'
1812 , p_merge_duplicate_code => 'N'
1813 );
1814 --
1815 l_acc_rev_natural_side_code := 'D'; -- 4262811
1816 --
1817 --
1818 -- set accounting line type info
1819 --
1820 xla_ae_lines_pkg.SetAcctLineType
1821 (p_component_type => l_component_type
1822 ,p_event_type_code => l_event_type_code
1823 ,p_line_definition_owner_code => l_line_definition_owner_code
1824 ,p_line_definition_code => l_line_definition_code
1825 ,p_accounting_line_code => l_component_code
1826 ,p_accounting_line_type_code => l_component_type_code
1827 ,p_accounting_line_appl_id => l_component_appl_id
1828 ,p_amb_context_code => l_amb_context_code
1829 ,p_entity_code => l_entity_code
1830 ,p_event_class_code => l_event_class_code);
1831 --
1832 -- set accounting class
1833 --
1834 xla_ae_lines_pkg.SetAcctClass(
1835 p_accounting_class_code => 'FEDERAL_EXP'
1836 , p_ae_header_id => l_ae_header_id
1837 );
1838
1839 --
1840 -- set rounding class
1841 --
1842 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
1843 'FEDERAL_EXP';
1844
1845 --
1846 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
1847 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
1848 --
1849 -- bulk performance
1850 --
1851 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
1852
1853 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
1854 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
1855
1856 -- 4955764
1857 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
1858 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
1859
1860 -- 4458381 Public Sector Enh
1861
1862 --
1863 -- set accounting attributes for the line type
1864 --
1865 l_entered_amt_idx := 17;
1866 l_accted_amt_idx := 22;
1867 l_bflow_applied_to_amt_idx := NULL; -- 5132302
1868 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
1869 l_rec_acct_attrs.array_num_value(1) := p_source_7;
1870 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
1871 l_rec_acct_attrs.array_char_value(2) := p_source_8;
1872 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
1873 l_rec_acct_attrs.array_char_value(3) := p_source_9;
1874 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
1875 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
1876 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
1877 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
1878 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
1879 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
1880 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
1881 l_rec_acct_attrs.array_char_value(7) := p_source_13;
1882 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
1883 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
1884 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
1885 l_rec_acct_attrs.array_num_value(9) := p_source_14;
1886 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
1887 l_rec_acct_attrs.array_char_value(10) := p_source_15;
1888 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
1889 l_rec_acct_attrs.array_num_value(11) := p_source_16;
1890 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
1891 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
1892 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
1893 l_rec_acct_attrs.array_num_value(13) := p_source_14;
1894 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
1895 l_rec_acct_attrs.array_char_value(14) := p_source_15;
1896 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
1897 l_rec_acct_attrs.array_num_value(15) := p_source_16;
1898 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
1899 l_rec_acct_attrs.array_char_value(16) := p_source_17;
1900 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
1901 l_rec_acct_attrs.array_num_value(17) := p_source_18;
1902 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
1903 l_rec_acct_attrs.array_char_value(18) := p_source_15;
1904 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
1905 l_rec_acct_attrs.array_date_value(19) := p_source_19;
1906 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
1907 l_rec_acct_attrs.array_num_value(20) := p_source_20;
1908 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
1909 l_rec_acct_attrs.array_char_value(21) := p_source_21;
1910 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
1911 l_rec_acct_attrs.array_num_value(22) := p_source_18;
1912 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
1913 l_rec_acct_attrs.array_num_value(23) := p_source_22;
1914 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
1915 l_rec_acct_attrs.array_num_value(24) := p_source_22;
1916
1917 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
1918 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
1919
1920 ---------------------------------------------------------------------------------------------------------------
1921 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
1922 ---------------------------------------------------------------------------------------------------------------
1923 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
1924
1925 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
1926 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
1927
1928 IF xla_accounting_cache_pkg.GetValueChar
1929 (p_source_code => 'LEDGER_CATEGORY_CODE'
1930 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
1931 AND l_bflow_method_code = 'PRIOR_ENTRY'
1932 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
1933 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
1934 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
1935 )
1936 THEN
1937 xla_ae_lines_pkg.BflowUpgEntry
1938 (p_business_method_code => l_bflow_method_code
1939 ,p_business_class_code => l_bflow_class_code
1940 ,p_balance_type => l_balance_type_code);
1941 ELSE
1942 NULL;
1943 -- No business flow processing for business flow method of NONE.
1944 END IF;
1945
1946 --
1947 -- call analytical criteria
1948 --
1949
1950 --
1951 -- call description
1952 --
1953 -- No description or it is inherited.
1954 --
1955 -- call ADRs
1956 -- Bug 4922099
1957 --
1958 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
1959 (NVL(l_actual_upg_option, 'N') = 'O') OR
1960 (NVL(l_enc_upg_option, 'N') = 'O')
1961 )
1962 THEN
1963 NULL;
1964 --
1965 --
1966
1967 l_ccid := AcctDerRule_11(
1968 p_application_id => p_application_id
1969 , p_ae_header_id => l_ae_header_id
1970 , p_source_3 => p_source_3
1971 , x_transaction_coa_id => l_adr_transaction_coa_id
1972 , x_accounting_coa_id => l_adr_accounting_coa_id
1973 , x_value_type_code => l_adr_value_type_code
1974 , p_side => 'NA'
1975 );
1976
1977 xla_ae_lines_pkg.set_ccid(
1978 p_code_combination_id => l_ccid
1979 , p_value_type_code => l_adr_value_type_code
1980 , p_transaction_coa_id => l_adr_transaction_coa_id
1981 , p_accounting_coa_id => l_adr_accounting_coa_id
1982 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
1983 , p_adr_type_code => 'S'
1984 , p_component_type => l_component_type
1985 , p_component_code => l_component_code
1986 , p_component_type_code => l_component_type_code
1987 , p_component_appl_id => l_component_appl_id
1988 , p_amb_context_code => l_amb_context_code
1989 , p_side => 'NA'
1990 );
1991
1992
1993 l_segment := AcctDerRule_2(
1994 p_application_id => p_application_id
1995 , p_ae_header_id => l_ae_header_id
1996 , x_transaction_coa_id => l_adr_transaction_coa_id
1997 , x_accounting_coa_id => l_adr_accounting_coa_id
1998 , x_flexfield_segment_code => l_adr_flexfield_segment_code
1999 , x_flex_value_set_id => l_adr_flex_value_set_id
2000 , x_value_type_code => l_adr_value_type_code
2001 , x_value_combination_id => l_adr_value_combination_id
2002 , x_value_segment_code => l_adr_value_segment_code
2003 , p_side => 'NA'
2004 , p_override_seg_flag => 'Y'
2005 );
2006
2007 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
2008
2009 xla_ae_lines_pkg.set_segment(
2010 p_to_segment_code => 'GL_ACCOUNT'
2011 , p_segment_value => l_segment
2012 , p_from_segment_code => l_adr_value_segment_code
2013 , p_from_combination_id => l_adr_value_combination_id
2014 , p_value_type_code => l_adr_value_type_code
2015 , p_transaction_coa_id => l_adr_transaction_coa_id
2016 , p_accounting_coa_id => l_adr_accounting_coa_id
2017 , p_flexfield_segment_code => l_adr_flexfield_segment_code
2018 , p_flex_value_set_id => l_adr_flex_value_set_id
2019 , p_adr_code => 'FV_431002'
2020 , p_adr_type_code => 'S'
2021 , p_component_type => l_component_type
2022 , p_component_code => l_component_code
2023 , p_component_type_code => l_component_type_code
2024 , p_component_appl_id => l_component_appl_id
2025 , p_amb_context_code => l_amb_context_code
2026 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
2027 , p_event_class_code => 'DELIVER_EXPENSE'
2028 , p_side => 'NA'
2029 );
2030
2031 END IF;
2032
2033 --
2034 --
2035 END IF;
2036 --
2037 -- Bug 4922099
2038 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
2039 (NVL(l_enc_upg_option, 'N') = 'O')
2040 ) AND
2041 (l_bflow_method_code = 'PRIOR_ENTRY')
2042 )
2043 THEN
2044 IF
2045 --
2046 1 = 2
2047 --
2048 THEN
2049 xla_accounting_err_pkg.build_message
2050 (p_appli_s_name => 'XLA'
2051 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2052 ,p_token_1 => 'LINE_NUMBER'
2053 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
2054 ,p_token_2 => 'LINE_TYPE_NAME'
2055 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
2056 l_component_type
2057 ,l_component_code
2058 ,l_component_type_code
2059 ,l_component_appl_id
2060 ,l_amb_context_code
2061 ,l_entity_code
2062 ,l_event_class_code
2063 )
2064 ,p_token_3 => 'OWNER'
2065 ,p_value_3 => xla_lookups_pkg.get_meaning(
2066 p_lookup_type => 'XLA_OWNER_TYPE'
2067 ,p_lookup_code => l_component_type_code
2068 )
2069 ,p_token_4 => 'PRODUCT_NAME'
2070 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
2071 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
2072 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
2073 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
2074 ,p_ae_header_id => NULL
2075 );
2076
2077 IF (C_LEVEL_ERROR>= g_log_level) THEN
2078 trace
2079 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2080 ,p_level => C_LEVEL_ERROR
2081 ,p_module => l_log_module);
2082 END IF;
2083 END IF;
2084 END IF;
2085 --
2086 --
2087 ------------------------------------------------------------------------------------------------
2088 -- 4219869 Business Flow
2089 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
2090 -- Prior Entry. Currently, the following code is always generated.
2091 ------------------------------------------------------------------------------------------------
2092 XLA_AE_LINES_PKG.ValidateCurrentLine;
2093
2094 ------------------------------------------------------------------------------------
2095 -- 4219869 Business Flow
2096 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
2097 ------------------------------------------------------------------------------------
2098 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2099
2100 ----------------------------------------------------------------------------------
2101 -- 4219869 Business Flow
2102 -- Update journal entry status -- Need to generate this within IF <condition>
2103 ----------------------------------------------------------------------------------
2104 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2105 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
2106 ,p_balance_type_code => l_balance_type_code
2107 );
2108
2109 -------------------------------------------------------------------------------------------
2110 -- 4262811 - Generate the Accrual Reversal lines
2111 -------------------------------------------------------------------------------------------
2112 BEGIN
2113 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
2114 (g_array_event(p_event_id).array_value_num('header_index'));
2115 IF l_acc_rev_flag IS NULL THEN
2116 l_acc_rev_flag := 'N';
2117 END IF;
2118 EXCEPTION
2119 WHEN OTHERS THEN
2120 l_acc_rev_flag := 'N';
2121 END;
2122 --
2123 IF (l_acc_rev_flag = 'Y') THEN
2124
2125 -- 4645092 ------------------------------------------------------------------------------
2126 -- To allow MPA report to determine if it should generate report process
2127 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
2128 ------------------------------------------------------------------------------------------
2129
2130 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
2131 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
2132 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
2133 -- call ADRs
2134 -- Bug 4922099
2135 --
2136 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
2137 (NVL(l_actual_upg_option, 'N') = 'O') OR
2138 (NVL(l_enc_upg_option, 'N') = 'O')
2139 )
2140 THEN
2141 NULL;
2142 --
2143 --
2144
2145 l_ccid := AcctDerRule_11(
2146 p_application_id => p_application_id
2147 , p_ae_header_id => l_ae_header_id
2148 , p_source_3 => p_source_3
2149 , x_transaction_coa_id => l_adr_transaction_coa_id
2150 , x_accounting_coa_id => l_adr_accounting_coa_id
2151 , x_value_type_code => l_adr_value_type_code
2152 , p_side => 'NA'
2153 );
2154
2155 xla_ae_lines_pkg.set_ccid(
2156 p_code_combination_id => l_ccid
2157 , p_value_type_code => l_adr_value_type_code
2158 , p_transaction_coa_id => l_adr_transaction_coa_id
2159 , p_accounting_coa_id => l_adr_accounting_coa_id
2160 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
2161 , p_adr_type_code => 'S'
2162 , p_component_type => l_component_type
2163 , p_component_code => l_component_code
2164 , p_component_type_code => l_component_type_code
2165 , p_component_appl_id => l_component_appl_id
2166 , p_amb_context_code => l_amb_context_code
2167 , p_side => 'NA'
2168 );
2169
2170
2171 l_segment := AcctDerRule_2(
2172 p_application_id => p_application_id
2173 , p_ae_header_id => l_ae_header_id
2174 , x_transaction_coa_id => l_adr_transaction_coa_id
2175 , x_accounting_coa_id => l_adr_accounting_coa_id
2176 , x_flexfield_segment_code => l_adr_flexfield_segment_code
2177 , x_flex_value_set_id => l_adr_flex_value_set_id
2178 , x_value_type_code => l_adr_value_type_code
2179 , x_value_combination_id => l_adr_value_combination_id
2180 , x_value_segment_code => l_adr_value_segment_code
2181 , p_side => 'NA'
2182 , p_override_seg_flag => 'Y'
2183 );
2184
2185 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
2186
2187 xla_ae_lines_pkg.set_segment(
2188 p_to_segment_code => 'GL_ACCOUNT'
2189 , p_segment_value => l_segment
2190 , p_from_segment_code => l_adr_value_segment_code
2191 , p_from_combination_id => l_adr_value_combination_id
2192 , p_value_type_code => l_adr_value_type_code
2193 , p_transaction_coa_id => l_adr_transaction_coa_id
2194 , p_accounting_coa_id => l_adr_accounting_coa_id
2195 , p_flexfield_segment_code => l_adr_flexfield_segment_code
2196 , p_flex_value_set_id => l_adr_flex_value_set_id
2197 , p_adr_code => 'FV_431002'
2198 , p_adr_type_code => 'S'
2199 , p_component_type => l_component_type
2200 , p_component_code => l_component_code
2201 , p_component_type_code => l_component_type_code
2202 , p_component_appl_id => l_component_appl_id
2203 , p_amb_context_code => l_amb_context_code
2204 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
2205 , p_event_class_code => 'DELIVER_EXPENSE'
2206 , p_side => 'NA'
2207 );
2208
2209 END IF;
2210
2211 --
2212 --
2213 END IF;
2214
2215 --
2216 -- Update the line information that should be overwritten
2217 --
2218 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
2219 p_header_num => 1);
2220 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
2221
2222 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
2223
2224 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
2225 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
2226 END IF;
2227
2228 --
2229 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
2230 --
2231 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
2232 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
2233 ELSE
2234 ---------------------------------------------------------------------------------------------------
2235 -- 4262811a Switch Sign
2236 ---------------------------------------------------------------------------------------------------
2237 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
2238 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2239 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2240 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2241 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2242 -- 5132302
2243 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
2244 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2245
2246 END IF;
2247
2248 -- 4955764
2249 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
2250 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
2251
2252
2253 XLA_AE_LINES_PKG.ValidateCurrentLine;
2254 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2255
2256 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2257 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
2258 ,p_balance_type_code => l_balance_type_code);
2259
2260 END IF;
2261
2262 -----------------------------------------------------------------------------------------
2263 -- 4262811 Multiperiod Accounting
2264 -----------------------------------------------------------------------------------------
2265 -- No MPA option is assigned.
2266
2267
2268 END IF;
2269 END IF;
2270 --
2271
2272 --
2273 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2274 trace
2275 (p_msg => 'END of AcctLineType_12'
2276 ,p_level => C_LEVEL_PROCEDURE
2277 ,p_module => l_log_module);
2278 END IF;
2279 --
2280 EXCEPTION
2281 WHEN xla_exceptions_pkg.application_exception THEN
2282 RAISE;
2283 WHEN OTHERS THEN
2284 xla_exceptions_pkg.raise_message
2285 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_12');
2286 END AcctLineType_12;
2287 --
2288
2289 ---------------------------------------
2290 --
2291 -- PRIVATE FUNCTION
2292 -- AcctLineType_13
2293 --
2294 ---------------------------------------
2295 PROCEDURE AcctLineType_13 (
2296 p_application_id IN NUMBER
2297 ,p_event_id IN NUMBER
2298 ,p_calculate_acctd_flag IN VARCHAR2
2299 ,p_calculate_g_l_flag IN VARCHAR2
2300 ,p_actual_flag IN OUT VARCHAR2
2301 ,p_balance_type_code OUT VARCHAR2
2302 ,p_gain_or_loss_ref OUT VARCHAR2
2303
2304 --PO Budget Account
2305 , p_source_3 IN NUMBER
2306 --Federal Prior Year Flag
2307 , p_source_5 IN VARCHAR2
2308 --Applied to Application ID
2309 , p_source_7 IN NUMBER
2310 --Applied to Distribution Link Type
2311 , p_source_8 IN VARCHAR2
2312 --Applied to Entity Code
2313 , p_source_9 IN VARCHAR2
2314 --Applied To Purchase Document Identifier
2315 , p_source_11 IN NUMBER
2316 --DISTRIBUTION_IDENTIFIER
2317 , p_source_12 IN NUMBER
2318 --Distribution Type
2319 , p_source_13 IN VARCHAR2
2320 , p_source_13_meaning IN VARCHAR2
2321 --Encumbrance Reversal Amount Entered
2322 , p_source_14 IN NUMBER
2323 --Entered Currency Code
2324 , p_source_15 IN VARCHAR2
2325 --Transaction Encumbrance Reversal Amount
2326 , p_source_16 IN NUMBER
2327 --Costing Encumbrance Upgrade Option
2328 , p_source_17 IN VARCHAR2
2329 --Federal Anticipated Amt
2330 , p_source_18 IN NUMBER
2331 --Currency Conversion Date
2332 , p_source_19 IN DATE
2333 --Currency Conversion Rate
2334 , p_source_20 IN NUMBER
2335 --Currency Conversion Type
2336 , p_source_21 IN VARCHAR2
2337 --Purchasing Encumbrance Type Identifier
2338 , p_source_22 IN NUMBER
2339 --TXN_PO_DISTRIBUTION_ID
2340 , p_source_23 IN NUMBER
2341 )
2342 IS
2343
2344 l_component_type VARCHAR2(80);
2345 l_component_code VARCHAR2(30);
2346 l_component_type_code VARCHAR2(1);
2347 l_component_appl_id INTEGER;
2348 l_amb_context_code VARCHAR2(30);
2349 l_entity_code VARCHAR2(30);
2350 l_event_class_code VARCHAR2(30);
2351 l_ae_header_id NUMBER;
2352 l_event_type_code VARCHAR2(30);
2353 l_line_definition_code VARCHAR2(30);
2354 l_line_definition_owner_code VARCHAR2(1);
2355 --
2356 -- adr variables
2357 l_segment VARCHAR2(30);
2358 l_ccid NUMBER;
2359 l_adr_transaction_coa_id NUMBER;
2360 l_adr_accounting_coa_id NUMBER;
2361 l_adr_flexfield_segment_code VARCHAR2(30);
2362 l_adr_flex_value_set_id NUMBER;
2363 l_adr_value_type_code VARCHAR2(30);
2364 l_adr_value_combination_id NUMBER;
2365 l_adr_value_segment_code VARCHAR2(30);
2366
2367 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
2368 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
2369 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
2370 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
2371
2372 -- 4262811 Variables ------------------------------------------------------------------------------------------
2373 l_entered_amt_idx NUMBER;
2374 l_accted_amt_idx NUMBER;
2375 l_acc_rev_flag VARCHAR2(1);
2376 l_accrual_line_num NUMBER;
2377 l_tmp_amt NUMBER;
2378 l_acc_rev_natural_side_code VARCHAR2(1);
2379
2380 l_num_entries NUMBER;
2381 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
2382 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
2383 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
2384 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
2385 l_recog_line_1 NUMBER;
2386 l_recog_line_2 NUMBER;
2387
2388 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
2389 l_bflow_applied_to_amt NUMBER; -- 5132302
2390 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
2391
2392 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
2393
2394 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
2395 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
2396
2397 ---------------------------------------------------------------------------------------------------------------
2398
2399
2400 --
2401 -- bulk performance
2402 --
2403 l_balance_type_code VARCHAR2(1);
2404 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
2405 l_log_module VARCHAR2(240);
2406
2407 --
2408 -- Upgrade strategy
2409 --
2410 l_actual_upg_option VARCHAR2(1);
2411 l_enc_upg_option VARCHAR2(1);
2412
2413 --
2414 BEGIN
2415 --
2416 IF g_log_enabled THEN
2417 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_13';
2418 END IF;
2419 --
2420 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2421
2422 trace
2423 (p_msg => 'BEGIN of AcctLineType_13'
2424 ,p_level => C_LEVEL_PROCEDURE
2425 ,p_module => l_log_module);
2426
2427 END IF;
2428 --
2429 l_component_type := 'AMB_JLT';
2430 l_component_code := 'FV_DOWNWARD_ANTICIPATED_CR_RTI';
2431 l_component_type_code := 'S';
2432 l_component_appl_id := 707;
2433 l_amb_context_code := 'DEFAULT';
2434 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
2435 l_event_class_code := 'PURCHASE_ORDER';
2436 l_event_type_code := 'PURCHASE_ORDER_ALL';
2437 l_line_definition_owner_code := 'S';
2438 l_line_definition_code := 'FV_RET_RI_INV';
2439 --
2440 l_balance_type_code := 'A';
2441 l_segment := NULL;
2442 l_ccid := NULL;
2443 l_adr_transaction_coa_id := NULL;
2444 l_adr_accounting_coa_id := NULL;
2445 l_adr_flexfield_segment_code := NULL;
2446 l_adr_flex_value_set_id := NULL;
2447 l_adr_value_type_code := NULL;
2448 l_adr_value_combination_id := NULL;
2449 l_adr_value_segment_code := NULL;
2450
2451 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
2452 l_bflow_class_code := ''; -- 4219869 Business Flow
2453 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
2454 l_budgetary_control_flag := 'Y';
2455
2456 l_bflow_applied_to_amt_idx := NULL; -- 5132302
2457 l_bflow_applied_to_amt := NULL; -- 5132302
2458 l_entered_amt_idx := NULL; -- 4262811
2459 l_accted_amt_idx := NULL; -- 4262811
2460 l_acc_rev_flag := NULL; -- 4262811
2461 l_accrual_line_num := NULL; -- 4262811
2462 l_tmp_amt := NULL; -- 4262811
2463 --
2464
2465 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
2466 l_balance_type_code <> 'B' THEN
2467 IF NVL(
2468 xla_ae_sources_pkg.GetSystemSourceChar(
2469 p_source_code => 'XLA_EVENT_TYPE_CODE'
2470 , p_source_type_code => 'Y'
2471 , p_source_application_id => 602
2472 ),'
2473 ') = 'RET_RI_INV' AND
2474 NVL(p_source_5,'
2475 ') = 'Y'
2476 THEN
2477
2478 --
2479 XLA_AE_LINES_PKG.SetNewLine;
2480
2481 p_balance_type_code := l_balance_type_code;
2482 -- set the flag so later we will know whether the gain loss line needs to be created
2483
2484 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
2485 p_actual_flag :='A';
2486 END IF;
2487
2488 --
2489 -- bulk performance
2490 --
2491 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
2492 p_header_num => 0); -- 4262811
2493 --
2494 -- set accounting line options
2495 --
2496 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
2497 p_natural_side_code => 'C'
2498 , p_gain_or_loss_flag => 'N'
2499 , p_gl_transfer_mode_code => 'S'
2500 , p_acct_entry_type_code => 'A'
2501 , p_switch_side_flag => 'N'
2502 , p_merge_duplicate_code => 'N'
2503 );
2504 --
2505 l_acc_rev_natural_side_code := 'D'; -- 4262811
2506 --
2507 --
2508 -- set accounting line type info
2509 --
2510 xla_ae_lines_pkg.SetAcctLineType
2511 (p_component_type => l_component_type
2512 ,p_event_type_code => l_event_type_code
2513 ,p_line_definition_owner_code => l_line_definition_owner_code
2514 ,p_line_definition_code => l_line_definition_code
2515 ,p_accounting_line_code => l_component_code
2516 ,p_accounting_line_type_code => l_component_type_code
2517 ,p_accounting_line_appl_id => l_component_appl_id
2518 ,p_amb_context_code => l_amb_context_code
2519 ,p_entity_code => l_entity_code
2520 ,p_event_class_code => l_event_class_code);
2521 --
2522 -- set accounting class
2523 --
2524 xla_ae_lines_pkg.SetAcctClass(
2525 p_accounting_class_code => 'FEDERAL_INV'
2526 , p_ae_header_id => l_ae_header_id
2527 );
2528
2529 --
2530 -- set rounding class
2531 --
2532 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
2533 'FEDERAL_INV';
2534
2535 --
2536 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
2537 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
2538 --
2539 -- bulk performance
2540 --
2541 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
2542
2543 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
2544 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
2545
2546 -- 4955764
2547 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
2548 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
2549
2550 -- 4458381 Public Sector Enh
2551
2552 --
2553 -- set accounting attributes for the line type
2554 --
2555 l_entered_amt_idx := 17;
2556 l_accted_amt_idx := 22;
2557 l_bflow_applied_to_amt_idx := NULL; -- 5132302
2558 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
2559 l_rec_acct_attrs.array_num_value(1) := p_source_7;
2560 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
2561 l_rec_acct_attrs.array_char_value(2) := p_source_8;
2562 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
2563 l_rec_acct_attrs.array_char_value(3) := p_source_9;
2564 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
2565 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
2566 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
2567 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
2568 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
2569 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
2570 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
2571 l_rec_acct_attrs.array_char_value(7) := p_source_13;
2572 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
2573 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
2574 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
2575 l_rec_acct_attrs.array_num_value(9) := p_source_14;
2576 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
2577 l_rec_acct_attrs.array_char_value(10) := p_source_15;
2578 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
2579 l_rec_acct_attrs.array_num_value(11) := p_source_16;
2580 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
2581 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
2582 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
2583 l_rec_acct_attrs.array_num_value(13) := p_source_14;
2584 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
2585 l_rec_acct_attrs.array_char_value(14) := p_source_15;
2586 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
2587 l_rec_acct_attrs.array_num_value(15) := p_source_16;
2588 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
2589 l_rec_acct_attrs.array_char_value(16) := p_source_17;
2590 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
2591 l_rec_acct_attrs.array_num_value(17) := p_source_18;
2592 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
2593 l_rec_acct_attrs.array_char_value(18) := p_source_15;
2594 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
2595 l_rec_acct_attrs.array_date_value(19) := p_source_19;
2596 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
2597 l_rec_acct_attrs.array_num_value(20) := p_source_20;
2598 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
2599 l_rec_acct_attrs.array_char_value(21) := p_source_21;
2600 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
2601 l_rec_acct_attrs.array_num_value(22) := p_source_18;
2602 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
2603 l_rec_acct_attrs.array_num_value(23) := p_source_22;
2604 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
2605 l_rec_acct_attrs.array_num_value(24) := p_source_22;
2606
2607 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
2608 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
2609
2610 ---------------------------------------------------------------------------------------------------------------
2611 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
2612 ---------------------------------------------------------------------------------------------------------------
2613 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
2614
2615 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
2616 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
2617
2618 IF xla_accounting_cache_pkg.GetValueChar
2619 (p_source_code => 'LEDGER_CATEGORY_CODE'
2620 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
2621 AND l_bflow_method_code = 'PRIOR_ENTRY'
2622 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
2623 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
2624 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
2625 )
2626 THEN
2627 xla_ae_lines_pkg.BflowUpgEntry
2628 (p_business_method_code => l_bflow_method_code
2629 ,p_business_class_code => l_bflow_class_code
2630 ,p_balance_type => l_balance_type_code);
2631 ELSE
2632 NULL;
2633 -- No business flow processing for business flow method of NONE.
2634 END IF;
2635
2636 --
2637 -- call analytical criteria
2638 --
2639
2640 --
2641 -- call description
2642 --
2643 -- No description or it is inherited.
2644 --
2645 -- call ADRs
2646 -- Bug 4922099
2647 --
2648 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
2649 (NVL(l_actual_upg_option, 'N') = 'O') OR
2650 (NVL(l_enc_upg_option, 'N') = 'O')
2651 )
2652 THEN
2653 NULL;
2654 --
2655 --
2656
2657 l_ccid := AcctDerRule_11(
2658 p_application_id => p_application_id
2659 , p_ae_header_id => l_ae_header_id
2660 , p_source_3 => p_source_3
2661 , x_transaction_coa_id => l_adr_transaction_coa_id
2662 , x_accounting_coa_id => l_adr_accounting_coa_id
2663 , x_value_type_code => l_adr_value_type_code
2664 , p_side => 'NA'
2665 );
2666
2667 xla_ae_lines_pkg.set_ccid(
2668 p_code_combination_id => l_ccid
2669 , p_value_type_code => l_adr_value_type_code
2670 , p_transaction_coa_id => l_adr_transaction_coa_id
2671 , p_accounting_coa_id => l_adr_accounting_coa_id
2672 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
2673 , p_adr_type_code => 'S'
2674 , p_component_type => l_component_type
2675 , p_component_code => l_component_code
2676 , p_component_type_code => l_component_type_code
2677 , p_component_appl_id => l_component_appl_id
2678 , p_amb_context_code => l_amb_context_code
2679 , p_side => 'NA'
2680 );
2681
2682
2683 l_segment := AcctDerRule_2(
2684 p_application_id => p_application_id
2685 , p_ae_header_id => l_ae_header_id
2686 , x_transaction_coa_id => l_adr_transaction_coa_id
2687 , x_accounting_coa_id => l_adr_accounting_coa_id
2688 , x_flexfield_segment_code => l_adr_flexfield_segment_code
2689 , x_flex_value_set_id => l_adr_flex_value_set_id
2690 , x_value_type_code => l_adr_value_type_code
2691 , x_value_combination_id => l_adr_value_combination_id
2692 , x_value_segment_code => l_adr_value_segment_code
2693 , p_side => 'NA'
2694 , p_override_seg_flag => 'Y'
2695 );
2696
2697 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
2698
2699 xla_ae_lines_pkg.set_segment(
2700 p_to_segment_code => 'GL_ACCOUNT'
2701 , p_segment_value => l_segment
2702 , p_from_segment_code => l_adr_value_segment_code
2703 , p_from_combination_id => l_adr_value_combination_id
2704 , p_value_type_code => l_adr_value_type_code
2705 , p_transaction_coa_id => l_adr_transaction_coa_id
2706 , p_accounting_coa_id => l_adr_accounting_coa_id
2707 , p_flexfield_segment_code => l_adr_flexfield_segment_code
2708 , p_flex_value_set_id => l_adr_flex_value_set_id
2709 , p_adr_code => 'FV_431002'
2710 , p_adr_type_code => 'S'
2711 , p_component_type => l_component_type
2712 , p_component_code => l_component_code
2713 , p_component_type_code => l_component_type_code
2714 , p_component_appl_id => l_component_appl_id
2715 , p_amb_context_code => l_amb_context_code
2716 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
2717 , p_event_class_code => 'PURCHASE_ORDER'
2718 , p_side => 'NA'
2719 );
2720
2721 END IF;
2722
2723 --
2724 --
2725 END IF;
2726 --
2727 -- Bug 4922099
2728 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
2729 (NVL(l_enc_upg_option, 'N') = 'O')
2730 ) AND
2731 (l_bflow_method_code = 'PRIOR_ENTRY')
2732 )
2733 THEN
2734 IF
2735 --
2736 1 = 2
2737 --
2738 THEN
2739 xla_accounting_err_pkg.build_message
2740 (p_appli_s_name => 'XLA'
2741 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2742 ,p_token_1 => 'LINE_NUMBER'
2743 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
2744 ,p_token_2 => 'LINE_TYPE_NAME'
2745 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
2746 l_component_type
2747 ,l_component_code
2748 ,l_component_type_code
2749 ,l_component_appl_id
2750 ,l_amb_context_code
2751 ,l_entity_code
2752 ,l_event_class_code
2753 )
2754 ,p_token_3 => 'OWNER'
2755 ,p_value_3 => xla_lookups_pkg.get_meaning(
2756 p_lookup_type => 'XLA_OWNER_TYPE'
2757 ,p_lookup_code => l_component_type_code
2758 )
2759 ,p_token_4 => 'PRODUCT_NAME'
2760 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
2761 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
2762 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
2763 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
2764 ,p_ae_header_id => NULL
2765 );
2766
2767 IF (C_LEVEL_ERROR>= g_log_level) THEN
2768 trace
2769 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2770 ,p_level => C_LEVEL_ERROR
2771 ,p_module => l_log_module);
2772 END IF;
2773 END IF;
2774 END IF;
2775 --
2776 --
2777 ------------------------------------------------------------------------------------------------
2778 -- 4219869 Business Flow
2779 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
2780 -- Prior Entry. Currently, the following code is always generated.
2781 ------------------------------------------------------------------------------------------------
2782 XLA_AE_LINES_PKG.ValidateCurrentLine;
2783
2784 ------------------------------------------------------------------------------------
2785 -- 4219869 Business Flow
2786 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
2787 ------------------------------------------------------------------------------------
2788 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2789
2790 ----------------------------------------------------------------------------------
2791 -- 4219869 Business Flow
2792 -- Update journal entry status -- Need to generate this within IF <condition>
2793 ----------------------------------------------------------------------------------
2794 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2795 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
2796 ,p_balance_type_code => l_balance_type_code
2797 );
2798
2799 -------------------------------------------------------------------------------------------
2800 -- 4262811 - Generate the Accrual Reversal lines
2801 -------------------------------------------------------------------------------------------
2802 BEGIN
2803 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
2804 (g_array_event(p_event_id).array_value_num('header_index'));
2805 IF l_acc_rev_flag IS NULL THEN
2806 l_acc_rev_flag := 'N';
2807 END IF;
2808 EXCEPTION
2809 WHEN OTHERS THEN
2810 l_acc_rev_flag := 'N';
2811 END;
2812 --
2813 IF (l_acc_rev_flag = 'Y') THEN
2814
2815 -- 4645092 ------------------------------------------------------------------------------
2816 -- To allow MPA report to determine if it should generate report process
2817 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
2818 ------------------------------------------------------------------------------------------
2819
2820 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
2821 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
2822 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
2823 -- call ADRs
2824 -- Bug 4922099
2825 --
2826 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
2827 (NVL(l_actual_upg_option, 'N') = 'O') OR
2828 (NVL(l_enc_upg_option, 'N') = 'O')
2829 )
2830 THEN
2831 NULL;
2832 --
2833 --
2834
2835 l_ccid := AcctDerRule_11(
2836 p_application_id => p_application_id
2837 , p_ae_header_id => l_ae_header_id
2838 , p_source_3 => p_source_3
2839 , x_transaction_coa_id => l_adr_transaction_coa_id
2840 , x_accounting_coa_id => l_adr_accounting_coa_id
2841 , x_value_type_code => l_adr_value_type_code
2842 , p_side => 'NA'
2843 );
2844
2845 xla_ae_lines_pkg.set_ccid(
2846 p_code_combination_id => l_ccid
2847 , p_value_type_code => l_adr_value_type_code
2848 , p_transaction_coa_id => l_adr_transaction_coa_id
2849 , p_accounting_coa_id => l_adr_accounting_coa_id
2850 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
2851 , p_adr_type_code => 'S'
2852 , p_component_type => l_component_type
2853 , p_component_code => l_component_code
2854 , p_component_type_code => l_component_type_code
2855 , p_component_appl_id => l_component_appl_id
2856 , p_amb_context_code => l_amb_context_code
2857 , p_side => 'NA'
2858 );
2859
2860
2861 l_segment := AcctDerRule_2(
2862 p_application_id => p_application_id
2863 , p_ae_header_id => l_ae_header_id
2864 , x_transaction_coa_id => l_adr_transaction_coa_id
2865 , x_accounting_coa_id => l_adr_accounting_coa_id
2866 , x_flexfield_segment_code => l_adr_flexfield_segment_code
2867 , x_flex_value_set_id => l_adr_flex_value_set_id
2868 , x_value_type_code => l_adr_value_type_code
2869 , x_value_combination_id => l_adr_value_combination_id
2870 , x_value_segment_code => l_adr_value_segment_code
2871 , p_side => 'NA'
2872 , p_override_seg_flag => 'Y'
2873 );
2874
2875 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
2876
2877 xla_ae_lines_pkg.set_segment(
2878 p_to_segment_code => 'GL_ACCOUNT'
2879 , p_segment_value => l_segment
2880 , p_from_segment_code => l_adr_value_segment_code
2881 , p_from_combination_id => l_adr_value_combination_id
2882 , p_value_type_code => l_adr_value_type_code
2883 , p_transaction_coa_id => l_adr_transaction_coa_id
2884 , p_accounting_coa_id => l_adr_accounting_coa_id
2885 , p_flexfield_segment_code => l_adr_flexfield_segment_code
2886 , p_flex_value_set_id => l_adr_flex_value_set_id
2887 , p_adr_code => 'FV_431002'
2888 , p_adr_type_code => 'S'
2889 , p_component_type => l_component_type
2890 , p_component_code => l_component_code
2891 , p_component_type_code => l_component_type_code
2892 , p_component_appl_id => l_component_appl_id
2893 , p_amb_context_code => l_amb_context_code
2894 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
2895 , p_event_class_code => 'PURCHASE_ORDER'
2896 , p_side => 'NA'
2897 );
2898
2899 END IF;
2900
2901 --
2902 --
2903 END IF;
2904
2905 --
2906 -- Update the line information that should be overwritten
2907 --
2908 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
2909 p_header_num => 1);
2910 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
2911
2912 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
2913
2914 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
2915 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
2916 END IF;
2917
2918 --
2919 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
2920 --
2921 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
2922 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
2923 ELSE
2924 ---------------------------------------------------------------------------------------------------
2925 -- 4262811a Switch Sign
2926 ---------------------------------------------------------------------------------------------------
2927 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
2928 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2929 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2930 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2931 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2932 -- 5132302
2933 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
2934 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2935
2936 END IF;
2937
2938 -- 4955764
2939 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
2940 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
2941
2942
2943 XLA_AE_LINES_PKG.ValidateCurrentLine;
2944 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2945
2946 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2947 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
2948 ,p_balance_type_code => l_balance_type_code);
2949
2950 END IF;
2951
2952 -----------------------------------------------------------------------------------------
2953 -- 4262811 Multiperiod Accounting
2954 -----------------------------------------------------------------------------------------
2955 -- No MPA option is assigned.
2956
2957
2958 END IF;
2959 END IF;
2960 --
2961
2962 --
2963 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2964 trace
2965 (p_msg => 'END of AcctLineType_13'
2966 ,p_level => C_LEVEL_PROCEDURE
2967 ,p_module => l_log_module);
2968 END IF;
2969 --
2970 EXCEPTION
2971 WHEN xla_exceptions_pkg.application_exception THEN
2972 RAISE;
2973 WHEN OTHERS THEN
2974 xla_exceptions_pkg.raise_message
2975 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_13');
2976 END AcctLineType_13;
2977 --
2978
2979 ---------------------------------------
2980 --
2981 -- PRIVATE FUNCTION
2982 -- AcctLineType_14
2983 --
2984 ---------------------------------------
2985 PROCEDURE AcctLineType_14 (
2986 p_application_id IN NUMBER
2987 ,p_event_id IN NUMBER
2988 ,p_calculate_acctd_flag IN VARCHAR2
2989 ,p_calculate_g_l_flag IN VARCHAR2
2990 ,p_actual_flag IN OUT VARCHAR2
2991 ,p_balance_type_code OUT VARCHAR2
2992 ,p_gain_or_loss_ref OUT VARCHAR2
2993
2994 --PO Budget Account
2995 , p_source_3 IN NUMBER
2996 --Federal Prior Year Flag
2997 , p_source_5 IN VARCHAR2
2998 --Receiving Accounting Line Type
2999 , p_source_6 IN VARCHAR2
3000 --Applied to Application ID
3001 , p_source_7 IN NUMBER
3002 --Applied to Distribution Link Type
3003 , p_source_8 IN VARCHAR2
3004 --Applied to Entity Code
3005 , p_source_9 IN VARCHAR2
3006 --PO_DISTRIBUTION_ID
3007 , p_source_10 IN NUMBER
3008 --Applied To Purchase Document Identifier
3009 , p_source_11 IN NUMBER
3010 --DISTRIBUTION_IDENTIFIER
3011 , p_source_12 IN NUMBER
3012 --Distribution Type
3013 , p_source_13 IN VARCHAR2
3014 , p_source_13_meaning IN VARCHAR2
3015 --Encumbrance Reversal Amount Entered
3016 , p_source_14 IN NUMBER
3017 --Entered Currency Code
3018 , p_source_15 IN VARCHAR2
3019 --Transaction Encumbrance Reversal Amount
3020 , p_source_16 IN NUMBER
3021 --Costing Encumbrance Upgrade Option
3022 , p_source_17 IN VARCHAR2
3023 --Currency Conversion Date
3024 , p_source_19 IN DATE
3025 --Currency Conversion Rate
3026 , p_source_20 IN NUMBER
3027 --Currency Conversion Type
3028 , p_source_21 IN VARCHAR2
3029 --Purchasing Encumbrance Type Identifier
3030 , p_source_22 IN NUMBER
3031 --Federal Unanticipated Amt
3032 , p_source_24 IN NUMBER
3033 )
3034 IS
3035
3036 l_component_type VARCHAR2(80);
3037 l_component_code VARCHAR2(30);
3038 l_component_type_code VARCHAR2(1);
3039 l_component_appl_id INTEGER;
3040 l_amb_context_code VARCHAR2(30);
3041 l_entity_code VARCHAR2(30);
3042 l_event_class_code VARCHAR2(30);
3043 l_ae_header_id NUMBER;
3044 l_event_type_code VARCHAR2(30);
3045 l_line_definition_code VARCHAR2(30);
3046 l_line_definition_owner_code VARCHAR2(1);
3047 --
3048 -- adr variables
3049 l_segment VARCHAR2(30);
3050 l_ccid NUMBER;
3051 l_adr_transaction_coa_id NUMBER;
3052 l_adr_accounting_coa_id NUMBER;
3053 l_adr_flexfield_segment_code VARCHAR2(30);
3054 l_adr_flex_value_set_id NUMBER;
3055 l_adr_value_type_code VARCHAR2(30);
3056 l_adr_value_combination_id NUMBER;
3057 l_adr_value_segment_code VARCHAR2(30);
3058
3059 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
3060 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
3061 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
3062 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
3063
3064 -- 4262811 Variables ------------------------------------------------------------------------------------------
3065 l_entered_amt_idx NUMBER;
3066 l_accted_amt_idx NUMBER;
3067 l_acc_rev_flag VARCHAR2(1);
3068 l_accrual_line_num NUMBER;
3069 l_tmp_amt NUMBER;
3070 l_acc_rev_natural_side_code VARCHAR2(1);
3071
3072 l_num_entries NUMBER;
3073 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
3074 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
3075 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
3076 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
3077 l_recog_line_1 NUMBER;
3078 l_recog_line_2 NUMBER;
3079
3080 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
3081 l_bflow_applied_to_amt NUMBER; -- 5132302
3082 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
3083
3084 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
3085
3086 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
3087 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
3088
3089 ---------------------------------------------------------------------------------------------------------------
3090
3091
3092 --
3093 -- bulk performance
3094 --
3095 l_balance_type_code VARCHAR2(1);
3096 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
3097 l_log_module VARCHAR2(240);
3098
3099 --
3100 -- Upgrade strategy
3101 --
3102 l_actual_upg_option VARCHAR2(1);
3103 l_enc_upg_option VARCHAR2(1);
3104
3105 --
3106 BEGIN
3107 --
3108 IF g_log_enabled THEN
3109 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_14';
3110 END IF;
3111 --
3112 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3113
3114 trace
3115 (p_msg => 'BEGIN of AcctLineType_14'
3116 ,p_level => C_LEVEL_PROCEDURE
3117 ,p_module => l_log_module);
3118
3119 END IF;
3120 --
3121 l_component_type := 'AMB_JLT';
3122 l_component_code := 'FV_DOWNWARD_UNANTICIPATED_CR';
3123 l_component_type_code := 'S';
3124 l_component_appl_id := 707;
3125 l_amb_context_code := 'DEFAULT';
3126 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
3127 l_event_class_code := 'DELIVER_EXPENSE';
3128 l_event_type_code := 'DELIVER_EXPENSE_ALL';
3129 l_line_definition_owner_code := 'S';
3130 l_line_definition_code := 'FV_RETURN_TO_RECEIVING';
3131 --
3132 l_balance_type_code := 'A';
3133 l_segment := NULL;
3134 l_ccid := NULL;
3135 l_adr_transaction_coa_id := NULL;
3136 l_adr_accounting_coa_id := NULL;
3137 l_adr_flexfield_segment_code := NULL;
3138 l_adr_flex_value_set_id := NULL;
3139 l_adr_value_type_code := NULL;
3140 l_adr_value_combination_id := NULL;
3141 l_adr_value_segment_code := NULL;
3142
3143 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
3144 l_bflow_class_code := ''; -- 4219869 Business Flow
3145 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
3146 l_budgetary_control_flag := 'Y';
3147
3148 l_bflow_applied_to_amt_idx := NULL; -- 5132302
3149 l_bflow_applied_to_amt := NULL; -- 5132302
3150 l_entered_amt_idx := NULL; -- 4262811
3151 l_accted_amt_idx := NULL; -- 4262811
3152 l_acc_rev_flag := NULL; -- 4262811
3153 l_accrual_line_num := NULL; -- 4262811
3154 l_tmp_amt := NULL; -- 4262811
3155 --
3156
3157 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
3158 l_balance_type_code <> 'B' THEN
3159 IF NVL(
3160 xla_ae_sources_pkg.GetSystemSourceChar(
3161 p_source_code => 'XLA_EVENT_TYPE_CODE'
3162 , p_source_type_code => 'Y'
3163 , p_source_application_id => 602
3164 ),'
3165 ') = 'RETURN_TO_RECEIVING' AND
3166 NVL(p_source_5,'
3167 ') = 'Y' AND
3168 NVL(p_source_6,'
3169 ') = 'Charge'
3170 THEN
3171
3172 --
3173 XLA_AE_LINES_PKG.SetNewLine;
3174
3175 p_balance_type_code := l_balance_type_code;
3176 -- set the flag so later we will know whether the gain loss line needs to be created
3177
3178 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
3179 p_actual_flag :='A';
3180 END IF;
3181
3182 --
3183 -- bulk performance
3184 --
3185 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
3186 p_header_num => 0); -- 4262811
3187 --
3188 -- set accounting line options
3189 --
3190 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
3191 p_natural_side_code => 'C'
3192 , p_gain_or_loss_flag => 'N'
3193 , p_gl_transfer_mode_code => 'S'
3194 , p_acct_entry_type_code => 'A'
3195 , p_switch_side_flag => 'N'
3196 , p_merge_duplicate_code => 'N'
3197 );
3198 --
3199 l_acc_rev_natural_side_code := 'D'; -- 4262811
3200 --
3201 --
3202 -- set accounting line type info
3203 --
3204 xla_ae_lines_pkg.SetAcctLineType
3205 (p_component_type => l_component_type
3206 ,p_event_type_code => l_event_type_code
3207 ,p_line_definition_owner_code => l_line_definition_owner_code
3208 ,p_line_definition_code => l_line_definition_code
3209 ,p_accounting_line_code => l_component_code
3210 ,p_accounting_line_type_code => l_component_type_code
3211 ,p_accounting_line_appl_id => l_component_appl_id
3212 ,p_amb_context_code => l_amb_context_code
3213 ,p_entity_code => l_entity_code
3214 ,p_event_class_code => l_event_class_code);
3215 --
3216 -- set accounting class
3217 --
3218 xla_ae_lines_pkg.SetAcctClass(
3219 p_accounting_class_code => 'FEDERAL_EXP'
3220 , p_ae_header_id => l_ae_header_id
3221 );
3222
3223 --
3224 -- set rounding class
3225 --
3226 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
3227 'FEDERAL_EXP';
3228
3229 --
3230 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
3231 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
3232 --
3233 -- bulk performance
3234 --
3235 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
3236
3237 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
3238 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
3239
3240 -- 4955764
3241 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
3242 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
3243
3244 -- 4458381 Public Sector Enh
3245
3246 --
3247 -- set accounting attributes for the line type
3248 --
3249 l_entered_amt_idx := 17;
3250 l_accted_amt_idx := 22;
3251 l_bflow_applied_to_amt_idx := NULL; -- 5132302
3252 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
3253 l_rec_acct_attrs.array_num_value(1) := p_source_7;
3254 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
3255 l_rec_acct_attrs.array_char_value(2) := p_source_8;
3256 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
3257 l_rec_acct_attrs.array_char_value(3) := p_source_9;
3258 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
3259 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
3260 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
3261 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
3262 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
3263 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
3264 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
3265 l_rec_acct_attrs.array_char_value(7) := p_source_13;
3266 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
3267 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
3268 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
3269 l_rec_acct_attrs.array_num_value(9) := p_source_14;
3270 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
3271 l_rec_acct_attrs.array_char_value(10) := p_source_15;
3272 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
3273 l_rec_acct_attrs.array_num_value(11) := p_source_16;
3274 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
3275 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
3276 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
3277 l_rec_acct_attrs.array_num_value(13) := p_source_14;
3278 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
3279 l_rec_acct_attrs.array_char_value(14) := p_source_15;
3280 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
3281 l_rec_acct_attrs.array_num_value(15) := p_source_16;
3282 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
3283 l_rec_acct_attrs.array_char_value(16) := p_source_17;
3284 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
3285 l_rec_acct_attrs.array_num_value(17) := p_source_24;
3286 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
3287 l_rec_acct_attrs.array_char_value(18) := p_source_15;
3288 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
3289 l_rec_acct_attrs.array_date_value(19) := p_source_19;
3290 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
3291 l_rec_acct_attrs.array_num_value(20) := p_source_20;
3292 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
3293 l_rec_acct_attrs.array_char_value(21) := p_source_21;
3294 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
3295 l_rec_acct_attrs.array_num_value(22) := p_source_24;
3296 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
3297 l_rec_acct_attrs.array_num_value(23) := p_source_22;
3298 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
3299 l_rec_acct_attrs.array_num_value(24) := p_source_22;
3300
3301 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
3302 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
3303
3304 ---------------------------------------------------------------------------------------------------------------
3305 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
3306 ---------------------------------------------------------------------------------------------------------------
3307 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
3308
3309 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
3310 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
3311
3312 IF xla_accounting_cache_pkg.GetValueChar
3313 (p_source_code => 'LEDGER_CATEGORY_CODE'
3314 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
3315 AND l_bflow_method_code = 'PRIOR_ENTRY'
3316 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
3317 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
3318 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
3319 )
3320 THEN
3321 xla_ae_lines_pkg.BflowUpgEntry
3322 (p_business_method_code => l_bflow_method_code
3323 ,p_business_class_code => l_bflow_class_code
3324 ,p_balance_type => l_balance_type_code);
3325 ELSE
3326 NULL;
3327 -- No business flow processing for business flow method of NONE.
3328 END IF;
3329
3330 --
3331 -- call analytical criteria
3332 --
3333
3334 --
3335 -- call description
3336 --
3337 -- No description or it is inherited.
3338 --
3339 -- call ADRs
3340 -- Bug 4922099
3341 --
3342 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
3343 (NVL(l_actual_upg_option, 'N') = 'O') OR
3344 (NVL(l_enc_upg_option, 'N') = 'O')
3345 )
3346 THEN
3347 NULL;
3348 --
3349 --
3350
3351 l_ccid := AcctDerRule_11(
3352 p_application_id => p_application_id
3353 , p_ae_header_id => l_ae_header_id
3354 , p_source_3 => p_source_3
3355 , x_transaction_coa_id => l_adr_transaction_coa_id
3356 , x_accounting_coa_id => l_adr_accounting_coa_id
3357 , x_value_type_code => l_adr_value_type_code
3358 , p_side => 'NA'
3359 );
3360
3361 xla_ae_lines_pkg.set_ccid(
3362 p_code_combination_id => l_ccid
3363 , p_value_type_code => l_adr_value_type_code
3364 , p_transaction_coa_id => l_adr_transaction_coa_id
3365 , p_accounting_coa_id => l_adr_accounting_coa_id
3366 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
3367 , p_adr_type_code => 'S'
3368 , p_component_type => l_component_type
3369 , p_component_code => l_component_code
3370 , p_component_type_code => l_component_type_code
3371 , p_component_appl_id => l_component_appl_id
3372 , p_amb_context_code => l_amb_context_code
3373 , p_side => 'NA'
3374 );
3375
3376
3377 l_segment := AcctDerRule_3(
3378 p_application_id => p_application_id
3379 , p_ae_header_id => l_ae_header_id
3380 , x_transaction_coa_id => l_adr_transaction_coa_id
3381 , x_accounting_coa_id => l_adr_accounting_coa_id
3382 , x_flexfield_segment_code => l_adr_flexfield_segment_code
3383 , x_flex_value_set_id => l_adr_flex_value_set_id
3384 , x_value_type_code => l_adr_value_type_code
3385 , x_value_combination_id => l_adr_value_combination_id
3386 , x_value_segment_code => l_adr_value_segment_code
3387 , p_side => 'NA'
3388 , p_override_seg_flag => 'Y'
3389 );
3390
3391 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
3392
3393 xla_ae_lines_pkg.set_segment(
3394 p_to_segment_code => 'GL_ACCOUNT'
3395 , p_segment_value => l_segment
3396 , p_from_segment_code => l_adr_value_segment_code
3397 , p_from_combination_id => l_adr_value_combination_id
3398 , p_value_type_code => l_adr_value_type_code
3399 , p_transaction_coa_id => l_adr_transaction_coa_id
3400 , p_accounting_coa_id => l_adr_accounting_coa_id
3401 , p_flexfield_segment_code => l_adr_flexfield_segment_code
3402 , p_flex_value_set_id => l_adr_flex_value_set_id
3403 , p_adr_code => 'FV_445002'
3404 , p_adr_type_code => 'S'
3405 , p_component_type => l_component_type
3406 , p_component_code => l_component_code
3407 , p_component_type_code => l_component_type_code
3408 , p_component_appl_id => l_component_appl_id
3409 , p_amb_context_code => l_amb_context_code
3410 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
3411 , p_event_class_code => 'DELIVER_EXPENSE'
3412 , p_side => 'NA'
3413 );
3414
3415 END IF;
3416
3417 --
3418 --
3419 END IF;
3420 --
3421 -- Bug 4922099
3422 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
3423 (NVL(l_enc_upg_option, 'N') = 'O')
3424 ) AND
3425 (l_bflow_method_code = 'PRIOR_ENTRY')
3426 )
3427 THEN
3428 IF
3429 --
3430 1 = 2
3431 --
3432 THEN
3433 xla_accounting_err_pkg.build_message
3434 (p_appli_s_name => 'XLA'
3435 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
3436 ,p_token_1 => 'LINE_NUMBER'
3437 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
3438 ,p_token_2 => 'LINE_TYPE_NAME'
3439 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
3440 l_component_type
3441 ,l_component_code
3442 ,l_component_type_code
3443 ,l_component_appl_id
3444 ,l_amb_context_code
3445 ,l_entity_code
3446 ,l_event_class_code
3447 )
3448 ,p_token_3 => 'OWNER'
3449 ,p_value_3 => xla_lookups_pkg.get_meaning(
3450 p_lookup_type => 'XLA_OWNER_TYPE'
3451 ,p_lookup_code => l_component_type_code
3452 )
3453 ,p_token_4 => 'PRODUCT_NAME'
3454 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
3455 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
3456 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
3457 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
3458 ,p_ae_header_id => NULL
3459 );
3460
3461 IF (C_LEVEL_ERROR>= g_log_level) THEN
3462 trace
3463 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
3464 ,p_level => C_LEVEL_ERROR
3465 ,p_module => l_log_module);
3466 END IF;
3467 END IF;
3468 END IF;
3469 --
3470 --
3471 ------------------------------------------------------------------------------------------------
3472 -- 4219869 Business Flow
3473 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
3474 -- Prior Entry. Currently, the following code is always generated.
3475 ------------------------------------------------------------------------------------------------
3476 XLA_AE_LINES_PKG.ValidateCurrentLine;
3477
3478 ------------------------------------------------------------------------------------
3479 -- 4219869 Business Flow
3480 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
3481 ------------------------------------------------------------------------------------
3482 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
3483
3484 ----------------------------------------------------------------------------------
3485 -- 4219869 Business Flow
3486 -- Update journal entry status -- Need to generate this within IF <condition>
3487 ----------------------------------------------------------------------------------
3488 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
3489 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
3490 ,p_balance_type_code => l_balance_type_code
3491 );
3492
3493 -------------------------------------------------------------------------------------------
3494 -- 4262811 - Generate the Accrual Reversal lines
3495 -------------------------------------------------------------------------------------------
3496 BEGIN
3497 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
3498 (g_array_event(p_event_id).array_value_num('header_index'));
3499 IF l_acc_rev_flag IS NULL THEN
3500 l_acc_rev_flag := 'N';
3501 END IF;
3502 EXCEPTION
3503 WHEN OTHERS THEN
3504 l_acc_rev_flag := 'N';
3505 END;
3506 --
3507 IF (l_acc_rev_flag = 'Y') THEN
3508
3509 -- 4645092 ------------------------------------------------------------------------------
3510 -- To allow MPA report to determine if it should generate report process
3511 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
3512 ------------------------------------------------------------------------------------------
3513
3514 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
3515 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
3516 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
3517 -- call ADRs
3518 -- Bug 4922099
3519 --
3520 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
3521 (NVL(l_actual_upg_option, 'N') = 'O') OR
3522 (NVL(l_enc_upg_option, 'N') = 'O')
3523 )
3524 THEN
3525 NULL;
3526 --
3527 --
3528
3529 l_ccid := AcctDerRule_11(
3530 p_application_id => p_application_id
3531 , p_ae_header_id => l_ae_header_id
3532 , p_source_3 => p_source_3
3533 , x_transaction_coa_id => l_adr_transaction_coa_id
3534 , x_accounting_coa_id => l_adr_accounting_coa_id
3535 , x_value_type_code => l_adr_value_type_code
3536 , p_side => 'NA'
3537 );
3538
3539 xla_ae_lines_pkg.set_ccid(
3540 p_code_combination_id => l_ccid
3541 , p_value_type_code => l_adr_value_type_code
3542 , p_transaction_coa_id => l_adr_transaction_coa_id
3543 , p_accounting_coa_id => l_adr_accounting_coa_id
3544 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
3545 , p_adr_type_code => 'S'
3546 , p_component_type => l_component_type
3547 , p_component_code => l_component_code
3548 , p_component_type_code => l_component_type_code
3549 , p_component_appl_id => l_component_appl_id
3550 , p_amb_context_code => l_amb_context_code
3551 , p_side => 'NA'
3552 );
3553
3554
3555 l_segment := AcctDerRule_3(
3556 p_application_id => p_application_id
3557 , p_ae_header_id => l_ae_header_id
3558 , x_transaction_coa_id => l_adr_transaction_coa_id
3559 , x_accounting_coa_id => l_adr_accounting_coa_id
3560 , x_flexfield_segment_code => l_adr_flexfield_segment_code
3561 , x_flex_value_set_id => l_adr_flex_value_set_id
3562 , x_value_type_code => l_adr_value_type_code
3563 , x_value_combination_id => l_adr_value_combination_id
3564 , x_value_segment_code => l_adr_value_segment_code
3565 , p_side => 'NA'
3566 , p_override_seg_flag => 'Y'
3567 );
3568
3569 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
3570
3571 xla_ae_lines_pkg.set_segment(
3572 p_to_segment_code => 'GL_ACCOUNT'
3573 , p_segment_value => l_segment
3574 , p_from_segment_code => l_adr_value_segment_code
3575 , p_from_combination_id => l_adr_value_combination_id
3576 , p_value_type_code => l_adr_value_type_code
3577 , p_transaction_coa_id => l_adr_transaction_coa_id
3578 , p_accounting_coa_id => l_adr_accounting_coa_id
3579 , p_flexfield_segment_code => l_adr_flexfield_segment_code
3580 , p_flex_value_set_id => l_adr_flex_value_set_id
3581 , p_adr_code => 'FV_445002'
3582 , p_adr_type_code => 'S'
3583 , p_component_type => l_component_type
3584 , p_component_code => l_component_code
3585 , p_component_type_code => l_component_type_code
3586 , p_component_appl_id => l_component_appl_id
3587 , p_amb_context_code => l_amb_context_code
3588 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
3589 , p_event_class_code => 'DELIVER_EXPENSE'
3590 , p_side => 'NA'
3591 );
3592
3593 END IF;
3594
3595 --
3596 --
3597 END IF;
3598
3599 --
3600 -- Update the line information that should be overwritten
3601 --
3602 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
3603 p_header_num => 1);
3604 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
3605
3606 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
3607
3608 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
3609 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
3610 END IF;
3611
3612 --
3613 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
3614 --
3615 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
3616 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
3617 ELSE
3618 ---------------------------------------------------------------------------------------------------
3619 -- 4262811a Switch Sign
3620 ---------------------------------------------------------------------------------------------------
3621 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
3622 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
3623 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3624 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
3625 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3626 -- 5132302
3627 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
3628 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3629
3630 END IF;
3631
3632 -- 4955764
3633 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
3634 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
3635
3636
3637 XLA_AE_LINES_PKG.ValidateCurrentLine;
3638 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
3639
3640 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
3641 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
3642 ,p_balance_type_code => l_balance_type_code);
3643
3644 END IF;
3645
3646 -----------------------------------------------------------------------------------------
3647 -- 4262811 Multiperiod Accounting
3648 -----------------------------------------------------------------------------------------
3649 -- No MPA option is assigned.
3650
3651
3652 END IF;
3653 END IF;
3654 --
3655
3656 --
3657 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3658 trace
3659 (p_msg => 'END of AcctLineType_14'
3660 ,p_level => C_LEVEL_PROCEDURE
3661 ,p_module => l_log_module);
3662 END IF;
3663 --
3664 EXCEPTION
3665 WHEN xla_exceptions_pkg.application_exception THEN
3666 RAISE;
3667 WHEN OTHERS THEN
3668 xla_exceptions_pkg.raise_message
3669 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_14');
3670 END AcctLineType_14;
3671 --
3672
3673 ---------------------------------------
3674 --
3675 -- PRIVATE FUNCTION
3676 -- AcctLineType_15
3677 --
3678 ---------------------------------------
3679 PROCEDURE AcctLineType_15 (
3680 p_application_id IN NUMBER
3681 ,p_event_id IN NUMBER
3682 ,p_calculate_acctd_flag IN VARCHAR2
3683 ,p_calculate_g_l_flag IN VARCHAR2
3684 ,p_actual_flag IN OUT VARCHAR2
3685 ,p_balance_type_code OUT VARCHAR2
3686 ,p_gain_or_loss_ref OUT VARCHAR2
3687
3688 --PO Budget Account
3689 , p_source_3 IN NUMBER
3690 --Federal Prior Year Flag
3691 , p_source_5 IN VARCHAR2
3692 --Applied to Application ID
3693 , p_source_7 IN NUMBER
3694 --Applied to Distribution Link Type
3695 , p_source_8 IN VARCHAR2
3696 --Applied to Entity Code
3697 , p_source_9 IN VARCHAR2
3698 --Applied To Purchase Document Identifier
3699 , p_source_11 IN NUMBER
3700 --DISTRIBUTION_IDENTIFIER
3701 , p_source_12 IN NUMBER
3702 --Distribution Type
3703 , p_source_13 IN VARCHAR2
3704 , p_source_13_meaning IN VARCHAR2
3705 --Encumbrance Reversal Amount Entered
3706 , p_source_14 IN NUMBER
3707 --Entered Currency Code
3708 , p_source_15 IN VARCHAR2
3709 --Transaction Encumbrance Reversal Amount
3710 , p_source_16 IN NUMBER
3711 --Costing Encumbrance Upgrade Option
3712 , p_source_17 IN VARCHAR2
3713 --Currency Conversion Date
3714 , p_source_19 IN DATE
3715 --Currency Conversion Rate
3716 , p_source_20 IN NUMBER
3717 --Currency Conversion Type
3718 , p_source_21 IN VARCHAR2
3719 --Purchasing Encumbrance Type Identifier
3720 , p_source_22 IN NUMBER
3721 --TXN_PO_DISTRIBUTION_ID
3722 , p_source_23 IN NUMBER
3723 --Federal Unanticipated Amt
3724 , p_source_24 IN NUMBER
3725 )
3726 IS
3727
3728 l_component_type VARCHAR2(80);
3729 l_component_code VARCHAR2(30);
3730 l_component_type_code VARCHAR2(1);
3731 l_component_appl_id INTEGER;
3732 l_amb_context_code VARCHAR2(30);
3733 l_entity_code VARCHAR2(30);
3734 l_event_class_code VARCHAR2(30);
3735 l_ae_header_id NUMBER;
3736 l_event_type_code VARCHAR2(30);
3737 l_line_definition_code VARCHAR2(30);
3738 l_line_definition_owner_code VARCHAR2(1);
3739 --
3740 -- adr variables
3741 l_segment VARCHAR2(30);
3742 l_ccid NUMBER;
3743 l_adr_transaction_coa_id NUMBER;
3744 l_adr_accounting_coa_id NUMBER;
3745 l_adr_flexfield_segment_code VARCHAR2(30);
3746 l_adr_flex_value_set_id NUMBER;
3747 l_adr_value_type_code VARCHAR2(30);
3748 l_adr_value_combination_id NUMBER;
3749 l_adr_value_segment_code VARCHAR2(30);
3750
3751 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
3752 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
3753 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
3754 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
3755
3756 -- 4262811 Variables ------------------------------------------------------------------------------------------
3757 l_entered_amt_idx NUMBER;
3758 l_accted_amt_idx NUMBER;
3759 l_acc_rev_flag VARCHAR2(1);
3760 l_accrual_line_num NUMBER;
3761 l_tmp_amt NUMBER;
3762 l_acc_rev_natural_side_code VARCHAR2(1);
3763
3764 l_num_entries NUMBER;
3765 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
3766 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
3767 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
3768 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
3769 l_recog_line_1 NUMBER;
3770 l_recog_line_2 NUMBER;
3771
3772 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
3773 l_bflow_applied_to_amt NUMBER; -- 5132302
3774 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
3775
3776 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
3777
3778 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
3779 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
3780
3781 ---------------------------------------------------------------------------------------------------------------
3782
3783
3784 --
3785 -- bulk performance
3786 --
3787 l_balance_type_code VARCHAR2(1);
3788 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
3789 l_log_module VARCHAR2(240);
3790
3791 --
3792 -- Upgrade strategy
3793 --
3794 l_actual_upg_option VARCHAR2(1);
3795 l_enc_upg_option VARCHAR2(1);
3796
3797 --
3798 BEGIN
3799 --
3800 IF g_log_enabled THEN
3801 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_15';
3802 END IF;
3803 --
3804 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3805
3806 trace
3807 (p_msg => 'BEGIN of AcctLineType_15'
3808 ,p_level => C_LEVEL_PROCEDURE
3809 ,p_module => l_log_module);
3810
3811 END IF;
3812 --
3813 l_component_type := 'AMB_JLT';
3814 l_component_code := 'FV_DOWNWD_UNANTICIPATED_CR_RTI';
3815 l_component_type_code := 'S';
3816 l_component_appl_id := 707;
3817 l_amb_context_code := 'DEFAULT';
3818 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
3819 l_event_class_code := 'PURCHASE_ORDER';
3820 l_event_type_code := 'PURCHASE_ORDER_ALL';
3821 l_line_definition_owner_code := 'S';
3822 l_line_definition_code := 'FV_RET_RI_INV';
3823 --
3824 l_balance_type_code := 'A';
3825 l_segment := NULL;
3826 l_ccid := NULL;
3827 l_adr_transaction_coa_id := NULL;
3828 l_adr_accounting_coa_id := NULL;
3829 l_adr_flexfield_segment_code := NULL;
3830 l_adr_flex_value_set_id := NULL;
3831 l_adr_value_type_code := NULL;
3832 l_adr_value_combination_id := NULL;
3833 l_adr_value_segment_code := NULL;
3834
3835 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
3836 l_bflow_class_code := ''; -- 4219869 Business Flow
3837 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
3838 l_budgetary_control_flag := 'Y';
3839
3840 l_bflow_applied_to_amt_idx := NULL; -- 5132302
3841 l_bflow_applied_to_amt := NULL; -- 5132302
3842 l_entered_amt_idx := NULL; -- 4262811
3843 l_accted_amt_idx := NULL; -- 4262811
3844 l_acc_rev_flag := NULL; -- 4262811
3845 l_accrual_line_num := NULL; -- 4262811
3846 l_tmp_amt := NULL; -- 4262811
3847 --
3848
3849 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
3850 l_balance_type_code <> 'B' THEN
3851 IF NVL(
3852 xla_ae_sources_pkg.GetSystemSourceChar(
3853 p_source_code => 'XLA_EVENT_TYPE_CODE'
3854 , p_source_type_code => 'Y'
3855 , p_source_application_id => 602
3856 ),'
3857 ') = 'RET_RI_INV' AND
3858 NVL(p_source_5,'
3859 ') = 'Y'
3860 THEN
3861
3862 --
3863 XLA_AE_LINES_PKG.SetNewLine;
3864
3865 p_balance_type_code := l_balance_type_code;
3866 -- set the flag so later we will know whether the gain loss line needs to be created
3867
3868 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
3869 p_actual_flag :='A';
3870 END IF;
3871
3872 --
3873 -- bulk performance
3874 --
3875 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
3876 p_header_num => 0); -- 4262811
3877 --
3878 -- set accounting line options
3879 --
3880 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
3881 p_natural_side_code => 'C'
3882 , p_gain_or_loss_flag => 'N'
3883 , p_gl_transfer_mode_code => 'S'
3884 , p_acct_entry_type_code => 'A'
3885 , p_switch_side_flag => 'N'
3886 , p_merge_duplicate_code => 'N'
3887 );
3888 --
3889 l_acc_rev_natural_side_code := 'D'; -- 4262811
3890 --
3891 --
3892 -- set accounting line type info
3893 --
3894 xla_ae_lines_pkg.SetAcctLineType
3895 (p_component_type => l_component_type
3896 ,p_event_type_code => l_event_type_code
3897 ,p_line_definition_owner_code => l_line_definition_owner_code
3898 ,p_line_definition_code => l_line_definition_code
3899 ,p_accounting_line_code => l_component_code
3900 ,p_accounting_line_type_code => l_component_type_code
3901 ,p_accounting_line_appl_id => l_component_appl_id
3902 ,p_amb_context_code => l_amb_context_code
3903 ,p_entity_code => l_entity_code
3904 ,p_event_class_code => l_event_class_code);
3905 --
3906 -- set accounting class
3907 --
3908 xla_ae_lines_pkg.SetAcctClass(
3909 p_accounting_class_code => 'FEDERAL_INV'
3910 , p_ae_header_id => l_ae_header_id
3911 );
3912
3913 --
3914 -- set rounding class
3915 --
3916 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
3917 'FEDERAL_INV';
3918
3919 --
3920 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
3921 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
3922 --
3923 -- bulk performance
3924 --
3925 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
3926
3927 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
3928 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
3929
3930 -- 4955764
3931 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
3932 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
3933
3934 -- 4458381 Public Sector Enh
3935
3936 --
3937 -- set accounting attributes for the line type
3938 --
3939 l_entered_amt_idx := 17;
3940 l_accted_amt_idx := 22;
3941 l_bflow_applied_to_amt_idx := NULL; -- 5132302
3942 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
3943 l_rec_acct_attrs.array_num_value(1) := p_source_7;
3944 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
3945 l_rec_acct_attrs.array_char_value(2) := p_source_8;
3946 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
3947 l_rec_acct_attrs.array_char_value(3) := p_source_9;
3948 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
3949 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
3950 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
3951 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
3952 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
3953 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
3954 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
3955 l_rec_acct_attrs.array_char_value(7) := p_source_13;
3956 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
3957 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
3958 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
3959 l_rec_acct_attrs.array_num_value(9) := p_source_14;
3960 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
3961 l_rec_acct_attrs.array_char_value(10) := p_source_15;
3962 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
3963 l_rec_acct_attrs.array_num_value(11) := p_source_16;
3964 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
3965 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
3966 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
3967 l_rec_acct_attrs.array_num_value(13) := p_source_14;
3968 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
3969 l_rec_acct_attrs.array_char_value(14) := p_source_15;
3970 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
3971 l_rec_acct_attrs.array_num_value(15) := p_source_16;
3972 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
3973 l_rec_acct_attrs.array_char_value(16) := p_source_17;
3974 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
3975 l_rec_acct_attrs.array_num_value(17) := p_source_24;
3976 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
3977 l_rec_acct_attrs.array_char_value(18) := p_source_15;
3978 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
3979 l_rec_acct_attrs.array_date_value(19) := p_source_19;
3980 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
3981 l_rec_acct_attrs.array_num_value(20) := p_source_20;
3982 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
3983 l_rec_acct_attrs.array_char_value(21) := p_source_21;
3984 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
3985 l_rec_acct_attrs.array_num_value(22) := p_source_24;
3986 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
3987 l_rec_acct_attrs.array_num_value(23) := p_source_22;
3988 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
3989 l_rec_acct_attrs.array_num_value(24) := p_source_22;
3990
3991 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
3992 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
3993
3994 ---------------------------------------------------------------------------------------------------------------
3995 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
3996 ---------------------------------------------------------------------------------------------------------------
3997 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
3998
3999 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4000 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4001
4002 IF xla_accounting_cache_pkg.GetValueChar
4003 (p_source_code => 'LEDGER_CATEGORY_CODE'
4004 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
4005 AND l_bflow_method_code = 'PRIOR_ENTRY'
4006 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
4007 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
4008 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
4009 )
4010 THEN
4011 xla_ae_lines_pkg.BflowUpgEntry
4012 (p_business_method_code => l_bflow_method_code
4013 ,p_business_class_code => l_bflow_class_code
4014 ,p_balance_type => l_balance_type_code);
4015 ELSE
4016 NULL;
4017 -- No business flow processing for business flow method of NONE.
4018 END IF;
4019
4020 --
4021 -- call analytical criteria
4022 --
4023
4024 --
4025 -- call description
4026 --
4027 -- No description or it is inherited.
4028 --
4029 -- call ADRs
4030 -- Bug 4922099
4031 --
4032 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4033 (NVL(l_actual_upg_option, 'N') = 'O') OR
4034 (NVL(l_enc_upg_option, 'N') = 'O')
4035 )
4036 THEN
4037 NULL;
4038 --
4039 --
4040
4041 l_ccid := AcctDerRule_11(
4042 p_application_id => p_application_id
4043 , p_ae_header_id => l_ae_header_id
4044 , p_source_3 => p_source_3
4045 , x_transaction_coa_id => l_adr_transaction_coa_id
4046 , x_accounting_coa_id => l_adr_accounting_coa_id
4047 , x_value_type_code => l_adr_value_type_code
4048 , p_side => 'NA'
4049 );
4050
4051 xla_ae_lines_pkg.set_ccid(
4052 p_code_combination_id => l_ccid
4053 , p_value_type_code => l_adr_value_type_code
4054 , p_transaction_coa_id => l_adr_transaction_coa_id
4055 , p_accounting_coa_id => l_adr_accounting_coa_id
4056 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
4057 , p_adr_type_code => 'S'
4058 , p_component_type => l_component_type
4059 , p_component_code => l_component_code
4060 , p_component_type_code => l_component_type_code
4061 , p_component_appl_id => l_component_appl_id
4062 , p_amb_context_code => l_amb_context_code
4063 , p_side => 'NA'
4064 );
4065
4066
4067 l_segment := AcctDerRule_3(
4068 p_application_id => p_application_id
4069 , p_ae_header_id => l_ae_header_id
4070 , x_transaction_coa_id => l_adr_transaction_coa_id
4071 , x_accounting_coa_id => l_adr_accounting_coa_id
4072 , x_flexfield_segment_code => l_adr_flexfield_segment_code
4073 , x_flex_value_set_id => l_adr_flex_value_set_id
4074 , x_value_type_code => l_adr_value_type_code
4075 , x_value_combination_id => l_adr_value_combination_id
4076 , x_value_segment_code => l_adr_value_segment_code
4077 , p_side => 'NA'
4078 , p_override_seg_flag => 'Y'
4079 );
4080
4081 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
4082
4083 xla_ae_lines_pkg.set_segment(
4084 p_to_segment_code => 'GL_ACCOUNT'
4085 , p_segment_value => l_segment
4086 , p_from_segment_code => l_adr_value_segment_code
4087 , p_from_combination_id => l_adr_value_combination_id
4088 , p_value_type_code => l_adr_value_type_code
4089 , p_transaction_coa_id => l_adr_transaction_coa_id
4090 , p_accounting_coa_id => l_adr_accounting_coa_id
4091 , p_flexfield_segment_code => l_adr_flexfield_segment_code
4092 , p_flex_value_set_id => l_adr_flex_value_set_id
4093 , p_adr_code => 'FV_445002'
4094 , p_adr_type_code => 'S'
4095 , p_component_type => l_component_type
4096 , p_component_code => l_component_code
4097 , p_component_type_code => l_component_type_code
4098 , p_component_appl_id => l_component_appl_id
4099 , p_amb_context_code => l_amb_context_code
4100 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
4101 , p_event_class_code => 'PURCHASE_ORDER'
4102 , p_side => 'NA'
4103 );
4104
4105 END IF;
4106
4107 --
4108 --
4109 END IF;
4110 --
4111 -- Bug 4922099
4112 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
4113 (NVL(l_enc_upg_option, 'N') = 'O')
4114 ) AND
4115 (l_bflow_method_code = 'PRIOR_ENTRY')
4116 )
4117 THEN
4118 IF
4119 --
4120 1 = 2
4121 --
4122 THEN
4123 xla_accounting_err_pkg.build_message
4124 (p_appli_s_name => 'XLA'
4125 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4126 ,p_token_1 => 'LINE_NUMBER'
4127 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
4128 ,p_token_2 => 'LINE_TYPE_NAME'
4129 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
4130 l_component_type
4131 ,l_component_code
4132 ,l_component_type_code
4133 ,l_component_appl_id
4134 ,l_amb_context_code
4135 ,l_entity_code
4136 ,l_event_class_code
4137 )
4138 ,p_token_3 => 'OWNER'
4139 ,p_value_3 => xla_lookups_pkg.get_meaning(
4140 p_lookup_type => 'XLA_OWNER_TYPE'
4141 ,p_lookup_code => l_component_type_code
4142 )
4143 ,p_token_4 => 'PRODUCT_NAME'
4144 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
4145 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
4146 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
4147 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
4148 ,p_ae_header_id => NULL
4149 );
4150
4151 IF (C_LEVEL_ERROR>= g_log_level) THEN
4152 trace
4153 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4154 ,p_level => C_LEVEL_ERROR
4155 ,p_module => l_log_module);
4156 END IF;
4157 END IF;
4158 END IF;
4159 --
4160 --
4161 ------------------------------------------------------------------------------------------------
4162 -- 4219869 Business Flow
4163 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
4164 -- Prior Entry. Currently, the following code is always generated.
4165 ------------------------------------------------------------------------------------------------
4166 XLA_AE_LINES_PKG.ValidateCurrentLine;
4167
4168 ------------------------------------------------------------------------------------
4169 -- 4219869 Business Flow
4170 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
4171 ------------------------------------------------------------------------------------
4172 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
4173
4174 ----------------------------------------------------------------------------------
4175 -- 4219869 Business Flow
4176 -- Update journal entry status -- Need to generate this within IF <condition>
4177 ----------------------------------------------------------------------------------
4178 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
4179 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
4180 ,p_balance_type_code => l_balance_type_code
4181 );
4182
4183 -------------------------------------------------------------------------------------------
4184 -- 4262811 - Generate the Accrual Reversal lines
4185 -------------------------------------------------------------------------------------------
4186 BEGIN
4187 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
4188 (g_array_event(p_event_id).array_value_num('header_index'));
4189 IF l_acc_rev_flag IS NULL THEN
4190 l_acc_rev_flag := 'N';
4191 END IF;
4192 EXCEPTION
4193 WHEN OTHERS THEN
4194 l_acc_rev_flag := 'N';
4195 END;
4196 --
4197 IF (l_acc_rev_flag = 'Y') THEN
4198
4199 -- 4645092 ------------------------------------------------------------------------------
4200 -- To allow MPA report to determine if it should generate report process
4201 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
4202 ------------------------------------------------------------------------------------------
4203
4204 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
4205 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
4206 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
4207 -- call ADRs
4208 -- Bug 4922099
4209 --
4210 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4211 (NVL(l_actual_upg_option, 'N') = 'O') OR
4212 (NVL(l_enc_upg_option, 'N') = 'O')
4213 )
4214 THEN
4215 NULL;
4216 --
4217 --
4218
4219 l_ccid := AcctDerRule_11(
4220 p_application_id => p_application_id
4221 , p_ae_header_id => l_ae_header_id
4222 , p_source_3 => p_source_3
4223 , x_transaction_coa_id => l_adr_transaction_coa_id
4224 , x_accounting_coa_id => l_adr_accounting_coa_id
4225 , x_value_type_code => l_adr_value_type_code
4226 , p_side => 'NA'
4227 );
4228
4229 xla_ae_lines_pkg.set_ccid(
4230 p_code_combination_id => l_ccid
4231 , p_value_type_code => l_adr_value_type_code
4232 , p_transaction_coa_id => l_adr_transaction_coa_id
4233 , p_accounting_coa_id => l_adr_accounting_coa_id
4234 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
4235 , p_adr_type_code => 'S'
4236 , p_component_type => l_component_type
4237 , p_component_code => l_component_code
4238 , p_component_type_code => l_component_type_code
4239 , p_component_appl_id => l_component_appl_id
4240 , p_amb_context_code => l_amb_context_code
4241 , p_side => 'NA'
4242 );
4243
4244
4245 l_segment := AcctDerRule_3(
4246 p_application_id => p_application_id
4247 , p_ae_header_id => l_ae_header_id
4248 , x_transaction_coa_id => l_adr_transaction_coa_id
4249 , x_accounting_coa_id => l_adr_accounting_coa_id
4250 , x_flexfield_segment_code => l_adr_flexfield_segment_code
4251 , x_flex_value_set_id => l_adr_flex_value_set_id
4252 , x_value_type_code => l_adr_value_type_code
4253 , x_value_combination_id => l_adr_value_combination_id
4254 , x_value_segment_code => l_adr_value_segment_code
4255 , p_side => 'NA'
4256 , p_override_seg_flag => 'Y'
4257 );
4258
4259 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
4260
4261 xla_ae_lines_pkg.set_segment(
4262 p_to_segment_code => 'GL_ACCOUNT'
4263 , p_segment_value => l_segment
4264 , p_from_segment_code => l_adr_value_segment_code
4265 , p_from_combination_id => l_adr_value_combination_id
4266 , p_value_type_code => l_adr_value_type_code
4267 , p_transaction_coa_id => l_adr_transaction_coa_id
4268 , p_accounting_coa_id => l_adr_accounting_coa_id
4269 , p_flexfield_segment_code => l_adr_flexfield_segment_code
4270 , p_flex_value_set_id => l_adr_flex_value_set_id
4271 , p_adr_code => 'FV_445002'
4272 , p_adr_type_code => 'S'
4273 , p_component_type => l_component_type
4274 , p_component_code => l_component_code
4275 , p_component_type_code => l_component_type_code
4276 , p_component_appl_id => l_component_appl_id
4277 , p_amb_context_code => l_amb_context_code
4278 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
4279 , p_event_class_code => 'PURCHASE_ORDER'
4280 , p_side => 'NA'
4281 );
4282
4283 END IF;
4284
4285 --
4286 --
4287 END IF;
4288
4289 --
4290 -- Update the line information that should be overwritten
4291 --
4292 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
4293 p_header_num => 1);
4294 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
4295
4296 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
4297
4298 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
4299 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
4300 END IF;
4301
4302 --
4303 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
4304 --
4305 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
4306 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
4307 ELSE
4308 ---------------------------------------------------------------------------------------------------
4309 -- 4262811a Switch Sign
4310 ---------------------------------------------------------------------------------------------------
4311 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
4312 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
4313 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
4314 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
4315 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
4316 -- 5132302
4317 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
4318 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
4319
4320 END IF;
4321
4322 -- 4955764
4323 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
4324 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
4325
4326
4327 XLA_AE_LINES_PKG.ValidateCurrentLine;
4328 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
4329
4330 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
4331 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
4332 ,p_balance_type_code => l_balance_type_code);
4333
4334 END IF;
4335
4336 -----------------------------------------------------------------------------------------
4337 -- 4262811 Multiperiod Accounting
4338 -----------------------------------------------------------------------------------------
4339 -- No MPA option is assigned.
4340
4341
4342 END IF;
4343 END IF;
4344 --
4345
4346 --
4347 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4348 trace
4349 (p_msg => 'END of AcctLineType_15'
4350 ,p_level => C_LEVEL_PROCEDURE
4351 ,p_module => l_log_module);
4352 END IF;
4353 --
4354 EXCEPTION
4355 WHEN xla_exceptions_pkg.application_exception THEN
4356 RAISE;
4357 WHEN OTHERS THEN
4358 xla_exceptions_pkg.raise_message
4359 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_15');
4360 END AcctLineType_15;
4361 --
4362
4363 ---------------------------------------
4364 --
4365 -- PRIVATE FUNCTION
4366 -- AcctLineType_16
4367 --
4368 ---------------------------------------
4369 PROCEDURE AcctLineType_16 (
4370 p_application_id IN NUMBER
4371 ,p_event_id IN NUMBER
4372 ,p_calculate_acctd_flag IN VARCHAR2
4373 ,p_calculate_g_l_flag IN VARCHAR2
4374 ,p_actual_flag IN OUT VARCHAR2
4375 ,p_balance_type_code OUT VARCHAR2
4376 ,p_gain_or_loss_ref OUT VARCHAR2
4377
4378 --PO Budget Account
4379 , p_source_3 IN NUMBER
4380 --Receiving Accounting Line Type
4381 , p_source_6 IN VARCHAR2
4382 --Applied to Application ID
4383 , p_source_7 IN NUMBER
4384 --Applied to Distribution Link Type
4385 , p_source_8 IN VARCHAR2
4386 --Applied to Entity Code
4387 , p_source_9 IN VARCHAR2
4388 --PO_DISTRIBUTION_ID
4389 , p_source_10 IN NUMBER
4390 --Applied To Purchase Document Identifier
4391 , p_source_11 IN NUMBER
4392 --DISTRIBUTION_IDENTIFIER
4393 , p_source_12 IN NUMBER
4394 --Distribution Type
4395 , p_source_13 IN VARCHAR2
4396 , p_source_13_meaning IN VARCHAR2
4397 --Encumbrance Reversal Amount Entered
4398 , p_source_14 IN NUMBER
4399 --Entered Currency Code
4400 , p_source_15 IN VARCHAR2
4401 --Transaction Encumbrance Reversal Amount
4402 , p_source_16 IN NUMBER
4403 --Costing Encumbrance Upgrade Option
4404 , p_source_17 IN VARCHAR2
4405 --Currency Conversion Date
4406 , p_source_19 IN DATE
4407 --Currency Conversion Rate
4408 , p_source_20 IN NUMBER
4409 --Currency Conversion Type
4410 , p_source_21 IN VARCHAR2
4411 --Purchasing Encumbrance Type Identifier
4412 , p_source_22 IN NUMBER
4413 --Entered Amount
4414 , p_source_25 IN NUMBER
4415 --Accounted Amount
4416 , p_source_26 IN NUMBER
4417 )
4418 IS
4419
4420 l_component_type VARCHAR2(80);
4421 l_component_code VARCHAR2(30);
4422 l_component_type_code VARCHAR2(1);
4423 l_component_appl_id INTEGER;
4424 l_amb_context_code VARCHAR2(30);
4425 l_entity_code VARCHAR2(30);
4426 l_event_class_code VARCHAR2(30);
4427 l_ae_header_id NUMBER;
4428 l_event_type_code VARCHAR2(30);
4429 l_line_definition_code VARCHAR2(30);
4430 l_line_definition_owner_code VARCHAR2(1);
4431 --
4432 -- adr variables
4433 l_segment VARCHAR2(30);
4434 l_ccid NUMBER;
4435 l_adr_transaction_coa_id NUMBER;
4436 l_adr_accounting_coa_id NUMBER;
4437 l_adr_flexfield_segment_code VARCHAR2(30);
4438 l_adr_flex_value_set_id NUMBER;
4439 l_adr_value_type_code VARCHAR2(30);
4440 l_adr_value_combination_id NUMBER;
4441 l_adr_value_segment_code VARCHAR2(30);
4442
4443 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
4444 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
4445 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
4446 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
4447
4448 -- 4262811 Variables ------------------------------------------------------------------------------------------
4449 l_entered_amt_idx NUMBER;
4450 l_accted_amt_idx NUMBER;
4451 l_acc_rev_flag VARCHAR2(1);
4452 l_accrual_line_num NUMBER;
4453 l_tmp_amt NUMBER;
4454 l_acc_rev_natural_side_code VARCHAR2(1);
4455
4456 l_num_entries NUMBER;
4457 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
4458 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
4459 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
4460 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
4461 l_recog_line_1 NUMBER;
4462 l_recog_line_2 NUMBER;
4463
4464 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
4465 l_bflow_applied_to_amt NUMBER; -- 5132302
4466 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
4467
4468 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
4469
4470 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
4471 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
4472
4473 ---------------------------------------------------------------------------------------------------------------
4474
4475
4476 --
4477 -- bulk performance
4478 --
4479 l_balance_type_code VARCHAR2(1);
4480 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
4481 l_log_module VARCHAR2(240);
4482
4483 --
4484 -- Upgrade strategy
4485 --
4486 l_actual_upg_option VARCHAR2(1);
4487 l_enc_upg_option VARCHAR2(1);
4488
4489 --
4490 BEGIN
4491 --
4492 IF g_log_enabled THEN
4493 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_16';
4494 END IF;
4495 --
4496 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4497
4498 trace
4499 (p_msg => 'BEGIN of AcctLineType_16'
4500 ,p_level => C_LEVEL_PROCEDURE
4501 ,p_module => l_log_module);
4502
4503 END IF;
4504 --
4505 l_component_type := 'AMB_JLT';
4506 l_component_code := 'FV_EXP_OBLIGATION _CR';
4507 l_component_type_code := 'S';
4508 l_component_appl_id := 707;
4509 l_amb_context_code := 'DEFAULT';
4510 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
4511 l_event_class_code := 'DELIVER_EXPENSE';
4512 l_event_type_code := 'DELIVER_EXPENSE_ALL';
4513 l_line_definition_owner_code := 'S';
4514 l_line_definition_code := 'FV_DELIVER_EXPENSE';
4515 --
4516 l_balance_type_code := 'A';
4517 l_segment := NULL;
4518 l_ccid := NULL;
4519 l_adr_transaction_coa_id := NULL;
4520 l_adr_accounting_coa_id := NULL;
4521 l_adr_flexfield_segment_code := NULL;
4522 l_adr_flex_value_set_id := NULL;
4523 l_adr_value_type_code := NULL;
4524 l_adr_value_combination_id := NULL;
4525 l_adr_value_segment_code := NULL;
4526
4527 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
4528 l_bflow_class_code := ''; -- 4219869 Business Flow
4529 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
4530 l_budgetary_control_flag := 'Y';
4531
4532 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4533 l_bflow_applied_to_amt := NULL; -- 5132302
4534 l_entered_amt_idx := NULL; -- 4262811
4535 l_accted_amt_idx := NULL; -- 4262811
4536 l_acc_rev_flag := NULL; -- 4262811
4537 l_accrual_line_num := NULL; -- 4262811
4538 l_tmp_amt := NULL; -- 4262811
4539 --
4540
4541 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
4542 l_balance_type_code <> 'B' THEN
4543 IF NVL(
4544 xla_ae_sources_pkg.GetSystemSourceChar(
4545 p_source_code => 'XLA_EVENT_TYPE_CODE'
4546 , p_source_type_code => 'Y'
4547 , p_source_application_id => 602
4548 ),'
4549 ') = 'DELIVER_EXPENSE' AND
4550 NVL(p_source_6,'
4551 ') = 'Charge'
4552 THEN
4553
4554 --
4555 XLA_AE_LINES_PKG.SetNewLine;
4556
4557 p_balance_type_code := l_balance_type_code;
4558 -- set the flag so later we will know whether the gain loss line needs to be created
4559
4560 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
4561 p_actual_flag :='A';
4562 END IF;
4563
4564 --
4565 -- bulk performance
4566 --
4567 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
4568 p_header_num => 0); -- 4262811
4569 --
4570 -- set accounting line options
4571 --
4572 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
4573 p_natural_side_code => 'C'
4574 , p_gain_or_loss_flag => 'N'
4575 , p_gl_transfer_mode_code => 'S'
4576 , p_acct_entry_type_code => 'A'
4577 , p_switch_side_flag => 'N'
4578 , p_merge_duplicate_code => 'N'
4579 );
4580 --
4581 l_acc_rev_natural_side_code := 'D'; -- 4262811
4582 --
4583 --
4584 -- set accounting line type info
4585 --
4586 xla_ae_lines_pkg.SetAcctLineType
4587 (p_component_type => l_component_type
4588 ,p_event_type_code => l_event_type_code
4589 ,p_line_definition_owner_code => l_line_definition_owner_code
4590 ,p_line_definition_code => l_line_definition_code
4591 ,p_accounting_line_code => l_component_code
4592 ,p_accounting_line_type_code => l_component_type_code
4593 ,p_accounting_line_appl_id => l_component_appl_id
4594 ,p_amb_context_code => l_amb_context_code
4595 ,p_entity_code => l_entity_code
4596 ,p_event_class_code => l_event_class_code);
4597 --
4598 -- set accounting class
4599 --
4600 xla_ae_lines_pkg.SetAcctClass(
4601 p_accounting_class_code => 'FEDERAL_EXP'
4602 , p_ae_header_id => l_ae_header_id
4603 );
4604
4605 --
4606 -- set rounding class
4607 --
4608 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
4609 'FEDERAL_EXP';
4610
4611 --
4612 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
4613 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
4614 --
4615 -- bulk performance
4616 --
4617 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
4618
4619 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
4620 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
4621
4622 -- 4955764
4623 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
4624 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
4625
4626 -- 4458381 Public Sector Enh
4627
4628 --
4629 -- set accounting attributes for the line type
4630 --
4631 l_entered_amt_idx := 17;
4632 l_accted_amt_idx := 22;
4633 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4634 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
4635 l_rec_acct_attrs.array_num_value(1) := p_source_7;
4636 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
4637 l_rec_acct_attrs.array_char_value(2) := p_source_8;
4638 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
4639 l_rec_acct_attrs.array_char_value(3) := p_source_9;
4640 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
4641 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
4642 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
4643 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
4644 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
4645 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
4646 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
4647 l_rec_acct_attrs.array_char_value(7) := p_source_13;
4648 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
4649 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
4650 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
4651 l_rec_acct_attrs.array_num_value(9) := p_source_14;
4652 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
4653 l_rec_acct_attrs.array_char_value(10) := p_source_15;
4654 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
4655 l_rec_acct_attrs.array_num_value(11) := p_source_16;
4656 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
4657 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
4658 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
4659 l_rec_acct_attrs.array_num_value(13) := p_source_14;
4660 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
4661 l_rec_acct_attrs.array_char_value(14) := p_source_15;
4662 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
4663 l_rec_acct_attrs.array_num_value(15) := p_source_16;
4664 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
4665 l_rec_acct_attrs.array_char_value(16) := p_source_17;
4666 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
4667 l_rec_acct_attrs.array_num_value(17) := p_source_25;
4668 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
4669 l_rec_acct_attrs.array_char_value(18) := p_source_15;
4670 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
4671 l_rec_acct_attrs.array_date_value(19) := p_source_19;
4672 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
4673 l_rec_acct_attrs.array_num_value(20) := p_source_20;
4674 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
4675 l_rec_acct_attrs.array_char_value(21) := p_source_21;
4676 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
4677 l_rec_acct_attrs.array_num_value(22) := p_source_26;
4678 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
4679 l_rec_acct_attrs.array_num_value(23) := p_source_22;
4680 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
4681 l_rec_acct_attrs.array_num_value(24) := p_source_22;
4682
4683 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
4684 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
4685
4686 ---------------------------------------------------------------------------------------------------------------
4687 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
4688 ---------------------------------------------------------------------------------------------------------------
4689 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
4690
4691 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4692 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4693
4694 IF xla_accounting_cache_pkg.GetValueChar
4695 (p_source_code => 'LEDGER_CATEGORY_CODE'
4696 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
4697 AND l_bflow_method_code = 'PRIOR_ENTRY'
4698 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
4699 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
4700 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
4701 )
4702 THEN
4703 xla_ae_lines_pkg.BflowUpgEntry
4704 (p_business_method_code => l_bflow_method_code
4705 ,p_business_class_code => l_bflow_class_code
4706 ,p_balance_type => l_balance_type_code);
4707 ELSE
4708 NULL;
4709 -- No business flow processing for business flow method of NONE.
4710 END IF;
4711
4712 --
4713 -- call analytical criteria
4714 --
4715
4716 --
4717 -- call description
4718 --
4719 -- No description or it is inherited.
4720 --
4721 -- call ADRs
4722 -- Bug 4922099
4723 --
4724 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4725 (NVL(l_actual_upg_option, 'N') = 'O') OR
4726 (NVL(l_enc_upg_option, 'N') = 'O')
4727 )
4728 THEN
4729 NULL;
4730 --
4731 --
4732
4733 l_ccid := AcctDerRule_11(
4734 p_application_id => p_application_id
4735 , p_ae_header_id => l_ae_header_id
4736 , p_source_3 => p_source_3
4737 , x_transaction_coa_id => l_adr_transaction_coa_id
4738 , x_accounting_coa_id => l_adr_accounting_coa_id
4739 , x_value_type_code => l_adr_value_type_code
4740 , p_side => 'NA'
4741 );
4742
4743 xla_ae_lines_pkg.set_ccid(
4744 p_code_combination_id => l_ccid
4745 , p_value_type_code => l_adr_value_type_code
4746 , p_transaction_coa_id => l_adr_transaction_coa_id
4747 , p_accounting_coa_id => l_adr_accounting_coa_id
4748 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
4749 , p_adr_type_code => 'S'
4750 , p_component_type => l_component_type
4751 , p_component_code => l_component_code
4752 , p_component_type_code => l_component_type_code
4753 , p_component_appl_id => l_component_appl_id
4754 , p_amb_context_code => l_amb_context_code
4755 , p_side => 'NA'
4756 );
4757
4758
4759 l_segment := AcctDerRule_9(
4760 p_application_id => p_application_id
4761 , p_ae_header_id => l_ae_header_id
4762 , x_transaction_coa_id => l_adr_transaction_coa_id
4763 , x_accounting_coa_id => l_adr_accounting_coa_id
4764 , x_flexfield_segment_code => l_adr_flexfield_segment_code
4765 , x_flex_value_set_id => l_adr_flex_value_set_id
4766 , x_value_type_code => l_adr_value_type_code
4767 , x_value_combination_id => l_adr_value_combination_id
4768 , x_value_segment_code => l_adr_value_segment_code
4769 , p_side => 'NA'
4770 , p_override_seg_flag => 'Y'
4771 );
4772
4773 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
4774
4775 xla_ae_lines_pkg.set_segment(
4776 p_to_segment_code => 'GL_ACCOUNT'
4777 , p_segment_value => l_segment
4778 , p_from_segment_code => l_adr_value_segment_code
4779 , p_from_combination_id => l_adr_value_combination_id
4780 , p_value_type_code => l_adr_value_type_code
4781 , p_transaction_coa_id => l_adr_transaction_coa_id
4782 , p_accounting_coa_id => l_adr_accounting_coa_id
4783 , p_flexfield_segment_code => l_adr_flexfield_segment_code
4784 , p_flex_value_set_id => l_adr_flex_value_set_id
4785 , p_adr_code => 'FV_490101'
4786 , p_adr_type_code => 'S'
4787 , p_component_type => l_component_type
4788 , p_component_code => l_component_code
4789 , p_component_type_code => l_component_type_code
4790 , p_component_appl_id => l_component_appl_id
4791 , p_amb_context_code => l_amb_context_code
4792 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
4793 , p_event_class_code => 'DELIVER_EXPENSE'
4794 , p_side => 'NA'
4795 );
4796
4797 END IF;
4798
4799 --
4800 --
4801 END IF;
4802 --
4803 -- Bug 4922099
4804 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
4805 (NVL(l_enc_upg_option, 'N') = 'O')
4806 ) AND
4807 (l_bflow_method_code = 'PRIOR_ENTRY')
4808 )
4809 THEN
4810 IF
4811 --
4812 1 = 2
4813 --
4814 THEN
4815 xla_accounting_err_pkg.build_message
4816 (p_appli_s_name => 'XLA'
4817 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4818 ,p_token_1 => 'LINE_NUMBER'
4819 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
4820 ,p_token_2 => 'LINE_TYPE_NAME'
4821 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
4822 l_component_type
4823 ,l_component_code
4824 ,l_component_type_code
4825 ,l_component_appl_id
4826 ,l_amb_context_code
4827 ,l_entity_code
4828 ,l_event_class_code
4829 )
4830 ,p_token_3 => 'OWNER'
4831 ,p_value_3 => xla_lookups_pkg.get_meaning(
4832 p_lookup_type => 'XLA_OWNER_TYPE'
4833 ,p_lookup_code => l_component_type_code
4834 )
4835 ,p_token_4 => 'PRODUCT_NAME'
4836 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
4837 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
4838 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
4839 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
4840 ,p_ae_header_id => NULL
4841 );
4842
4843 IF (C_LEVEL_ERROR>= g_log_level) THEN
4844 trace
4845 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4846 ,p_level => C_LEVEL_ERROR
4847 ,p_module => l_log_module);
4848 END IF;
4849 END IF;
4850 END IF;
4851 --
4852 --
4853 ------------------------------------------------------------------------------------------------
4854 -- 4219869 Business Flow
4855 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
4856 -- Prior Entry. Currently, the following code is always generated.
4857 ------------------------------------------------------------------------------------------------
4858 XLA_AE_LINES_PKG.ValidateCurrentLine;
4859
4860 ------------------------------------------------------------------------------------
4861 -- 4219869 Business Flow
4862 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
4863 ------------------------------------------------------------------------------------
4864 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
4865
4866 ----------------------------------------------------------------------------------
4867 -- 4219869 Business Flow
4868 -- Update journal entry status -- Need to generate this within IF <condition>
4869 ----------------------------------------------------------------------------------
4870 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
4871 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
4872 ,p_balance_type_code => l_balance_type_code
4873 );
4874
4875 -------------------------------------------------------------------------------------------
4876 -- 4262811 - Generate the Accrual Reversal lines
4877 -------------------------------------------------------------------------------------------
4878 BEGIN
4879 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
4880 (g_array_event(p_event_id).array_value_num('header_index'));
4881 IF l_acc_rev_flag IS NULL THEN
4882 l_acc_rev_flag := 'N';
4883 END IF;
4884 EXCEPTION
4885 WHEN OTHERS THEN
4886 l_acc_rev_flag := 'N';
4887 END;
4888 --
4889 IF (l_acc_rev_flag = 'Y') THEN
4890
4891 -- 4645092 ------------------------------------------------------------------------------
4892 -- To allow MPA report to determine if it should generate report process
4893 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
4894 ------------------------------------------------------------------------------------------
4895
4896 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
4897 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
4898 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
4899 -- call ADRs
4900 -- Bug 4922099
4901 --
4902 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4903 (NVL(l_actual_upg_option, 'N') = 'O') OR
4904 (NVL(l_enc_upg_option, 'N') = 'O')
4905 )
4906 THEN
4907 NULL;
4908 --
4909 --
4910
4911 l_ccid := AcctDerRule_11(
4912 p_application_id => p_application_id
4913 , p_ae_header_id => l_ae_header_id
4914 , p_source_3 => p_source_3
4915 , x_transaction_coa_id => l_adr_transaction_coa_id
4916 , x_accounting_coa_id => l_adr_accounting_coa_id
4917 , x_value_type_code => l_adr_value_type_code
4918 , p_side => 'NA'
4919 );
4920
4921 xla_ae_lines_pkg.set_ccid(
4922 p_code_combination_id => l_ccid
4923 , p_value_type_code => l_adr_value_type_code
4924 , p_transaction_coa_id => l_adr_transaction_coa_id
4925 , p_accounting_coa_id => l_adr_accounting_coa_id
4926 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
4927 , p_adr_type_code => 'S'
4928 , p_component_type => l_component_type
4929 , p_component_code => l_component_code
4930 , p_component_type_code => l_component_type_code
4931 , p_component_appl_id => l_component_appl_id
4932 , p_amb_context_code => l_amb_context_code
4933 , p_side => 'NA'
4934 );
4935
4936
4937 l_segment := AcctDerRule_9(
4938 p_application_id => p_application_id
4939 , p_ae_header_id => l_ae_header_id
4940 , x_transaction_coa_id => l_adr_transaction_coa_id
4941 , x_accounting_coa_id => l_adr_accounting_coa_id
4942 , x_flexfield_segment_code => l_adr_flexfield_segment_code
4943 , x_flex_value_set_id => l_adr_flex_value_set_id
4944 , x_value_type_code => l_adr_value_type_code
4945 , x_value_combination_id => l_adr_value_combination_id
4946 , x_value_segment_code => l_adr_value_segment_code
4947 , p_side => 'NA'
4948 , p_override_seg_flag => 'Y'
4949 );
4950
4951 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
4952
4953 xla_ae_lines_pkg.set_segment(
4954 p_to_segment_code => 'GL_ACCOUNT'
4955 , p_segment_value => l_segment
4956 , p_from_segment_code => l_adr_value_segment_code
4957 , p_from_combination_id => l_adr_value_combination_id
4958 , p_value_type_code => l_adr_value_type_code
4959 , p_transaction_coa_id => l_adr_transaction_coa_id
4960 , p_accounting_coa_id => l_adr_accounting_coa_id
4961 , p_flexfield_segment_code => l_adr_flexfield_segment_code
4962 , p_flex_value_set_id => l_adr_flex_value_set_id
4963 , p_adr_code => 'FV_490101'
4964 , p_adr_type_code => 'S'
4965 , p_component_type => l_component_type
4966 , p_component_code => l_component_code
4967 , p_component_type_code => l_component_type_code
4968 , p_component_appl_id => l_component_appl_id
4969 , p_amb_context_code => l_amb_context_code
4970 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
4971 , p_event_class_code => 'DELIVER_EXPENSE'
4972 , p_side => 'NA'
4973 );
4974
4975 END IF;
4976
4977 --
4978 --
4979 END IF;
4980
4981 --
4982 -- Update the line information that should be overwritten
4983 --
4984 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
4985 p_header_num => 1);
4986 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
4987
4988 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
4989
4990 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
4991 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
4992 END IF;
4993
4994 --
4995 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
4996 --
4997 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
4998 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
4999 ELSE
5000 ---------------------------------------------------------------------------------------------------
5001 -- 4262811a Switch Sign
5002 ---------------------------------------------------------------------------------------------------
5003 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
5004 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5005 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5006 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5007 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5008 -- 5132302
5009 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
5010 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5011
5012 END IF;
5013
5014 -- 4955764
5015 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5016 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
5017
5018
5019 XLA_AE_LINES_PKG.ValidateCurrentLine;
5020 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5021
5022 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5023 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
5024 ,p_balance_type_code => l_balance_type_code);
5025
5026 END IF;
5027
5028 -----------------------------------------------------------------------------------------
5029 -- 4262811 Multiperiod Accounting
5030 -----------------------------------------------------------------------------------------
5031 -- No MPA option is assigned.
5032
5033
5034 END IF;
5035 END IF;
5036 --
5037
5038 --
5039 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5040 trace
5041 (p_msg => 'END of AcctLineType_16'
5042 ,p_level => C_LEVEL_PROCEDURE
5043 ,p_module => l_log_module);
5044 END IF;
5045 --
5046 EXCEPTION
5047 WHEN xla_exceptions_pkg.application_exception THEN
5048 RAISE;
5049 WHEN OTHERS THEN
5050 xla_exceptions_pkg.raise_message
5051 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_16');
5052 END AcctLineType_16;
5053 --
5054
5055 ---------------------------------------
5056 --
5057 -- PRIVATE FUNCTION
5058 -- AcctLineType_17
5059 --
5060 ---------------------------------------
5061 PROCEDURE AcctLineType_17 (
5062 p_application_id IN NUMBER
5063 ,p_event_id IN NUMBER
5064 ,p_calculate_acctd_flag IN VARCHAR2
5065 ,p_calculate_g_l_flag IN VARCHAR2
5066 ,p_actual_flag IN OUT VARCHAR2
5067 ,p_balance_type_code OUT VARCHAR2
5068 ,p_gain_or_loss_ref OUT VARCHAR2
5069
5070 --PO Budget Account
5071 , p_source_3 IN NUMBER
5072 --Applied to Application ID
5073 , p_source_7 IN NUMBER
5074 --Applied to Distribution Link Type
5075 , p_source_8 IN VARCHAR2
5076 --Applied to Entity Code
5077 , p_source_9 IN VARCHAR2
5078 --Applied To Purchase Document Identifier
5079 , p_source_11 IN NUMBER
5080 --DISTRIBUTION_IDENTIFIER
5081 , p_source_12 IN NUMBER
5082 --Distribution Type
5083 , p_source_13 IN VARCHAR2
5084 , p_source_13_meaning IN VARCHAR2
5085 --Encumbrance Reversal Amount Entered
5086 , p_source_14 IN NUMBER
5087 --Entered Currency Code
5088 , p_source_15 IN VARCHAR2
5089 --Transaction Encumbrance Reversal Amount
5090 , p_source_16 IN NUMBER
5091 --Costing Encumbrance Upgrade Option
5092 , p_source_17 IN VARCHAR2
5093 --Currency Conversion Date
5094 , p_source_19 IN DATE
5095 --Currency Conversion Rate
5096 , p_source_20 IN NUMBER
5097 --Currency Conversion Type
5098 , p_source_21 IN VARCHAR2
5099 --Purchasing Encumbrance Type Identifier
5100 , p_source_22 IN NUMBER
5101 --TXN_PO_DISTRIBUTION_ID
5102 , p_source_23 IN NUMBER
5103 --Entered Amount
5104 , p_source_25 IN NUMBER
5105 --Accounted Amount
5106 , p_source_26 IN NUMBER
5107 )
5108 IS
5109
5110 l_component_type VARCHAR2(80);
5111 l_component_code VARCHAR2(30);
5112 l_component_type_code VARCHAR2(1);
5113 l_component_appl_id INTEGER;
5114 l_amb_context_code VARCHAR2(30);
5115 l_entity_code VARCHAR2(30);
5116 l_event_class_code VARCHAR2(30);
5117 l_ae_header_id NUMBER;
5118 l_event_type_code VARCHAR2(30);
5119 l_line_definition_code VARCHAR2(30);
5120 l_line_definition_owner_code VARCHAR2(1);
5121 --
5122 -- adr variables
5123 l_segment VARCHAR2(30);
5124 l_ccid NUMBER;
5125 l_adr_transaction_coa_id NUMBER;
5126 l_adr_accounting_coa_id NUMBER;
5127 l_adr_flexfield_segment_code VARCHAR2(30);
5128 l_adr_flex_value_set_id NUMBER;
5129 l_adr_value_type_code VARCHAR2(30);
5130 l_adr_value_combination_id NUMBER;
5131 l_adr_value_segment_code VARCHAR2(30);
5132
5133 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
5134 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
5135 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
5136 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
5137
5138 -- 4262811 Variables ------------------------------------------------------------------------------------------
5139 l_entered_amt_idx NUMBER;
5140 l_accted_amt_idx NUMBER;
5141 l_acc_rev_flag VARCHAR2(1);
5142 l_accrual_line_num NUMBER;
5143 l_tmp_amt NUMBER;
5144 l_acc_rev_natural_side_code VARCHAR2(1);
5145
5146 l_num_entries NUMBER;
5147 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
5148 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
5149 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
5150 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
5151 l_recog_line_1 NUMBER;
5152 l_recog_line_2 NUMBER;
5153
5154 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
5155 l_bflow_applied_to_amt NUMBER; -- 5132302
5156 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
5157
5158 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
5159
5160 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
5161 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
5162
5163 ---------------------------------------------------------------------------------------------------------------
5164
5165
5166 --
5167 -- bulk performance
5168 --
5169 l_balance_type_code VARCHAR2(1);
5170 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
5171 l_log_module VARCHAR2(240);
5172
5173 --
5174 -- Upgrade strategy
5175 --
5176 l_actual_upg_option VARCHAR2(1);
5177 l_enc_upg_option VARCHAR2(1);
5178
5179 --
5180 BEGIN
5181 --
5182 IF g_log_enabled THEN
5183 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_17';
5184 END IF;
5185 --
5186 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5187
5188 trace
5189 (p_msg => 'BEGIN of AcctLineType_17'
5190 ,p_level => C_LEVEL_PROCEDURE
5191 ,p_module => l_log_module);
5192
5193 END IF;
5194 --
5195 l_component_type := 'AMB_JLT';
5196 l_component_code := 'FV_EXP_OBLIGATION_CR_DTI';
5197 l_component_type_code := 'S';
5198 l_component_appl_id := 707;
5199 l_amb_context_code := 'DEFAULT';
5200 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
5201 l_event_class_code := 'PURCHASE_ORDER';
5202 l_event_type_code := 'PURCHASE_ORDER_ALL';
5203 l_line_definition_owner_code := 'S';
5204 l_line_definition_code := 'FV_PO_DEL_INV';
5205 --
5206 l_balance_type_code := 'A';
5207 l_segment := NULL;
5208 l_ccid := NULL;
5209 l_adr_transaction_coa_id := NULL;
5210 l_adr_accounting_coa_id := NULL;
5211 l_adr_flexfield_segment_code := NULL;
5212 l_adr_flex_value_set_id := NULL;
5213 l_adr_value_type_code := NULL;
5214 l_adr_value_combination_id := NULL;
5215 l_adr_value_segment_code := NULL;
5216
5217 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
5218 l_bflow_class_code := 'FV_INV_REC_CR'; -- 4219869 Business Flow
5219 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
5220 l_budgetary_control_flag := 'Y';
5221
5222 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5223 l_bflow_applied_to_amt := NULL; -- 5132302
5224 l_entered_amt_idx := NULL; -- 4262811
5225 l_accted_amt_idx := NULL; -- 4262811
5226 l_acc_rev_flag := NULL; -- 4262811
5227 l_accrual_line_num := NULL; -- 4262811
5228 l_tmp_amt := NULL; -- 4262811
5229 --
5230
5231 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
5232 l_balance_type_code <> 'B' THEN
5233 IF NVL(
5234 xla_ae_sources_pkg.GetSystemSourceChar(
5235 p_source_code => 'XLA_EVENT_TYPE_CODE'
5236 , p_source_type_code => 'Y'
5237 , p_source_application_id => 602
5238 ),'
5239 ') = 'PO_DEL_INV'
5240 THEN
5241
5242 --
5243 XLA_AE_LINES_PKG.SetNewLine;
5244
5245 p_balance_type_code := l_balance_type_code;
5246 -- set the flag so later we will know whether the gain loss line needs to be created
5247
5248 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
5249 p_actual_flag :='A';
5250 END IF;
5251
5252 --
5253 -- bulk performance
5254 --
5255 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
5256 p_header_num => 0); -- 4262811
5257 --
5258 -- set accounting line options
5259 --
5260 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
5261 p_natural_side_code => 'C'
5262 , p_gain_or_loss_flag => 'N'
5263 , p_gl_transfer_mode_code => 'S'
5264 , p_acct_entry_type_code => 'A'
5265 , p_switch_side_flag => 'N'
5266 , p_merge_duplicate_code => 'N'
5267 );
5268 --
5269 l_acc_rev_natural_side_code := 'D'; -- 4262811
5270 --
5271 --
5272 -- set accounting line type info
5273 --
5274 xla_ae_lines_pkg.SetAcctLineType
5275 (p_component_type => l_component_type
5276 ,p_event_type_code => l_event_type_code
5277 ,p_line_definition_owner_code => l_line_definition_owner_code
5278 ,p_line_definition_code => l_line_definition_code
5279 ,p_accounting_line_code => l_component_code
5280 ,p_accounting_line_type_code => l_component_type_code
5281 ,p_accounting_line_appl_id => l_component_appl_id
5282 ,p_amb_context_code => l_amb_context_code
5283 ,p_entity_code => l_entity_code
5284 ,p_event_class_code => l_event_class_code);
5285 --
5286 -- set accounting class
5287 --
5288 xla_ae_lines_pkg.SetAcctClass(
5289 p_accounting_class_code => 'FEDERAL_INV'
5290 , p_ae_header_id => l_ae_header_id
5291 );
5292
5293 --
5294 -- set rounding class
5295 --
5296 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
5297 'FEDERAL_INV';
5298
5299 --
5300 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
5301 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
5302 --
5303 -- bulk performance
5304 --
5305 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
5306
5307 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
5308 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
5309
5310 -- 4955764
5311 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5312 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
5313
5314 -- 4458381 Public Sector Enh
5315
5316 --
5317 -- set accounting attributes for the line type
5318 --
5319 l_entered_amt_idx := 17;
5320 l_accted_amt_idx := 22;
5321 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5322 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
5323 l_rec_acct_attrs.array_num_value(1) := p_source_7;
5324 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
5325 l_rec_acct_attrs.array_char_value(2) := p_source_8;
5326 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
5327 l_rec_acct_attrs.array_char_value(3) := p_source_9;
5328 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
5329 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
5330 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
5331 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
5332 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
5333 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
5334 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
5335 l_rec_acct_attrs.array_char_value(7) := p_source_13;
5336 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
5337 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
5338 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
5339 l_rec_acct_attrs.array_num_value(9) := p_source_14;
5340 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
5341 l_rec_acct_attrs.array_char_value(10) := p_source_15;
5342 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
5343 l_rec_acct_attrs.array_num_value(11) := p_source_16;
5344 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
5345 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
5346 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
5347 l_rec_acct_attrs.array_num_value(13) := p_source_14;
5348 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
5349 l_rec_acct_attrs.array_char_value(14) := p_source_15;
5350 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
5351 l_rec_acct_attrs.array_num_value(15) := p_source_16;
5352 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
5353 l_rec_acct_attrs.array_char_value(16) := p_source_17;
5354 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
5355 l_rec_acct_attrs.array_num_value(17) := p_source_25;
5356 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
5357 l_rec_acct_attrs.array_char_value(18) := p_source_15;
5358 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
5359 l_rec_acct_attrs.array_date_value(19) := p_source_19;
5360 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
5361 l_rec_acct_attrs.array_num_value(20) := p_source_20;
5362 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
5363 l_rec_acct_attrs.array_char_value(21) := p_source_21;
5364 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
5365 l_rec_acct_attrs.array_num_value(22) := p_source_26;
5366 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
5367 l_rec_acct_attrs.array_num_value(23) := p_source_22;
5368 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
5369 l_rec_acct_attrs.array_num_value(24) := p_source_22;
5370
5371 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
5372 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
5373
5374 ---------------------------------------------------------------------------------------------------------------
5375 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
5376 ---------------------------------------------------------------------------------------------------------------
5377 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
5378
5379 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5380 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5381
5382 IF xla_accounting_cache_pkg.GetValueChar
5383 (p_source_code => 'LEDGER_CATEGORY_CODE'
5384 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
5385 AND l_bflow_method_code = 'PRIOR_ENTRY'
5386 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
5387 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
5388 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
5389 )
5390 THEN
5391 xla_ae_lines_pkg.BflowUpgEntry
5392 (p_business_method_code => l_bflow_method_code
5393 ,p_business_class_code => l_bflow_class_code
5394 ,p_balance_type => l_balance_type_code);
5395 ELSE
5396 NULL;
5397 -- No business flow processing for business flow method of NONE.
5398 END IF;
5399
5400 --
5401 -- call analytical criteria
5402 --
5403
5404 --
5405 -- call description
5406 --
5407 -- No description or it is inherited.
5408 --
5409 -- call ADRs
5410 -- Bug 4922099
5411 --
5412 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5413 (NVL(l_actual_upg_option, 'N') = 'O') OR
5414 (NVL(l_enc_upg_option, 'N') = 'O')
5415 )
5416 THEN
5417 NULL;
5418 --
5419 --
5420
5421 l_ccid := AcctDerRule_11(
5422 p_application_id => p_application_id
5423 , p_ae_header_id => l_ae_header_id
5424 , p_source_3 => p_source_3
5425 , x_transaction_coa_id => l_adr_transaction_coa_id
5426 , x_accounting_coa_id => l_adr_accounting_coa_id
5427 , x_value_type_code => l_adr_value_type_code
5428 , p_side => 'NA'
5429 );
5430
5431 xla_ae_lines_pkg.set_ccid(
5432 p_code_combination_id => l_ccid
5433 , p_value_type_code => l_adr_value_type_code
5434 , p_transaction_coa_id => l_adr_transaction_coa_id
5435 , p_accounting_coa_id => l_adr_accounting_coa_id
5436 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
5437 , p_adr_type_code => 'S'
5438 , p_component_type => l_component_type
5439 , p_component_code => l_component_code
5440 , p_component_type_code => l_component_type_code
5441 , p_component_appl_id => l_component_appl_id
5442 , p_amb_context_code => l_amb_context_code
5443 , p_side => 'NA'
5444 );
5445
5446
5447 l_segment := AcctDerRule_9(
5448 p_application_id => p_application_id
5449 , p_ae_header_id => l_ae_header_id
5450 , x_transaction_coa_id => l_adr_transaction_coa_id
5451 , x_accounting_coa_id => l_adr_accounting_coa_id
5452 , x_flexfield_segment_code => l_adr_flexfield_segment_code
5453 , x_flex_value_set_id => l_adr_flex_value_set_id
5454 , x_value_type_code => l_adr_value_type_code
5455 , x_value_combination_id => l_adr_value_combination_id
5456 , x_value_segment_code => l_adr_value_segment_code
5457 , p_side => 'NA'
5458 , p_override_seg_flag => 'Y'
5459 );
5460
5461 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
5462
5463 xla_ae_lines_pkg.set_segment(
5464 p_to_segment_code => 'GL_ACCOUNT'
5465 , p_segment_value => l_segment
5466 , p_from_segment_code => l_adr_value_segment_code
5467 , p_from_combination_id => l_adr_value_combination_id
5468 , p_value_type_code => l_adr_value_type_code
5469 , p_transaction_coa_id => l_adr_transaction_coa_id
5470 , p_accounting_coa_id => l_adr_accounting_coa_id
5471 , p_flexfield_segment_code => l_adr_flexfield_segment_code
5472 , p_flex_value_set_id => l_adr_flex_value_set_id
5473 , p_adr_code => 'FV_490101'
5474 , p_adr_type_code => 'S'
5475 , p_component_type => l_component_type
5476 , p_component_code => l_component_code
5477 , p_component_type_code => l_component_type_code
5478 , p_component_appl_id => l_component_appl_id
5479 , p_amb_context_code => l_amb_context_code
5480 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
5481 , p_event_class_code => 'PURCHASE_ORDER'
5482 , p_side => 'NA'
5483 );
5484
5485 END IF;
5486
5487 --
5488 --
5489 END IF;
5490 --
5491 -- Bug 4922099
5492 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
5493 (NVL(l_enc_upg_option, 'N') = 'O')
5494 ) AND
5495 (l_bflow_method_code = 'PRIOR_ENTRY')
5496 )
5497 THEN
5498 IF
5499 --
5500 1 = 2
5501 --
5502 THEN
5503 xla_accounting_err_pkg.build_message
5504 (p_appli_s_name => 'XLA'
5505 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5506 ,p_token_1 => 'LINE_NUMBER'
5507 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
5508 ,p_token_2 => 'LINE_TYPE_NAME'
5509 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
5510 l_component_type
5511 ,l_component_code
5512 ,l_component_type_code
5513 ,l_component_appl_id
5514 ,l_amb_context_code
5515 ,l_entity_code
5516 ,l_event_class_code
5517 )
5518 ,p_token_3 => 'OWNER'
5519 ,p_value_3 => xla_lookups_pkg.get_meaning(
5520 p_lookup_type => 'XLA_OWNER_TYPE'
5521 ,p_lookup_code => l_component_type_code
5522 )
5523 ,p_token_4 => 'PRODUCT_NAME'
5524 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
5525 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
5526 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
5527 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
5528 ,p_ae_header_id => NULL
5529 );
5530
5531 IF (C_LEVEL_ERROR>= g_log_level) THEN
5532 trace
5533 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5534 ,p_level => C_LEVEL_ERROR
5535 ,p_module => l_log_module);
5536 END IF;
5537 END IF;
5538 END IF;
5539 --
5540 --
5541 ------------------------------------------------------------------------------------------------
5542 -- 4219869 Business Flow
5543 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
5544 -- Prior Entry. Currently, the following code is always generated.
5545 ------------------------------------------------------------------------------------------------
5546 XLA_AE_LINES_PKG.ValidateCurrentLine;
5547
5548 ------------------------------------------------------------------------------------
5549 -- 4219869 Business Flow
5550 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
5551 ------------------------------------------------------------------------------------
5552 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5553
5554 ----------------------------------------------------------------------------------
5555 -- 4219869 Business Flow
5556 -- Update journal entry status -- Need to generate this within IF <condition>
5557 ----------------------------------------------------------------------------------
5558 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5559 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
5560 ,p_balance_type_code => l_balance_type_code
5561 );
5562
5563 -------------------------------------------------------------------------------------------
5564 -- 4262811 - Generate the Accrual Reversal lines
5565 -------------------------------------------------------------------------------------------
5566 BEGIN
5567 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
5568 (g_array_event(p_event_id).array_value_num('header_index'));
5569 IF l_acc_rev_flag IS NULL THEN
5570 l_acc_rev_flag := 'N';
5571 END IF;
5572 EXCEPTION
5573 WHEN OTHERS THEN
5574 l_acc_rev_flag := 'N';
5575 END;
5576 --
5577 IF (l_acc_rev_flag = 'Y') THEN
5578
5579 -- 4645092 ------------------------------------------------------------------------------
5580 -- To allow MPA report to determine if it should generate report process
5581 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
5582 ------------------------------------------------------------------------------------------
5583
5584 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
5585 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
5586 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
5587 -- call ADRs
5588 -- Bug 4922099
5589 --
5590 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5591 (NVL(l_actual_upg_option, 'N') = 'O') OR
5592 (NVL(l_enc_upg_option, 'N') = 'O')
5593 )
5594 THEN
5595 NULL;
5596 --
5597 --
5598
5599 l_ccid := AcctDerRule_11(
5600 p_application_id => p_application_id
5601 , p_ae_header_id => l_ae_header_id
5602 , p_source_3 => p_source_3
5603 , x_transaction_coa_id => l_adr_transaction_coa_id
5604 , x_accounting_coa_id => l_adr_accounting_coa_id
5605 , x_value_type_code => l_adr_value_type_code
5606 , p_side => 'NA'
5607 );
5608
5609 xla_ae_lines_pkg.set_ccid(
5610 p_code_combination_id => l_ccid
5611 , p_value_type_code => l_adr_value_type_code
5612 , p_transaction_coa_id => l_adr_transaction_coa_id
5613 , p_accounting_coa_id => l_adr_accounting_coa_id
5614 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
5615 , p_adr_type_code => 'S'
5616 , p_component_type => l_component_type
5617 , p_component_code => l_component_code
5618 , p_component_type_code => l_component_type_code
5619 , p_component_appl_id => l_component_appl_id
5620 , p_amb_context_code => l_amb_context_code
5621 , p_side => 'NA'
5622 );
5623
5624
5625 l_segment := AcctDerRule_9(
5626 p_application_id => p_application_id
5627 , p_ae_header_id => l_ae_header_id
5628 , x_transaction_coa_id => l_adr_transaction_coa_id
5629 , x_accounting_coa_id => l_adr_accounting_coa_id
5630 , x_flexfield_segment_code => l_adr_flexfield_segment_code
5631 , x_flex_value_set_id => l_adr_flex_value_set_id
5632 , x_value_type_code => l_adr_value_type_code
5633 , x_value_combination_id => l_adr_value_combination_id
5634 , x_value_segment_code => l_adr_value_segment_code
5635 , p_side => 'NA'
5636 , p_override_seg_flag => 'Y'
5637 );
5638
5639 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
5640
5641 xla_ae_lines_pkg.set_segment(
5642 p_to_segment_code => 'GL_ACCOUNT'
5643 , p_segment_value => l_segment
5644 , p_from_segment_code => l_adr_value_segment_code
5645 , p_from_combination_id => l_adr_value_combination_id
5646 , p_value_type_code => l_adr_value_type_code
5647 , p_transaction_coa_id => l_adr_transaction_coa_id
5648 , p_accounting_coa_id => l_adr_accounting_coa_id
5649 , p_flexfield_segment_code => l_adr_flexfield_segment_code
5650 , p_flex_value_set_id => l_adr_flex_value_set_id
5651 , p_adr_code => 'FV_490101'
5652 , p_adr_type_code => 'S'
5653 , p_component_type => l_component_type
5654 , p_component_code => l_component_code
5655 , p_component_type_code => l_component_type_code
5656 , p_component_appl_id => l_component_appl_id
5657 , p_amb_context_code => l_amb_context_code
5658 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
5659 , p_event_class_code => 'PURCHASE_ORDER'
5660 , p_side => 'NA'
5661 );
5662
5663 END IF;
5664
5665 --
5666 --
5667 END IF;
5668
5669 --
5670 -- Update the line information that should be overwritten
5671 --
5672 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
5673 p_header_num => 1);
5674 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
5675
5676 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
5677
5678 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
5679 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
5680 END IF;
5681
5682 --
5683 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
5684 --
5685 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
5686 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
5687 ELSE
5688 ---------------------------------------------------------------------------------------------------
5689 -- 4262811a Switch Sign
5690 ---------------------------------------------------------------------------------------------------
5691 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
5692 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5693 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5694 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5695 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5696 -- 5132302
5697 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
5698 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5699
5700 END IF;
5701
5702 -- 4955764
5703 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5704 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
5705
5706
5707 XLA_AE_LINES_PKG.ValidateCurrentLine;
5708 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5709
5710 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5711 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
5712 ,p_balance_type_code => l_balance_type_code);
5713
5714 END IF;
5715
5716 -----------------------------------------------------------------------------------------
5717 -- 4262811 Multiperiod Accounting
5718 -----------------------------------------------------------------------------------------
5719 -- No MPA option is assigned.
5720
5721
5722 END IF;
5723 END IF;
5724 --
5725
5726 --
5727 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5728 trace
5729 (p_msg => 'END of AcctLineType_17'
5730 ,p_level => C_LEVEL_PROCEDURE
5731 ,p_module => l_log_module);
5732 END IF;
5733 --
5734 EXCEPTION
5735 WHEN xla_exceptions_pkg.application_exception THEN
5736 RAISE;
5737 WHEN OTHERS THEN
5738 xla_exceptions_pkg.raise_message
5739 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_17');
5740 END AcctLineType_17;
5741 --
5742
5743 ---------------------------------------
5744 --
5745 -- PRIVATE FUNCTION
5746 -- AcctLineType_18
5747 --
5748 ---------------------------------------
5749 PROCEDURE AcctLineType_18 (
5750 p_application_id IN NUMBER
5751 ,p_event_id IN NUMBER
5752 ,p_calculate_acctd_flag IN VARCHAR2
5753 ,p_calculate_g_l_flag IN VARCHAR2
5754 ,p_actual_flag IN OUT VARCHAR2
5755 ,p_balance_type_code OUT VARCHAR2
5756 ,p_gain_or_loss_ref OUT VARCHAR2
5757
5758 --Federal Fund Category
5759 , p_source_2 IN VARCHAR2
5760 --PO Budget Account
5761 , p_source_3 IN NUMBER
5762 --Receiving Accounting Line Type
5763 , p_source_6 IN VARCHAR2
5764 --Applied to Application ID
5765 , p_source_7 IN NUMBER
5766 --Applied to Distribution Link Type
5767 , p_source_8 IN VARCHAR2
5768 --Applied to Entity Code
5769 , p_source_9 IN VARCHAR2
5770 --PO_DISTRIBUTION_ID
5771 , p_source_10 IN NUMBER
5772 --Applied To Purchase Document Identifier
5773 , p_source_11 IN NUMBER
5774 --DISTRIBUTION_IDENTIFIER
5775 , p_source_12 IN NUMBER
5776 --Distribution Type
5777 , p_source_13 IN VARCHAR2
5778 , p_source_13_meaning IN VARCHAR2
5779 --Encumbrance Reversal Amount Entered
5780 , p_source_14 IN NUMBER
5781 --Entered Currency Code
5782 , p_source_15 IN VARCHAR2
5783 --Transaction Encumbrance Reversal Amount
5784 , p_source_16 IN NUMBER
5785 --Costing Encumbrance Upgrade Option
5786 , p_source_17 IN VARCHAR2
5787 --Currency Conversion Date
5788 , p_source_19 IN DATE
5789 --Currency Conversion Rate
5790 , p_source_20 IN NUMBER
5791 --Currency Conversion Type
5792 , p_source_21 IN VARCHAR2
5793 --Purchasing Encumbrance Type Identifier
5794 , p_source_22 IN NUMBER
5795 --Entered Amount
5796 , p_source_25 IN NUMBER
5797 --Accounted Amount
5798 , p_source_26 IN NUMBER
5799 )
5800 IS
5801
5802 l_component_type VARCHAR2(80);
5803 l_component_code VARCHAR2(30);
5804 l_component_type_code VARCHAR2(1);
5805 l_component_appl_id INTEGER;
5806 l_amb_context_code VARCHAR2(30);
5807 l_entity_code VARCHAR2(30);
5808 l_event_class_code VARCHAR2(30);
5809 l_ae_header_id NUMBER;
5810 l_event_type_code VARCHAR2(30);
5811 l_line_definition_code VARCHAR2(30);
5812 l_line_definition_owner_code VARCHAR2(1);
5813 --
5814 -- adr variables
5815 l_segment VARCHAR2(30);
5816 l_ccid NUMBER;
5817 l_adr_transaction_coa_id NUMBER;
5818 l_adr_accounting_coa_id NUMBER;
5819 l_adr_flexfield_segment_code VARCHAR2(30);
5820 l_adr_flex_value_set_id NUMBER;
5821 l_adr_value_type_code VARCHAR2(30);
5822 l_adr_value_combination_id NUMBER;
5823 l_adr_value_segment_code VARCHAR2(30);
5824
5825 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
5826 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
5827 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
5828 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
5829
5830 -- 4262811 Variables ------------------------------------------------------------------------------------------
5831 l_entered_amt_idx NUMBER;
5832 l_accted_amt_idx NUMBER;
5833 l_acc_rev_flag VARCHAR2(1);
5834 l_accrual_line_num NUMBER;
5835 l_tmp_amt NUMBER;
5836 l_acc_rev_natural_side_code VARCHAR2(1);
5837
5838 l_num_entries NUMBER;
5839 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
5840 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
5841 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
5842 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
5843 l_recog_line_1 NUMBER;
5844 l_recog_line_2 NUMBER;
5845
5846 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
5847 l_bflow_applied_to_amt NUMBER; -- 5132302
5848 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
5849
5850 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
5851
5852 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
5853 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
5854
5855 ---------------------------------------------------------------------------------------------------------------
5856
5857
5858 --
5859 -- bulk performance
5860 --
5861 l_balance_type_code VARCHAR2(1);
5862 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
5863 l_log_module VARCHAR2(240);
5864
5865 --
5866 -- Upgrade strategy
5867 --
5868 l_actual_upg_option VARCHAR2(1);
5869 l_enc_upg_option VARCHAR2(1);
5870
5871 --
5872 BEGIN
5873 --
5874 IF g_log_enabled THEN
5875 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_18';
5876 END IF;
5877 --
5878 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5879
5880 trace
5881 (p_msg => 'BEGIN of AcctLineType_18'
5882 ,p_level => C_LEVEL_PROCEDURE
5883 ,p_module => l_log_module);
5884
5885 END IF;
5886 --
5887 l_component_type := 'AMB_JLT';
5888 l_component_code := 'FV_RECLASSIFY_APPROP_CR';
5889 l_component_type_code := 'S';
5890 l_component_appl_id := 707;
5891 l_amb_context_code := 'DEFAULT';
5892 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
5893 l_event_class_code := 'DELIVER_EXPENSE';
5894 l_event_type_code := 'DELIVER_EXPENSE_ALL';
5895 l_line_definition_owner_code := 'S';
5896 l_line_definition_code := 'FV_DELIVER_EXPENSE';
5897 --
5898 l_balance_type_code := 'A';
5899 l_segment := NULL;
5900 l_ccid := NULL;
5901 l_adr_transaction_coa_id := NULL;
5902 l_adr_accounting_coa_id := NULL;
5903 l_adr_flexfield_segment_code := NULL;
5904 l_adr_flex_value_set_id := NULL;
5905 l_adr_value_type_code := NULL;
5906 l_adr_value_combination_id := NULL;
5907 l_adr_value_segment_code := NULL;
5908
5909 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
5910 l_bflow_class_code := 'FV_EXP_APPR'; -- 4219869 Business Flow
5911 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
5912 l_budgetary_control_flag := 'Y';
5913
5914 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5915 l_bflow_applied_to_amt := NULL; -- 5132302
5916 l_entered_amt_idx := NULL; -- 4262811
5917 l_accted_amt_idx := NULL; -- 4262811
5918 l_acc_rev_flag := NULL; -- 4262811
5919 l_accrual_line_num := NULL; -- 4262811
5920 l_tmp_amt := NULL; -- 4262811
5921 --
5922
5923 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
5924 l_balance_type_code <> 'B' THEN
5925 IF (NVL(p_source_2,'
5926 ') = 'A' OR
5927 NVL(p_source_2,'
5928 ') = 'B' OR
5929 NVL(p_source_2,'
5930 ') = 'C') AND
5931 NVL(
5932 xla_ae_sources_pkg.GetSystemSourceChar(
5933 p_source_code => 'XLA_EVENT_TYPE_CODE'
5934 , p_source_type_code => 'Y'
5935 , p_source_application_id => 602
5936 ),'
5937 ') = 'DELIVER_EXPENSE' AND
5938 NVL(p_source_6,'
5939 ') = 'Charge'
5940 THEN
5941
5942 --
5943 XLA_AE_LINES_PKG.SetNewLine;
5944
5945 p_balance_type_code := l_balance_type_code;
5946 -- set the flag so later we will know whether the gain loss line needs to be created
5947
5948 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
5949 p_actual_flag :='A';
5950 END IF;
5951
5952 --
5953 -- bulk performance
5954 --
5955 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
5956 p_header_num => 0); -- 4262811
5957 --
5958 -- set accounting line options
5959 --
5960 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
5961 p_natural_side_code => 'C'
5962 , p_gain_or_loss_flag => 'N'
5963 , p_gl_transfer_mode_code => 'S'
5964 , p_acct_entry_type_code => 'A'
5965 , p_switch_side_flag => 'N'
5966 , p_merge_duplicate_code => 'N'
5967 );
5968 --
5969 l_acc_rev_natural_side_code := 'D'; -- 4262811
5970 --
5971 --
5972 -- set accounting line type info
5973 --
5974 xla_ae_lines_pkg.SetAcctLineType
5975 (p_component_type => l_component_type
5976 ,p_event_type_code => l_event_type_code
5977 ,p_line_definition_owner_code => l_line_definition_owner_code
5978 ,p_line_definition_code => l_line_definition_code
5979 ,p_accounting_line_code => l_component_code
5980 ,p_accounting_line_type_code => l_component_type_code
5981 ,p_accounting_line_appl_id => l_component_appl_id
5982 ,p_amb_context_code => l_amb_context_code
5983 ,p_entity_code => l_entity_code
5984 ,p_event_class_code => l_event_class_code);
5985 --
5986 -- set accounting class
5987 --
5988 xla_ae_lines_pkg.SetAcctClass(
5989 p_accounting_class_code => 'FEDERAL_EXP'
5990 , p_ae_header_id => l_ae_header_id
5991 );
5992
5993 --
5994 -- set rounding class
5995 --
5996 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
5997 'FEDERAL_EXP';
5998
5999 --
6000 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
6001 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
6002 --
6003 -- bulk performance
6004 --
6005 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
6006
6007 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
6008 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
6009
6010 -- 4955764
6011 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6012 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
6013
6014 -- 4458381 Public Sector Enh
6015
6016 --
6017 -- set accounting attributes for the line type
6018 --
6019 l_entered_amt_idx := 17;
6020 l_accted_amt_idx := 22;
6021 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6022 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
6023 l_rec_acct_attrs.array_num_value(1) := p_source_7;
6024 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
6025 l_rec_acct_attrs.array_char_value(2) := p_source_8;
6026 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
6027 l_rec_acct_attrs.array_char_value(3) := p_source_9;
6028 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
6029 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
6030 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
6031 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
6032 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
6033 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
6034 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
6035 l_rec_acct_attrs.array_char_value(7) := p_source_13;
6036 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
6037 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
6038 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
6039 l_rec_acct_attrs.array_num_value(9) := p_source_14;
6040 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
6041 l_rec_acct_attrs.array_char_value(10) := p_source_15;
6042 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
6043 l_rec_acct_attrs.array_num_value(11) := p_source_16;
6044 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
6045 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
6046 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
6047 l_rec_acct_attrs.array_num_value(13) := p_source_14;
6048 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
6049 l_rec_acct_attrs.array_char_value(14) := p_source_15;
6050 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
6051 l_rec_acct_attrs.array_num_value(15) := p_source_16;
6052 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
6053 l_rec_acct_attrs.array_char_value(16) := p_source_17;
6054 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
6055 l_rec_acct_attrs.array_num_value(17) := p_source_25;
6056 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
6057 l_rec_acct_attrs.array_char_value(18) := p_source_15;
6058 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
6059 l_rec_acct_attrs.array_date_value(19) := p_source_19;
6060 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
6061 l_rec_acct_attrs.array_num_value(20) := p_source_20;
6062 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
6063 l_rec_acct_attrs.array_char_value(21) := p_source_21;
6064 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
6065 l_rec_acct_attrs.array_num_value(22) := p_source_26;
6066 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
6067 l_rec_acct_attrs.array_num_value(23) := p_source_22;
6068 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
6069 l_rec_acct_attrs.array_num_value(24) := p_source_22;
6070
6071 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
6072 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
6073
6074 ---------------------------------------------------------------------------------------------------------------
6075 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
6076 ---------------------------------------------------------------------------------------------------------------
6077 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
6078
6079 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6080 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6081
6082 IF xla_accounting_cache_pkg.GetValueChar
6083 (p_source_code => 'LEDGER_CATEGORY_CODE'
6084 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
6085 AND l_bflow_method_code = 'PRIOR_ENTRY'
6086 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
6087 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
6088 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
6089 )
6090 THEN
6091 xla_ae_lines_pkg.BflowUpgEntry
6092 (p_business_method_code => l_bflow_method_code
6093 ,p_business_class_code => l_bflow_class_code
6094 ,p_balance_type => l_balance_type_code);
6095 ELSE
6096 NULL;
6097 -- No business flow processing for business flow method of NONE.
6098 END IF;
6099
6100 --
6101 -- call analytical criteria
6102 --
6103
6104 --
6105 -- call description
6106 --
6107 -- No description or it is inherited.
6108 --
6109 -- call ADRs
6110 -- Bug 4922099
6111 --
6112 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6113 (NVL(l_actual_upg_option, 'N') = 'O') OR
6114 (NVL(l_enc_upg_option, 'N') = 'O')
6115 )
6116 THEN
6117 NULL;
6118 --
6119 --
6120
6121 l_ccid := AcctDerRule_11(
6122 p_application_id => p_application_id
6123 , p_ae_header_id => l_ae_header_id
6124 , p_source_3 => p_source_3
6125 , x_transaction_coa_id => l_adr_transaction_coa_id
6126 , x_accounting_coa_id => l_adr_accounting_coa_id
6127 , x_value_type_code => l_adr_value_type_code
6128 , p_side => 'NA'
6129 );
6130
6131 xla_ae_lines_pkg.set_ccid(
6132 p_code_combination_id => l_ccid
6133 , p_value_type_code => l_adr_value_type_code
6134 , p_transaction_coa_id => l_adr_transaction_coa_id
6135 , p_accounting_coa_id => l_adr_accounting_coa_id
6136 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
6137 , p_adr_type_code => 'S'
6138 , p_component_type => l_component_type
6139 , p_component_code => l_component_code
6140 , p_component_type_code => l_component_type_code
6141 , p_component_appl_id => l_component_appl_id
6142 , p_amb_context_code => l_amb_context_code
6143 , p_side => 'NA'
6144 );
6145
6146
6147 l_segment := AcctDerRule_10(
6148 p_application_id => p_application_id
6149 , p_ae_header_id => l_ae_header_id
6150 , x_transaction_coa_id => l_adr_transaction_coa_id
6151 , x_accounting_coa_id => l_adr_accounting_coa_id
6152 , x_flexfield_segment_code => l_adr_flexfield_segment_code
6153 , x_flex_value_set_id => l_adr_flex_value_set_id
6154 , x_value_type_code => l_adr_value_type_code
6155 , x_value_combination_id => l_adr_value_combination_id
6156 , x_value_segment_code => l_adr_value_segment_code
6157 , p_side => 'NA'
6158 , p_override_seg_flag => 'Y'
6159 );
6160
6161 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
6162
6163 xla_ae_lines_pkg.set_segment(
6164 p_to_segment_code => 'GL_ACCOUNT'
6165 , p_segment_value => l_segment
6166 , p_from_segment_code => l_adr_value_segment_code
6167 , p_from_combination_id => l_adr_value_combination_id
6168 , p_value_type_code => l_adr_value_type_code
6169 , p_transaction_coa_id => l_adr_transaction_coa_id
6170 , p_accounting_coa_id => l_adr_accounting_coa_id
6171 , p_flexfield_segment_code => l_adr_flexfield_segment_code
6172 , p_flex_value_set_id => l_adr_flex_value_set_id
6173 , p_adr_code => 'FV_570001'
6174 , p_adr_type_code => 'S'
6175 , p_component_type => l_component_type
6176 , p_component_code => l_component_code
6177 , p_component_type_code => l_component_type_code
6178 , p_component_appl_id => l_component_appl_id
6179 , p_amb_context_code => l_amb_context_code
6180 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
6181 , p_event_class_code => 'DELIVER_EXPENSE'
6182 , p_side => 'NA'
6183 );
6184
6185 END IF;
6186
6187 --
6188 --
6189 END IF;
6190 --
6191 -- Bug 4922099
6192 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
6193 (NVL(l_enc_upg_option, 'N') = 'O')
6194 ) AND
6195 (l_bflow_method_code = 'PRIOR_ENTRY')
6196 )
6197 THEN
6198 IF
6199 --
6200 1 = 2
6201 --
6202 THEN
6203 xla_accounting_err_pkg.build_message
6204 (p_appli_s_name => 'XLA'
6205 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6206 ,p_token_1 => 'LINE_NUMBER'
6207 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
6208 ,p_token_2 => 'LINE_TYPE_NAME'
6209 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
6210 l_component_type
6211 ,l_component_code
6212 ,l_component_type_code
6213 ,l_component_appl_id
6214 ,l_amb_context_code
6215 ,l_entity_code
6216 ,l_event_class_code
6217 )
6218 ,p_token_3 => 'OWNER'
6219 ,p_value_3 => xla_lookups_pkg.get_meaning(
6220 p_lookup_type => 'XLA_OWNER_TYPE'
6221 ,p_lookup_code => l_component_type_code
6222 )
6223 ,p_token_4 => 'PRODUCT_NAME'
6224 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
6225 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
6226 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
6227 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
6228 ,p_ae_header_id => NULL
6229 );
6230
6231 IF (C_LEVEL_ERROR>= g_log_level) THEN
6232 trace
6233 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6234 ,p_level => C_LEVEL_ERROR
6235 ,p_module => l_log_module);
6236 END IF;
6237 END IF;
6238 END IF;
6239 --
6240 --
6241 ------------------------------------------------------------------------------------------------
6242 -- 4219869 Business Flow
6243 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
6244 -- Prior Entry. Currently, the following code is always generated.
6245 ------------------------------------------------------------------------------------------------
6246 XLA_AE_LINES_PKG.ValidateCurrentLine;
6247
6248 ------------------------------------------------------------------------------------
6249 -- 4219869 Business Flow
6250 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
6251 ------------------------------------------------------------------------------------
6252 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6253
6254 ----------------------------------------------------------------------------------
6255 -- 4219869 Business Flow
6256 -- Update journal entry status -- Need to generate this within IF <condition>
6257 ----------------------------------------------------------------------------------
6258 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6259 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
6260 ,p_balance_type_code => l_balance_type_code
6261 );
6262
6263 -------------------------------------------------------------------------------------------
6264 -- 4262811 - Generate the Accrual Reversal lines
6265 -------------------------------------------------------------------------------------------
6266 BEGIN
6267 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
6268 (g_array_event(p_event_id).array_value_num('header_index'));
6269 IF l_acc_rev_flag IS NULL THEN
6270 l_acc_rev_flag := 'N';
6271 END IF;
6272 EXCEPTION
6273 WHEN OTHERS THEN
6274 l_acc_rev_flag := 'N';
6275 END;
6276 --
6277 IF (l_acc_rev_flag = 'Y') THEN
6278
6279 -- 4645092 ------------------------------------------------------------------------------
6280 -- To allow MPA report to determine if it should generate report process
6281 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
6282 ------------------------------------------------------------------------------------------
6283
6284 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
6285 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
6286 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
6287 -- call ADRs
6288 -- Bug 4922099
6289 --
6290 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6291 (NVL(l_actual_upg_option, 'N') = 'O') OR
6292 (NVL(l_enc_upg_option, 'N') = 'O')
6293 )
6294 THEN
6295 NULL;
6296 --
6297 --
6298
6299 l_ccid := AcctDerRule_11(
6300 p_application_id => p_application_id
6301 , p_ae_header_id => l_ae_header_id
6302 , p_source_3 => p_source_3
6303 , x_transaction_coa_id => l_adr_transaction_coa_id
6304 , x_accounting_coa_id => l_adr_accounting_coa_id
6305 , x_value_type_code => l_adr_value_type_code
6306 , p_side => 'NA'
6307 );
6308
6309 xla_ae_lines_pkg.set_ccid(
6310 p_code_combination_id => l_ccid
6311 , p_value_type_code => l_adr_value_type_code
6312 , p_transaction_coa_id => l_adr_transaction_coa_id
6313 , p_accounting_coa_id => l_adr_accounting_coa_id
6314 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
6315 , p_adr_type_code => 'S'
6316 , p_component_type => l_component_type
6317 , p_component_code => l_component_code
6318 , p_component_type_code => l_component_type_code
6319 , p_component_appl_id => l_component_appl_id
6320 , p_amb_context_code => l_amb_context_code
6321 , p_side => 'NA'
6322 );
6323
6324
6325 l_segment := AcctDerRule_10(
6326 p_application_id => p_application_id
6327 , p_ae_header_id => l_ae_header_id
6328 , x_transaction_coa_id => l_adr_transaction_coa_id
6329 , x_accounting_coa_id => l_adr_accounting_coa_id
6330 , x_flexfield_segment_code => l_adr_flexfield_segment_code
6331 , x_flex_value_set_id => l_adr_flex_value_set_id
6332 , x_value_type_code => l_adr_value_type_code
6333 , x_value_combination_id => l_adr_value_combination_id
6334 , x_value_segment_code => l_adr_value_segment_code
6335 , p_side => 'NA'
6336 , p_override_seg_flag => 'Y'
6337 );
6338
6339 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
6340
6341 xla_ae_lines_pkg.set_segment(
6342 p_to_segment_code => 'GL_ACCOUNT'
6343 , p_segment_value => l_segment
6344 , p_from_segment_code => l_adr_value_segment_code
6345 , p_from_combination_id => l_adr_value_combination_id
6346 , p_value_type_code => l_adr_value_type_code
6347 , p_transaction_coa_id => l_adr_transaction_coa_id
6348 , p_accounting_coa_id => l_adr_accounting_coa_id
6349 , p_flexfield_segment_code => l_adr_flexfield_segment_code
6350 , p_flex_value_set_id => l_adr_flex_value_set_id
6351 , p_adr_code => 'FV_570001'
6352 , p_adr_type_code => 'S'
6353 , p_component_type => l_component_type
6354 , p_component_code => l_component_code
6355 , p_component_type_code => l_component_type_code
6356 , p_component_appl_id => l_component_appl_id
6357 , p_amb_context_code => l_amb_context_code
6358 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
6359 , p_event_class_code => 'DELIVER_EXPENSE'
6360 , p_side => 'NA'
6361 );
6362
6363 END IF;
6364
6365 --
6366 --
6367 END IF;
6368
6369 --
6370 -- Update the line information that should be overwritten
6371 --
6372 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
6373 p_header_num => 1);
6374 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
6375
6376 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
6377
6378 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
6379 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
6380 END IF;
6381
6382 --
6383 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
6384 --
6385 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
6386 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
6387 ELSE
6388 ---------------------------------------------------------------------------------------------------
6389 -- 4262811a Switch Sign
6390 ---------------------------------------------------------------------------------------------------
6391 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
6392 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6393 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6394 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6395 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6396 -- 5132302
6397 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
6398 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6399
6400 END IF;
6401
6402 -- 4955764
6403 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6404 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
6405
6406
6407 XLA_AE_LINES_PKG.ValidateCurrentLine;
6408 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6409
6410 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6411 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
6412 ,p_balance_type_code => l_balance_type_code);
6413
6414 END IF;
6415
6416 -----------------------------------------------------------------------------------------
6417 -- 4262811 Multiperiod Accounting
6418 -----------------------------------------------------------------------------------------
6419 -- No MPA option is assigned.
6420
6421
6422 END IF;
6423 END IF;
6424 --
6425
6426 --
6427 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6428 trace
6429 (p_msg => 'END of AcctLineType_18'
6430 ,p_level => C_LEVEL_PROCEDURE
6431 ,p_module => l_log_module);
6432 END IF;
6433 --
6434 EXCEPTION
6435 WHEN xla_exceptions_pkg.application_exception THEN
6436 RAISE;
6437 WHEN OTHERS THEN
6438 xla_exceptions_pkg.raise_message
6439 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_18');
6440 END AcctLineType_18;
6441 --
6442
6443 ---------------------------------------
6444 --
6445 -- PRIVATE FUNCTION
6446 -- AcctLineType_19
6447 --
6448 ---------------------------------------
6449 PROCEDURE AcctLineType_19 (
6450 p_application_id IN NUMBER
6451 ,p_event_id IN NUMBER
6452 ,p_calculate_acctd_flag IN VARCHAR2
6453 ,p_calculate_g_l_flag IN VARCHAR2
6454 ,p_actual_flag IN OUT VARCHAR2
6455 ,p_balance_type_code OUT VARCHAR2
6456 ,p_gain_or_loss_ref OUT VARCHAR2
6457
6458 --Federal Fund Category
6459 , p_source_2 IN VARCHAR2
6460 --PO Budget Account
6461 , p_source_3 IN NUMBER
6462 --Applied to Application ID
6463 , p_source_7 IN NUMBER
6464 --Applied to Distribution Link Type
6465 , p_source_8 IN VARCHAR2
6466 --Applied to Entity Code
6467 , p_source_9 IN VARCHAR2
6468 --Applied To Purchase Document Identifier
6469 , p_source_11 IN NUMBER
6470 --DISTRIBUTION_IDENTIFIER
6471 , p_source_12 IN NUMBER
6472 --Distribution Type
6473 , p_source_13 IN VARCHAR2
6474 , p_source_13_meaning IN VARCHAR2
6475 --Encumbrance Reversal Amount Entered
6476 , p_source_14 IN NUMBER
6477 --Entered Currency Code
6478 , p_source_15 IN VARCHAR2
6479 --Transaction Encumbrance Reversal Amount
6480 , p_source_16 IN NUMBER
6481 --Costing Encumbrance Upgrade Option
6482 , p_source_17 IN VARCHAR2
6483 --Currency Conversion Date
6484 , p_source_19 IN DATE
6485 --Currency Conversion Rate
6486 , p_source_20 IN NUMBER
6487 --Currency Conversion Type
6488 , p_source_21 IN VARCHAR2
6489 --Purchasing Encumbrance Type Identifier
6490 , p_source_22 IN NUMBER
6491 --TXN_PO_DISTRIBUTION_ID
6492 , p_source_23 IN NUMBER
6493 --Entered Amount
6494 , p_source_25 IN NUMBER
6495 --Accounted Amount
6496 , p_source_26 IN NUMBER
6497 )
6498 IS
6499
6500 l_component_type VARCHAR2(80);
6501 l_component_code VARCHAR2(30);
6502 l_component_type_code VARCHAR2(1);
6503 l_component_appl_id INTEGER;
6504 l_amb_context_code VARCHAR2(30);
6505 l_entity_code VARCHAR2(30);
6506 l_event_class_code VARCHAR2(30);
6507 l_ae_header_id NUMBER;
6508 l_event_type_code VARCHAR2(30);
6509 l_line_definition_code VARCHAR2(30);
6510 l_line_definition_owner_code VARCHAR2(1);
6511 --
6512 -- adr variables
6513 l_segment VARCHAR2(30);
6514 l_ccid NUMBER;
6515 l_adr_transaction_coa_id NUMBER;
6516 l_adr_accounting_coa_id NUMBER;
6517 l_adr_flexfield_segment_code VARCHAR2(30);
6518 l_adr_flex_value_set_id NUMBER;
6519 l_adr_value_type_code VARCHAR2(30);
6520 l_adr_value_combination_id NUMBER;
6521 l_adr_value_segment_code VARCHAR2(30);
6522
6523 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
6524 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
6525 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
6526 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
6527
6528 -- 4262811 Variables ------------------------------------------------------------------------------------------
6529 l_entered_amt_idx NUMBER;
6530 l_accted_amt_idx NUMBER;
6531 l_acc_rev_flag VARCHAR2(1);
6532 l_accrual_line_num NUMBER;
6533 l_tmp_amt NUMBER;
6534 l_acc_rev_natural_side_code VARCHAR2(1);
6535
6536 l_num_entries NUMBER;
6537 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
6538 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
6539 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
6540 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
6541 l_recog_line_1 NUMBER;
6542 l_recog_line_2 NUMBER;
6543
6544 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
6545 l_bflow_applied_to_amt NUMBER; -- 5132302
6546 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
6547
6548 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
6549
6550 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
6551 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
6552
6553 ---------------------------------------------------------------------------------------------------------------
6554
6555
6556 --
6557 -- bulk performance
6558 --
6559 l_balance_type_code VARCHAR2(1);
6560 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
6561 l_log_module VARCHAR2(240);
6562
6563 --
6564 -- Upgrade strategy
6565 --
6566 l_actual_upg_option VARCHAR2(1);
6567 l_enc_upg_option VARCHAR2(1);
6568
6569 --
6570 BEGIN
6571 --
6572 IF g_log_enabled THEN
6573 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_19';
6574 END IF;
6575 --
6576 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6577
6578 trace
6579 (p_msg => 'BEGIN of AcctLineType_19'
6580 ,p_level => C_LEVEL_PROCEDURE
6581 ,p_module => l_log_module);
6582
6583 END IF;
6584 --
6585 l_component_type := 'AMB_JLT';
6586 l_component_code := 'FV_RECLASSIFY_APPROP_CR_DTI';
6587 l_component_type_code := 'S';
6588 l_component_appl_id := 707;
6589 l_amb_context_code := 'DEFAULT';
6590 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
6591 l_event_class_code := 'PURCHASE_ORDER';
6592 l_event_type_code := 'PURCHASE_ORDER_ALL';
6593 l_line_definition_owner_code := 'S';
6594 l_line_definition_code := 'FV_PO_DEL_INV';
6595 --
6596 l_balance_type_code := 'A';
6597 l_segment := NULL;
6598 l_ccid := NULL;
6599 l_adr_transaction_coa_id := NULL;
6600 l_adr_accounting_coa_id := NULL;
6601 l_adr_flexfield_segment_code := NULL;
6602 l_adr_flex_value_set_id := NULL;
6603 l_adr_value_type_code := NULL;
6604 l_adr_value_combination_id := NULL;
6605 l_adr_value_segment_code := NULL;
6606
6607 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
6608 l_bflow_class_code := 'FV_EXP_APPR'; -- 4219869 Business Flow
6609 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
6610 l_budgetary_control_flag := 'Y';
6611
6612 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6613 l_bflow_applied_to_amt := NULL; -- 5132302
6614 l_entered_amt_idx := NULL; -- 4262811
6615 l_accted_amt_idx := NULL; -- 4262811
6616 l_acc_rev_flag := NULL; -- 4262811
6617 l_accrual_line_num := NULL; -- 4262811
6618 l_tmp_amt := NULL; -- 4262811
6619 --
6620
6621 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
6622 l_balance_type_code <> 'B' THEN
6623 IF NVL(
6624 xla_ae_sources_pkg.GetSystemSourceChar(
6625 p_source_code => 'XLA_EVENT_TYPE_CODE'
6626 , p_source_type_code => 'Y'
6627 , p_source_application_id => 602
6628 ),'
6629 ') = 'PO_DEL_INV' AND
6630 (NVL(p_source_2,'
6631 ') = 'A' OR
6632 NVL(p_source_2,'
6633 ') = 'B' OR
6634 NVL(p_source_2,'
6635 ') = 'C')
6636 THEN
6637
6638 --
6639 XLA_AE_LINES_PKG.SetNewLine;
6640
6641 p_balance_type_code := l_balance_type_code;
6642 -- set the flag so later we will know whether the gain loss line needs to be created
6643
6644 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
6645 p_actual_flag :='A';
6646 END IF;
6647
6648 --
6649 -- bulk performance
6650 --
6651 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
6652 p_header_num => 0); -- 4262811
6653 --
6654 -- set accounting line options
6655 --
6656 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
6657 p_natural_side_code => 'C'
6658 , p_gain_or_loss_flag => 'N'
6659 , p_gl_transfer_mode_code => 'S'
6660 , p_acct_entry_type_code => 'A'
6661 , p_switch_side_flag => 'N'
6662 , p_merge_duplicate_code => 'N'
6663 );
6664 --
6665 l_acc_rev_natural_side_code := 'D'; -- 4262811
6666 --
6667 --
6668 -- set accounting line type info
6669 --
6670 xla_ae_lines_pkg.SetAcctLineType
6671 (p_component_type => l_component_type
6672 ,p_event_type_code => l_event_type_code
6673 ,p_line_definition_owner_code => l_line_definition_owner_code
6674 ,p_line_definition_code => l_line_definition_code
6675 ,p_accounting_line_code => l_component_code
6676 ,p_accounting_line_type_code => l_component_type_code
6677 ,p_accounting_line_appl_id => l_component_appl_id
6678 ,p_amb_context_code => l_amb_context_code
6679 ,p_entity_code => l_entity_code
6680 ,p_event_class_code => l_event_class_code);
6681 --
6682 -- set accounting class
6683 --
6684 xla_ae_lines_pkg.SetAcctClass(
6685 p_accounting_class_code => 'FEDERAL_INV'
6686 , p_ae_header_id => l_ae_header_id
6687 );
6688
6689 --
6690 -- set rounding class
6691 --
6692 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
6693 'FEDERAL_INV';
6694
6695 --
6696 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
6697 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
6698 --
6699 -- bulk performance
6700 --
6701 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
6702
6703 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
6704 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
6705
6706 -- 4955764
6707 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6708 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
6709
6710 -- 4458381 Public Sector Enh
6711
6712 --
6713 -- set accounting attributes for the line type
6714 --
6715 l_entered_amt_idx := 17;
6716 l_accted_amt_idx := 22;
6717 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6718 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
6719 l_rec_acct_attrs.array_num_value(1) := p_source_7;
6720 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
6721 l_rec_acct_attrs.array_char_value(2) := p_source_8;
6722 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
6723 l_rec_acct_attrs.array_char_value(3) := p_source_9;
6724 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
6725 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
6726 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
6727 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
6728 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
6729 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
6730 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
6731 l_rec_acct_attrs.array_char_value(7) := p_source_13;
6732 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
6733 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
6734 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
6735 l_rec_acct_attrs.array_num_value(9) := p_source_14;
6736 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
6737 l_rec_acct_attrs.array_char_value(10) := p_source_15;
6738 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
6739 l_rec_acct_attrs.array_num_value(11) := p_source_16;
6740 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
6741 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
6742 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
6743 l_rec_acct_attrs.array_num_value(13) := p_source_14;
6744 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
6745 l_rec_acct_attrs.array_char_value(14) := p_source_15;
6746 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
6747 l_rec_acct_attrs.array_num_value(15) := p_source_16;
6748 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
6749 l_rec_acct_attrs.array_char_value(16) := p_source_17;
6750 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
6751 l_rec_acct_attrs.array_num_value(17) := p_source_25;
6752 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
6753 l_rec_acct_attrs.array_char_value(18) := p_source_15;
6754 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
6755 l_rec_acct_attrs.array_date_value(19) := p_source_19;
6756 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
6757 l_rec_acct_attrs.array_num_value(20) := p_source_20;
6758 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
6759 l_rec_acct_attrs.array_char_value(21) := p_source_21;
6760 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
6761 l_rec_acct_attrs.array_num_value(22) := p_source_26;
6762 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
6763 l_rec_acct_attrs.array_num_value(23) := p_source_22;
6764 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
6765 l_rec_acct_attrs.array_num_value(24) := p_source_22;
6766
6767 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
6768 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
6769
6770 ---------------------------------------------------------------------------------------------------------------
6771 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
6772 ---------------------------------------------------------------------------------------------------------------
6773 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
6774
6775 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6776 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6777
6778 IF xla_accounting_cache_pkg.GetValueChar
6779 (p_source_code => 'LEDGER_CATEGORY_CODE'
6780 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
6781 AND l_bflow_method_code = 'PRIOR_ENTRY'
6782 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
6783 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
6784 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
6785 )
6786 THEN
6787 xla_ae_lines_pkg.BflowUpgEntry
6788 (p_business_method_code => l_bflow_method_code
6789 ,p_business_class_code => l_bflow_class_code
6790 ,p_balance_type => l_balance_type_code);
6791 ELSE
6792 NULL;
6793 -- No business flow processing for business flow method of NONE.
6794 END IF;
6795
6796 --
6797 -- call analytical criteria
6798 --
6799
6800 --
6801 -- call description
6802 --
6803 -- No description or it is inherited.
6804 --
6805 -- call ADRs
6806 -- Bug 4922099
6807 --
6808 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6809 (NVL(l_actual_upg_option, 'N') = 'O') OR
6810 (NVL(l_enc_upg_option, 'N') = 'O')
6811 )
6812 THEN
6813 NULL;
6814 --
6815 --
6816
6817 l_ccid := AcctDerRule_11(
6818 p_application_id => p_application_id
6819 , p_ae_header_id => l_ae_header_id
6820 , p_source_3 => p_source_3
6821 , x_transaction_coa_id => l_adr_transaction_coa_id
6822 , x_accounting_coa_id => l_adr_accounting_coa_id
6823 , x_value_type_code => l_adr_value_type_code
6824 , p_side => 'NA'
6825 );
6826
6827 xla_ae_lines_pkg.set_ccid(
6828 p_code_combination_id => l_ccid
6829 , p_value_type_code => l_adr_value_type_code
6830 , p_transaction_coa_id => l_adr_transaction_coa_id
6831 , p_accounting_coa_id => l_adr_accounting_coa_id
6832 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
6833 , p_adr_type_code => 'S'
6834 , p_component_type => l_component_type
6835 , p_component_code => l_component_code
6836 , p_component_type_code => l_component_type_code
6837 , p_component_appl_id => l_component_appl_id
6838 , p_amb_context_code => l_amb_context_code
6839 , p_side => 'NA'
6840 );
6841
6842
6843 l_segment := AcctDerRule_10(
6844 p_application_id => p_application_id
6845 , p_ae_header_id => l_ae_header_id
6846 , x_transaction_coa_id => l_adr_transaction_coa_id
6847 , x_accounting_coa_id => l_adr_accounting_coa_id
6848 , x_flexfield_segment_code => l_adr_flexfield_segment_code
6849 , x_flex_value_set_id => l_adr_flex_value_set_id
6850 , x_value_type_code => l_adr_value_type_code
6851 , x_value_combination_id => l_adr_value_combination_id
6852 , x_value_segment_code => l_adr_value_segment_code
6853 , p_side => 'NA'
6854 , p_override_seg_flag => 'Y'
6855 );
6856
6857 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
6858
6859 xla_ae_lines_pkg.set_segment(
6860 p_to_segment_code => 'GL_ACCOUNT'
6861 , p_segment_value => l_segment
6862 , p_from_segment_code => l_adr_value_segment_code
6863 , p_from_combination_id => l_adr_value_combination_id
6864 , p_value_type_code => l_adr_value_type_code
6865 , p_transaction_coa_id => l_adr_transaction_coa_id
6866 , p_accounting_coa_id => l_adr_accounting_coa_id
6867 , p_flexfield_segment_code => l_adr_flexfield_segment_code
6868 , p_flex_value_set_id => l_adr_flex_value_set_id
6869 , p_adr_code => 'FV_570001'
6870 , p_adr_type_code => 'S'
6871 , p_component_type => l_component_type
6872 , p_component_code => l_component_code
6873 , p_component_type_code => l_component_type_code
6874 , p_component_appl_id => l_component_appl_id
6875 , p_amb_context_code => l_amb_context_code
6876 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
6877 , p_event_class_code => 'PURCHASE_ORDER'
6878 , p_side => 'NA'
6879 );
6880
6881 END IF;
6882
6883 --
6884 --
6885 END IF;
6886 --
6887 -- Bug 4922099
6888 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
6889 (NVL(l_enc_upg_option, 'N') = 'O')
6890 ) AND
6891 (l_bflow_method_code = 'PRIOR_ENTRY')
6892 )
6893 THEN
6894 IF
6895 --
6896 1 = 2
6897 --
6898 THEN
6899 xla_accounting_err_pkg.build_message
6900 (p_appli_s_name => 'XLA'
6901 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6902 ,p_token_1 => 'LINE_NUMBER'
6903 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
6904 ,p_token_2 => 'LINE_TYPE_NAME'
6905 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
6906 l_component_type
6907 ,l_component_code
6908 ,l_component_type_code
6909 ,l_component_appl_id
6910 ,l_amb_context_code
6911 ,l_entity_code
6912 ,l_event_class_code
6913 )
6914 ,p_token_3 => 'OWNER'
6915 ,p_value_3 => xla_lookups_pkg.get_meaning(
6916 p_lookup_type => 'XLA_OWNER_TYPE'
6917 ,p_lookup_code => l_component_type_code
6918 )
6919 ,p_token_4 => 'PRODUCT_NAME'
6920 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
6921 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
6922 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
6923 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
6924 ,p_ae_header_id => NULL
6925 );
6926
6927 IF (C_LEVEL_ERROR>= g_log_level) THEN
6928 trace
6929 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6930 ,p_level => C_LEVEL_ERROR
6931 ,p_module => l_log_module);
6932 END IF;
6933 END IF;
6934 END IF;
6935 --
6936 --
6937 ------------------------------------------------------------------------------------------------
6938 -- 4219869 Business Flow
6939 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
6940 -- Prior Entry. Currently, the following code is always generated.
6941 ------------------------------------------------------------------------------------------------
6942 XLA_AE_LINES_PKG.ValidateCurrentLine;
6943
6944 ------------------------------------------------------------------------------------
6945 -- 4219869 Business Flow
6946 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
6947 ------------------------------------------------------------------------------------
6948 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6949
6950 ----------------------------------------------------------------------------------
6951 -- 4219869 Business Flow
6952 -- Update journal entry status -- Need to generate this within IF <condition>
6953 ----------------------------------------------------------------------------------
6954 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6955 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
6956 ,p_balance_type_code => l_balance_type_code
6957 );
6958
6959 -------------------------------------------------------------------------------------------
6960 -- 4262811 - Generate the Accrual Reversal lines
6961 -------------------------------------------------------------------------------------------
6962 BEGIN
6963 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
6964 (g_array_event(p_event_id).array_value_num('header_index'));
6965 IF l_acc_rev_flag IS NULL THEN
6966 l_acc_rev_flag := 'N';
6967 END IF;
6968 EXCEPTION
6969 WHEN OTHERS THEN
6970 l_acc_rev_flag := 'N';
6971 END;
6972 --
6973 IF (l_acc_rev_flag = 'Y') THEN
6974
6975 -- 4645092 ------------------------------------------------------------------------------
6976 -- To allow MPA report to determine if it should generate report process
6977 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
6978 ------------------------------------------------------------------------------------------
6979
6980 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
6981 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
6982 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
6983 -- call ADRs
6984 -- Bug 4922099
6985 --
6986 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6987 (NVL(l_actual_upg_option, 'N') = 'O') OR
6988 (NVL(l_enc_upg_option, 'N') = 'O')
6989 )
6990 THEN
6991 NULL;
6992 --
6993 --
6994
6995 l_ccid := AcctDerRule_11(
6996 p_application_id => p_application_id
6997 , p_ae_header_id => l_ae_header_id
6998 , p_source_3 => p_source_3
6999 , x_transaction_coa_id => l_adr_transaction_coa_id
7000 , x_accounting_coa_id => l_adr_accounting_coa_id
7001 , x_value_type_code => l_adr_value_type_code
7002 , p_side => 'NA'
7003 );
7004
7005 xla_ae_lines_pkg.set_ccid(
7006 p_code_combination_id => l_ccid
7007 , p_value_type_code => l_adr_value_type_code
7008 , p_transaction_coa_id => l_adr_transaction_coa_id
7009 , p_accounting_coa_id => l_adr_accounting_coa_id
7010 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
7011 , p_adr_type_code => 'S'
7012 , p_component_type => l_component_type
7013 , p_component_code => l_component_code
7014 , p_component_type_code => l_component_type_code
7015 , p_component_appl_id => l_component_appl_id
7016 , p_amb_context_code => l_amb_context_code
7017 , p_side => 'NA'
7018 );
7019
7020
7021 l_segment := AcctDerRule_10(
7022 p_application_id => p_application_id
7023 , p_ae_header_id => l_ae_header_id
7024 , x_transaction_coa_id => l_adr_transaction_coa_id
7025 , x_accounting_coa_id => l_adr_accounting_coa_id
7026 , x_flexfield_segment_code => l_adr_flexfield_segment_code
7027 , x_flex_value_set_id => l_adr_flex_value_set_id
7028 , x_value_type_code => l_adr_value_type_code
7029 , x_value_combination_id => l_adr_value_combination_id
7030 , x_value_segment_code => l_adr_value_segment_code
7031 , p_side => 'NA'
7032 , p_override_seg_flag => 'Y'
7033 );
7034
7035 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
7036
7037 xla_ae_lines_pkg.set_segment(
7038 p_to_segment_code => 'GL_ACCOUNT'
7039 , p_segment_value => l_segment
7040 , p_from_segment_code => l_adr_value_segment_code
7041 , p_from_combination_id => l_adr_value_combination_id
7042 , p_value_type_code => l_adr_value_type_code
7043 , p_transaction_coa_id => l_adr_transaction_coa_id
7044 , p_accounting_coa_id => l_adr_accounting_coa_id
7045 , p_flexfield_segment_code => l_adr_flexfield_segment_code
7046 , p_flex_value_set_id => l_adr_flex_value_set_id
7047 , p_adr_code => 'FV_570001'
7048 , p_adr_type_code => 'S'
7049 , p_component_type => l_component_type
7050 , p_component_code => l_component_code
7051 , p_component_type_code => l_component_type_code
7052 , p_component_appl_id => l_component_appl_id
7053 , p_amb_context_code => l_amb_context_code
7054 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
7055 , p_event_class_code => 'PURCHASE_ORDER'
7056 , p_side => 'NA'
7057 );
7058
7059 END IF;
7060
7061 --
7062 --
7063 END IF;
7064
7065 --
7066 -- Update the line information that should be overwritten
7067 --
7068 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
7069 p_header_num => 1);
7070 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
7071
7072 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
7073
7074 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
7075 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
7076 END IF;
7077
7078 --
7079 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
7080 --
7081 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
7082 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
7083 ELSE
7084 ---------------------------------------------------------------------------------------------------
7085 -- 4262811a Switch Sign
7086 ---------------------------------------------------------------------------------------------------
7087 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
7088 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7089 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7090 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7091 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7092 -- 5132302
7093 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
7094 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7095
7096 END IF;
7097
7098 -- 4955764
7099 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7100 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
7101
7102
7103 XLA_AE_LINES_PKG.ValidateCurrentLine;
7104 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7105
7106 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7107 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
7108 ,p_balance_type_code => l_balance_type_code);
7109
7110 END IF;
7111
7112 -----------------------------------------------------------------------------------------
7113 -- 4262811 Multiperiod Accounting
7114 -----------------------------------------------------------------------------------------
7115 -- No MPA option is assigned.
7116
7117
7118 END IF;
7119 END IF;
7120 --
7121
7122 --
7123 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7124 trace
7125 (p_msg => 'END of AcctLineType_19'
7126 ,p_level => C_LEVEL_PROCEDURE
7127 ,p_module => l_log_module);
7128 END IF;
7129 --
7130 EXCEPTION
7131 WHEN xla_exceptions_pkg.application_exception THEN
7132 RAISE;
7133 WHEN OTHERS THEN
7134 xla_exceptions_pkg.raise_message
7135 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_19');
7136 END AcctLineType_19;
7137 --
7138
7139 ---------------------------------------
7140 --
7141 -- PRIVATE FUNCTION
7142 -- AcctLineType_20
7143 --
7144 ---------------------------------------
7145 PROCEDURE AcctLineType_20 (
7146 p_application_id IN NUMBER
7147 ,p_event_id IN NUMBER
7148 ,p_calculate_acctd_flag IN VARCHAR2
7149 ,p_calculate_g_l_flag IN VARCHAR2
7150 ,p_actual_flag IN OUT VARCHAR2
7151 ,p_balance_type_code OUT VARCHAR2
7152 ,p_gain_or_loss_ref OUT VARCHAR2
7153
7154 --Federal Fund Category
7155 , p_source_2 IN VARCHAR2
7156 --PO Budget Account
7157 , p_source_3 IN NUMBER
7158 --Receiving Accounting Line Type
7159 , p_source_6 IN VARCHAR2
7160 --Applied to Application ID
7161 , p_source_7 IN NUMBER
7162 --Applied to Distribution Link Type
7163 , p_source_8 IN VARCHAR2
7164 --Applied to Entity Code
7165 , p_source_9 IN VARCHAR2
7166 --PO_DISTRIBUTION_ID
7167 , p_source_10 IN NUMBER
7168 --Applied To Purchase Document Identifier
7169 , p_source_11 IN NUMBER
7170 --DISTRIBUTION_IDENTIFIER
7171 , p_source_12 IN NUMBER
7172 --Distribution Type
7173 , p_source_13 IN VARCHAR2
7174 , p_source_13_meaning IN VARCHAR2
7175 --Encumbrance Reversal Amount Entered
7176 , p_source_14 IN NUMBER
7177 --Entered Currency Code
7178 , p_source_15 IN VARCHAR2
7179 --Transaction Encumbrance Reversal Amount
7180 , p_source_16 IN NUMBER
7181 --Costing Encumbrance Upgrade Option
7182 , p_source_17 IN VARCHAR2
7183 --Currency Conversion Date
7184 , p_source_19 IN DATE
7185 --Currency Conversion Rate
7186 , p_source_20 IN NUMBER
7187 --Currency Conversion Type
7188 , p_source_21 IN VARCHAR2
7189 --Purchasing Encumbrance Type Identifier
7190 , p_source_22 IN NUMBER
7191 --Entered Amount
7192 , p_source_25 IN NUMBER
7193 --Accounted Amount
7194 , p_source_26 IN NUMBER
7195 )
7196 IS
7197
7198 l_component_type VARCHAR2(80);
7199 l_component_code VARCHAR2(30);
7200 l_component_type_code VARCHAR2(1);
7201 l_component_appl_id INTEGER;
7202 l_amb_context_code VARCHAR2(30);
7203 l_entity_code VARCHAR2(30);
7204 l_event_class_code VARCHAR2(30);
7205 l_ae_header_id NUMBER;
7206 l_event_type_code VARCHAR2(30);
7207 l_line_definition_code VARCHAR2(30);
7208 l_line_definition_owner_code VARCHAR2(1);
7209 --
7210 -- adr variables
7211 l_segment VARCHAR2(30);
7212 l_ccid NUMBER;
7213 l_adr_transaction_coa_id NUMBER;
7214 l_adr_accounting_coa_id NUMBER;
7215 l_adr_flexfield_segment_code VARCHAR2(30);
7216 l_adr_flex_value_set_id NUMBER;
7217 l_adr_value_type_code VARCHAR2(30);
7218 l_adr_value_combination_id NUMBER;
7219 l_adr_value_segment_code VARCHAR2(30);
7220
7221 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
7222 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
7223 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
7224 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
7225
7226 -- 4262811 Variables ------------------------------------------------------------------------------------------
7227 l_entered_amt_idx NUMBER;
7228 l_accted_amt_idx NUMBER;
7229 l_acc_rev_flag VARCHAR2(1);
7230 l_accrual_line_num NUMBER;
7231 l_tmp_amt NUMBER;
7232 l_acc_rev_natural_side_code VARCHAR2(1);
7233
7234 l_num_entries NUMBER;
7235 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
7236 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
7237 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
7238 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
7239 l_recog_line_1 NUMBER;
7240 l_recog_line_2 NUMBER;
7241
7242 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
7243 l_bflow_applied_to_amt NUMBER; -- 5132302
7244 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
7245
7246 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
7247
7248 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
7249 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
7250
7251 ---------------------------------------------------------------------------------------------------------------
7252
7253
7254 --
7255 -- bulk performance
7256 --
7257 l_balance_type_code VARCHAR2(1);
7258 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
7259 l_log_module VARCHAR2(240);
7260
7261 --
7262 -- Upgrade strategy
7263 --
7264 l_actual_upg_option VARCHAR2(1);
7265 l_enc_upg_option VARCHAR2(1);
7266
7267 --
7268 BEGIN
7269 --
7270 IF g_log_enabled THEN
7271 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_20';
7272 END IF;
7273 --
7274 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7275
7276 trace
7277 (p_msg => 'BEGIN of AcctLineType_20'
7278 ,p_level => C_LEVEL_PROCEDURE
7279 ,p_module => l_log_module);
7280
7281 END IF;
7282 --
7283 l_component_type := 'AMB_JLT';
7284 l_component_code := 'FV_RECLASSIFY_APPROP_DR';
7285 l_component_type_code := 'S';
7286 l_component_appl_id := 707;
7287 l_amb_context_code := 'DEFAULT';
7288 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
7289 l_event_class_code := 'DELIVER_EXPENSE';
7290 l_event_type_code := 'DELIVER_EXPENSE_ALL';
7291 l_line_definition_owner_code := 'S';
7292 l_line_definition_code := 'FV_DELIVER_EXPENSE';
7293 --
7294 l_balance_type_code := 'A';
7295 l_segment := NULL;
7296 l_ccid := NULL;
7297 l_adr_transaction_coa_id := NULL;
7298 l_adr_accounting_coa_id := NULL;
7299 l_adr_flexfield_segment_code := NULL;
7300 l_adr_flex_value_set_id := NULL;
7301 l_adr_value_type_code := NULL;
7302 l_adr_value_combination_id := NULL;
7303 l_adr_value_segment_code := NULL;
7304
7305 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
7306 l_bflow_class_code := 'FV_UNEXP_APPR'; -- 4219869 Business Flow
7307 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
7308 l_budgetary_control_flag := 'Y';
7309
7310 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7311 l_bflow_applied_to_amt := NULL; -- 5132302
7312 l_entered_amt_idx := NULL; -- 4262811
7313 l_accted_amt_idx := NULL; -- 4262811
7314 l_acc_rev_flag := NULL; -- 4262811
7315 l_accrual_line_num := NULL; -- 4262811
7316 l_tmp_amt := NULL; -- 4262811
7317 --
7318
7319 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
7320 l_balance_type_code <> 'B' THEN
7321 IF (NVL(p_source_2,'
7322 ') = 'A' OR
7323 NVL(p_source_2,'
7324 ') = 'B' OR
7325 NVL(p_source_2,'
7326 ') = 'C') AND
7327 NVL(
7328 xla_ae_sources_pkg.GetSystemSourceChar(
7329 p_source_code => 'XLA_EVENT_TYPE_CODE'
7330 , p_source_type_code => 'Y'
7331 , p_source_application_id => 602
7332 ),'
7333 ') = 'DELIVER_EXPENSE' AND
7334 NVL(p_source_6,'
7335 ') = 'Charge'
7336 THEN
7337
7338 --
7339 XLA_AE_LINES_PKG.SetNewLine;
7340
7341 p_balance_type_code := l_balance_type_code;
7342 -- set the flag so later we will know whether the gain loss line needs to be created
7343
7344 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
7345 p_actual_flag :='A';
7346 END IF;
7347
7348 --
7349 -- bulk performance
7350 --
7351 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
7352 p_header_num => 0); -- 4262811
7353 --
7354 -- set accounting line options
7355 --
7356 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
7357 p_natural_side_code => 'D'
7358 , p_gain_or_loss_flag => 'N'
7359 , p_gl_transfer_mode_code => 'S'
7360 , p_acct_entry_type_code => 'A'
7361 , p_switch_side_flag => 'N'
7362 , p_merge_duplicate_code => 'N'
7363 );
7364 --
7365 l_acc_rev_natural_side_code := 'C'; -- 4262811
7366 --
7367 --
7368 -- set accounting line type info
7369 --
7370 xla_ae_lines_pkg.SetAcctLineType
7371 (p_component_type => l_component_type
7372 ,p_event_type_code => l_event_type_code
7373 ,p_line_definition_owner_code => l_line_definition_owner_code
7374 ,p_line_definition_code => l_line_definition_code
7375 ,p_accounting_line_code => l_component_code
7376 ,p_accounting_line_type_code => l_component_type_code
7377 ,p_accounting_line_appl_id => l_component_appl_id
7378 ,p_amb_context_code => l_amb_context_code
7379 ,p_entity_code => l_entity_code
7380 ,p_event_class_code => l_event_class_code);
7381 --
7382 -- set accounting class
7383 --
7384 xla_ae_lines_pkg.SetAcctClass(
7385 p_accounting_class_code => 'FEDERAL_EXP'
7386 , p_ae_header_id => l_ae_header_id
7387 );
7388
7389 --
7390 -- set rounding class
7391 --
7392 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
7393 'FEDERAL_EXP';
7394
7395 --
7396 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
7397 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
7398 --
7399 -- bulk performance
7400 --
7401 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
7402
7403 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
7404 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
7405
7406 -- 4955764
7407 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7408 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
7409
7410 -- 4458381 Public Sector Enh
7411
7412 --
7413 -- set accounting attributes for the line type
7414 --
7415 l_entered_amt_idx := 17;
7416 l_accted_amt_idx := 22;
7417 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7418 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
7419 l_rec_acct_attrs.array_num_value(1) := p_source_7;
7420 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
7421 l_rec_acct_attrs.array_char_value(2) := p_source_8;
7422 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
7423 l_rec_acct_attrs.array_char_value(3) := p_source_9;
7424 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
7425 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
7426 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
7427 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
7428 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
7429 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
7430 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
7431 l_rec_acct_attrs.array_char_value(7) := p_source_13;
7432 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
7433 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
7434 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
7435 l_rec_acct_attrs.array_num_value(9) := p_source_14;
7436 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
7437 l_rec_acct_attrs.array_char_value(10) := p_source_15;
7438 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
7439 l_rec_acct_attrs.array_num_value(11) := p_source_16;
7440 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
7441 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
7442 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
7443 l_rec_acct_attrs.array_num_value(13) := p_source_14;
7444 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
7445 l_rec_acct_attrs.array_char_value(14) := p_source_15;
7446 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
7447 l_rec_acct_attrs.array_num_value(15) := p_source_16;
7448 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
7449 l_rec_acct_attrs.array_char_value(16) := p_source_17;
7450 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
7451 l_rec_acct_attrs.array_num_value(17) := p_source_25;
7452 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
7453 l_rec_acct_attrs.array_char_value(18) := p_source_15;
7454 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
7455 l_rec_acct_attrs.array_date_value(19) := p_source_19;
7456 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
7457 l_rec_acct_attrs.array_num_value(20) := p_source_20;
7458 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
7459 l_rec_acct_attrs.array_char_value(21) := p_source_21;
7460 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
7461 l_rec_acct_attrs.array_num_value(22) := p_source_26;
7462 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
7463 l_rec_acct_attrs.array_num_value(23) := p_source_22;
7464 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
7465 l_rec_acct_attrs.array_num_value(24) := p_source_22;
7466
7467 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
7468 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
7469
7470 ---------------------------------------------------------------------------------------------------------------
7471 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
7472 ---------------------------------------------------------------------------------------------------------------
7473 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
7474
7475 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7476 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7477
7478 IF xla_accounting_cache_pkg.GetValueChar
7479 (p_source_code => 'LEDGER_CATEGORY_CODE'
7480 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
7481 AND l_bflow_method_code = 'PRIOR_ENTRY'
7482 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
7483 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
7484 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
7485 )
7486 THEN
7487 xla_ae_lines_pkg.BflowUpgEntry
7488 (p_business_method_code => l_bflow_method_code
7489 ,p_business_class_code => l_bflow_class_code
7490 ,p_balance_type => l_balance_type_code);
7491 ELSE
7492 NULL;
7493 -- No business flow processing for business flow method of NONE.
7494 END IF;
7495
7496 --
7497 -- call analytical criteria
7498 --
7499
7500 --
7501 -- call description
7502 --
7503 -- No description or it is inherited.
7504 --
7505 -- call ADRs
7506 -- Bug 4922099
7507 --
7508 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7509 (NVL(l_actual_upg_option, 'N') = 'O') OR
7510 (NVL(l_enc_upg_option, 'N') = 'O')
7511 )
7512 THEN
7513 NULL;
7514 --
7515 --
7516
7517 l_ccid := AcctDerRule_11(
7518 p_application_id => p_application_id
7519 , p_ae_header_id => l_ae_header_id
7520 , p_source_3 => p_source_3
7521 , x_transaction_coa_id => l_adr_transaction_coa_id
7522 , x_accounting_coa_id => l_adr_accounting_coa_id
7523 , x_value_type_code => l_adr_value_type_code
7524 , p_side => 'NA'
7525 );
7526
7527 xla_ae_lines_pkg.set_ccid(
7528 p_code_combination_id => l_ccid
7529 , p_value_type_code => l_adr_value_type_code
7530 , p_transaction_coa_id => l_adr_transaction_coa_id
7531 , p_accounting_coa_id => l_adr_accounting_coa_id
7532 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
7533 , p_adr_type_code => 'S'
7534 , p_component_type => l_component_type
7535 , p_component_code => l_component_code
7536 , p_component_type_code => l_component_type_code
7537 , p_component_appl_id => l_component_appl_id
7538 , p_amb_context_code => l_amb_context_code
7539 , p_side => 'NA'
7540 );
7541
7542
7543 l_segment := AcctDerRule_1(
7544 p_application_id => p_application_id
7545 , p_ae_header_id => l_ae_header_id
7546 , x_transaction_coa_id => l_adr_transaction_coa_id
7547 , x_accounting_coa_id => l_adr_accounting_coa_id
7548 , x_flexfield_segment_code => l_adr_flexfield_segment_code
7549 , x_flex_value_set_id => l_adr_flex_value_set_id
7550 , x_value_type_code => l_adr_value_type_code
7551 , x_value_combination_id => l_adr_value_combination_id
7552 , x_value_segment_code => l_adr_value_segment_code
7553 , p_side => 'NA'
7554 , p_override_seg_flag => 'Y'
7555 );
7556
7557 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
7558
7559 xla_ae_lines_pkg.set_segment(
7560 p_to_segment_code => 'GL_ACCOUNT'
7561 , p_segment_value => l_segment
7562 , p_from_segment_code => l_adr_value_segment_code
7563 , p_from_combination_id => l_adr_value_combination_id
7564 , p_value_type_code => l_adr_value_type_code
7565 , p_transaction_coa_id => l_adr_transaction_coa_id
7566 , p_accounting_coa_id => l_adr_accounting_coa_id
7567 , p_flexfield_segment_code => l_adr_flexfield_segment_code
7568 , p_flex_value_set_id => l_adr_flex_value_set_id
7569 , p_adr_code => 'FV_310701'
7570 , p_adr_type_code => 'S'
7571 , p_component_type => l_component_type
7572 , p_component_code => l_component_code
7573 , p_component_type_code => l_component_type_code
7574 , p_component_appl_id => l_component_appl_id
7575 , p_amb_context_code => l_amb_context_code
7576 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
7577 , p_event_class_code => 'DELIVER_EXPENSE'
7578 , p_side => 'NA'
7579 );
7580
7581 END IF;
7582
7583 --
7584 --
7585 END IF;
7586 --
7587 -- Bug 4922099
7588 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
7589 (NVL(l_enc_upg_option, 'N') = 'O')
7590 ) AND
7591 (l_bflow_method_code = 'PRIOR_ENTRY')
7592 )
7593 THEN
7594 IF
7595 --
7596 1 = 2
7597 --
7598 THEN
7599 xla_accounting_err_pkg.build_message
7600 (p_appli_s_name => 'XLA'
7601 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7602 ,p_token_1 => 'LINE_NUMBER'
7603 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
7604 ,p_token_2 => 'LINE_TYPE_NAME'
7605 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
7606 l_component_type
7607 ,l_component_code
7608 ,l_component_type_code
7609 ,l_component_appl_id
7610 ,l_amb_context_code
7611 ,l_entity_code
7612 ,l_event_class_code
7613 )
7614 ,p_token_3 => 'OWNER'
7615 ,p_value_3 => xla_lookups_pkg.get_meaning(
7616 p_lookup_type => 'XLA_OWNER_TYPE'
7617 ,p_lookup_code => l_component_type_code
7618 )
7619 ,p_token_4 => 'PRODUCT_NAME'
7620 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
7621 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
7622 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
7623 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
7624 ,p_ae_header_id => NULL
7625 );
7626
7627 IF (C_LEVEL_ERROR>= g_log_level) THEN
7628 trace
7629 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7630 ,p_level => C_LEVEL_ERROR
7631 ,p_module => l_log_module);
7632 END IF;
7633 END IF;
7634 END IF;
7635 --
7636 --
7637 ------------------------------------------------------------------------------------------------
7638 -- 4219869 Business Flow
7639 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
7640 -- Prior Entry. Currently, the following code is always generated.
7641 ------------------------------------------------------------------------------------------------
7642 XLA_AE_LINES_PKG.ValidateCurrentLine;
7643
7644 ------------------------------------------------------------------------------------
7645 -- 4219869 Business Flow
7646 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
7647 ------------------------------------------------------------------------------------
7648 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7649
7650 ----------------------------------------------------------------------------------
7651 -- 4219869 Business Flow
7652 -- Update journal entry status -- Need to generate this within IF <condition>
7653 ----------------------------------------------------------------------------------
7654 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7655 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
7656 ,p_balance_type_code => l_balance_type_code
7657 );
7658
7659 -------------------------------------------------------------------------------------------
7660 -- 4262811 - Generate the Accrual Reversal lines
7661 -------------------------------------------------------------------------------------------
7662 BEGIN
7663 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
7664 (g_array_event(p_event_id).array_value_num('header_index'));
7665 IF l_acc_rev_flag IS NULL THEN
7666 l_acc_rev_flag := 'N';
7667 END IF;
7668 EXCEPTION
7669 WHEN OTHERS THEN
7670 l_acc_rev_flag := 'N';
7671 END;
7672 --
7673 IF (l_acc_rev_flag = 'Y') THEN
7674
7675 -- 4645092 ------------------------------------------------------------------------------
7676 -- To allow MPA report to determine if it should generate report process
7677 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
7678 ------------------------------------------------------------------------------------------
7679
7680 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
7681 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
7682 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
7683 -- call ADRs
7684 -- Bug 4922099
7685 --
7686 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7687 (NVL(l_actual_upg_option, 'N') = 'O') OR
7688 (NVL(l_enc_upg_option, 'N') = 'O')
7689 )
7690 THEN
7691 NULL;
7692 --
7693 --
7694
7695 l_ccid := AcctDerRule_11(
7696 p_application_id => p_application_id
7697 , p_ae_header_id => l_ae_header_id
7698 , p_source_3 => p_source_3
7699 , x_transaction_coa_id => l_adr_transaction_coa_id
7700 , x_accounting_coa_id => l_adr_accounting_coa_id
7701 , x_value_type_code => l_adr_value_type_code
7702 , p_side => 'NA'
7703 );
7704
7705 xla_ae_lines_pkg.set_ccid(
7706 p_code_combination_id => l_ccid
7707 , p_value_type_code => l_adr_value_type_code
7708 , p_transaction_coa_id => l_adr_transaction_coa_id
7709 , p_accounting_coa_id => l_adr_accounting_coa_id
7710 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
7711 , p_adr_type_code => 'S'
7712 , p_component_type => l_component_type
7713 , p_component_code => l_component_code
7714 , p_component_type_code => l_component_type_code
7715 , p_component_appl_id => l_component_appl_id
7716 , p_amb_context_code => l_amb_context_code
7717 , p_side => 'NA'
7718 );
7719
7720
7721 l_segment := AcctDerRule_1(
7722 p_application_id => p_application_id
7723 , p_ae_header_id => l_ae_header_id
7724 , x_transaction_coa_id => l_adr_transaction_coa_id
7725 , x_accounting_coa_id => l_adr_accounting_coa_id
7726 , x_flexfield_segment_code => l_adr_flexfield_segment_code
7727 , x_flex_value_set_id => l_adr_flex_value_set_id
7728 , x_value_type_code => l_adr_value_type_code
7729 , x_value_combination_id => l_adr_value_combination_id
7730 , x_value_segment_code => l_adr_value_segment_code
7731 , p_side => 'NA'
7732 , p_override_seg_flag => 'Y'
7733 );
7734
7735 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
7736
7737 xla_ae_lines_pkg.set_segment(
7738 p_to_segment_code => 'GL_ACCOUNT'
7739 , p_segment_value => l_segment
7740 , p_from_segment_code => l_adr_value_segment_code
7741 , p_from_combination_id => l_adr_value_combination_id
7742 , p_value_type_code => l_adr_value_type_code
7743 , p_transaction_coa_id => l_adr_transaction_coa_id
7744 , p_accounting_coa_id => l_adr_accounting_coa_id
7745 , p_flexfield_segment_code => l_adr_flexfield_segment_code
7746 , p_flex_value_set_id => l_adr_flex_value_set_id
7747 , p_adr_code => 'FV_310701'
7748 , p_adr_type_code => 'S'
7749 , p_component_type => l_component_type
7750 , p_component_code => l_component_code
7751 , p_component_type_code => l_component_type_code
7752 , p_component_appl_id => l_component_appl_id
7753 , p_amb_context_code => l_amb_context_code
7754 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
7755 , p_event_class_code => 'DELIVER_EXPENSE'
7756 , p_side => 'NA'
7757 );
7758
7759 END IF;
7760
7761 --
7762 --
7763 END IF;
7764
7765 --
7766 -- Update the line information that should be overwritten
7767 --
7768 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
7769 p_header_num => 1);
7770 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
7771
7772 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
7773
7774 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
7775 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
7776 END IF;
7777
7778 --
7779 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
7780 --
7781 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
7782 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
7783 ELSE
7784 ---------------------------------------------------------------------------------------------------
7785 -- 4262811a Switch Sign
7786 ---------------------------------------------------------------------------------------------------
7787 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
7788 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7789 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7790 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7791 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7792 -- 5132302
7793 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
7794 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7795
7796 END IF;
7797
7798 -- 4955764
7799 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7800 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
7801
7802
7803 XLA_AE_LINES_PKG.ValidateCurrentLine;
7804 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7805
7806 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7807 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
7808 ,p_balance_type_code => l_balance_type_code);
7809
7810 END IF;
7811
7812 -----------------------------------------------------------------------------------------
7813 -- 4262811 Multiperiod Accounting
7814 -----------------------------------------------------------------------------------------
7815 -- No MPA option is assigned.
7816
7817
7818 END IF;
7819 END IF;
7820 --
7821
7822 --
7823 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7824 trace
7825 (p_msg => 'END of AcctLineType_20'
7826 ,p_level => C_LEVEL_PROCEDURE
7827 ,p_module => l_log_module);
7828 END IF;
7829 --
7830 EXCEPTION
7831 WHEN xla_exceptions_pkg.application_exception THEN
7832 RAISE;
7833 WHEN OTHERS THEN
7834 xla_exceptions_pkg.raise_message
7835 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_20');
7836 END AcctLineType_20;
7837 --
7838
7839 ---------------------------------------
7840 --
7841 -- PRIVATE FUNCTION
7842 -- AcctLineType_21
7843 --
7844 ---------------------------------------
7845 PROCEDURE AcctLineType_21 (
7846 p_application_id IN NUMBER
7847 ,p_event_id IN NUMBER
7848 ,p_calculate_acctd_flag IN VARCHAR2
7849 ,p_calculate_g_l_flag IN VARCHAR2
7850 ,p_actual_flag IN OUT VARCHAR2
7851 ,p_balance_type_code OUT VARCHAR2
7852 ,p_gain_or_loss_ref OUT VARCHAR2
7853
7854 --Federal Fund Category
7855 , p_source_2 IN VARCHAR2
7856 --PO Budget Account
7857 , p_source_3 IN NUMBER
7858 --Applied to Application ID
7859 , p_source_7 IN NUMBER
7860 --Applied to Distribution Link Type
7861 , p_source_8 IN VARCHAR2
7862 --Applied to Entity Code
7863 , p_source_9 IN VARCHAR2
7864 --Applied To Purchase Document Identifier
7865 , p_source_11 IN NUMBER
7866 --DISTRIBUTION_IDENTIFIER
7867 , p_source_12 IN NUMBER
7868 --Distribution Type
7869 , p_source_13 IN VARCHAR2
7870 , p_source_13_meaning IN VARCHAR2
7871 --Encumbrance Reversal Amount Entered
7872 , p_source_14 IN NUMBER
7873 --Entered Currency Code
7874 , p_source_15 IN VARCHAR2
7875 --Transaction Encumbrance Reversal Amount
7876 , p_source_16 IN NUMBER
7877 --Costing Encumbrance Upgrade Option
7878 , p_source_17 IN VARCHAR2
7879 --Currency Conversion Date
7880 , p_source_19 IN DATE
7881 --Currency Conversion Rate
7882 , p_source_20 IN NUMBER
7883 --Currency Conversion Type
7884 , p_source_21 IN VARCHAR2
7885 --Purchasing Encumbrance Type Identifier
7886 , p_source_22 IN NUMBER
7887 --TXN_PO_DISTRIBUTION_ID
7888 , p_source_23 IN NUMBER
7889 --Entered Amount
7890 , p_source_25 IN NUMBER
7891 --Accounted Amount
7892 , p_source_26 IN NUMBER
7893 )
7894 IS
7895
7896 l_component_type VARCHAR2(80);
7897 l_component_code VARCHAR2(30);
7898 l_component_type_code VARCHAR2(1);
7899 l_component_appl_id INTEGER;
7900 l_amb_context_code VARCHAR2(30);
7901 l_entity_code VARCHAR2(30);
7902 l_event_class_code VARCHAR2(30);
7903 l_ae_header_id NUMBER;
7904 l_event_type_code VARCHAR2(30);
7905 l_line_definition_code VARCHAR2(30);
7906 l_line_definition_owner_code VARCHAR2(1);
7907 --
7908 -- adr variables
7909 l_segment VARCHAR2(30);
7910 l_ccid NUMBER;
7911 l_adr_transaction_coa_id NUMBER;
7912 l_adr_accounting_coa_id NUMBER;
7913 l_adr_flexfield_segment_code VARCHAR2(30);
7914 l_adr_flex_value_set_id NUMBER;
7915 l_adr_value_type_code VARCHAR2(30);
7916 l_adr_value_combination_id NUMBER;
7917 l_adr_value_segment_code VARCHAR2(30);
7918
7919 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
7920 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
7921 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
7922 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
7923
7924 -- 4262811 Variables ------------------------------------------------------------------------------------------
7925 l_entered_amt_idx NUMBER;
7926 l_accted_amt_idx NUMBER;
7927 l_acc_rev_flag VARCHAR2(1);
7928 l_accrual_line_num NUMBER;
7929 l_tmp_amt NUMBER;
7930 l_acc_rev_natural_side_code VARCHAR2(1);
7931
7932 l_num_entries NUMBER;
7933 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
7934 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
7935 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
7936 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
7937 l_recog_line_1 NUMBER;
7938 l_recog_line_2 NUMBER;
7939
7940 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
7941 l_bflow_applied_to_amt NUMBER; -- 5132302
7942 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
7943
7944 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
7945
7946 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
7947 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
7948
7949 ---------------------------------------------------------------------------------------------------------------
7950
7951
7952 --
7953 -- bulk performance
7954 --
7955 l_balance_type_code VARCHAR2(1);
7956 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
7957 l_log_module VARCHAR2(240);
7958
7959 --
7960 -- Upgrade strategy
7961 --
7962 l_actual_upg_option VARCHAR2(1);
7963 l_enc_upg_option VARCHAR2(1);
7964
7965 --
7966 BEGIN
7967 --
7968 IF g_log_enabled THEN
7969 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_21';
7970 END IF;
7971 --
7972 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7973
7974 trace
7975 (p_msg => 'BEGIN of AcctLineType_21'
7976 ,p_level => C_LEVEL_PROCEDURE
7977 ,p_module => l_log_module);
7978
7979 END IF;
7980 --
7981 l_component_type := 'AMB_JLT';
7982 l_component_code := 'FV_RECLASSIFY_APPROP_DR_DTI';
7983 l_component_type_code := 'S';
7984 l_component_appl_id := 707;
7985 l_amb_context_code := 'DEFAULT';
7986 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
7987 l_event_class_code := 'PURCHASE_ORDER';
7988 l_event_type_code := 'PURCHASE_ORDER_ALL';
7989 l_line_definition_owner_code := 'S';
7990 l_line_definition_code := 'FV_PO_DEL_INV';
7991 --
7992 l_balance_type_code := 'A';
7993 l_segment := NULL;
7994 l_ccid := NULL;
7995 l_adr_transaction_coa_id := NULL;
7996 l_adr_accounting_coa_id := NULL;
7997 l_adr_flexfield_segment_code := NULL;
7998 l_adr_flex_value_set_id := NULL;
7999 l_adr_value_type_code := NULL;
8000 l_adr_value_combination_id := NULL;
8001 l_adr_value_segment_code := NULL;
8002
8003 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
8004 l_bflow_class_code := 'FV_UNEXP_APPR'; -- 4219869 Business Flow
8005 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
8006 l_budgetary_control_flag := 'Y';
8007
8008 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8009 l_bflow_applied_to_amt := NULL; -- 5132302
8010 l_entered_amt_idx := NULL; -- 4262811
8011 l_accted_amt_idx := NULL; -- 4262811
8012 l_acc_rev_flag := NULL; -- 4262811
8013 l_accrual_line_num := NULL; -- 4262811
8014 l_tmp_amt := NULL; -- 4262811
8015 --
8016
8017 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
8018 l_balance_type_code <> 'B' THEN
8019 IF NVL(
8020 xla_ae_sources_pkg.GetSystemSourceChar(
8021 p_source_code => 'XLA_EVENT_TYPE_CODE'
8022 , p_source_type_code => 'Y'
8023 , p_source_application_id => 602
8024 ),'
8025 ') = 'PO_DEL_INV' AND
8026 (NVL(p_source_2,'
8027 ') = 'A' OR
8028 NVL(p_source_2,'
8029 ') = 'B' OR
8030 NVL(p_source_2,'
8031 ') = 'C')
8032 THEN
8033
8034 --
8035 XLA_AE_LINES_PKG.SetNewLine;
8036
8037 p_balance_type_code := l_balance_type_code;
8038 -- set the flag so later we will know whether the gain loss line needs to be created
8039
8040 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
8041 p_actual_flag :='A';
8042 END IF;
8043
8044 --
8045 -- bulk performance
8046 --
8047 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
8048 p_header_num => 0); -- 4262811
8049 --
8050 -- set accounting line options
8051 --
8052 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
8053 p_natural_side_code => 'D'
8054 , p_gain_or_loss_flag => 'N'
8055 , p_gl_transfer_mode_code => 'S'
8056 , p_acct_entry_type_code => 'A'
8057 , p_switch_side_flag => 'N'
8058 , p_merge_duplicate_code => 'N'
8059 );
8060 --
8061 l_acc_rev_natural_side_code := 'C'; -- 4262811
8062 --
8063 --
8064 -- set accounting line type info
8065 --
8066 xla_ae_lines_pkg.SetAcctLineType
8067 (p_component_type => l_component_type
8068 ,p_event_type_code => l_event_type_code
8069 ,p_line_definition_owner_code => l_line_definition_owner_code
8070 ,p_line_definition_code => l_line_definition_code
8071 ,p_accounting_line_code => l_component_code
8072 ,p_accounting_line_type_code => l_component_type_code
8073 ,p_accounting_line_appl_id => l_component_appl_id
8074 ,p_amb_context_code => l_amb_context_code
8075 ,p_entity_code => l_entity_code
8076 ,p_event_class_code => l_event_class_code);
8077 --
8078 -- set accounting class
8079 --
8080 xla_ae_lines_pkg.SetAcctClass(
8081 p_accounting_class_code => 'FEDERAL_INV'
8082 , p_ae_header_id => l_ae_header_id
8083 );
8084
8085 --
8086 -- set rounding class
8087 --
8088 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
8089 'FEDERAL_INV';
8090
8091 --
8092 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
8093 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
8094 --
8095 -- bulk performance
8096 --
8097 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
8098
8099 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
8100 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
8101
8102 -- 4955764
8103 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8104 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
8105
8106 -- 4458381 Public Sector Enh
8107
8108 --
8109 -- set accounting attributes for the line type
8110 --
8111 l_entered_amt_idx := 17;
8112 l_accted_amt_idx := 22;
8113 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8114 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
8115 l_rec_acct_attrs.array_num_value(1) := p_source_7;
8116 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
8117 l_rec_acct_attrs.array_char_value(2) := p_source_8;
8118 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
8119 l_rec_acct_attrs.array_char_value(3) := p_source_9;
8120 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
8121 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
8122 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
8123 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
8124 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
8125 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
8126 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
8127 l_rec_acct_attrs.array_char_value(7) := p_source_13;
8128 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
8129 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
8130 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
8131 l_rec_acct_attrs.array_num_value(9) := p_source_14;
8132 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
8133 l_rec_acct_attrs.array_char_value(10) := p_source_15;
8134 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
8135 l_rec_acct_attrs.array_num_value(11) := p_source_16;
8136 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
8137 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
8138 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
8139 l_rec_acct_attrs.array_num_value(13) := p_source_14;
8140 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
8141 l_rec_acct_attrs.array_char_value(14) := p_source_15;
8142 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
8143 l_rec_acct_attrs.array_num_value(15) := p_source_16;
8144 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
8145 l_rec_acct_attrs.array_char_value(16) := p_source_17;
8146 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
8147 l_rec_acct_attrs.array_num_value(17) := p_source_25;
8148 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
8149 l_rec_acct_attrs.array_char_value(18) := p_source_15;
8150 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
8151 l_rec_acct_attrs.array_date_value(19) := p_source_19;
8152 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
8153 l_rec_acct_attrs.array_num_value(20) := p_source_20;
8154 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
8155 l_rec_acct_attrs.array_char_value(21) := p_source_21;
8156 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
8157 l_rec_acct_attrs.array_num_value(22) := p_source_26;
8158 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
8159 l_rec_acct_attrs.array_num_value(23) := p_source_22;
8160 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
8161 l_rec_acct_attrs.array_num_value(24) := p_source_22;
8162
8163 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
8164 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
8165
8166 ---------------------------------------------------------------------------------------------------------------
8167 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
8168 ---------------------------------------------------------------------------------------------------------------
8169 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
8170
8171 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8172 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8173
8174 IF xla_accounting_cache_pkg.GetValueChar
8175 (p_source_code => 'LEDGER_CATEGORY_CODE'
8176 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
8177 AND l_bflow_method_code = 'PRIOR_ENTRY'
8178 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
8179 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
8180 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
8181 )
8182 THEN
8183 xla_ae_lines_pkg.BflowUpgEntry
8184 (p_business_method_code => l_bflow_method_code
8185 ,p_business_class_code => l_bflow_class_code
8186 ,p_balance_type => l_balance_type_code);
8187 ELSE
8188 NULL;
8189 -- No business flow processing for business flow method of NONE.
8190 END IF;
8191
8192 --
8193 -- call analytical criteria
8194 --
8195
8196 --
8197 -- call description
8198 --
8199 -- No description or it is inherited.
8200 --
8201 -- call ADRs
8202 -- Bug 4922099
8203 --
8204 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8205 (NVL(l_actual_upg_option, 'N') = 'O') OR
8206 (NVL(l_enc_upg_option, 'N') = 'O')
8207 )
8208 THEN
8209 NULL;
8210 --
8211 --
8212
8213 l_ccid := AcctDerRule_11(
8214 p_application_id => p_application_id
8215 , p_ae_header_id => l_ae_header_id
8216 , p_source_3 => p_source_3
8217 , x_transaction_coa_id => l_adr_transaction_coa_id
8218 , x_accounting_coa_id => l_adr_accounting_coa_id
8219 , x_value_type_code => l_adr_value_type_code
8220 , p_side => 'NA'
8221 );
8222
8223 xla_ae_lines_pkg.set_ccid(
8224 p_code_combination_id => l_ccid
8225 , p_value_type_code => l_adr_value_type_code
8226 , p_transaction_coa_id => l_adr_transaction_coa_id
8227 , p_accounting_coa_id => l_adr_accounting_coa_id
8228 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
8229 , p_adr_type_code => 'S'
8230 , p_component_type => l_component_type
8231 , p_component_code => l_component_code
8232 , p_component_type_code => l_component_type_code
8233 , p_component_appl_id => l_component_appl_id
8234 , p_amb_context_code => l_amb_context_code
8235 , p_side => 'NA'
8236 );
8237
8238
8239 l_segment := AcctDerRule_1(
8240 p_application_id => p_application_id
8241 , p_ae_header_id => l_ae_header_id
8242 , x_transaction_coa_id => l_adr_transaction_coa_id
8243 , x_accounting_coa_id => l_adr_accounting_coa_id
8244 , x_flexfield_segment_code => l_adr_flexfield_segment_code
8245 , x_flex_value_set_id => l_adr_flex_value_set_id
8246 , x_value_type_code => l_adr_value_type_code
8247 , x_value_combination_id => l_adr_value_combination_id
8248 , x_value_segment_code => l_adr_value_segment_code
8249 , p_side => 'NA'
8250 , p_override_seg_flag => 'Y'
8251 );
8252
8253 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
8254
8255 xla_ae_lines_pkg.set_segment(
8256 p_to_segment_code => 'GL_ACCOUNT'
8257 , p_segment_value => l_segment
8258 , p_from_segment_code => l_adr_value_segment_code
8259 , p_from_combination_id => l_adr_value_combination_id
8260 , p_value_type_code => l_adr_value_type_code
8261 , p_transaction_coa_id => l_adr_transaction_coa_id
8262 , p_accounting_coa_id => l_adr_accounting_coa_id
8263 , p_flexfield_segment_code => l_adr_flexfield_segment_code
8264 , p_flex_value_set_id => l_adr_flex_value_set_id
8265 , p_adr_code => 'FV_310701'
8266 , p_adr_type_code => 'S'
8267 , p_component_type => l_component_type
8268 , p_component_code => l_component_code
8269 , p_component_type_code => l_component_type_code
8270 , p_component_appl_id => l_component_appl_id
8271 , p_amb_context_code => l_amb_context_code
8272 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
8273 , p_event_class_code => 'PURCHASE_ORDER'
8274 , p_side => 'NA'
8275 );
8276
8277 END IF;
8278
8279 --
8280 --
8281 END IF;
8282 --
8283 -- Bug 4922099
8284 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
8285 (NVL(l_enc_upg_option, 'N') = 'O')
8286 ) AND
8287 (l_bflow_method_code = 'PRIOR_ENTRY')
8288 )
8289 THEN
8290 IF
8291 --
8292 1 = 2
8293 --
8294 THEN
8295 xla_accounting_err_pkg.build_message
8296 (p_appli_s_name => 'XLA'
8297 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8298 ,p_token_1 => 'LINE_NUMBER'
8299 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
8300 ,p_token_2 => 'LINE_TYPE_NAME'
8301 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
8302 l_component_type
8303 ,l_component_code
8304 ,l_component_type_code
8305 ,l_component_appl_id
8306 ,l_amb_context_code
8307 ,l_entity_code
8308 ,l_event_class_code
8309 )
8310 ,p_token_3 => 'OWNER'
8311 ,p_value_3 => xla_lookups_pkg.get_meaning(
8312 p_lookup_type => 'XLA_OWNER_TYPE'
8313 ,p_lookup_code => l_component_type_code
8314 )
8315 ,p_token_4 => 'PRODUCT_NAME'
8316 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
8317 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
8318 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
8319 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
8320 ,p_ae_header_id => NULL
8321 );
8322
8323 IF (C_LEVEL_ERROR>= g_log_level) THEN
8324 trace
8325 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8326 ,p_level => C_LEVEL_ERROR
8327 ,p_module => l_log_module);
8328 END IF;
8329 END IF;
8330 END IF;
8331 --
8332 --
8333 ------------------------------------------------------------------------------------------------
8334 -- 4219869 Business Flow
8335 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
8336 -- Prior Entry. Currently, the following code is always generated.
8337 ------------------------------------------------------------------------------------------------
8338 XLA_AE_LINES_PKG.ValidateCurrentLine;
8339
8340 ------------------------------------------------------------------------------------
8341 -- 4219869 Business Flow
8342 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
8343 ------------------------------------------------------------------------------------
8344 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8345
8346 ----------------------------------------------------------------------------------
8347 -- 4219869 Business Flow
8348 -- Update journal entry status -- Need to generate this within IF <condition>
8349 ----------------------------------------------------------------------------------
8350 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8351 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
8352 ,p_balance_type_code => l_balance_type_code
8353 );
8354
8355 -------------------------------------------------------------------------------------------
8356 -- 4262811 - Generate the Accrual Reversal lines
8357 -------------------------------------------------------------------------------------------
8358 BEGIN
8359 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
8360 (g_array_event(p_event_id).array_value_num('header_index'));
8361 IF l_acc_rev_flag IS NULL THEN
8362 l_acc_rev_flag := 'N';
8363 END IF;
8364 EXCEPTION
8365 WHEN OTHERS THEN
8366 l_acc_rev_flag := 'N';
8367 END;
8368 --
8369 IF (l_acc_rev_flag = 'Y') THEN
8370
8371 -- 4645092 ------------------------------------------------------------------------------
8372 -- To allow MPA report to determine if it should generate report process
8373 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
8374 ------------------------------------------------------------------------------------------
8375
8376 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
8377 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
8378 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
8379 -- call ADRs
8380 -- Bug 4922099
8381 --
8382 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8383 (NVL(l_actual_upg_option, 'N') = 'O') OR
8384 (NVL(l_enc_upg_option, 'N') = 'O')
8385 )
8386 THEN
8387 NULL;
8388 --
8389 --
8390
8391 l_ccid := AcctDerRule_11(
8392 p_application_id => p_application_id
8393 , p_ae_header_id => l_ae_header_id
8394 , p_source_3 => p_source_3
8395 , x_transaction_coa_id => l_adr_transaction_coa_id
8396 , x_accounting_coa_id => l_adr_accounting_coa_id
8397 , x_value_type_code => l_adr_value_type_code
8398 , p_side => 'NA'
8399 );
8400
8401 xla_ae_lines_pkg.set_ccid(
8402 p_code_combination_id => l_ccid
8403 , p_value_type_code => l_adr_value_type_code
8404 , p_transaction_coa_id => l_adr_transaction_coa_id
8405 , p_accounting_coa_id => l_adr_accounting_coa_id
8406 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
8407 , p_adr_type_code => 'S'
8408 , p_component_type => l_component_type
8409 , p_component_code => l_component_code
8410 , p_component_type_code => l_component_type_code
8411 , p_component_appl_id => l_component_appl_id
8412 , p_amb_context_code => l_amb_context_code
8413 , p_side => 'NA'
8414 );
8415
8416
8417 l_segment := AcctDerRule_1(
8418 p_application_id => p_application_id
8419 , p_ae_header_id => l_ae_header_id
8420 , x_transaction_coa_id => l_adr_transaction_coa_id
8421 , x_accounting_coa_id => l_adr_accounting_coa_id
8422 , x_flexfield_segment_code => l_adr_flexfield_segment_code
8423 , x_flex_value_set_id => l_adr_flex_value_set_id
8424 , x_value_type_code => l_adr_value_type_code
8425 , x_value_combination_id => l_adr_value_combination_id
8426 , x_value_segment_code => l_adr_value_segment_code
8427 , p_side => 'NA'
8428 , p_override_seg_flag => 'Y'
8429 );
8430
8431 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
8432
8433 xla_ae_lines_pkg.set_segment(
8434 p_to_segment_code => 'GL_ACCOUNT'
8435 , p_segment_value => l_segment
8436 , p_from_segment_code => l_adr_value_segment_code
8437 , p_from_combination_id => l_adr_value_combination_id
8438 , p_value_type_code => l_adr_value_type_code
8439 , p_transaction_coa_id => l_adr_transaction_coa_id
8440 , p_accounting_coa_id => l_adr_accounting_coa_id
8441 , p_flexfield_segment_code => l_adr_flexfield_segment_code
8442 , p_flex_value_set_id => l_adr_flex_value_set_id
8443 , p_adr_code => 'FV_310701'
8444 , p_adr_type_code => 'S'
8445 , p_component_type => l_component_type
8446 , p_component_code => l_component_code
8447 , p_component_type_code => l_component_type_code
8448 , p_component_appl_id => l_component_appl_id
8449 , p_amb_context_code => l_amb_context_code
8450 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
8451 , p_event_class_code => 'PURCHASE_ORDER'
8452 , p_side => 'NA'
8453 );
8454
8455 END IF;
8456
8457 --
8458 --
8459 END IF;
8460
8461 --
8462 -- Update the line information that should be overwritten
8463 --
8464 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
8465 p_header_num => 1);
8466 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
8467
8468 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
8469
8470 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
8471 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
8472 END IF;
8473
8474 --
8475 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
8476 --
8477 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
8478 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
8479 ELSE
8480 ---------------------------------------------------------------------------------------------------
8481 -- 4262811a Switch Sign
8482 ---------------------------------------------------------------------------------------------------
8483 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
8484 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8485 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8486 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8487 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8488 -- 5132302
8489 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
8490 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8491
8492 END IF;
8493
8494 -- 4955764
8495 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8496 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
8497
8498
8499 XLA_AE_LINES_PKG.ValidateCurrentLine;
8500 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8501
8502 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8503 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
8504 ,p_balance_type_code => l_balance_type_code);
8505
8506 END IF;
8507
8508 -----------------------------------------------------------------------------------------
8509 -- 4262811 Multiperiod Accounting
8510 -----------------------------------------------------------------------------------------
8511 -- No MPA option is assigned.
8512
8513
8514 END IF;
8515 END IF;
8516 --
8517
8518 --
8519 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8520 trace
8521 (p_msg => 'END of AcctLineType_21'
8522 ,p_level => C_LEVEL_PROCEDURE
8523 ,p_module => l_log_module);
8524 END IF;
8525 --
8526 EXCEPTION
8527 WHEN xla_exceptions_pkg.application_exception THEN
8528 RAISE;
8529 WHEN OTHERS THEN
8530 xla_exceptions_pkg.raise_message
8531 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_21');
8532 END AcctLineType_21;
8533 --
8534
8535 ---------------------------------------
8536 --
8537 -- PRIVATE FUNCTION
8538 -- AcctLineType_22
8539 --
8540 ---------------------------------------
8541 PROCEDURE AcctLineType_22 (
8542 p_application_id IN NUMBER
8543 ,p_event_id IN NUMBER
8544 ,p_calculate_acctd_flag IN VARCHAR2
8545 ,p_calculate_g_l_flag IN VARCHAR2
8546 ,p_actual_flag IN OUT VARCHAR2
8547 ,p_balance_type_code OUT VARCHAR2
8548 ,p_gain_or_loss_ref OUT VARCHAR2
8549
8550 --Federal Fund Expired Status
8551 , p_source_1 IN VARCHAR2
8552 --Federal Fund Category
8553 , p_source_2 IN VARCHAR2
8554 --PO Budget Account
8555 , p_source_3 IN NUMBER
8556 --Receiving Accounting Line Type
8557 , p_source_6 IN VARCHAR2
8558 --Applied to Application ID
8559 , p_source_7 IN NUMBER
8560 --Applied to Distribution Link Type
8561 , p_source_8 IN VARCHAR2
8562 --Applied to Entity Code
8563 , p_source_9 IN VARCHAR2
8564 --PO_DISTRIBUTION_ID
8565 , p_source_10 IN NUMBER
8566 --Applied To Purchase Document Identifier
8567 , p_source_11 IN NUMBER
8568 --DISTRIBUTION_IDENTIFIER
8569 , p_source_12 IN NUMBER
8570 --Distribution Type
8571 , p_source_13 IN VARCHAR2
8572 , p_source_13_meaning IN VARCHAR2
8573 --Encumbrance Reversal Amount Entered
8574 , p_source_14 IN NUMBER
8575 --Entered Currency Code
8576 , p_source_15 IN VARCHAR2
8577 --Transaction Encumbrance Reversal Amount
8578 , p_source_16 IN NUMBER
8579 --Costing Encumbrance Upgrade Option
8580 , p_source_17 IN VARCHAR2
8581 --Currency Conversion Date
8582 , p_source_19 IN DATE
8583 --Currency Conversion Rate
8584 , p_source_20 IN NUMBER
8585 --Currency Conversion Type
8586 , p_source_21 IN VARCHAR2
8587 --Purchasing Encumbrance Type Identifier
8588 , p_source_22 IN NUMBER
8589 --Entered Amount
8590 , p_source_25 IN NUMBER
8591 --Accounted Amount
8592 , p_source_26 IN NUMBER
8593 )
8594 IS
8595
8596 l_component_type VARCHAR2(80);
8597 l_component_code VARCHAR2(30);
8598 l_component_type_code VARCHAR2(1);
8599 l_component_appl_id INTEGER;
8600 l_amb_context_code VARCHAR2(30);
8601 l_entity_code VARCHAR2(30);
8602 l_event_class_code VARCHAR2(30);
8603 l_ae_header_id NUMBER;
8604 l_event_type_code VARCHAR2(30);
8605 l_line_definition_code VARCHAR2(30);
8606 l_line_definition_owner_code VARCHAR2(1);
8607 --
8608 -- adr variables
8609 l_segment VARCHAR2(30);
8610 l_ccid NUMBER;
8611 l_adr_transaction_coa_id NUMBER;
8612 l_adr_accounting_coa_id NUMBER;
8613 l_adr_flexfield_segment_code VARCHAR2(30);
8614 l_adr_flex_value_set_id NUMBER;
8615 l_adr_value_type_code VARCHAR2(30);
8616 l_adr_value_combination_id NUMBER;
8617 l_adr_value_segment_code VARCHAR2(30);
8618
8619 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
8620 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
8621 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
8622 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
8623
8624 -- 4262811 Variables ------------------------------------------------------------------------------------------
8625 l_entered_amt_idx NUMBER;
8626 l_accted_amt_idx NUMBER;
8627 l_acc_rev_flag VARCHAR2(1);
8628 l_accrual_line_num NUMBER;
8629 l_tmp_amt NUMBER;
8630 l_acc_rev_natural_side_code VARCHAR2(1);
8631
8632 l_num_entries NUMBER;
8633 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
8634 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
8635 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
8636 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
8637 l_recog_line_1 NUMBER;
8638 l_recog_line_2 NUMBER;
8639
8640 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
8641 l_bflow_applied_to_amt NUMBER; -- 5132302
8642 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
8643
8644 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
8645
8646 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
8647 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
8648
8649 ---------------------------------------------------------------------------------------------------------------
8650
8651
8652 --
8653 -- bulk performance
8654 --
8655 l_balance_type_code VARCHAR2(1);
8656 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
8657 l_log_module VARCHAR2(240);
8658
8659 --
8660 -- Upgrade strategy
8661 --
8662 l_actual_upg_option VARCHAR2(1);
8663 l_enc_upg_option VARCHAR2(1);
8664
8665 --
8666 BEGIN
8667 --
8668 IF g_log_enabled THEN
8669 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_22';
8670 END IF;
8671 --
8672 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8673
8674 trace
8675 (p_msg => 'BEGIN of AcctLineType_22'
8676 ,p_level => C_LEVEL_PROCEDURE
8677 ,p_module => l_log_module);
8678
8679 END IF;
8680 --
8681 l_component_type := 'AMB_JLT';
8682 l_component_code := 'FV_RECORD_RECEIPT_DR';
8683 l_component_type_code := 'S';
8684 l_component_appl_id := 707;
8685 l_amb_context_code := 'DEFAULT';
8686 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
8687 l_event_class_code := 'DELIVER_EXPENSE';
8688 l_event_type_code := 'DELIVER_EXPENSE_ALL';
8689 l_line_definition_owner_code := 'S';
8690 l_line_definition_code := 'FV_DELIVER_EXPENSE';
8691 --
8692 l_balance_type_code := 'A';
8693 l_segment := NULL;
8694 l_ccid := NULL;
8695 l_adr_transaction_coa_id := NULL;
8696 l_adr_accounting_coa_id := NULL;
8697 l_adr_flexfield_segment_code := NULL;
8698 l_adr_flex_value_set_id := NULL;
8699 l_adr_value_type_code := NULL;
8700 l_adr_value_combination_id := NULL;
8701 l_adr_value_segment_code := NULL;
8702
8703 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
8704 l_bflow_class_code := 'FV_REC_DR'; -- 4219869 Business Flow
8705 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
8706 l_budgetary_control_flag := 'Y';
8707
8708 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8709 l_bflow_applied_to_amt := NULL; -- 5132302
8710 l_entered_amt_idx := NULL; -- 4262811
8711 l_accted_amt_idx := NULL; -- 4262811
8712 l_acc_rev_flag := NULL; -- 4262811
8713 l_accrual_line_num := NULL; -- 4262811
8714 l_tmp_amt := NULL; -- 4262811
8715 --
8716
8717 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
8718 l_balance_type_code <> 'B' THEN
8719 IF NVL(
8720 xla_ae_sources_pkg.GetSystemSourceChar(
8721 p_source_code => 'XLA_EVENT_TYPE_CODE'
8722 , p_source_type_code => 'Y'
8723 , p_source_application_id => 602
8724 ),'
8725 ') = 'DELIVER_EXPENSE' AND
8726 NVL(p_source_6,'
8727 ') = 'Charge'
8728 THEN
8729
8730 --
8731 XLA_AE_LINES_PKG.SetNewLine;
8732
8733 p_balance_type_code := l_balance_type_code;
8734 -- set the flag so later we will know whether the gain loss line needs to be created
8735
8736 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
8737 p_actual_flag :='A';
8738 END IF;
8739
8740 --
8741 -- bulk performance
8742 --
8743 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
8744 p_header_num => 0); -- 4262811
8745 --
8746 -- set accounting line options
8747 --
8748 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
8749 p_natural_side_code => 'D'
8750 , p_gain_or_loss_flag => 'N'
8751 , p_gl_transfer_mode_code => 'S'
8752 , p_acct_entry_type_code => 'A'
8753 , p_switch_side_flag => 'N'
8754 , p_merge_duplicate_code => 'N'
8755 );
8756 --
8757 l_acc_rev_natural_side_code := 'C'; -- 4262811
8758 --
8759 --
8760 -- set accounting line type info
8761 --
8762 xla_ae_lines_pkg.SetAcctLineType
8763 (p_component_type => l_component_type
8764 ,p_event_type_code => l_event_type_code
8765 ,p_line_definition_owner_code => l_line_definition_owner_code
8766 ,p_line_definition_code => l_line_definition_code
8767 ,p_accounting_line_code => l_component_code
8768 ,p_accounting_line_type_code => l_component_type_code
8769 ,p_accounting_line_appl_id => l_component_appl_id
8770 ,p_amb_context_code => l_amb_context_code
8771 ,p_entity_code => l_entity_code
8772 ,p_event_class_code => l_event_class_code);
8773 --
8774 -- set accounting class
8775 --
8776 xla_ae_lines_pkg.SetAcctClass(
8777 p_accounting_class_code => 'FEDERAL_EXP'
8778 , p_ae_header_id => l_ae_header_id
8779 );
8780
8781 --
8782 -- set rounding class
8783 --
8784 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
8785 'FEDERAL_EXP';
8786
8787 --
8788 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
8789 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
8790 --
8791 -- bulk performance
8792 --
8793 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
8794
8795 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
8796 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
8797
8798 -- 4955764
8799 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8800 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
8801
8802 -- 4458381 Public Sector Enh
8803
8804 --
8805 -- set accounting attributes for the line type
8806 --
8807 l_entered_amt_idx := 17;
8808 l_accted_amt_idx := 22;
8809 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8810 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
8811 l_rec_acct_attrs.array_num_value(1) := p_source_7;
8812 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
8813 l_rec_acct_attrs.array_char_value(2) := p_source_8;
8814 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
8815 l_rec_acct_attrs.array_char_value(3) := p_source_9;
8816 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
8817 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
8818 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
8819 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
8820 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
8821 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
8822 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
8823 l_rec_acct_attrs.array_char_value(7) := p_source_13;
8824 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
8825 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
8826 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
8827 l_rec_acct_attrs.array_num_value(9) := p_source_14;
8828 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
8829 l_rec_acct_attrs.array_char_value(10) := p_source_15;
8830 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
8831 l_rec_acct_attrs.array_num_value(11) := p_source_16;
8832 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
8833 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
8834 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
8835 l_rec_acct_attrs.array_num_value(13) := p_source_14;
8836 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
8837 l_rec_acct_attrs.array_char_value(14) := p_source_15;
8838 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
8839 l_rec_acct_attrs.array_num_value(15) := p_source_16;
8840 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
8841 l_rec_acct_attrs.array_char_value(16) := p_source_17;
8842 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
8843 l_rec_acct_attrs.array_num_value(17) := p_source_25;
8844 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
8845 l_rec_acct_attrs.array_char_value(18) := p_source_15;
8846 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
8847 l_rec_acct_attrs.array_date_value(19) := p_source_19;
8848 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
8849 l_rec_acct_attrs.array_num_value(20) := p_source_20;
8850 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
8851 l_rec_acct_attrs.array_char_value(21) := p_source_21;
8852 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
8853 l_rec_acct_attrs.array_num_value(22) := p_source_26;
8854 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
8855 l_rec_acct_attrs.array_num_value(23) := p_source_22;
8856 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
8857 l_rec_acct_attrs.array_num_value(24) := p_source_22;
8858
8859 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
8860 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
8861
8862 ---------------------------------------------------------------------------------------------------------------
8863 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
8864 ---------------------------------------------------------------------------------------------------------------
8865 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
8866
8867 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8868 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8869
8870 IF xla_accounting_cache_pkg.GetValueChar
8871 (p_source_code => 'LEDGER_CATEGORY_CODE'
8872 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
8873 AND l_bflow_method_code = 'PRIOR_ENTRY'
8874 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
8875 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
8876 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
8877 )
8878 THEN
8879 xla_ae_lines_pkg.BflowUpgEntry
8880 (p_business_method_code => l_bflow_method_code
8881 ,p_business_class_code => l_bflow_class_code
8882 ,p_balance_type => l_balance_type_code);
8883 ELSE
8884 NULL;
8885 -- No business flow processing for business flow method of NONE.
8886 END IF;
8887
8888 --
8889 -- call analytical criteria
8890 --
8891
8892 --
8893 -- call description
8894 --
8895 -- No description or it is inherited.
8896 --
8897 -- call ADRs
8898 -- Bug 4922099
8899 --
8900 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8901 (NVL(l_actual_upg_option, 'N') = 'O') OR
8902 (NVL(l_enc_upg_option, 'N') = 'O')
8903 )
8904 THEN
8905 NULL;
8906 --
8907 --
8908
8909 l_ccid := AcctDerRule_11(
8910 p_application_id => p_application_id
8911 , p_ae_header_id => l_ae_header_id
8912 , p_source_3 => p_source_3
8913 , x_transaction_coa_id => l_adr_transaction_coa_id
8914 , x_accounting_coa_id => l_adr_accounting_coa_id
8915 , x_value_type_code => l_adr_value_type_code
8916 , p_side => 'NA'
8917 );
8918
8919 xla_ae_lines_pkg.set_ccid(
8920 p_code_combination_id => l_ccid
8921 , p_value_type_code => l_adr_value_type_code
8922 , p_transaction_coa_id => l_adr_transaction_coa_id
8923 , p_accounting_coa_id => l_adr_accounting_coa_id
8924 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
8925 , p_adr_type_code => 'S'
8926 , p_component_type => l_component_type
8927 , p_component_code => l_component_code
8928 , p_component_type_code => l_component_type_code
8929 , p_component_appl_id => l_component_appl_id
8930 , p_amb_context_code => l_amb_context_code
8931 , p_side => 'NA'
8932 );
8933
8934
8935 l_segment := AcctDerRule_4(
8936 p_application_id => p_application_id
8937 , p_ae_header_id => l_ae_header_id
8938 , p_source_1 => p_source_1
8939 , p_source_2 => p_source_2
8940 , x_transaction_coa_id => l_adr_transaction_coa_id
8941 , x_accounting_coa_id => l_adr_accounting_coa_id
8942 , x_flexfield_segment_code => l_adr_flexfield_segment_code
8943 , x_flex_value_set_id => l_adr_flex_value_set_id
8944 , x_value_type_code => l_adr_value_type_code
8945 , x_value_combination_id => l_adr_value_combination_id
8946 , x_value_segment_code => l_adr_value_segment_code
8947 , p_side => 'NA'
8948 , p_override_seg_flag => 'Y'
8949 );
8950
8951 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
8952
8953 xla_ae_lines_pkg.set_segment(
8954 p_to_segment_code => 'GL_ACCOUNT'
8955 , p_segment_value => l_segment
8956 , p_from_segment_code => l_adr_value_segment_code
8957 , p_from_combination_id => l_adr_value_combination_id
8958 , p_value_type_code => l_adr_value_type_code
8959 , p_transaction_coa_id => l_adr_transaction_coa_id
8960 , p_accounting_coa_id => l_adr_accounting_coa_id
8961 , p_flexfield_segment_code => l_adr_flexfield_segment_code
8962 , p_flex_value_set_id => l_adr_flex_value_set_id
8963 , p_adr_code => 'FV_46X002'
8964 , p_adr_type_code => 'S'
8965 , p_component_type => l_component_type
8966 , p_component_code => l_component_code
8967 , p_component_type_code => l_component_type_code
8968 , p_component_appl_id => l_component_appl_id
8969 , p_amb_context_code => l_amb_context_code
8970 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
8971 , p_event_class_code => 'DELIVER_EXPENSE'
8972 , p_side => 'NA'
8973 );
8974
8975 END IF;
8976
8977 --
8978 --
8979 END IF;
8980 --
8981 -- Bug 4922099
8982 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
8983 (NVL(l_enc_upg_option, 'N') = 'O')
8984 ) AND
8985 (l_bflow_method_code = 'PRIOR_ENTRY')
8986 )
8987 THEN
8988 IF
8989 --
8990 1 = 2
8991 --
8992 THEN
8993 xla_accounting_err_pkg.build_message
8994 (p_appli_s_name => 'XLA'
8995 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8996 ,p_token_1 => 'LINE_NUMBER'
8997 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
8998 ,p_token_2 => 'LINE_TYPE_NAME'
8999 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
9000 l_component_type
9001 ,l_component_code
9002 ,l_component_type_code
9003 ,l_component_appl_id
9004 ,l_amb_context_code
9005 ,l_entity_code
9006 ,l_event_class_code
9007 )
9008 ,p_token_3 => 'OWNER'
9009 ,p_value_3 => xla_lookups_pkg.get_meaning(
9010 p_lookup_type => 'XLA_OWNER_TYPE'
9011 ,p_lookup_code => l_component_type_code
9012 )
9013 ,p_token_4 => 'PRODUCT_NAME'
9014 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
9015 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
9016 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
9017 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
9018 ,p_ae_header_id => NULL
9019 );
9020
9021 IF (C_LEVEL_ERROR>= g_log_level) THEN
9022 trace
9023 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9024 ,p_level => C_LEVEL_ERROR
9025 ,p_module => l_log_module);
9026 END IF;
9027 END IF;
9028 END IF;
9029 --
9030 --
9031 ------------------------------------------------------------------------------------------------
9032 -- 4219869 Business Flow
9033 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
9034 -- Prior Entry. Currently, the following code is always generated.
9035 ------------------------------------------------------------------------------------------------
9036 XLA_AE_LINES_PKG.ValidateCurrentLine;
9037
9038 ------------------------------------------------------------------------------------
9039 -- 4219869 Business Flow
9040 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
9041 ------------------------------------------------------------------------------------
9042 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9043
9044 ----------------------------------------------------------------------------------
9045 -- 4219869 Business Flow
9046 -- Update journal entry status -- Need to generate this within IF <condition>
9047 ----------------------------------------------------------------------------------
9048 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9049 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
9050 ,p_balance_type_code => l_balance_type_code
9051 );
9052
9053 -------------------------------------------------------------------------------------------
9054 -- 4262811 - Generate the Accrual Reversal lines
9055 -------------------------------------------------------------------------------------------
9056 BEGIN
9057 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
9058 (g_array_event(p_event_id).array_value_num('header_index'));
9059 IF l_acc_rev_flag IS NULL THEN
9060 l_acc_rev_flag := 'N';
9061 END IF;
9062 EXCEPTION
9063 WHEN OTHERS THEN
9064 l_acc_rev_flag := 'N';
9065 END;
9066 --
9067 IF (l_acc_rev_flag = 'Y') THEN
9068
9069 -- 4645092 ------------------------------------------------------------------------------
9070 -- To allow MPA report to determine if it should generate report process
9071 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
9072 ------------------------------------------------------------------------------------------
9073
9074 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
9075 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
9076 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
9077 -- call ADRs
9078 -- Bug 4922099
9079 --
9080 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9081 (NVL(l_actual_upg_option, 'N') = 'O') OR
9082 (NVL(l_enc_upg_option, 'N') = 'O')
9083 )
9084 THEN
9085 NULL;
9086 --
9087 --
9088
9089 l_ccid := AcctDerRule_11(
9090 p_application_id => p_application_id
9091 , p_ae_header_id => l_ae_header_id
9092 , p_source_3 => p_source_3
9093 , x_transaction_coa_id => l_adr_transaction_coa_id
9094 , x_accounting_coa_id => l_adr_accounting_coa_id
9095 , x_value_type_code => l_adr_value_type_code
9096 , p_side => 'NA'
9097 );
9098
9099 xla_ae_lines_pkg.set_ccid(
9100 p_code_combination_id => l_ccid
9101 , p_value_type_code => l_adr_value_type_code
9102 , p_transaction_coa_id => l_adr_transaction_coa_id
9103 , p_accounting_coa_id => l_adr_accounting_coa_id
9104 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
9105 , p_adr_type_code => 'S'
9106 , p_component_type => l_component_type
9107 , p_component_code => l_component_code
9108 , p_component_type_code => l_component_type_code
9109 , p_component_appl_id => l_component_appl_id
9110 , p_amb_context_code => l_amb_context_code
9111 , p_side => 'NA'
9112 );
9113
9114
9115 l_segment := AcctDerRule_4(
9116 p_application_id => p_application_id
9117 , p_ae_header_id => l_ae_header_id
9118 , p_source_1 => p_source_1
9119 , p_source_2 => p_source_2
9120 , x_transaction_coa_id => l_adr_transaction_coa_id
9121 , x_accounting_coa_id => l_adr_accounting_coa_id
9122 , x_flexfield_segment_code => l_adr_flexfield_segment_code
9123 , x_flex_value_set_id => l_adr_flex_value_set_id
9124 , x_value_type_code => l_adr_value_type_code
9125 , x_value_combination_id => l_adr_value_combination_id
9126 , x_value_segment_code => l_adr_value_segment_code
9127 , p_side => 'NA'
9128 , p_override_seg_flag => 'Y'
9129 );
9130
9131 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
9132
9133 xla_ae_lines_pkg.set_segment(
9134 p_to_segment_code => 'GL_ACCOUNT'
9135 , p_segment_value => l_segment
9136 , p_from_segment_code => l_adr_value_segment_code
9137 , p_from_combination_id => l_adr_value_combination_id
9138 , p_value_type_code => l_adr_value_type_code
9139 , p_transaction_coa_id => l_adr_transaction_coa_id
9140 , p_accounting_coa_id => l_adr_accounting_coa_id
9141 , p_flexfield_segment_code => l_adr_flexfield_segment_code
9142 , p_flex_value_set_id => l_adr_flex_value_set_id
9143 , p_adr_code => 'FV_46X002'
9144 , p_adr_type_code => 'S'
9145 , p_component_type => l_component_type
9146 , p_component_code => l_component_code
9147 , p_component_type_code => l_component_type_code
9148 , p_component_appl_id => l_component_appl_id
9149 , p_amb_context_code => l_amb_context_code
9150 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
9151 , p_event_class_code => 'DELIVER_EXPENSE'
9152 , p_side => 'NA'
9153 );
9154
9155 END IF;
9156
9157 --
9158 --
9159 END IF;
9160
9161 --
9162 -- Update the line information that should be overwritten
9163 --
9164 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
9165 p_header_num => 1);
9166 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
9167
9168 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
9169
9170 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
9171 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
9172 END IF;
9173
9174 --
9175 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
9176 --
9177 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
9178 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
9179 ELSE
9180 ---------------------------------------------------------------------------------------------------
9181 -- 4262811a Switch Sign
9182 ---------------------------------------------------------------------------------------------------
9183 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
9184 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9185 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9186 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9187 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9188 -- 5132302
9189 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
9190 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9191
9192 END IF;
9193
9194 -- 4955764
9195 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9196 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
9197
9198
9199 XLA_AE_LINES_PKG.ValidateCurrentLine;
9200 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9201
9202 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9203 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
9204 ,p_balance_type_code => l_balance_type_code);
9205
9206 END IF;
9207
9208 -----------------------------------------------------------------------------------------
9209 -- 4262811 Multiperiod Accounting
9210 -----------------------------------------------------------------------------------------
9211 -- No MPA option is assigned.
9212
9213
9214 END IF;
9215 END IF;
9216 --
9217
9218 --
9219 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9220 trace
9221 (p_msg => 'END of AcctLineType_22'
9222 ,p_level => C_LEVEL_PROCEDURE
9223 ,p_module => l_log_module);
9224 END IF;
9225 --
9226 EXCEPTION
9227 WHEN xla_exceptions_pkg.application_exception THEN
9228 RAISE;
9229 WHEN OTHERS THEN
9230 xla_exceptions_pkg.raise_message
9231 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_22');
9232 END AcctLineType_22;
9233 --
9234
9235 ---------------------------------------
9236 --
9237 -- PRIVATE FUNCTION
9238 -- AcctLineType_23
9239 --
9240 ---------------------------------------
9241 PROCEDURE AcctLineType_23 (
9242 p_application_id IN NUMBER
9243 ,p_event_id IN NUMBER
9244 ,p_calculate_acctd_flag IN VARCHAR2
9245 ,p_calculate_g_l_flag IN VARCHAR2
9246 ,p_actual_flag IN OUT VARCHAR2
9247 ,p_balance_type_code OUT VARCHAR2
9248 ,p_gain_or_loss_ref OUT VARCHAR2
9249
9250 --Federal Fund Expired Status
9251 , p_source_1 IN VARCHAR2
9252 --Federal Fund Category
9253 , p_source_2 IN VARCHAR2
9254 --PO Budget Account
9255 , p_source_3 IN NUMBER
9256 --Applied to Application ID
9257 , p_source_7 IN NUMBER
9258 --Applied to Distribution Link Type
9259 , p_source_8 IN VARCHAR2
9260 --Applied to Entity Code
9261 , p_source_9 IN VARCHAR2
9262 --Applied To Purchase Document Identifier
9263 , p_source_11 IN NUMBER
9264 --DISTRIBUTION_IDENTIFIER
9265 , p_source_12 IN NUMBER
9266 --Distribution Type
9267 , p_source_13 IN VARCHAR2
9268 , p_source_13_meaning IN VARCHAR2
9269 --Encumbrance Reversal Amount Entered
9270 , p_source_14 IN NUMBER
9271 --Entered Currency Code
9272 , p_source_15 IN VARCHAR2
9273 --Transaction Encumbrance Reversal Amount
9274 , p_source_16 IN NUMBER
9275 --Costing Encumbrance Upgrade Option
9276 , p_source_17 IN VARCHAR2
9277 --Currency Conversion Date
9278 , p_source_19 IN DATE
9279 --Currency Conversion Rate
9280 , p_source_20 IN NUMBER
9281 --Currency Conversion Type
9282 , p_source_21 IN VARCHAR2
9283 --Purchasing Encumbrance Type Identifier
9284 , p_source_22 IN NUMBER
9285 --TXN_PO_DISTRIBUTION_ID
9286 , p_source_23 IN NUMBER
9287 --Entered Amount
9288 , p_source_25 IN NUMBER
9289 --Accounted Amount
9290 , p_source_26 IN NUMBER
9291 )
9292 IS
9293
9294 l_component_type VARCHAR2(80);
9295 l_component_code VARCHAR2(30);
9296 l_component_type_code VARCHAR2(1);
9297 l_component_appl_id INTEGER;
9298 l_amb_context_code VARCHAR2(30);
9299 l_entity_code VARCHAR2(30);
9300 l_event_class_code VARCHAR2(30);
9301 l_ae_header_id NUMBER;
9302 l_event_type_code VARCHAR2(30);
9303 l_line_definition_code VARCHAR2(30);
9304 l_line_definition_owner_code VARCHAR2(1);
9305 --
9306 -- adr variables
9307 l_segment VARCHAR2(30);
9308 l_ccid NUMBER;
9309 l_adr_transaction_coa_id NUMBER;
9310 l_adr_accounting_coa_id NUMBER;
9311 l_adr_flexfield_segment_code VARCHAR2(30);
9312 l_adr_flex_value_set_id NUMBER;
9313 l_adr_value_type_code VARCHAR2(30);
9314 l_adr_value_combination_id NUMBER;
9315 l_adr_value_segment_code VARCHAR2(30);
9316
9317 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
9318 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
9319 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
9320 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
9321
9322 -- 4262811 Variables ------------------------------------------------------------------------------------------
9323 l_entered_amt_idx NUMBER;
9324 l_accted_amt_idx NUMBER;
9325 l_acc_rev_flag VARCHAR2(1);
9326 l_accrual_line_num NUMBER;
9327 l_tmp_amt NUMBER;
9328 l_acc_rev_natural_side_code VARCHAR2(1);
9329
9330 l_num_entries NUMBER;
9331 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
9332 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
9333 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
9334 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
9335 l_recog_line_1 NUMBER;
9336 l_recog_line_2 NUMBER;
9337
9338 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
9339 l_bflow_applied_to_amt NUMBER; -- 5132302
9340 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
9341
9342 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
9343
9344 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
9345 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
9346
9347 ---------------------------------------------------------------------------------------------------------------
9348
9349
9350 --
9351 -- bulk performance
9352 --
9353 l_balance_type_code VARCHAR2(1);
9354 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
9355 l_log_module VARCHAR2(240);
9356
9357 --
9358 -- Upgrade strategy
9359 --
9360 l_actual_upg_option VARCHAR2(1);
9361 l_enc_upg_option VARCHAR2(1);
9362
9363 --
9364 BEGIN
9365 --
9366 IF g_log_enabled THEN
9367 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_23';
9368 END IF;
9369 --
9370 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9371
9372 trace
9373 (p_msg => 'BEGIN of AcctLineType_23'
9374 ,p_level => C_LEVEL_PROCEDURE
9375 ,p_module => l_log_module);
9376
9377 END IF;
9378 --
9379 l_component_type := 'AMB_JLT';
9380 l_component_code := 'FV_RECORD_RECEIPT_DR_DTI';
9381 l_component_type_code := 'S';
9382 l_component_appl_id := 707;
9383 l_amb_context_code := 'DEFAULT';
9384 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
9385 l_event_class_code := 'PURCHASE_ORDER';
9386 l_event_type_code := 'PURCHASE_ORDER_ALL';
9387 l_line_definition_owner_code := 'S';
9388 l_line_definition_code := 'FV_PO_DEL_INV';
9389 --
9390 l_balance_type_code := 'A';
9391 l_segment := NULL;
9392 l_ccid := NULL;
9393 l_adr_transaction_coa_id := NULL;
9394 l_adr_accounting_coa_id := NULL;
9395 l_adr_flexfield_segment_code := NULL;
9396 l_adr_flex_value_set_id := NULL;
9397 l_adr_value_type_code := NULL;
9398 l_adr_value_combination_id := NULL;
9399 l_adr_value_segment_code := NULL;
9400
9401 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
9402 l_bflow_class_code := 'FV_INV_REC_DR'; -- 4219869 Business Flow
9403 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
9404 l_budgetary_control_flag := 'Y';
9405
9406 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9407 l_bflow_applied_to_amt := NULL; -- 5132302
9408 l_entered_amt_idx := NULL; -- 4262811
9409 l_accted_amt_idx := NULL; -- 4262811
9410 l_acc_rev_flag := NULL; -- 4262811
9411 l_accrual_line_num := NULL; -- 4262811
9412 l_tmp_amt := NULL; -- 4262811
9413 --
9414
9415 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
9416 l_balance_type_code <> 'B' THEN
9417 IF NVL(
9418 xla_ae_sources_pkg.GetSystemSourceChar(
9419 p_source_code => 'XLA_EVENT_TYPE_CODE'
9420 , p_source_type_code => 'Y'
9421 , p_source_application_id => 602
9422 ),'
9423 ') = 'PO_DEL_INV'
9424 THEN
9425
9426 --
9427 XLA_AE_LINES_PKG.SetNewLine;
9428
9429 p_balance_type_code := l_balance_type_code;
9430 -- set the flag so later we will know whether the gain loss line needs to be created
9431
9432 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
9433 p_actual_flag :='A';
9434 END IF;
9435
9436 --
9437 -- bulk performance
9438 --
9439 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
9440 p_header_num => 0); -- 4262811
9441 --
9442 -- set accounting line options
9443 --
9444 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
9445 p_natural_side_code => 'D'
9446 , p_gain_or_loss_flag => 'N'
9447 , p_gl_transfer_mode_code => 'S'
9448 , p_acct_entry_type_code => 'A'
9449 , p_switch_side_flag => 'N'
9450 , p_merge_duplicate_code => 'N'
9451 );
9452 --
9453 l_acc_rev_natural_side_code := 'C'; -- 4262811
9454 --
9455 --
9456 -- set accounting line type info
9457 --
9458 xla_ae_lines_pkg.SetAcctLineType
9459 (p_component_type => l_component_type
9460 ,p_event_type_code => l_event_type_code
9461 ,p_line_definition_owner_code => l_line_definition_owner_code
9462 ,p_line_definition_code => l_line_definition_code
9463 ,p_accounting_line_code => l_component_code
9464 ,p_accounting_line_type_code => l_component_type_code
9465 ,p_accounting_line_appl_id => l_component_appl_id
9466 ,p_amb_context_code => l_amb_context_code
9467 ,p_entity_code => l_entity_code
9468 ,p_event_class_code => l_event_class_code);
9469 --
9470 -- set accounting class
9471 --
9472 xla_ae_lines_pkg.SetAcctClass(
9473 p_accounting_class_code => 'FEDERAL_INV'
9474 , p_ae_header_id => l_ae_header_id
9475 );
9476
9477 --
9478 -- set rounding class
9479 --
9480 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
9481 'FEDERAL_INV';
9482
9483 --
9484 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
9485 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
9486 --
9487 -- bulk performance
9488 --
9489 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
9490
9491 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
9492 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
9493
9494 -- 4955764
9495 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9496 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
9497
9498 -- 4458381 Public Sector Enh
9499
9500 --
9501 -- set accounting attributes for the line type
9502 --
9503 l_entered_amt_idx := 17;
9504 l_accted_amt_idx := 22;
9505 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9506 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
9507 l_rec_acct_attrs.array_num_value(1) := p_source_7;
9508 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
9509 l_rec_acct_attrs.array_char_value(2) := p_source_8;
9510 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
9511 l_rec_acct_attrs.array_char_value(3) := p_source_9;
9512 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
9513 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
9514 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
9515 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
9516 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
9517 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
9518 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
9519 l_rec_acct_attrs.array_char_value(7) := p_source_13;
9520 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
9521 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
9522 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
9523 l_rec_acct_attrs.array_num_value(9) := p_source_14;
9524 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
9525 l_rec_acct_attrs.array_char_value(10) := p_source_15;
9526 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
9527 l_rec_acct_attrs.array_num_value(11) := p_source_16;
9528 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
9529 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
9530 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
9531 l_rec_acct_attrs.array_num_value(13) := p_source_14;
9532 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
9533 l_rec_acct_attrs.array_char_value(14) := p_source_15;
9534 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
9535 l_rec_acct_attrs.array_num_value(15) := p_source_16;
9536 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
9537 l_rec_acct_attrs.array_char_value(16) := p_source_17;
9538 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
9539 l_rec_acct_attrs.array_num_value(17) := p_source_25;
9540 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
9541 l_rec_acct_attrs.array_char_value(18) := p_source_15;
9542 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
9543 l_rec_acct_attrs.array_date_value(19) := p_source_19;
9544 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
9545 l_rec_acct_attrs.array_num_value(20) := p_source_20;
9546 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
9547 l_rec_acct_attrs.array_char_value(21) := p_source_21;
9548 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
9549 l_rec_acct_attrs.array_num_value(22) := p_source_26;
9550 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
9551 l_rec_acct_attrs.array_num_value(23) := p_source_22;
9552 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
9553 l_rec_acct_attrs.array_num_value(24) := p_source_22;
9554
9555 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
9556 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
9557
9558 ---------------------------------------------------------------------------------------------------------------
9559 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
9560 ---------------------------------------------------------------------------------------------------------------
9561 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
9562
9563 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9564 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9565
9566 IF xla_accounting_cache_pkg.GetValueChar
9567 (p_source_code => 'LEDGER_CATEGORY_CODE'
9568 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
9569 AND l_bflow_method_code = 'PRIOR_ENTRY'
9570 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
9571 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
9572 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
9573 )
9574 THEN
9575 xla_ae_lines_pkg.BflowUpgEntry
9576 (p_business_method_code => l_bflow_method_code
9577 ,p_business_class_code => l_bflow_class_code
9578 ,p_balance_type => l_balance_type_code);
9579 ELSE
9580 NULL;
9581 -- No business flow processing for business flow method of NONE.
9582 END IF;
9583
9584 --
9585 -- call analytical criteria
9586 --
9587
9588 --
9589 -- call description
9590 --
9591 -- No description or it is inherited.
9592 --
9593 -- call ADRs
9594 -- Bug 4922099
9595 --
9596 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9597 (NVL(l_actual_upg_option, 'N') = 'O') OR
9598 (NVL(l_enc_upg_option, 'N') = 'O')
9599 )
9600 THEN
9601 NULL;
9602 --
9603 --
9604
9605 l_ccid := AcctDerRule_11(
9606 p_application_id => p_application_id
9607 , p_ae_header_id => l_ae_header_id
9608 , p_source_3 => p_source_3
9609 , x_transaction_coa_id => l_adr_transaction_coa_id
9610 , x_accounting_coa_id => l_adr_accounting_coa_id
9611 , x_value_type_code => l_adr_value_type_code
9612 , p_side => 'NA'
9613 );
9614
9615 xla_ae_lines_pkg.set_ccid(
9616 p_code_combination_id => l_ccid
9617 , p_value_type_code => l_adr_value_type_code
9618 , p_transaction_coa_id => l_adr_transaction_coa_id
9619 , p_accounting_coa_id => l_adr_accounting_coa_id
9620 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
9621 , p_adr_type_code => 'S'
9622 , p_component_type => l_component_type
9623 , p_component_code => l_component_code
9624 , p_component_type_code => l_component_type_code
9625 , p_component_appl_id => l_component_appl_id
9626 , p_amb_context_code => l_amb_context_code
9627 , p_side => 'NA'
9628 );
9629
9630
9631 l_segment := AcctDerRule_4(
9632 p_application_id => p_application_id
9633 , p_ae_header_id => l_ae_header_id
9634 , p_source_1 => p_source_1
9635 , p_source_2 => p_source_2
9636 , x_transaction_coa_id => l_adr_transaction_coa_id
9637 , x_accounting_coa_id => l_adr_accounting_coa_id
9638 , x_flexfield_segment_code => l_adr_flexfield_segment_code
9639 , x_flex_value_set_id => l_adr_flex_value_set_id
9640 , x_value_type_code => l_adr_value_type_code
9641 , x_value_combination_id => l_adr_value_combination_id
9642 , x_value_segment_code => l_adr_value_segment_code
9643 , p_side => 'NA'
9644 , p_override_seg_flag => 'Y'
9645 );
9646
9647 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
9648
9649 xla_ae_lines_pkg.set_segment(
9650 p_to_segment_code => 'GL_ACCOUNT'
9651 , p_segment_value => l_segment
9652 , p_from_segment_code => l_adr_value_segment_code
9653 , p_from_combination_id => l_adr_value_combination_id
9654 , p_value_type_code => l_adr_value_type_code
9655 , p_transaction_coa_id => l_adr_transaction_coa_id
9656 , p_accounting_coa_id => l_adr_accounting_coa_id
9657 , p_flexfield_segment_code => l_adr_flexfield_segment_code
9658 , p_flex_value_set_id => l_adr_flex_value_set_id
9659 , p_adr_code => 'FV_46X002'
9660 , p_adr_type_code => 'S'
9661 , p_component_type => l_component_type
9662 , p_component_code => l_component_code
9663 , p_component_type_code => l_component_type_code
9664 , p_component_appl_id => l_component_appl_id
9665 , p_amb_context_code => l_amb_context_code
9666 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
9667 , p_event_class_code => 'PURCHASE_ORDER'
9668 , p_side => 'NA'
9669 );
9670
9671 END IF;
9672
9673 --
9674 --
9675 END IF;
9676 --
9677 -- Bug 4922099
9678 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
9679 (NVL(l_enc_upg_option, 'N') = 'O')
9680 ) AND
9681 (l_bflow_method_code = 'PRIOR_ENTRY')
9682 )
9683 THEN
9684 IF
9685 --
9686 1 = 2
9687 --
9688 THEN
9689 xla_accounting_err_pkg.build_message
9690 (p_appli_s_name => 'XLA'
9691 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9692 ,p_token_1 => 'LINE_NUMBER'
9693 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
9694 ,p_token_2 => 'LINE_TYPE_NAME'
9695 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
9696 l_component_type
9697 ,l_component_code
9698 ,l_component_type_code
9699 ,l_component_appl_id
9700 ,l_amb_context_code
9701 ,l_entity_code
9702 ,l_event_class_code
9703 )
9704 ,p_token_3 => 'OWNER'
9705 ,p_value_3 => xla_lookups_pkg.get_meaning(
9706 p_lookup_type => 'XLA_OWNER_TYPE'
9707 ,p_lookup_code => l_component_type_code
9708 )
9709 ,p_token_4 => 'PRODUCT_NAME'
9710 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
9711 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
9712 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
9713 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
9714 ,p_ae_header_id => NULL
9715 );
9716
9717 IF (C_LEVEL_ERROR>= g_log_level) THEN
9718 trace
9719 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9720 ,p_level => C_LEVEL_ERROR
9721 ,p_module => l_log_module);
9722 END IF;
9723 END IF;
9724 END IF;
9725 --
9726 --
9727 ------------------------------------------------------------------------------------------------
9728 -- 4219869 Business Flow
9729 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
9730 -- Prior Entry. Currently, the following code is always generated.
9731 ------------------------------------------------------------------------------------------------
9732 XLA_AE_LINES_PKG.ValidateCurrentLine;
9733
9734 ------------------------------------------------------------------------------------
9735 -- 4219869 Business Flow
9736 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
9737 ------------------------------------------------------------------------------------
9738 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9739
9740 ----------------------------------------------------------------------------------
9741 -- 4219869 Business Flow
9742 -- Update journal entry status -- Need to generate this within IF <condition>
9743 ----------------------------------------------------------------------------------
9744 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9745 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
9746 ,p_balance_type_code => l_balance_type_code
9747 );
9748
9749 -------------------------------------------------------------------------------------------
9750 -- 4262811 - Generate the Accrual Reversal lines
9751 -------------------------------------------------------------------------------------------
9752 BEGIN
9753 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
9754 (g_array_event(p_event_id).array_value_num('header_index'));
9755 IF l_acc_rev_flag IS NULL THEN
9756 l_acc_rev_flag := 'N';
9757 END IF;
9758 EXCEPTION
9759 WHEN OTHERS THEN
9760 l_acc_rev_flag := 'N';
9761 END;
9762 --
9763 IF (l_acc_rev_flag = 'Y') THEN
9764
9765 -- 4645092 ------------------------------------------------------------------------------
9766 -- To allow MPA report to determine if it should generate report process
9767 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
9768 ------------------------------------------------------------------------------------------
9769
9770 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
9771 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
9772 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
9773 -- call ADRs
9774 -- Bug 4922099
9775 --
9776 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9777 (NVL(l_actual_upg_option, 'N') = 'O') OR
9778 (NVL(l_enc_upg_option, 'N') = 'O')
9779 )
9780 THEN
9781 NULL;
9782 --
9783 --
9784
9785 l_ccid := AcctDerRule_11(
9786 p_application_id => p_application_id
9787 , p_ae_header_id => l_ae_header_id
9788 , p_source_3 => p_source_3
9789 , x_transaction_coa_id => l_adr_transaction_coa_id
9790 , x_accounting_coa_id => l_adr_accounting_coa_id
9791 , x_value_type_code => l_adr_value_type_code
9792 , p_side => 'NA'
9793 );
9794
9795 xla_ae_lines_pkg.set_ccid(
9796 p_code_combination_id => l_ccid
9797 , p_value_type_code => l_adr_value_type_code
9798 , p_transaction_coa_id => l_adr_transaction_coa_id
9799 , p_accounting_coa_id => l_adr_accounting_coa_id
9800 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
9801 , p_adr_type_code => 'S'
9802 , p_component_type => l_component_type
9803 , p_component_code => l_component_code
9804 , p_component_type_code => l_component_type_code
9805 , p_component_appl_id => l_component_appl_id
9806 , p_amb_context_code => l_amb_context_code
9807 , p_side => 'NA'
9808 );
9809
9810
9811 l_segment := AcctDerRule_4(
9812 p_application_id => p_application_id
9813 , p_ae_header_id => l_ae_header_id
9814 , p_source_1 => p_source_1
9815 , p_source_2 => p_source_2
9816 , x_transaction_coa_id => l_adr_transaction_coa_id
9817 , x_accounting_coa_id => l_adr_accounting_coa_id
9818 , x_flexfield_segment_code => l_adr_flexfield_segment_code
9819 , x_flex_value_set_id => l_adr_flex_value_set_id
9820 , x_value_type_code => l_adr_value_type_code
9821 , x_value_combination_id => l_adr_value_combination_id
9822 , x_value_segment_code => l_adr_value_segment_code
9823 , p_side => 'NA'
9824 , p_override_seg_flag => 'Y'
9825 );
9826
9827 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
9828
9829 xla_ae_lines_pkg.set_segment(
9830 p_to_segment_code => 'GL_ACCOUNT'
9831 , p_segment_value => l_segment
9832 , p_from_segment_code => l_adr_value_segment_code
9833 , p_from_combination_id => l_adr_value_combination_id
9834 , p_value_type_code => l_adr_value_type_code
9835 , p_transaction_coa_id => l_adr_transaction_coa_id
9836 , p_accounting_coa_id => l_adr_accounting_coa_id
9837 , p_flexfield_segment_code => l_adr_flexfield_segment_code
9838 , p_flex_value_set_id => l_adr_flex_value_set_id
9839 , p_adr_code => 'FV_46X002'
9840 , p_adr_type_code => 'S'
9841 , p_component_type => l_component_type
9842 , p_component_code => l_component_code
9843 , p_component_type_code => l_component_type_code
9844 , p_component_appl_id => l_component_appl_id
9845 , p_amb_context_code => l_amb_context_code
9846 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
9847 , p_event_class_code => 'PURCHASE_ORDER'
9848 , p_side => 'NA'
9849 );
9850
9851 END IF;
9852
9853 --
9854 --
9855 END IF;
9856
9857 --
9858 -- Update the line information that should be overwritten
9859 --
9860 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
9861 p_header_num => 1);
9862 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
9863
9864 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
9865
9866 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
9867 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
9868 END IF;
9869
9870 --
9871 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
9872 --
9873 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
9874 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
9875 ELSE
9876 ---------------------------------------------------------------------------------------------------
9877 -- 4262811a Switch Sign
9878 ---------------------------------------------------------------------------------------------------
9879 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
9880 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9881 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9882 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9883 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9884 -- 5132302
9885 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
9886 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9887
9888 END IF;
9889
9890 -- 4955764
9891 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9892 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
9893
9894
9895 XLA_AE_LINES_PKG.ValidateCurrentLine;
9896 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9897
9898 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9899 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
9900 ,p_balance_type_code => l_balance_type_code);
9901
9902 END IF;
9903
9904 -----------------------------------------------------------------------------------------
9905 -- 4262811 Multiperiod Accounting
9906 -----------------------------------------------------------------------------------------
9907 -- No MPA option is assigned.
9908
9909
9910 END IF;
9911 END IF;
9912 --
9913
9914 --
9915 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9916 trace
9917 (p_msg => 'END of AcctLineType_23'
9918 ,p_level => C_LEVEL_PROCEDURE
9919 ,p_module => l_log_module);
9920 END IF;
9921 --
9922 EXCEPTION
9923 WHEN xla_exceptions_pkg.application_exception THEN
9924 RAISE;
9925 WHEN OTHERS THEN
9926 xla_exceptions_pkg.raise_message
9927 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_23');
9928 END AcctLineType_23;
9929 --
9930
9931 ---------------------------------------
9932 --
9933 -- PRIVATE FUNCTION
9934 -- AcctLineType_24
9935 --
9936 ---------------------------------------
9937 PROCEDURE AcctLineType_24 (
9938 p_application_id IN NUMBER
9939 ,p_event_id IN NUMBER
9940 ,p_calculate_acctd_flag IN VARCHAR2
9941 ,p_calculate_g_l_flag IN VARCHAR2
9942 ,p_actual_flag IN OUT VARCHAR2
9943 ,p_balance_type_code OUT VARCHAR2
9944 ,p_gain_or_loss_ref OUT VARCHAR2
9945
9946 --PO Budget Account
9947 , p_source_3 IN NUMBER
9948 --Federal Prior Year Flag
9949 , p_source_5 IN VARCHAR2
9950 --Receiving Accounting Line Type
9951 , p_source_6 IN VARCHAR2
9952 --Applied to Application ID
9953 , p_source_7 IN NUMBER
9954 --Applied to Distribution Link Type
9955 , p_source_8 IN VARCHAR2
9956 --Applied to Entity Code
9957 , p_source_9 IN VARCHAR2
9958 --PO_DISTRIBUTION_ID
9959 , p_source_10 IN NUMBER
9960 --Applied To Purchase Document Identifier
9961 , p_source_11 IN NUMBER
9962 --DISTRIBUTION_IDENTIFIER
9963 , p_source_12 IN NUMBER
9964 --Distribution Type
9965 , p_source_13 IN VARCHAR2
9966 , p_source_13_meaning IN VARCHAR2
9967 --Encumbrance Reversal Amount Entered
9968 , p_source_14 IN NUMBER
9969 --Entered Currency Code
9970 , p_source_15 IN VARCHAR2
9971 --Transaction Encumbrance Reversal Amount
9972 , p_source_16 IN NUMBER
9973 --Costing Encumbrance Upgrade Option
9974 , p_source_17 IN VARCHAR2
9975 --Currency Conversion Date
9976 , p_source_19 IN DATE
9977 --Currency Conversion Rate
9978 , p_source_20 IN NUMBER
9979 --Currency Conversion Type
9980 , p_source_21 IN VARCHAR2
9981 --Purchasing Encumbrance Type Identifier
9982 , p_source_22 IN NUMBER
9983 --Federal Net Pya Adj Amt
9984 , p_source_27 IN NUMBER
9985 )
9986 IS
9987
9988 l_component_type VARCHAR2(80);
9989 l_component_code VARCHAR2(30);
9990 l_component_type_code VARCHAR2(1);
9991 l_component_appl_id INTEGER;
9992 l_amb_context_code VARCHAR2(30);
9993 l_entity_code VARCHAR2(30);
9994 l_event_class_code VARCHAR2(30);
9995 l_ae_header_id NUMBER;
9996 l_event_type_code VARCHAR2(30);
9997 l_line_definition_code VARCHAR2(30);
9998 l_line_definition_owner_code VARCHAR2(1);
9999 --
10000 -- adr variables
10001 l_segment VARCHAR2(30);
10002 l_ccid NUMBER;
10003 l_adr_transaction_coa_id NUMBER;
10004 l_adr_accounting_coa_id NUMBER;
10005 l_adr_flexfield_segment_code VARCHAR2(30);
10006 l_adr_flex_value_set_id NUMBER;
10007 l_adr_value_type_code VARCHAR2(30);
10008 l_adr_value_combination_id NUMBER;
10009 l_adr_value_segment_code VARCHAR2(30);
10010
10011 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
10012 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
10013 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
10014 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
10015
10016 -- 4262811 Variables ------------------------------------------------------------------------------------------
10017 l_entered_amt_idx NUMBER;
10018 l_accted_amt_idx NUMBER;
10019 l_acc_rev_flag VARCHAR2(1);
10020 l_accrual_line_num NUMBER;
10021 l_tmp_amt NUMBER;
10022 l_acc_rev_natural_side_code VARCHAR2(1);
10023
10024 l_num_entries NUMBER;
10025 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
10026 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
10027 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
10028 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
10029 l_recog_line_1 NUMBER;
10030 l_recog_line_2 NUMBER;
10031
10032 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
10033 l_bflow_applied_to_amt NUMBER; -- 5132302
10034 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
10035
10036 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
10037
10038 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
10039 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
10040
10041 ---------------------------------------------------------------------------------------------------------------
10042
10043
10044 --
10045 -- bulk performance
10046 --
10047 l_balance_type_code VARCHAR2(1);
10048 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
10049 l_log_module VARCHAR2(240);
10050
10051 --
10052 -- Upgrade strategy
10053 --
10054 l_actual_upg_option VARCHAR2(1);
10055 l_enc_upg_option VARCHAR2(1);
10056
10057 --
10058 BEGIN
10059 --
10060 IF g_log_enabled THEN
10061 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_24';
10062 END IF;
10063 --
10064 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10065
10066 trace
10067 (p_msg => 'BEGIN of AcctLineType_24'
10068 ,p_level => C_LEVEL_PROCEDURE
10069 ,p_module => l_log_module);
10070
10071 END IF;
10072 --
10073 l_component_type := 'AMB_JLT';
10074 l_component_code := 'FV_REC_DOWNWARD_PYA_DR';
10075 l_component_type_code := 'S';
10076 l_component_appl_id := 707;
10077 l_amb_context_code := 'DEFAULT';
10078 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
10079 l_event_class_code := 'DELIVER_EXPENSE';
10080 l_event_type_code := 'DELIVER_EXPENSE_ALL';
10081 l_line_definition_owner_code := 'S';
10082 l_line_definition_code := 'FV_RETURN_TO_RECEIVING';
10083 --
10084 l_balance_type_code := 'A';
10085 l_segment := NULL;
10086 l_ccid := NULL;
10087 l_adr_transaction_coa_id := NULL;
10088 l_adr_accounting_coa_id := NULL;
10089 l_adr_flexfield_segment_code := NULL;
10090 l_adr_flex_value_set_id := NULL;
10091 l_adr_value_type_code := NULL;
10092 l_adr_value_combination_id := NULL;
10093 l_adr_value_segment_code := NULL;
10094
10095 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
10096 l_bflow_class_code := ''; -- 4219869 Business Flow
10097 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
10098 l_budgetary_control_flag := 'Y';
10099
10100 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10101 l_bflow_applied_to_amt := NULL; -- 5132302
10102 l_entered_amt_idx := NULL; -- 4262811
10103 l_accted_amt_idx := NULL; -- 4262811
10104 l_acc_rev_flag := NULL; -- 4262811
10105 l_accrual_line_num := NULL; -- 4262811
10106 l_tmp_amt := NULL; -- 4262811
10107 --
10108
10109 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
10110 l_balance_type_code <> 'B' THEN
10111 IF NVL(
10112 xla_ae_sources_pkg.GetSystemSourceChar(
10113 p_source_code => 'XLA_EVENT_TYPE_CODE'
10114 , p_source_type_code => 'Y'
10115 , p_source_application_id => 602
10116 ),'
10117 ') = 'RETURN_TO_RECEIVING' AND
10118 NVL(p_source_5,'
10119 ') = 'Y' AND
10120 NVL(p_source_6,'
10121 ') = 'Charge'
10122 THEN
10123
10124 --
10125 XLA_AE_LINES_PKG.SetNewLine;
10126
10127 p_balance_type_code := l_balance_type_code;
10128 -- set the flag so later we will know whether the gain loss line needs to be created
10129
10130 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
10131 p_actual_flag :='A';
10132 END IF;
10133
10134 --
10135 -- bulk performance
10136 --
10137 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
10138 p_header_num => 0); -- 4262811
10139 --
10140 -- set accounting line options
10141 --
10142 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
10143 p_natural_side_code => 'D'
10144 , p_gain_or_loss_flag => 'N'
10145 , p_gl_transfer_mode_code => 'S'
10146 , p_acct_entry_type_code => 'A'
10147 , p_switch_side_flag => 'N'
10148 , p_merge_duplicate_code => 'N'
10149 );
10150 --
10151 l_acc_rev_natural_side_code := 'C'; -- 4262811
10152 --
10153 --
10154 -- set accounting line type info
10155 --
10156 xla_ae_lines_pkg.SetAcctLineType
10157 (p_component_type => l_component_type
10158 ,p_event_type_code => l_event_type_code
10159 ,p_line_definition_owner_code => l_line_definition_owner_code
10160 ,p_line_definition_code => l_line_definition_code
10161 ,p_accounting_line_code => l_component_code
10162 ,p_accounting_line_type_code => l_component_type_code
10163 ,p_accounting_line_appl_id => l_component_appl_id
10164 ,p_amb_context_code => l_amb_context_code
10165 ,p_entity_code => l_entity_code
10166 ,p_event_class_code => l_event_class_code);
10167 --
10168 -- set accounting class
10169 --
10170 xla_ae_lines_pkg.SetAcctClass(
10171 p_accounting_class_code => 'FEDERAL_EXP'
10172 , p_ae_header_id => l_ae_header_id
10173 );
10174
10175 --
10176 -- set rounding class
10177 --
10178 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
10179 'FEDERAL_EXP';
10180
10181 --
10182 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
10183 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
10184 --
10185 -- bulk performance
10186 --
10187 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
10188
10189 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
10190 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
10191
10192 -- 4955764
10193 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10194 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
10195
10196 -- 4458381 Public Sector Enh
10197
10198 --
10199 -- set accounting attributes for the line type
10200 --
10201 l_entered_amt_idx := 17;
10202 l_accted_amt_idx := 22;
10203 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10204 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
10205 l_rec_acct_attrs.array_num_value(1) := p_source_7;
10206 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
10207 l_rec_acct_attrs.array_char_value(2) := p_source_8;
10208 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
10209 l_rec_acct_attrs.array_char_value(3) := p_source_9;
10210 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
10211 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
10212 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
10213 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
10214 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
10215 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
10216 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
10217 l_rec_acct_attrs.array_char_value(7) := p_source_13;
10218 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
10219 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
10220 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
10221 l_rec_acct_attrs.array_num_value(9) := p_source_14;
10222 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
10223 l_rec_acct_attrs.array_char_value(10) := p_source_15;
10224 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
10225 l_rec_acct_attrs.array_num_value(11) := p_source_16;
10226 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
10227 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
10228 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
10229 l_rec_acct_attrs.array_num_value(13) := p_source_14;
10230 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
10231 l_rec_acct_attrs.array_char_value(14) := p_source_15;
10232 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
10233 l_rec_acct_attrs.array_num_value(15) := p_source_16;
10234 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
10235 l_rec_acct_attrs.array_char_value(16) := p_source_17;
10236 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
10237 l_rec_acct_attrs.array_num_value(17) := p_source_27;
10238 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
10239 l_rec_acct_attrs.array_char_value(18) := p_source_15;
10240 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
10241 l_rec_acct_attrs.array_date_value(19) := p_source_19;
10242 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
10243 l_rec_acct_attrs.array_num_value(20) := p_source_20;
10244 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
10245 l_rec_acct_attrs.array_char_value(21) := p_source_21;
10246 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
10247 l_rec_acct_attrs.array_num_value(22) := p_source_27;
10248 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
10249 l_rec_acct_attrs.array_num_value(23) := p_source_22;
10250 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
10251 l_rec_acct_attrs.array_num_value(24) := p_source_22;
10252
10253 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
10254 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
10255
10256 ---------------------------------------------------------------------------------------------------------------
10257 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
10258 ---------------------------------------------------------------------------------------------------------------
10259 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
10260
10261 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10262 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10263
10264 IF xla_accounting_cache_pkg.GetValueChar
10265 (p_source_code => 'LEDGER_CATEGORY_CODE'
10266 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
10267 AND l_bflow_method_code = 'PRIOR_ENTRY'
10268 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
10269 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
10270 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
10271 )
10272 THEN
10273 xla_ae_lines_pkg.BflowUpgEntry
10274 (p_business_method_code => l_bflow_method_code
10275 ,p_business_class_code => l_bflow_class_code
10276 ,p_balance_type => l_balance_type_code);
10277 ELSE
10278 NULL;
10279 -- No business flow processing for business flow method of NONE.
10280 END IF;
10281
10282 --
10283 -- call analytical criteria
10284 --
10285
10286 --
10287 -- call description
10288 --
10289 -- No description or it is inherited.
10290 --
10291 -- call ADRs
10292 -- Bug 4922099
10293 --
10294 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10295 (NVL(l_actual_upg_option, 'N') = 'O') OR
10296 (NVL(l_enc_upg_option, 'N') = 'O')
10297 )
10298 THEN
10299 NULL;
10300 --
10301 --
10302
10303 l_ccid := AcctDerRule_11(
10304 p_application_id => p_application_id
10305 , p_ae_header_id => l_ae_header_id
10306 , p_source_3 => p_source_3
10307 , x_transaction_coa_id => l_adr_transaction_coa_id
10308 , x_accounting_coa_id => l_adr_accounting_coa_id
10309 , x_value_type_code => l_adr_value_type_code
10310 , p_side => 'NA'
10311 );
10312
10313 xla_ae_lines_pkg.set_ccid(
10314 p_code_combination_id => l_ccid
10315 , p_value_type_code => l_adr_value_type_code
10316 , p_transaction_coa_id => l_adr_transaction_coa_id
10317 , p_accounting_coa_id => l_adr_accounting_coa_id
10318 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
10319 , p_adr_type_code => 'S'
10320 , p_component_type => l_component_type
10321 , p_component_code => l_component_code
10322 , p_component_type_code => l_component_type_code
10323 , p_component_appl_id => l_component_appl_id
10324 , p_amb_context_code => l_amb_context_code
10325 , p_side => 'NA'
10326 );
10327
10328
10329 l_segment := AcctDerRule_7(
10330 p_application_id => p_application_id
10331 , p_ae_header_id => l_ae_header_id
10332 , x_transaction_coa_id => l_adr_transaction_coa_id
10333 , x_accounting_coa_id => l_adr_accounting_coa_id
10334 , x_flexfield_segment_code => l_adr_flexfield_segment_code
10335 , x_flex_value_set_id => l_adr_flex_value_set_id
10336 , x_value_type_code => l_adr_value_type_code
10337 , x_value_combination_id => l_adr_value_combination_id
10338 , x_value_segment_code => l_adr_value_segment_code
10339 , p_side => 'NA'
10340 , p_override_seg_flag => 'Y'
10341 );
10342
10343 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
10344
10345 xla_ae_lines_pkg.set_segment(
10346 p_to_segment_code => 'GL_ACCOUNT'
10347 , p_segment_value => l_segment
10348 , p_from_segment_code => l_adr_value_segment_code
10349 , p_from_combination_id => l_adr_value_combination_id
10350 , p_value_type_code => l_adr_value_type_code
10351 , p_transaction_coa_id => l_adr_transaction_coa_id
10352 , p_accounting_coa_id => l_adr_accounting_coa_id
10353 , p_flexfield_segment_code => l_adr_flexfield_segment_code
10354 , p_flex_value_set_id => l_adr_flex_value_set_id
10355 , p_adr_code => 'FV_487101'
10356 , p_adr_type_code => 'S'
10357 , p_component_type => l_component_type
10358 , p_component_code => l_component_code
10359 , p_component_type_code => l_component_type_code
10360 , p_component_appl_id => l_component_appl_id
10361 , p_amb_context_code => l_amb_context_code
10362 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
10363 , p_event_class_code => 'DELIVER_EXPENSE'
10364 , p_side => 'NA'
10365 );
10366
10367 END IF;
10368
10369 --
10370 --
10371 END IF;
10372 --
10373 -- Bug 4922099
10374 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
10375 (NVL(l_enc_upg_option, 'N') = 'O')
10376 ) AND
10377 (l_bflow_method_code = 'PRIOR_ENTRY')
10378 )
10379 THEN
10380 IF
10381 --
10382 1 = 2
10383 --
10384 THEN
10385 xla_accounting_err_pkg.build_message
10386 (p_appli_s_name => 'XLA'
10387 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10388 ,p_token_1 => 'LINE_NUMBER'
10389 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
10390 ,p_token_2 => 'LINE_TYPE_NAME'
10391 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
10392 l_component_type
10393 ,l_component_code
10394 ,l_component_type_code
10395 ,l_component_appl_id
10396 ,l_amb_context_code
10397 ,l_entity_code
10398 ,l_event_class_code
10399 )
10400 ,p_token_3 => 'OWNER'
10401 ,p_value_3 => xla_lookups_pkg.get_meaning(
10402 p_lookup_type => 'XLA_OWNER_TYPE'
10403 ,p_lookup_code => l_component_type_code
10404 )
10405 ,p_token_4 => 'PRODUCT_NAME'
10406 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
10407 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
10408 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
10409 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
10410 ,p_ae_header_id => NULL
10411 );
10412
10413 IF (C_LEVEL_ERROR>= g_log_level) THEN
10414 trace
10415 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10416 ,p_level => C_LEVEL_ERROR
10417 ,p_module => l_log_module);
10418 END IF;
10419 END IF;
10420 END IF;
10421 --
10422 --
10423 ------------------------------------------------------------------------------------------------
10424 -- 4219869 Business Flow
10425 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
10426 -- Prior Entry. Currently, the following code is always generated.
10427 ------------------------------------------------------------------------------------------------
10428 XLA_AE_LINES_PKG.ValidateCurrentLine;
10429
10430 ------------------------------------------------------------------------------------
10431 -- 4219869 Business Flow
10432 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
10433 ------------------------------------------------------------------------------------
10434 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10435
10436 ----------------------------------------------------------------------------------
10437 -- 4219869 Business Flow
10438 -- Update journal entry status -- Need to generate this within IF <condition>
10439 ----------------------------------------------------------------------------------
10440 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10441 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
10442 ,p_balance_type_code => l_balance_type_code
10443 );
10444
10445 -------------------------------------------------------------------------------------------
10446 -- 4262811 - Generate the Accrual Reversal lines
10447 -------------------------------------------------------------------------------------------
10448 BEGIN
10449 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
10450 (g_array_event(p_event_id).array_value_num('header_index'));
10451 IF l_acc_rev_flag IS NULL THEN
10452 l_acc_rev_flag := 'N';
10453 END IF;
10454 EXCEPTION
10455 WHEN OTHERS THEN
10456 l_acc_rev_flag := 'N';
10457 END;
10458 --
10459 IF (l_acc_rev_flag = 'Y') THEN
10460
10461 -- 4645092 ------------------------------------------------------------------------------
10462 -- To allow MPA report to determine if it should generate report process
10463 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
10464 ------------------------------------------------------------------------------------------
10465
10466 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
10467 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
10468 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
10469 -- call ADRs
10470 -- Bug 4922099
10471 --
10472 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10473 (NVL(l_actual_upg_option, 'N') = 'O') OR
10474 (NVL(l_enc_upg_option, 'N') = 'O')
10475 )
10476 THEN
10477 NULL;
10478 --
10479 --
10480
10481 l_ccid := AcctDerRule_11(
10482 p_application_id => p_application_id
10483 , p_ae_header_id => l_ae_header_id
10484 , p_source_3 => p_source_3
10485 , x_transaction_coa_id => l_adr_transaction_coa_id
10486 , x_accounting_coa_id => l_adr_accounting_coa_id
10487 , x_value_type_code => l_adr_value_type_code
10488 , p_side => 'NA'
10489 );
10490
10491 xla_ae_lines_pkg.set_ccid(
10492 p_code_combination_id => l_ccid
10493 , p_value_type_code => l_adr_value_type_code
10494 , p_transaction_coa_id => l_adr_transaction_coa_id
10495 , p_accounting_coa_id => l_adr_accounting_coa_id
10496 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
10497 , p_adr_type_code => 'S'
10498 , p_component_type => l_component_type
10499 , p_component_code => l_component_code
10500 , p_component_type_code => l_component_type_code
10501 , p_component_appl_id => l_component_appl_id
10502 , p_amb_context_code => l_amb_context_code
10503 , p_side => 'NA'
10504 );
10505
10506
10507 l_segment := AcctDerRule_7(
10508 p_application_id => p_application_id
10509 , p_ae_header_id => l_ae_header_id
10510 , x_transaction_coa_id => l_adr_transaction_coa_id
10511 , x_accounting_coa_id => l_adr_accounting_coa_id
10512 , x_flexfield_segment_code => l_adr_flexfield_segment_code
10513 , x_flex_value_set_id => l_adr_flex_value_set_id
10514 , x_value_type_code => l_adr_value_type_code
10515 , x_value_combination_id => l_adr_value_combination_id
10516 , x_value_segment_code => l_adr_value_segment_code
10517 , p_side => 'NA'
10518 , p_override_seg_flag => 'Y'
10519 );
10520
10521 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
10522
10523 xla_ae_lines_pkg.set_segment(
10524 p_to_segment_code => 'GL_ACCOUNT'
10525 , p_segment_value => l_segment
10526 , p_from_segment_code => l_adr_value_segment_code
10527 , p_from_combination_id => l_adr_value_combination_id
10528 , p_value_type_code => l_adr_value_type_code
10529 , p_transaction_coa_id => l_adr_transaction_coa_id
10530 , p_accounting_coa_id => l_adr_accounting_coa_id
10531 , p_flexfield_segment_code => l_adr_flexfield_segment_code
10532 , p_flex_value_set_id => l_adr_flex_value_set_id
10533 , p_adr_code => 'FV_487101'
10534 , p_adr_type_code => 'S'
10535 , p_component_type => l_component_type
10536 , p_component_code => l_component_code
10537 , p_component_type_code => l_component_type_code
10538 , p_component_appl_id => l_component_appl_id
10539 , p_amb_context_code => l_amb_context_code
10540 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
10541 , p_event_class_code => 'DELIVER_EXPENSE'
10542 , p_side => 'NA'
10543 );
10544
10545 END IF;
10546
10547 --
10548 --
10549 END IF;
10550
10551 --
10552 -- Update the line information that should be overwritten
10553 --
10554 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
10555 p_header_num => 1);
10556 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
10557
10558 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
10559
10560 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
10561 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
10562 END IF;
10563
10564 --
10565 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
10566 --
10567 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
10568 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
10569 ELSE
10570 ---------------------------------------------------------------------------------------------------
10571 -- 4262811a Switch Sign
10572 ---------------------------------------------------------------------------------------------------
10573 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
10574 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10575 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10576 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10577 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10578 -- 5132302
10579 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
10580 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10581
10582 END IF;
10583
10584 -- 4955764
10585 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10586 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
10587
10588
10589 XLA_AE_LINES_PKG.ValidateCurrentLine;
10590 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10591
10592 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10593 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
10594 ,p_balance_type_code => l_balance_type_code);
10595
10596 END IF;
10597
10598 -----------------------------------------------------------------------------------------
10599 -- 4262811 Multiperiod Accounting
10600 -----------------------------------------------------------------------------------------
10601 -- No MPA option is assigned.
10602
10603
10604 END IF;
10605 END IF;
10606 --
10607
10608 --
10609 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10610 trace
10611 (p_msg => 'END of AcctLineType_24'
10612 ,p_level => C_LEVEL_PROCEDURE
10613 ,p_module => l_log_module);
10614 END IF;
10615 --
10616 EXCEPTION
10617 WHEN xla_exceptions_pkg.application_exception THEN
10618 RAISE;
10619 WHEN OTHERS THEN
10620 xla_exceptions_pkg.raise_message
10621 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_24');
10622 END AcctLineType_24;
10623 --
10624
10625 ---------------------------------------
10626 --
10627 -- PRIVATE FUNCTION
10628 -- AcctLineType_25
10629 --
10630 ---------------------------------------
10631 PROCEDURE AcctLineType_25 (
10632 p_application_id IN NUMBER
10633 ,p_event_id IN NUMBER
10634 ,p_calculate_acctd_flag IN VARCHAR2
10635 ,p_calculate_g_l_flag IN VARCHAR2
10636 ,p_actual_flag IN OUT VARCHAR2
10637 ,p_balance_type_code OUT VARCHAR2
10638 ,p_gain_or_loss_ref OUT VARCHAR2
10639
10640 --PO Budget Account
10641 , p_source_3 IN NUMBER
10642 --Federal Prior Year Flag
10643 , p_source_5 IN VARCHAR2
10644 --Applied to Application ID
10645 , p_source_7 IN NUMBER
10646 --Applied to Distribution Link Type
10647 , p_source_8 IN VARCHAR2
10648 --Applied to Entity Code
10649 , p_source_9 IN VARCHAR2
10650 --Applied To Purchase Document Identifier
10651 , p_source_11 IN NUMBER
10652 --DISTRIBUTION_IDENTIFIER
10653 , p_source_12 IN NUMBER
10654 --Distribution Type
10655 , p_source_13 IN VARCHAR2
10656 , p_source_13_meaning IN VARCHAR2
10657 --Encumbrance Reversal Amount Entered
10658 , p_source_14 IN NUMBER
10659 --Entered Currency Code
10660 , p_source_15 IN VARCHAR2
10661 --Transaction Encumbrance Reversal Amount
10662 , p_source_16 IN NUMBER
10663 --Costing Encumbrance Upgrade Option
10664 , p_source_17 IN VARCHAR2
10665 --Currency Conversion Date
10666 , p_source_19 IN DATE
10667 --Currency Conversion Rate
10668 , p_source_20 IN NUMBER
10669 --Currency Conversion Type
10670 , p_source_21 IN VARCHAR2
10671 --Purchasing Encumbrance Type Identifier
10672 , p_source_22 IN NUMBER
10673 --TXN_PO_DISTRIBUTION_ID
10674 , p_source_23 IN NUMBER
10675 --Federal Net Pya Adj Amt
10676 , p_source_27 IN NUMBER
10677 )
10678 IS
10679
10680 l_component_type VARCHAR2(80);
10681 l_component_code VARCHAR2(30);
10682 l_component_type_code VARCHAR2(1);
10683 l_component_appl_id INTEGER;
10684 l_amb_context_code VARCHAR2(30);
10685 l_entity_code VARCHAR2(30);
10686 l_event_class_code VARCHAR2(30);
10687 l_ae_header_id NUMBER;
10688 l_event_type_code VARCHAR2(30);
10689 l_line_definition_code VARCHAR2(30);
10690 l_line_definition_owner_code VARCHAR2(1);
10691 --
10692 -- adr variables
10693 l_segment VARCHAR2(30);
10694 l_ccid NUMBER;
10695 l_adr_transaction_coa_id NUMBER;
10696 l_adr_accounting_coa_id NUMBER;
10697 l_adr_flexfield_segment_code VARCHAR2(30);
10698 l_adr_flex_value_set_id NUMBER;
10699 l_adr_value_type_code VARCHAR2(30);
10700 l_adr_value_combination_id NUMBER;
10701 l_adr_value_segment_code VARCHAR2(30);
10702
10703 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
10704 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
10705 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
10706 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
10707
10708 -- 4262811 Variables ------------------------------------------------------------------------------------------
10709 l_entered_amt_idx NUMBER;
10710 l_accted_amt_idx NUMBER;
10711 l_acc_rev_flag VARCHAR2(1);
10712 l_accrual_line_num NUMBER;
10713 l_tmp_amt NUMBER;
10714 l_acc_rev_natural_side_code VARCHAR2(1);
10715
10716 l_num_entries NUMBER;
10717 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
10718 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
10719 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
10720 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
10721 l_recog_line_1 NUMBER;
10722 l_recog_line_2 NUMBER;
10723
10724 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
10725 l_bflow_applied_to_amt NUMBER; -- 5132302
10726 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
10727
10728 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
10729
10730 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
10731 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
10732
10733 ---------------------------------------------------------------------------------------------------------------
10734
10735
10736 --
10737 -- bulk performance
10738 --
10739 l_balance_type_code VARCHAR2(1);
10740 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
10741 l_log_module VARCHAR2(240);
10742
10743 --
10744 -- Upgrade strategy
10745 --
10746 l_actual_upg_option VARCHAR2(1);
10747 l_enc_upg_option VARCHAR2(1);
10748
10749 --
10750 BEGIN
10751 --
10752 IF g_log_enabled THEN
10753 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_25';
10754 END IF;
10755 --
10756 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10757
10758 trace
10759 (p_msg => 'BEGIN of AcctLineType_25'
10760 ,p_level => C_LEVEL_PROCEDURE
10761 ,p_module => l_log_module);
10762
10763 END IF;
10764 --
10765 l_component_type := 'AMB_JLT';
10766 l_component_code := 'FV_REC_DOWNWARD_PYA_DR_RTI';
10767 l_component_type_code := 'S';
10768 l_component_appl_id := 707;
10769 l_amb_context_code := 'DEFAULT';
10770 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
10771 l_event_class_code := 'PURCHASE_ORDER';
10772 l_event_type_code := 'PURCHASE_ORDER_ALL';
10773 l_line_definition_owner_code := 'S';
10774 l_line_definition_code := 'FV_RET_RI_INV';
10775 --
10776 l_balance_type_code := 'A';
10777 l_segment := NULL;
10778 l_ccid := NULL;
10779 l_adr_transaction_coa_id := NULL;
10780 l_adr_accounting_coa_id := NULL;
10781 l_adr_flexfield_segment_code := NULL;
10782 l_adr_flex_value_set_id := NULL;
10783 l_adr_value_type_code := NULL;
10784 l_adr_value_combination_id := NULL;
10785 l_adr_value_segment_code := NULL;
10786
10787 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
10788 l_bflow_class_code := ''; -- 4219869 Business Flow
10789 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
10790 l_budgetary_control_flag := 'Y';
10791
10792 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10793 l_bflow_applied_to_amt := NULL; -- 5132302
10794 l_entered_amt_idx := NULL; -- 4262811
10795 l_accted_amt_idx := NULL; -- 4262811
10796 l_acc_rev_flag := NULL; -- 4262811
10797 l_accrual_line_num := NULL; -- 4262811
10798 l_tmp_amt := NULL; -- 4262811
10799 --
10800
10801 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
10802 l_balance_type_code <> 'B' THEN
10803 IF NVL(
10804 xla_ae_sources_pkg.GetSystemSourceChar(
10805 p_source_code => 'XLA_EVENT_TYPE_CODE'
10806 , p_source_type_code => 'Y'
10807 , p_source_application_id => 602
10808 ),'
10809 ') = 'RET_RI_INV' AND
10810 NVL(p_source_5,'
10811 ') = 'Y'
10812 THEN
10813
10814 --
10815 XLA_AE_LINES_PKG.SetNewLine;
10816
10817 p_balance_type_code := l_balance_type_code;
10818 -- set the flag so later we will know whether the gain loss line needs to be created
10819
10820 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
10821 p_actual_flag :='A';
10822 END IF;
10823
10824 --
10825 -- bulk performance
10826 --
10827 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
10828 p_header_num => 0); -- 4262811
10829 --
10830 -- set accounting line options
10831 --
10832 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
10833 p_natural_side_code => 'D'
10834 , p_gain_or_loss_flag => 'N'
10835 , p_gl_transfer_mode_code => 'S'
10836 , p_acct_entry_type_code => 'A'
10837 , p_switch_side_flag => 'N'
10838 , p_merge_duplicate_code => 'N'
10839 );
10840 --
10841 l_acc_rev_natural_side_code := 'C'; -- 4262811
10842 --
10843 --
10844 -- set accounting line type info
10845 --
10846 xla_ae_lines_pkg.SetAcctLineType
10847 (p_component_type => l_component_type
10848 ,p_event_type_code => l_event_type_code
10849 ,p_line_definition_owner_code => l_line_definition_owner_code
10850 ,p_line_definition_code => l_line_definition_code
10851 ,p_accounting_line_code => l_component_code
10852 ,p_accounting_line_type_code => l_component_type_code
10853 ,p_accounting_line_appl_id => l_component_appl_id
10854 ,p_amb_context_code => l_amb_context_code
10855 ,p_entity_code => l_entity_code
10856 ,p_event_class_code => l_event_class_code);
10857 --
10858 -- set accounting class
10859 --
10860 xla_ae_lines_pkg.SetAcctClass(
10861 p_accounting_class_code => 'FEDERAL_INV'
10862 , p_ae_header_id => l_ae_header_id
10863 );
10864
10865 --
10866 -- set rounding class
10867 --
10868 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
10869 'FEDERAL_INV';
10870
10871 --
10872 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
10873 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
10874 --
10875 -- bulk performance
10876 --
10877 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
10878
10879 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
10880 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
10881
10882 -- 4955764
10883 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10884 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
10885
10886 -- 4458381 Public Sector Enh
10887
10888 --
10889 -- set accounting attributes for the line type
10890 --
10891 l_entered_amt_idx := 17;
10892 l_accted_amt_idx := 22;
10893 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10894 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
10895 l_rec_acct_attrs.array_num_value(1) := p_source_7;
10896 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
10897 l_rec_acct_attrs.array_char_value(2) := p_source_8;
10898 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
10899 l_rec_acct_attrs.array_char_value(3) := p_source_9;
10900 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
10901 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
10902 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
10903 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
10904 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
10905 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
10906 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
10907 l_rec_acct_attrs.array_char_value(7) := p_source_13;
10908 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
10909 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
10910 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
10911 l_rec_acct_attrs.array_num_value(9) := p_source_14;
10912 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
10913 l_rec_acct_attrs.array_char_value(10) := p_source_15;
10914 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
10915 l_rec_acct_attrs.array_num_value(11) := p_source_16;
10916 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
10917 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
10918 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
10919 l_rec_acct_attrs.array_num_value(13) := p_source_14;
10920 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
10921 l_rec_acct_attrs.array_char_value(14) := p_source_15;
10922 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
10923 l_rec_acct_attrs.array_num_value(15) := p_source_16;
10924 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
10925 l_rec_acct_attrs.array_char_value(16) := p_source_17;
10926 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
10927 l_rec_acct_attrs.array_num_value(17) := p_source_27;
10928 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
10929 l_rec_acct_attrs.array_char_value(18) := p_source_15;
10930 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
10931 l_rec_acct_attrs.array_date_value(19) := p_source_19;
10932 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
10933 l_rec_acct_attrs.array_num_value(20) := p_source_20;
10934 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
10935 l_rec_acct_attrs.array_char_value(21) := p_source_21;
10936 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
10937 l_rec_acct_attrs.array_num_value(22) := p_source_27;
10938 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
10939 l_rec_acct_attrs.array_num_value(23) := p_source_22;
10940 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
10941 l_rec_acct_attrs.array_num_value(24) := p_source_22;
10942
10943 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
10944 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
10945
10946 ---------------------------------------------------------------------------------------------------------------
10947 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
10948 ---------------------------------------------------------------------------------------------------------------
10949 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
10950
10951 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10952 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10953
10954 IF xla_accounting_cache_pkg.GetValueChar
10955 (p_source_code => 'LEDGER_CATEGORY_CODE'
10956 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
10957 AND l_bflow_method_code = 'PRIOR_ENTRY'
10958 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
10959 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
10960 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
10961 )
10962 THEN
10963 xla_ae_lines_pkg.BflowUpgEntry
10964 (p_business_method_code => l_bflow_method_code
10965 ,p_business_class_code => l_bflow_class_code
10966 ,p_balance_type => l_balance_type_code);
10967 ELSE
10968 NULL;
10969 -- No business flow processing for business flow method of NONE.
10970 END IF;
10971
10972 --
10973 -- call analytical criteria
10974 --
10975
10976 --
10977 -- call description
10978 --
10979 -- No description or it is inherited.
10980 --
10981 -- call ADRs
10982 -- Bug 4922099
10983 --
10984 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10985 (NVL(l_actual_upg_option, 'N') = 'O') OR
10986 (NVL(l_enc_upg_option, 'N') = 'O')
10987 )
10988 THEN
10989 NULL;
10990 --
10991 --
10992
10993 l_ccid := AcctDerRule_11(
10994 p_application_id => p_application_id
10995 , p_ae_header_id => l_ae_header_id
10996 , p_source_3 => p_source_3
10997 , x_transaction_coa_id => l_adr_transaction_coa_id
10998 , x_accounting_coa_id => l_adr_accounting_coa_id
10999 , x_value_type_code => l_adr_value_type_code
11000 , p_side => 'NA'
11001 );
11002
11003 xla_ae_lines_pkg.set_ccid(
11004 p_code_combination_id => l_ccid
11005 , p_value_type_code => l_adr_value_type_code
11006 , p_transaction_coa_id => l_adr_transaction_coa_id
11007 , p_accounting_coa_id => l_adr_accounting_coa_id
11008 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
11009 , p_adr_type_code => 'S'
11010 , p_component_type => l_component_type
11011 , p_component_code => l_component_code
11012 , p_component_type_code => l_component_type_code
11013 , p_component_appl_id => l_component_appl_id
11014 , p_amb_context_code => l_amb_context_code
11015 , p_side => 'NA'
11016 );
11017
11018
11019 l_segment := AcctDerRule_7(
11020 p_application_id => p_application_id
11021 , p_ae_header_id => l_ae_header_id
11022 , x_transaction_coa_id => l_adr_transaction_coa_id
11023 , x_accounting_coa_id => l_adr_accounting_coa_id
11024 , x_flexfield_segment_code => l_adr_flexfield_segment_code
11025 , x_flex_value_set_id => l_adr_flex_value_set_id
11026 , x_value_type_code => l_adr_value_type_code
11027 , x_value_combination_id => l_adr_value_combination_id
11028 , x_value_segment_code => l_adr_value_segment_code
11029 , p_side => 'NA'
11030 , p_override_seg_flag => 'Y'
11031 );
11032
11033 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
11034
11035 xla_ae_lines_pkg.set_segment(
11036 p_to_segment_code => 'GL_ACCOUNT'
11037 , p_segment_value => l_segment
11038 , p_from_segment_code => l_adr_value_segment_code
11039 , p_from_combination_id => l_adr_value_combination_id
11040 , p_value_type_code => l_adr_value_type_code
11041 , p_transaction_coa_id => l_adr_transaction_coa_id
11042 , p_accounting_coa_id => l_adr_accounting_coa_id
11043 , p_flexfield_segment_code => l_adr_flexfield_segment_code
11044 , p_flex_value_set_id => l_adr_flex_value_set_id
11045 , p_adr_code => 'FV_487101'
11046 , p_adr_type_code => 'S'
11047 , p_component_type => l_component_type
11048 , p_component_code => l_component_code
11049 , p_component_type_code => l_component_type_code
11050 , p_component_appl_id => l_component_appl_id
11051 , p_amb_context_code => l_amb_context_code
11052 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
11053 , p_event_class_code => 'PURCHASE_ORDER'
11054 , p_side => 'NA'
11055 );
11056
11057 END IF;
11058
11059 --
11060 --
11061 END IF;
11062 --
11063 -- Bug 4922099
11064 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
11065 (NVL(l_enc_upg_option, 'N') = 'O')
11066 ) AND
11067 (l_bflow_method_code = 'PRIOR_ENTRY')
11068 )
11069 THEN
11070 IF
11071 --
11072 1 = 2
11073 --
11074 THEN
11075 xla_accounting_err_pkg.build_message
11076 (p_appli_s_name => 'XLA'
11077 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11078 ,p_token_1 => 'LINE_NUMBER'
11079 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
11080 ,p_token_2 => 'LINE_TYPE_NAME'
11081 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
11082 l_component_type
11083 ,l_component_code
11084 ,l_component_type_code
11085 ,l_component_appl_id
11086 ,l_amb_context_code
11087 ,l_entity_code
11088 ,l_event_class_code
11089 )
11090 ,p_token_3 => 'OWNER'
11091 ,p_value_3 => xla_lookups_pkg.get_meaning(
11092 p_lookup_type => 'XLA_OWNER_TYPE'
11093 ,p_lookup_code => l_component_type_code
11094 )
11095 ,p_token_4 => 'PRODUCT_NAME'
11096 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
11097 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
11098 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
11099 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
11100 ,p_ae_header_id => NULL
11101 );
11102
11103 IF (C_LEVEL_ERROR>= g_log_level) THEN
11104 trace
11105 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11106 ,p_level => C_LEVEL_ERROR
11107 ,p_module => l_log_module);
11108 END IF;
11109 END IF;
11110 END IF;
11111 --
11112 --
11113 ------------------------------------------------------------------------------------------------
11114 -- 4219869 Business Flow
11115 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
11116 -- Prior Entry. Currently, the following code is always generated.
11117 ------------------------------------------------------------------------------------------------
11118 XLA_AE_LINES_PKG.ValidateCurrentLine;
11119
11120 ------------------------------------------------------------------------------------
11121 -- 4219869 Business Flow
11122 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
11123 ------------------------------------------------------------------------------------
11124 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11125
11126 ----------------------------------------------------------------------------------
11127 -- 4219869 Business Flow
11128 -- Update journal entry status -- Need to generate this within IF <condition>
11129 ----------------------------------------------------------------------------------
11130 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11131 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
11132 ,p_balance_type_code => l_balance_type_code
11133 );
11134
11135 -------------------------------------------------------------------------------------------
11136 -- 4262811 - Generate the Accrual Reversal lines
11137 -------------------------------------------------------------------------------------------
11138 BEGIN
11139 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
11140 (g_array_event(p_event_id).array_value_num('header_index'));
11141 IF l_acc_rev_flag IS NULL THEN
11142 l_acc_rev_flag := 'N';
11143 END IF;
11144 EXCEPTION
11145 WHEN OTHERS THEN
11146 l_acc_rev_flag := 'N';
11147 END;
11148 --
11149 IF (l_acc_rev_flag = 'Y') THEN
11150
11151 -- 4645092 ------------------------------------------------------------------------------
11152 -- To allow MPA report to determine if it should generate report process
11153 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
11154 ------------------------------------------------------------------------------------------
11155
11156 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
11157 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
11158 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
11159 -- call ADRs
11160 -- Bug 4922099
11161 --
11162 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11163 (NVL(l_actual_upg_option, 'N') = 'O') OR
11164 (NVL(l_enc_upg_option, 'N') = 'O')
11165 )
11166 THEN
11167 NULL;
11168 --
11169 --
11170
11171 l_ccid := AcctDerRule_11(
11172 p_application_id => p_application_id
11173 , p_ae_header_id => l_ae_header_id
11174 , p_source_3 => p_source_3
11175 , x_transaction_coa_id => l_adr_transaction_coa_id
11176 , x_accounting_coa_id => l_adr_accounting_coa_id
11177 , x_value_type_code => l_adr_value_type_code
11178 , p_side => 'NA'
11179 );
11180
11181 xla_ae_lines_pkg.set_ccid(
11182 p_code_combination_id => l_ccid
11183 , p_value_type_code => l_adr_value_type_code
11184 , p_transaction_coa_id => l_adr_transaction_coa_id
11185 , p_accounting_coa_id => l_adr_accounting_coa_id
11186 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
11187 , p_adr_type_code => 'S'
11188 , p_component_type => l_component_type
11189 , p_component_code => l_component_code
11190 , p_component_type_code => l_component_type_code
11191 , p_component_appl_id => l_component_appl_id
11192 , p_amb_context_code => l_amb_context_code
11193 , p_side => 'NA'
11194 );
11195
11196
11197 l_segment := AcctDerRule_7(
11198 p_application_id => p_application_id
11199 , p_ae_header_id => l_ae_header_id
11200 , x_transaction_coa_id => l_adr_transaction_coa_id
11201 , x_accounting_coa_id => l_adr_accounting_coa_id
11202 , x_flexfield_segment_code => l_adr_flexfield_segment_code
11203 , x_flex_value_set_id => l_adr_flex_value_set_id
11204 , x_value_type_code => l_adr_value_type_code
11205 , x_value_combination_id => l_adr_value_combination_id
11206 , x_value_segment_code => l_adr_value_segment_code
11207 , p_side => 'NA'
11208 , p_override_seg_flag => 'Y'
11209 );
11210
11211 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
11212
11213 xla_ae_lines_pkg.set_segment(
11214 p_to_segment_code => 'GL_ACCOUNT'
11215 , p_segment_value => l_segment
11216 , p_from_segment_code => l_adr_value_segment_code
11217 , p_from_combination_id => l_adr_value_combination_id
11218 , p_value_type_code => l_adr_value_type_code
11219 , p_transaction_coa_id => l_adr_transaction_coa_id
11220 , p_accounting_coa_id => l_adr_accounting_coa_id
11221 , p_flexfield_segment_code => l_adr_flexfield_segment_code
11222 , p_flex_value_set_id => l_adr_flex_value_set_id
11223 , p_adr_code => 'FV_487101'
11224 , p_adr_type_code => 'S'
11225 , p_component_type => l_component_type
11226 , p_component_code => l_component_code
11227 , p_component_type_code => l_component_type_code
11228 , p_component_appl_id => l_component_appl_id
11229 , p_amb_context_code => l_amb_context_code
11230 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
11231 , p_event_class_code => 'PURCHASE_ORDER'
11232 , p_side => 'NA'
11233 );
11234
11235 END IF;
11236
11237 --
11238 --
11239 END IF;
11240
11241 --
11242 -- Update the line information that should be overwritten
11243 --
11244 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
11245 p_header_num => 1);
11246 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
11247
11248 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
11249
11250 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
11251 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
11252 END IF;
11253
11254 --
11255 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
11256 --
11257 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
11258 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
11259 ELSE
11260 ---------------------------------------------------------------------------------------------------
11261 -- 4262811a Switch Sign
11262 ---------------------------------------------------------------------------------------------------
11263 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
11264 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11265 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11266 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11267 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11268 -- 5132302
11269 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
11270 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11271
11272 END IF;
11273
11274 -- 4955764
11275 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11276 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
11277
11278
11279 XLA_AE_LINES_PKG.ValidateCurrentLine;
11280 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11281
11282 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11283 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
11284 ,p_balance_type_code => l_balance_type_code);
11285
11286 END IF;
11287
11288 -----------------------------------------------------------------------------------------
11289 -- 4262811 Multiperiod Accounting
11290 -----------------------------------------------------------------------------------------
11291 -- No MPA option is assigned.
11292
11293
11294 END IF;
11295 END IF;
11296 --
11297
11298 --
11299 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11300 trace
11301 (p_msg => 'END of AcctLineType_25'
11302 ,p_level => C_LEVEL_PROCEDURE
11303 ,p_module => l_log_module);
11304 END IF;
11305 --
11306 EXCEPTION
11307 WHEN xla_exceptions_pkg.application_exception THEN
11308 RAISE;
11309 WHEN OTHERS THEN
11310 xla_exceptions_pkg.raise_message
11311 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_25');
11312 END AcctLineType_25;
11313 --
11314
11315 ---------------------------------------
11316 --
11317 -- PRIVATE FUNCTION
11318 -- AcctLineType_26
11319 --
11320 ---------------------------------------
11321 PROCEDURE AcctLineType_26 (
11322 p_application_id IN NUMBER
11323 ,p_event_id IN NUMBER
11324 ,p_calculate_acctd_flag IN VARCHAR2
11325 ,p_calculate_g_l_flag IN VARCHAR2
11326 ,p_actual_flag IN OUT VARCHAR2
11327 ,p_balance_type_code OUT VARCHAR2
11328 ,p_gain_or_loss_ref OUT VARCHAR2
11329
11330 --PO Budget Account
11331 , p_source_3 IN NUMBER
11332 --Federal Prior Year Flag
11333 , p_source_5 IN VARCHAR2
11334 --Receiving Accounting Line Type
11335 , p_source_6 IN VARCHAR2
11336 --Applied to Application ID
11337 , p_source_7 IN NUMBER
11338 --Applied to Distribution Link Type
11339 , p_source_8 IN VARCHAR2
11340 --Applied to Entity Code
11341 , p_source_9 IN VARCHAR2
11342 --PO_DISTRIBUTION_ID
11343 , p_source_10 IN NUMBER
11344 --Applied To Purchase Document Identifier
11345 , p_source_11 IN NUMBER
11346 --DISTRIBUTION_IDENTIFIER
11347 , p_source_12 IN NUMBER
11348 --Distribution Type
11349 , p_source_13 IN VARCHAR2
11350 , p_source_13_meaning IN VARCHAR2
11351 --Encumbrance Reversal Amount Entered
11352 , p_source_14 IN NUMBER
11353 --Entered Currency Code
11354 , p_source_15 IN VARCHAR2
11355 --Transaction Encumbrance Reversal Amount
11356 , p_source_16 IN NUMBER
11357 --Costing Encumbrance Upgrade Option
11358 , p_source_17 IN VARCHAR2
11359 --Currency Conversion Date
11360 , p_source_19 IN DATE
11361 --Currency Conversion Rate
11362 , p_source_20 IN NUMBER
11363 --Currency Conversion Type
11364 , p_source_21 IN VARCHAR2
11365 --Purchasing Encumbrance Type Identifier
11366 , p_source_22 IN NUMBER
11367 --Federal Net Pya Adj Amt
11368 , p_source_27 IN NUMBER
11369 )
11370 IS
11371
11372 l_component_type VARCHAR2(80);
11373 l_component_code VARCHAR2(30);
11374 l_component_type_code VARCHAR2(1);
11375 l_component_appl_id INTEGER;
11376 l_amb_context_code VARCHAR2(30);
11377 l_entity_code VARCHAR2(30);
11378 l_event_class_code VARCHAR2(30);
11379 l_ae_header_id NUMBER;
11380 l_event_type_code VARCHAR2(30);
11381 l_line_definition_code VARCHAR2(30);
11382 l_line_definition_owner_code VARCHAR2(1);
11383 --
11384 -- adr variables
11385 l_segment VARCHAR2(30);
11386 l_ccid NUMBER;
11387 l_adr_transaction_coa_id NUMBER;
11388 l_adr_accounting_coa_id NUMBER;
11389 l_adr_flexfield_segment_code VARCHAR2(30);
11390 l_adr_flex_value_set_id NUMBER;
11391 l_adr_value_type_code VARCHAR2(30);
11392 l_adr_value_combination_id NUMBER;
11393 l_adr_value_segment_code VARCHAR2(30);
11394
11395 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
11396 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
11397 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
11398 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
11399
11400 -- 4262811 Variables ------------------------------------------------------------------------------------------
11401 l_entered_amt_idx NUMBER;
11402 l_accted_amt_idx NUMBER;
11403 l_acc_rev_flag VARCHAR2(1);
11404 l_accrual_line_num NUMBER;
11405 l_tmp_amt NUMBER;
11406 l_acc_rev_natural_side_code VARCHAR2(1);
11407
11408 l_num_entries NUMBER;
11409 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
11410 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
11411 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
11412 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
11413 l_recog_line_1 NUMBER;
11414 l_recog_line_2 NUMBER;
11415
11416 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
11417 l_bflow_applied_to_amt NUMBER; -- 5132302
11418 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
11419
11420 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
11421
11422 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
11423 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
11424
11425 ---------------------------------------------------------------------------------------------------------------
11426
11427
11428 --
11429 -- bulk performance
11430 --
11431 l_balance_type_code VARCHAR2(1);
11432 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
11433 l_log_module VARCHAR2(240);
11434
11435 --
11436 -- Upgrade strategy
11437 --
11438 l_actual_upg_option VARCHAR2(1);
11439 l_enc_upg_option VARCHAR2(1);
11440
11441 --
11442 BEGIN
11443 --
11444 IF g_log_enabled THEN
11445 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_26';
11446 END IF;
11447 --
11448 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11449
11450 trace
11451 (p_msg => 'BEGIN of AcctLineType_26'
11452 ,p_level => C_LEVEL_PROCEDURE
11453 ,p_module => l_log_module);
11454
11455 END IF;
11456 --
11457 l_component_type := 'AMB_JLT';
11458 l_component_code := 'FV_REC_UPWARD_PYA_CR';
11459 l_component_type_code := 'S';
11460 l_component_appl_id := 707;
11461 l_amb_context_code := 'DEFAULT';
11462 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
11463 l_event_class_code := 'DELIVER_EXPENSE';
11464 l_event_type_code := 'DELIVER_EXPENSE_ALL';
11465 l_line_definition_owner_code := 'S';
11466 l_line_definition_code := 'FV_DELIVER_EXPENSE';
11467 --
11468 l_balance_type_code := 'A';
11469 l_segment := NULL;
11470 l_ccid := NULL;
11471 l_adr_transaction_coa_id := NULL;
11472 l_adr_accounting_coa_id := NULL;
11473 l_adr_flexfield_segment_code := NULL;
11474 l_adr_flex_value_set_id := NULL;
11475 l_adr_value_type_code := NULL;
11476 l_adr_value_combination_id := NULL;
11477 l_adr_value_segment_code := NULL;
11478
11479 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
11480 l_bflow_class_code := ''; -- 4219869 Business Flow
11481 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
11482 l_budgetary_control_flag := 'Y';
11483
11484 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11485 l_bflow_applied_to_amt := NULL; -- 5132302
11486 l_entered_amt_idx := NULL; -- 4262811
11487 l_accted_amt_idx := NULL; -- 4262811
11488 l_acc_rev_flag := NULL; -- 4262811
11489 l_accrual_line_num := NULL; -- 4262811
11490 l_tmp_amt := NULL; -- 4262811
11491 --
11492
11493 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
11494 l_balance_type_code <> 'B' THEN
11495 IF NVL(p_source_5,'
11496 ') = 'Y' AND
11497 NVL(
11498 xla_ae_sources_pkg.GetSystemSourceChar(
11499 p_source_code => 'XLA_EVENT_TYPE_CODE'
11500 , p_source_type_code => 'Y'
11501 , p_source_application_id => 602
11502 ),'
11503 ') = 'DELIVER_EXPENSE' AND
11504 NVL(p_source_6,'
11505 ') = 'Charge'
11506 THEN
11507
11508 --
11509 XLA_AE_LINES_PKG.SetNewLine;
11510
11511 p_balance_type_code := l_balance_type_code;
11512 -- set the flag so later we will know whether the gain loss line needs to be created
11513
11514 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
11515 p_actual_flag :='A';
11516 END IF;
11517
11518 --
11519 -- bulk performance
11520 --
11521 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
11522 p_header_num => 0); -- 4262811
11523 --
11524 -- set accounting line options
11525 --
11526 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
11527 p_natural_side_code => 'C'
11528 , p_gain_or_loss_flag => 'N'
11529 , p_gl_transfer_mode_code => 'S'
11530 , p_acct_entry_type_code => 'A'
11531 , p_switch_side_flag => 'N'
11532 , p_merge_duplicate_code => 'N'
11533 );
11534 --
11535 l_acc_rev_natural_side_code := 'D'; -- 4262811
11536 --
11537 --
11538 -- set accounting line type info
11539 --
11540 xla_ae_lines_pkg.SetAcctLineType
11541 (p_component_type => l_component_type
11542 ,p_event_type_code => l_event_type_code
11543 ,p_line_definition_owner_code => l_line_definition_owner_code
11544 ,p_line_definition_code => l_line_definition_code
11545 ,p_accounting_line_code => l_component_code
11546 ,p_accounting_line_type_code => l_component_type_code
11547 ,p_accounting_line_appl_id => l_component_appl_id
11548 ,p_amb_context_code => l_amb_context_code
11549 ,p_entity_code => l_entity_code
11550 ,p_event_class_code => l_event_class_code);
11551 --
11552 -- set accounting class
11553 --
11554 xla_ae_lines_pkg.SetAcctClass(
11555 p_accounting_class_code => 'FEDERAL_EXP'
11556 , p_ae_header_id => l_ae_header_id
11557 );
11558
11559 --
11560 -- set rounding class
11561 --
11562 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
11563 'FEDERAL_EXP';
11564
11565 --
11566 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
11567 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
11568 --
11569 -- bulk performance
11570 --
11571 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
11572
11573 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
11574 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
11575
11576 -- 4955764
11577 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11578 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
11579
11580 -- 4458381 Public Sector Enh
11581
11582 --
11583 -- set accounting attributes for the line type
11584 --
11585 l_entered_amt_idx := 17;
11586 l_accted_amt_idx := 22;
11587 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11588 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
11589 l_rec_acct_attrs.array_num_value(1) := p_source_7;
11590 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
11591 l_rec_acct_attrs.array_char_value(2) := p_source_8;
11592 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
11593 l_rec_acct_attrs.array_char_value(3) := p_source_9;
11594 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
11595 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
11596 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
11597 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
11598 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
11599 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
11600 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
11601 l_rec_acct_attrs.array_char_value(7) := p_source_13;
11602 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
11603 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
11604 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
11605 l_rec_acct_attrs.array_num_value(9) := p_source_14;
11606 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
11607 l_rec_acct_attrs.array_char_value(10) := p_source_15;
11608 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
11609 l_rec_acct_attrs.array_num_value(11) := p_source_16;
11610 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
11611 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
11612 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
11613 l_rec_acct_attrs.array_num_value(13) := p_source_14;
11614 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
11615 l_rec_acct_attrs.array_char_value(14) := p_source_15;
11616 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
11617 l_rec_acct_attrs.array_num_value(15) := p_source_16;
11618 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
11619 l_rec_acct_attrs.array_char_value(16) := p_source_17;
11620 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
11621 l_rec_acct_attrs.array_num_value(17) := p_source_27;
11622 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
11623 l_rec_acct_attrs.array_char_value(18) := p_source_15;
11624 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
11625 l_rec_acct_attrs.array_date_value(19) := p_source_19;
11626 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
11627 l_rec_acct_attrs.array_num_value(20) := p_source_20;
11628 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
11629 l_rec_acct_attrs.array_char_value(21) := p_source_21;
11630 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
11631 l_rec_acct_attrs.array_num_value(22) := p_source_27;
11632 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
11633 l_rec_acct_attrs.array_num_value(23) := p_source_22;
11634 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
11635 l_rec_acct_attrs.array_num_value(24) := p_source_22;
11636
11637 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
11638 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
11639
11640 ---------------------------------------------------------------------------------------------------------------
11641 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
11642 ---------------------------------------------------------------------------------------------------------------
11643 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
11644
11645 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11646 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11647
11648 IF xla_accounting_cache_pkg.GetValueChar
11649 (p_source_code => 'LEDGER_CATEGORY_CODE'
11650 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
11651 AND l_bflow_method_code = 'PRIOR_ENTRY'
11652 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
11653 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
11654 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
11655 )
11656 THEN
11657 xla_ae_lines_pkg.BflowUpgEntry
11658 (p_business_method_code => l_bflow_method_code
11659 ,p_business_class_code => l_bflow_class_code
11660 ,p_balance_type => l_balance_type_code);
11661 ELSE
11662 NULL;
11663 -- No business flow processing for business flow method of NONE.
11664 END IF;
11665
11666 --
11667 -- call analytical criteria
11668 --
11669
11670 --
11671 -- call description
11672 --
11673 -- No description or it is inherited.
11674 --
11675 -- call ADRs
11676 -- Bug 4922099
11677 --
11678 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11679 (NVL(l_actual_upg_option, 'N') = 'O') OR
11680 (NVL(l_enc_upg_option, 'N') = 'O')
11681 )
11682 THEN
11683 NULL;
11684 --
11685 --
11686
11687 l_ccid := AcctDerRule_11(
11688 p_application_id => p_application_id
11689 , p_ae_header_id => l_ae_header_id
11690 , p_source_3 => p_source_3
11691 , x_transaction_coa_id => l_adr_transaction_coa_id
11692 , x_accounting_coa_id => l_adr_accounting_coa_id
11693 , x_value_type_code => l_adr_value_type_code
11694 , p_side => 'NA'
11695 );
11696
11697 xla_ae_lines_pkg.set_ccid(
11698 p_code_combination_id => l_ccid
11699 , p_value_type_code => l_adr_value_type_code
11700 , p_transaction_coa_id => l_adr_transaction_coa_id
11701 , p_accounting_coa_id => l_adr_accounting_coa_id
11702 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
11703 , p_adr_type_code => 'S'
11704 , p_component_type => l_component_type
11705 , p_component_code => l_component_code
11706 , p_component_type_code => l_component_type_code
11707 , p_component_appl_id => l_component_appl_id
11708 , p_amb_context_code => l_amb_context_code
11709 , p_side => 'NA'
11710 );
11711
11712
11713 l_segment := AcctDerRule_8(
11714 p_application_id => p_application_id
11715 , p_ae_header_id => l_ae_header_id
11716 , x_transaction_coa_id => l_adr_transaction_coa_id
11717 , x_accounting_coa_id => l_adr_accounting_coa_id
11718 , x_flexfield_segment_code => l_adr_flexfield_segment_code
11719 , x_flex_value_set_id => l_adr_flex_value_set_id
11720 , x_value_type_code => l_adr_value_type_code
11721 , x_value_combination_id => l_adr_value_combination_id
11722 , x_value_segment_code => l_adr_value_segment_code
11723 , p_side => 'NA'
11724 , p_override_seg_flag => 'Y'
11725 );
11726
11727 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
11728
11729 xla_ae_lines_pkg.set_segment(
11730 p_to_segment_code => 'GL_ACCOUNT'
11731 , p_segment_value => l_segment
11732 , p_from_segment_code => l_adr_value_segment_code
11733 , p_from_combination_id => l_adr_value_combination_id
11734 , p_value_type_code => l_adr_value_type_code
11735 , p_transaction_coa_id => l_adr_transaction_coa_id
11736 , p_accounting_coa_id => l_adr_accounting_coa_id
11737 , p_flexfield_segment_code => l_adr_flexfield_segment_code
11738 , p_flex_value_set_id => l_adr_flex_value_set_id
11739 , p_adr_code => 'FV_488101'
11740 , p_adr_type_code => 'S'
11741 , p_component_type => l_component_type
11742 , p_component_code => l_component_code
11743 , p_component_type_code => l_component_type_code
11744 , p_component_appl_id => l_component_appl_id
11745 , p_amb_context_code => l_amb_context_code
11746 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
11747 , p_event_class_code => 'DELIVER_EXPENSE'
11748 , p_side => 'NA'
11749 );
11750
11751 END IF;
11752
11753 --
11754 --
11755 END IF;
11756 --
11757 -- Bug 4922099
11758 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
11759 (NVL(l_enc_upg_option, 'N') = 'O')
11760 ) AND
11761 (l_bflow_method_code = 'PRIOR_ENTRY')
11762 )
11763 THEN
11764 IF
11765 --
11766 1 = 2
11767 --
11768 THEN
11769 xla_accounting_err_pkg.build_message
11770 (p_appli_s_name => 'XLA'
11771 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11772 ,p_token_1 => 'LINE_NUMBER'
11773 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
11774 ,p_token_2 => 'LINE_TYPE_NAME'
11775 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
11776 l_component_type
11777 ,l_component_code
11778 ,l_component_type_code
11779 ,l_component_appl_id
11780 ,l_amb_context_code
11781 ,l_entity_code
11782 ,l_event_class_code
11783 )
11784 ,p_token_3 => 'OWNER'
11785 ,p_value_3 => xla_lookups_pkg.get_meaning(
11786 p_lookup_type => 'XLA_OWNER_TYPE'
11787 ,p_lookup_code => l_component_type_code
11788 )
11789 ,p_token_4 => 'PRODUCT_NAME'
11790 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
11791 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
11792 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
11793 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
11794 ,p_ae_header_id => NULL
11795 );
11796
11797 IF (C_LEVEL_ERROR>= g_log_level) THEN
11798 trace
11799 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11800 ,p_level => C_LEVEL_ERROR
11801 ,p_module => l_log_module);
11802 END IF;
11803 END IF;
11804 END IF;
11805 --
11806 --
11807 ------------------------------------------------------------------------------------------------
11808 -- 4219869 Business Flow
11809 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
11810 -- Prior Entry. Currently, the following code is always generated.
11811 ------------------------------------------------------------------------------------------------
11812 XLA_AE_LINES_PKG.ValidateCurrentLine;
11813
11814 ------------------------------------------------------------------------------------
11815 -- 4219869 Business Flow
11816 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
11817 ------------------------------------------------------------------------------------
11818 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11819
11820 ----------------------------------------------------------------------------------
11821 -- 4219869 Business Flow
11822 -- Update journal entry status -- Need to generate this within IF <condition>
11823 ----------------------------------------------------------------------------------
11824 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11825 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
11826 ,p_balance_type_code => l_balance_type_code
11827 );
11828
11829 -------------------------------------------------------------------------------------------
11830 -- 4262811 - Generate the Accrual Reversal lines
11831 -------------------------------------------------------------------------------------------
11832 BEGIN
11833 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
11834 (g_array_event(p_event_id).array_value_num('header_index'));
11835 IF l_acc_rev_flag IS NULL THEN
11836 l_acc_rev_flag := 'N';
11837 END IF;
11838 EXCEPTION
11839 WHEN OTHERS THEN
11840 l_acc_rev_flag := 'N';
11841 END;
11842 --
11843 IF (l_acc_rev_flag = 'Y') THEN
11844
11845 -- 4645092 ------------------------------------------------------------------------------
11846 -- To allow MPA report to determine if it should generate report process
11847 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
11848 ------------------------------------------------------------------------------------------
11849
11850 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
11851 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
11852 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
11853 -- call ADRs
11854 -- Bug 4922099
11855 --
11856 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11857 (NVL(l_actual_upg_option, 'N') = 'O') OR
11858 (NVL(l_enc_upg_option, 'N') = 'O')
11859 )
11860 THEN
11861 NULL;
11862 --
11863 --
11864
11865 l_ccid := AcctDerRule_11(
11866 p_application_id => p_application_id
11867 , p_ae_header_id => l_ae_header_id
11868 , p_source_3 => p_source_3
11869 , x_transaction_coa_id => l_adr_transaction_coa_id
11870 , x_accounting_coa_id => l_adr_accounting_coa_id
11871 , x_value_type_code => l_adr_value_type_code
11872 , p_side => 'NA'
11873 );
11874
11875 xla_ae_lines_pkg.set_ccid(
11876 p_code_combination_id => l_ccid
11877 , p_value_type_code => l_adr_value_type_code
11878 , p_transaction_coa_id => l_adr_transaction_coa_id
11879 , p_accounting_coa_id => l_adr_accounting_coa_id
11880 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
11881 , p_adr_type_code => 'S'
11882 , p_component_type => l_component_type
11883 , p_component_code => l_component_code
11884 , p_component_type_code => l_component_type_code
11885 , p_component_appl_id => l_component_appl_id
11886 , p_amb_context_code => l_amb_context_code
11887 , p_side => 'NA'
11888 );
11889
11890
11891 l_segment := AcctDerRule_8(
11892 p_application_id => p_application_id
11893 , p_ae_header_id => l_ae_header_id
11894 , x_transaction_coa_id => l_adr_transaction_coa_id
11895 , x_accounting_coa_id => l_adr_accounting_coa_id
11896 , x_flexfield_segment_code => l_adr_flexfield_segment_code
11897 , x_flex_value_set_id => l_adr_flex_value_set_id
11898 , x_value_type_code => l_adr_value_type_code
11899 , x_value_combination_id => l_adr_value_combination_id
11900 , x_value_segment_code => l_adr_value_segment_code
11901 , p_side => 'NA'
11902 , p_override_seg_flag => 'Y'
11903 );
11904
11905 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
11906
11907 xla_ae_lines_pkg.set_segment(
11908 p_to_segment_code => 'GL_ACCOUNT'
11909 , p_segment_value => l_segment
11910 , p_from_segment_code => l_adr_value_segment_code
11911 , p_from_combination_id => l_adr_value_combination_id
11912 , p_value_type_code => l_adr_value_type_code
11913 , p_transaction_coa_id => l_adr_transaction_coa_id
11914 , p_accounting_coa_id => l_adr_accounting_coa_id
11915 , p_flexfield_segment_code => l_adr_flexfield_segment_code
11916 , p_flex_value_set_id => l_adr_flex_value_set_id
11917 , p_adr_code => 'FV_488101'
11918 , p_adr_type_code => 'S'
11919 , p_component_type => l_component_type
11920 , p_component_code => l_component_code
11921 , p_component_type_code => l_component_type_code
11922 , p_component_appl_id => l_component_appl_id
11923 , p_amb_context_code => l_amb_context_code
11924 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
11925 , p_event_class_code => 'DELIVER_EXPENSE'
11926 , p_side => 'NA'
11927 );
11928
11929 END IF;
11930
11931 --
11932 --
11933 END IF;
11934
11935 --
11936 -- Update the line information that should be overwritten
11937 --
11938 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
11939 p_header_num => 1);
11940 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
11941
11942 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
11943
11944 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
11945 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
11946 END IF;
11947
11948 --
11949 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
11950 --
11951 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
11952 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
11953 ELSE
11954 ---------------------------------------------------------------------------------------------------
11955 -- 4262811a Switch Sign
11956 ---------------------------------------------------------------------------------------------------
11957 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
11958 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11959 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11960 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11961 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11962 -- 5132302
11963 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
11964 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11965
11966 END IF;
11967
11968 -- 4955764
11969 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11970 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
11971
11972
11973 XLA_AE_LINES_PKG.ValidateCurrentLine;
11974 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11975
11976 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11977 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
11978 ,p_balance_type_code => l_balance_type_code);
11979
11980 END IF;
11981
11982 -----------------------------------------------------------------------------------------
11983 -- 4262811 Multiperiod Accounting
11984 -----------------------------------------------------------------------------------------
11985 -- No MPA option is assigned.
11986
11987
11988 END IF;
11989 END IF;
11990 --
11991
11992 --
11993 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11994 trace
11995 (p_msg => 'END of AcctLineType_26'
11996 ,p_level => C_LEVEL_PROCEDURE
11997 ,p_module => l_log_module);
11998 END IF;
11999 --
12000 EXCEPTION
12001 WHEN xla_exceptions_pkg.application_exception THEN
12002 RAISE;
12003 WHEN OTHERS THEN
12004 xla_exceptions_pkg.raise_message
12005 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_26');
12006 END AcctLineType_26;
12007 --
12008
12009 ---------------------------------------
12010 --
12011 -- PRIVATE FUNCTION
12012 -- AcctLineType_27
12013 --
12014 ---------------------------------------
12015 PROCEDURE AcctLineType_27 (
12016 p_application_id IN NUMBER
12017 ,p_event_id IN NUMBER
12018 ,p_calculate_acctd_flag IN VARCHAR2
12019 ,p_calculate_g_l_flag IN VARCHAR2
12020 ,p_actual_flag IN OUT VARCHAR2
12021 ,p_balance_type_code OUT VARCHAR2
12022 ,p_gain_or_loss_ref OUT VARCHAR2
12023
12024 --PO Budget Account
12025 , p_source_3 IN NUMBER
12026 --Federal Prior Year Flag
12027 , p_source_5 IN VARCHAR2
12028 --Applied to Application ID
12029 , p_source_7 IN NUMBER
12030 --Applied to Distribution Link Type
12031 , p_source_8 IN VARCHAR2
12032 --Applied to Entity Code
12033 , p_source_9 IN VARCHAR2
12034 --Applied To Purchase Document Identifier
12035 , p_source_11 IN NUMBER
12036 --DISTRIBUTION_IDENTIFIER
12037 , p_source_12 IN NUMBER
12038 --Distribution Type
12039 , p_source_13 IN VARCHAR2
12040 , p_source_13_meaning IN VARCHAR2
12041 --Encumbrance Reversal Amount Entered
12042 , p_source_14 IN NUMBER
12043 --Entered Currency Code
12044 , p_source_15 IN VARCHAR2
12045 --Transaction Encumbrance Reversal Amount
12046 , p_source_16 IN NUMBER
12047 --Costing Encumbrance Upgrade Option
12048 , p_source_17 IN VARCHAR2
12049 --Currency Conversion Date
12050 , p_source_19 IN DATE
12051 --Currency Conversion Rate
12052 , p_source_20 IN NUMBER
12053 --Currency Conversion Type
12054 , p_source_21 IN VARCHAR2
12055 --Purchasing Encumbrance Type Identifier
12056 , p_source_22 IN NUMBER
12057 --TXN_PO_DISTRIBUTION_ID
12058 , p_source_23 IN NUMBER
12059 --Federal Net Pya Adj Amt
12060 , p_source_27 IN NUMBER
12061 )
12062 IS
12063
12064 l_component_type VARCHAR2(80);
12065 l_component_code VARCHAR2(30);
12066 l_component_type_code VARCHAR2(1);
12067 l_component_appl_id INTEGER;
12068 l_amb_context_code VARCHAR2(30);
12069 l_entity_code VARCHAR2(30);
12070 l_event_class_code VARCHAR2(30);
12071 l_ae_header_id NUMBER;
12072 l_event_type_code VARCHAR2(30);
12073 l_line_definition_code VARCHAR2(30);
12074 l_line_definition_owner_code VARCHAR2(1);
12075 --
12076 -- adr variables
12077 l_segment VARCHAR2(30);
12078 l_ccid NUMBER;
12079 l_adr_transaction_coa_id NUMBER;
12080 l_adr_accounting_coa_id NUMBER;
12081 l_adr_flexfield_segment_code VARCHAR2(30);
12082 l_adr_flex_value_set_id NUMBER;
12083 l_adr_value_type_code VARCHAR2(30);
12084 l_adr_value_combination_id NUMBER;
12085 l_adr_value_segment_code VARCHAR2(30);
12086
12087 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
12088 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
12089 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
12090 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
12091
12092 -- 4262811 Variables ------------------------------------------------------------------------------------------
12093 l_entered_amt_idx NUMBER;
12094 l_accted_amt_idx NUMBER;
12095 l_acc_rev_flag VARCHAR2(1);
12096 l_accrual_line_num NUMBER;
12097 l_tmp_amt NUMBER;
12098 l_acc_rev_natural_side_code VARCHAR2(1);
12099
12100 l_num_entries NUMBER;
12101 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
12102 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
12103 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
12104 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
12105 l_recog_line_1 NUMBER;
12106 l_recog_line_2 NUMBER;
12107
12108 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
12109 l_bflow_applied_to_amt NUMBER; -- 5132302
12110 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
12111
12112 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
12113
12114 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
12115 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
12116
12117 ---------------------------------------------------------------------------------------------------------------
12118
12119
12120 --
12121 -- bulk performance
12122 --
12123 l_balance_type_code VARCHAR2(1);
12124 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
12125 l_log_module VARCHAR2(240);
12126
12127 --
12128 -- Upgrade strategy
12129 --
12130 l_actual_upg_option VARCHAR2(1);
12131 l_enc_upg_option VARCHAR2(1);
12132
12133 --
12134 BEGIN
12135 --
12136 IF g_log_enabled THEN
12137 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_27';
12138 END IF;
12139 --
12140 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12141
12142 trace
12143 (p_msg => 'BEGIN of AcctLineType_27'
12144 ,p_level => C_LEVEL_PROCEDURE
12145 ,p_module => l_log_module);
12146
12147 END IF;
12148 --
12149 l_component_type := 'AMB_JLT';
12150 l_component_code := 'FV_REC_UPWARD_PYA_CR_DTI';
12151 l_component_type_code := 'S';
12152 l_component_appl_id := 707;
12153 l_amb_context_code := 'DEFAULT';
12154 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
12155 l_event_class_code := 'PURCHASE_ORDER';
12156 l_event_type_code := 'PURCHASE_ORDER_ALL';
12157 l_line_definition_owner_code := 'S';
12158 l_line_definition_code := 'FV_PO_DEL_INV';
12159 --
12160 l_balance_type_code := 'A';
12161 l_segment := NULL;
12162 l_ccid := NULL;
12163 l_adr_transaction_coa_id := NULL;
12164 l_adr_accounting_coa_id := NULL;
12165 l_adr_flexfield_segment_code := NULL;
12166 l_adr_flex_value_set_id := NULL;
12167 l_adr_value_type_code := NULL;
12168 l_adr_value_combination_id := NULL;
12169 l_adr_value_segment_code := NULL;
12170
12171 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
12172 l_bflow_class_code := ''; -- 4219869 Business Flow
12173 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
12174 l_budgetary_control_flag := 'Y';
12175
12176 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12177 l_bflow_applied_to_amt := NULL; -- 5132302
12178 l_entered_amt_idx := NULL; -- 4262811
12179 l_accted_amt_idx := NULL; -- 4262811
12180 l_acc_rev_flag := NULL; -- 4262811
12181 l_accrual_line_num := NULL; -- 4262811
12182 l_tmp_amt := NULL; -- 4262811
12183 --
12184
12185 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
12186 l_balance_type_code <> 'B' THEN
12187 IF NVL(
12188 xla_ae_sources_pkg.GetSystemSourceChar(
12189 p_source_code => 'XLA_EVENT_TYPE_CODE'
12190 , p_source_type_code => 'Y'
12191 , p_source_application_id => 602
12192 ),'
12193 ') = 'PO_DEL_INV' AND
12194 NVL(p_source_5,'
12195 ') = 'Y'
12196 THEN
12197
12198 --
12199 XLA_AE_LINES_PKG.SetNewLine;
12200
12201 p_balance_type_code := l_balance_type_code;
12202 -- set the flag so later we will know whether the gain loss line needs to be created
12203
12204 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
12205 p_actual_flag :='A';
12206 END IF;
12207
12208 --
12209 -- bulk performance
12210 --
12211 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
12212 p_header_num => 0); -- 4262811
12213 --
12214 -- set accounting line options
12215 --
12216 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
12217 p_natural_side_code => 'C'
12218 , p_gain_or_loss_flag => 'N'
12219 , p_gl_transfer_mode_code => 'S'
12220 , p_acct_entry_type_code => 'A'
12221 , p_switch_side_flag => 'N'
12222 , p_merge_duplicate_code => 'N'
12223 );
12224 --
12225 l_acc_rev_natural_side_code := 'D'; -- 4262811
12226 --
12227 --
12228 -- set accounting line type info
12229 --
12230 xla_ae_lines_pkg.SetAcctLineType
12231 (p_component_type => l_component_type
12232 ,p_event_type_code => l_event_type_code
12233 ,p_line_definition_owner_code => l_line_definition_owner_code
12234 ,p_line_definition_code => l_line_definition_code
12235 ,p_accounting_line_code => l_component_code
12236 ,p_accounting_line_type_code => l_component_type_code
12237 ,p_accounting_line_appl_id => l_component_appl_id
12238 ,p_amb_context_code => l_amb_context_code
12239 ,p_entity_code => l_entity_code
12240 ,p_event_class_code => l_event_class_code);
12241 --
12242 -- set accounting class
12243 --
12244 xla_ae_lines_pkg.SetAcctClass(
12245 p_accounting_class_code => 'FEDERAL_INV'
12246 , p_ae_header_id => l_ae_header_id
12247 );
12248
12249 --
12250 -- set rounding class
12251 --
12252 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
12253 'FEDERAL_INV';
12254
12255 --
12256 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
12257 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
12258 --
12259 -- bulk performance
12260 --
12261 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
12262
12263 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
12264 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
12265
12266 -- 4955764
12267 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12268 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
12269
12270 -- 4458381 Public Sector Enh
12271
12272 --
12273 -- set accounting attributes for the line type
12274 --
12275 l_entered_amt_idx := 17;
12276 l_accted_amt_idx := 22;
12277 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12278 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
12279 l_rec_acct_attrs.array_num_value(1) := p_source_7;
12280 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
12281 l_rec_acct_attrs.array_char_value(2) := p_source_8;
12282 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
12283 l_rec_acct_attrs.array_char_value(3) := p_source_9;
12284 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
12285 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
12286 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
12287 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
12288 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
12289 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
12290 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
12291 l_rec_acct_attrs.array_char_value(7) := p_source_13;
12292 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
12293 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
12294 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
12295 l_rec_acct_attrs.array_num_value(9) := p_source_14;
12296 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
12297 l_rec_acct_attrs.array_char_value(10) := p_source_15;
12298 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
12299 l_rec_acct_attrs.array_num_value(11) := p_source_16;
12300 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
12301 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
12302 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
12303 l_rec_acct_attrs.array_num_value(13) := p_source_14;
12304 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
12305 l_rec_acct_attrs.array_char_value(14) := p_source_15;
12306 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
12307 l_rec_acct_attrs.array_num_value(15) := p_source_16;
12308 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
12309 l_rec_acct_attrs.array_char_value(16) := p_source_17;
12310 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
12311 l_rec_acct_attrs.array_num_value(17) := p_source_27;
12312 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
12313 l_rec_acct_attrs.array_char_value(18) := p_source_15;
12314 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
12315 l_rec_acct_attrs.array_date_value(19) := p_source_19;
12316 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
12317 l_rec_acct_attrs.array_num_value(20) := p_source_20;
12318 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
12319 l_rec_acct_attrs.array_char_value(21) := p_source_21;
12320 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
12321 l_rec_acct_attrs.array_num_value(22) := p_source_27;
12322 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
12323 l_rec_acct_attrs.array_num_value(23) := p_source_22;
12324 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
12325 l_rec_acct_attrs.array_num_value(24) := p_source_22;
12326
12327 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
12328 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
12329
12330 ---------------------------------------------------------------------------------------------------------------
12331 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
12332 ---------------------------------------------------------------------------------------------------------------
12333 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
12334
12335 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12336 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12337
12338 IF xla_accounting_cache_pkg.GetValueChar
12339 (p_source_code => 'LEDGER_CATEGORY_CODE'
12340 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
12341 AND l_bflow_method_code = 'PRIOR_ENTRY'
12342 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
12343 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
12344 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
12345 )
12346 THEN
12347 xla_ae_lines_pkg.BflowUpgEntry
12348 (p_business_method_code => l_bflow_method_code
12349 ,p_business_class_code => l_bflow_class_code
12350 ,p_balance_type => l_balance_type_code);
12351 ELSE
12352 NULL;
12353 -- No business flow processing for business flow method of NONE.
12354 END IF;
12355
12356 --
12357 -- call analytical criteria
12358 --
12359
12360 --
12361 -- call description
12362 --
12363 -- No description or it is inherited.
12364 --
12365 -- call ADRs
12366 -- Bug 4922099
12367 --
12368 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12369 (NVL(l_actual_upg_option, 'N') = 'O') OR
12370 (NVL(l_enc_upg_option, 'N') = 'O')
12371 )
12372 THEN
12373 NULL;
12374 --
12375 --
12376
12377 l_ccid := AcctDerRule_11(
12378 p_application_id => p_application_id
12379 , p_ae_header_id => l_ae_header_id
12380 , p_source_3 => p_source_3
12381 , x_transaction_coa_id => l_adr_transaction_coa_id
12382 , x_accounting_coa_id => l_adr_accounting_coa_id
12383 , x_value_type_code => l_adr_value_type_code
12384 , p_side => 'NA'
12385 );
12386
12387 xla_ae_lines_pkg.set_ccid(
12388 p_code_combination_id => l_ccid
12389 , p_value_type_code => l_adr_value_type_code
12390 , p_transaction_coa_id => l_adr_transaction_coa_id
12391 , p_accounting_coa_id => l_adr_accounting_coa_id
12392 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
12393 , p_adr_type_code => 'S'
12394 , p_component_type => l_component_type
12395 , p_component_code => l_component_code
12396 , p_component_type_code => l_component_type_code
12397 , p_component_appl_id => l_component_appl_id
12398 , p_amb_context_code => l_amb_context_code
12399 , p_side => 'NA'
12400 );
12401
12402
12403 l_segment := AcctDerRule_8(
12404 p_application_id => p_application_id
12405 , p_ae_header_id => l_ae_header_id
12406 , x_transaction_coa_id => l_adr_transaction_coa_id
12407 , x_accounting_coa_id => l_adr_accounting_coa_id
12408 , x_flexfield_segment_code => l_adr_flexfield_segment_code
12409 , x_flex_value_set_id => l_adr_flex_value_set_id
12410 , x_value_type_code => l_adr_value_type_code
12411 , x_value_combination_id => l_adr_value_combination_id
12412 , x_value_segment_code => l_adr_value_segment_code
12413 , p_side => 'NA'
12414 , p_override_seg_flag => 'Y'
12415 );
12416
12417 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
12418
12419 xla_ae_lines_pkg.set_segment(
12420 p_to_segment_code => 'GL_ACCOUNT'
12421 , p_segment_value => l_segment
12422 , p_from_segment_code => l_adr_value_segment_code
12423 , p_from_combination_id => l_adr_value_combination_id
12424 , p_value_type_code => l_adr_value_type_code
12425 , p_transaction_coa_id => l_adr_transaction_coa_id
12426 , p_accounting_coa_id => l_adr_accounting_coa_id
12427 , p_flexfield_segment_code => l_adr_flexfield_segment_code
12428 , p_flex_value_set_id => l_adr_flex_value_set_id
12429 , p_adr_code => 'FV_488101'
12430 , p_adr_type_code => 'S'
12431 , p_component_type => l_component_type
12432 , p_component_code => l_component_code
12433 , p_component_type_code => l_component_type_code
12434 , p_component_appl_id => l_component_appl_id
12435 , p_amb_context_code => l_amb_context_code
12436 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
12437 , p_event_class_code => 'PURCHASE_ORDER'
12438 , p_side => 'NA'
12439 );
12440
12441 END IF;
12442
12443 --
12444 --
12445 END IF;
12446 --
12447 -- Bug 4922099
12448 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
12449 (NVL(l_enc_upg_option, 'N') = 'O')
12450 ) AND
12451 (l_bflow_method_code = 'PRIOR_ENTRY')
12452 )
12453 THEN
12454 IF
12455 --
12456 1 = 2
12457 --
12458 THEN
12459 xla_accounting_err_pkg.build_message
12460 (p_appli_s_name => 'XLA'
12461 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12462 ,p_token_1 => 'LINE_NUMBER'
12463 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
12464 ,p_token_2 => 'LINE_TYPE_NAME'
12465 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
12466 l_component_type
12467 ,l_component_code
12468 ,l_component_type_code
12469 ,l_component_appl_id
12470 ,l_amb_context_code
12471 ,l_entity_code
12472 ,l_event_class_code
12473 )
12474 ,p_token_3 => 'OWNER'
12475 ,p_value_3 => xla_lookups_pkg.get_meaning(
12476 p_lookup_type => 'XLA_OWNER_TYPE'
12477 ,p_lookup_code => l_component_type_code
12478 )
12479 ,p_token_4 => 'PRODUCT_NAME'
12480 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
12481 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
12482 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
12483 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
12484 ,p_ae_header_id => NULL
12485 );
12486
12487 IF (C_LEVEL_ERROR>= g_log_level) THEN
12488 trace
12489 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12490 ,p_level => C_LEVEL_ERROR
12491 ,p_module => l_log_module);
12492 END IF;
12493 END IF;
12494 END IF;
12495 --
12496 --
12497 ------------------------------------------------------------------------------------------------
12498 -- 4219869 Business Flow
12499 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
12500 -- Prior Entry. Currently, the following code is always generated.
12501 ------------------------------------------------------------------------------------------------
12502 XLA_AE_LINES_PKG.ValidateCurrentLine;
12503
12504 ------------------------------------------------------------------------------------
12505 -- 4219869 Business Flow
12506 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
12507 ------------------------------------------------------------------------------------
12508 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12509
12510 ----------------------------------------------------------------------------------
12511 -- 4219869 Business Flow
12512 -- Update journal entry status -- Need to generate this within IF <condition>
12513 ----------------------------------------------------------------------------------
12514 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12515 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
12516 ,p_balance_type_code => l_balance_type_code
12517 );
12518
12519 -------------------------------------------------------------------------------------------
12520 -- 4262811 - Generate the Accrual Reversal lines
12521 -------------------------------------------------------------------------------------------
12522 BEGIN
12523 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
12524 (g_array_event(p_event_id).array_value_num('header_index'));
12525 IF l_acc_rev_flag IS NULL THEN
12526 l_acc_rev_flag := 'N';
12527 END IF;
12528 EXCEPTION
12529 WHEN OTHERS THEN
12530 l_acc_rev_flag := 'N';
12531 END;
12532 --
12533 IF (l_acc_rev_flag = 'Y') THEN
12534
12535 -- 4645092 ------------------------------------------------------------------------------
12536 -- To allow MPA report to determine if it should generate report process
12537 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
12538 ------------------------------------------------------------------------------------------
12539
12540 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
12541 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
12542 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
12543 -- call ADRs
12544 -- Bug 4922099
12545 --
12546 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12547 (NVL(l_actual_upg_option, 'N') = 'O') OR
12548 (NVL(l_enc_upg_option, 'N') = 'O')
12549 )
12550 THEN
12551 NULL;
12552 --
12553 --
12554
12555 l_ccid := AcctDerRule_11(
12556 p_application_id => p_application_id
12557 , p_ae_header_id => l_ae_header_id
12558 , p_source_3 => p_source_3
12559 , x_transaction_coa_id => l_adr_transaction_coa_id
12560 , x_accounting_coa_id => l_adr_accounting_coa_id
12561 , x_value_type_code => l_adr_value_type_code
12562 , p_side => 'NA'
12563 );
12564
12565 xla_ae_lines_pkg.set_ccid(
12566 p_code_combination_id => l_ccid
12567 , p_value_type_code => l_adr_value_type_code
12568 , p_transaction_coa_id => l_adr_transaction_coa_id
12569 , p_accounting_coa_id => l_adr_accounting_coa_id
12570 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
12571 , p_adr_type_code => 'S'
12572 , p_component_type => l_component_type
12573 , p_component_code => l_component_code
12574 , p_component_type_code => l_component_type_code
12575 , p_component_appl_id => l_component_appl_id
12576 , p_amb_context_code => l_amb_context_code
12577 , p_side => 'NA'
12578 );
12579
12580
12581 l_segment := AcctDerRule_8(
12582 p_application_id => p_application_id
12583 , p_ae_header_id => l_ae_header_id
12584 , x_transaction_coa_id => l_adr_transaction_coa_id
12585 , x_accounting_coa_id => l_adr_accounting_coa_id
12586 , x_flexfield_segment_code => l_adr_flexfield_segment_code
12587 , x_flex_value_set_id => l_adr_flex_value_set_id
12588 , x_value_type_code => l_adr_value_type_code
12589 , x_value_combination_id => l_adr_value_combination_id
12590 , x_value_segment_code => l_adr_value_segment_code
12591 , p_side => 'NA'
12592 , p_override_seg_flag => 'Y'
12593 );
12594
12595 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
12596
12597 xla_ae_lines_pkg.set_segment(
12598 p_to_segment_code => 'GL_ACCOUNT'
12599 , p_segment_value => l_segment
12600 , p_from_segment_code => l_adr_value_segment_code
12601 , p_from_combination_id => l_adr_value_combination_id
12602 , p_value_type_code => l_adr_value_type_code
12603 , p_transaction_coa_id => l_adr_transaction_coa_id
12604 , p_accounting_coa_id => l_adr_accounting_coa_id
12605 , p_flexfield_segment_code => l_adr_flexfield_segment_code
12606 , p_flex_value_set_id => l_adr_flex_value_set_id
12607 , p_adr_code => 'FV_488101'
12608 , p_adr_type_code => 'S'
12609 , p_component_type => l_component_type
12610 , p_component_code => l_component_code
12611 , p_component_type_code => l_component_type_code
12612 , p_component_appl_id => l_component_appl_id
12613 , p_amb_context_code => l_amb_context_code
12614 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
12615 , p_event_class_code => 'PURCHASE_ORDER'
12616 , p_side => 'NA'
12617 );
12618
12619 END IF;
12620
12621 --
12622 --
12623 END IF;
12624
12625 --
12626 -- Update the line information that should be overwritten
12627 --
12628 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
12629 p_header_num => 1);
12630 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
12631
12632 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
12633
12634 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
12635 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
12636 END IF;
12637
12638 --
12639 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
12640 --
12641 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
12642 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
12643 ELSE
12644 ---------------------------------------------------------------------------------------------------
12645 -- 4262811a Switch Sign
12646 ---------------------------------------------------------------------------------------------------
12647 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
12648 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12649 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12650 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12651 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12652 -- 5132302
12653 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
12654 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12655
12656 END IF;
12657
12658 -- 4955764
12659 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12660 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
12661
12662
12663 XLA_AE_LINES_PKG.ValidateCurrentLine;
12664 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12665
12666 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12667 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
12668 ,p_balance_type_code => l_balance_type_code);
12669
12670 END IF;
12671
12672 -----------------------------------------------------------------------------------------
12673 -- 4262811 Multiperiod Accounting
12674 -----------------------------------------------------------------------------------------
12675 -- No MPA option is assigned.
12676
12677
12678 END IF;
12679 END IF;
12680 --
12681
12682 --
12683 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12684 trace
12685 (p_msg => 'END of AcctLineType_27'
12686 ,p_level => C_LEVEL_PROCEDURE
12687 ,p_module => l_log_module);
12688 END IF;
12689 --
12690 EXCEPTION
12691 WHEN xla_exceptions_pkg.application_exception THEN
12692 RAISE;
12693 WHEN OTHERS THEN
12694 xla_exceptions_pkg.raise_message
12695 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_27');
12696 END AcctLineType_27;
12697 --
12698
12699 ---------------------------------------
12700 --
12701 -- PRIVATE FUNCTION
12702 -- AcctLineType_28
12703 --
12704 ---------------------------------------
12705 PROCEDURE AcctLineType_28 (
12706 p_application_id IN NUMBER
12707 ,p_event_id IN NUMBER
12708 ,p_calculate_acctd_flag IN VARCHAR2
12709 ,p_calculate_g_l_flag IN VARCHAR2
12710 ,p_actual_flag IN OUT VARCHAR2
12711 ,p_balance_type_code OUT VARCHAR2
12712 ,p_gain_or_loss_ref OUT VARCHAR2
12713
12714 --PO Budget Account
12715 , p_source_3 IN NUMBER
12716 --Federal Prior Year Flag
12717 , p_source_5 IN VARCHAR2
12718 --Receiving Accounting Line Type
12719 , p_source_6 IN VARCHAR2
12720 --Applied to Application ID
12721 , p_source_7 IN NUMBER
12722 --Applied to Distribution Link Type
12723 , p_source_8 IN VARCHAR2
12724 --Applied to Entity Code
12725 , p_source_9 IN VARCHAR2
12726 --PO_DISTRIBUTION_ID
12727 , p_source_10 IN NUMBER
12728 --Applied To Purchase Document Identifier
12729 , p_source_11 IN NUMBER
12730 --DISTRIBUTION_IDENTIFIER
12731 , p_source_12 IN NUMBER
12732 --Distribution Type
12733 , p_source_13 IN VARCHAR2
12734 , p_source_13_meaning IN VARCHAR2
12735 --Encumbrance Reversal Amount Entered
12736 , p_source_14 IN NUMBER
12737 --Entered Currency Code
12738 , p_source_15 IN VARCHAR2
12739 --Transaction Encumbrance Reversal Amount
12740 , p_source_16 IN NUMBER
12741 --Costing Encumbrance Upgrade Option
12742 , p_source_17 IN VARCHAR2
12743 --Currency Conversion Date
12744 , p_source_19 IN DATE
12745 --Currency Conversion Rate
12746 , p_source_20 IN NUMBER
12747 --Currency Conversion Type
12748 , p_source_21 IN VARCHAR2
12749 --Purchasing Encumbrance Type Identifier
12750 , p_source_22 IN NUMBER
12751 --Federal Net Pya Adj Amt
12752 , p_source_27 IN NUMBER
12753 )
12754 IS
12755
12756 l_component_type VARCHAR2(80);
12757 l_component_code VARCHAR2(30);
12758 l_component_type_code VARCHAR2(1);
12759 l_component_appl_id INTEGER;
12760 l_amb_context_code VARCHAR2(30);
12761 l_entity_code VARCHAR2(30);
12762 l_event_class_code VARCHAR2(30);
12763 l_ae_header_id NUMBER;
12764 l_event_type_code VARCHAR2(30);
12765 l_line_definition_code VARCHAR2(30);
12766 l_line_definition_owner_code VARCHAR2(1);
12767 --
12768 -- adr variables
12769 l_segment VARCHAR2(30);
12770 l_ccid NUMBER;
12771 l_adr_transaction_coa_id NUMBER;
12772 l_adr_accounting_coa_id NUMBER;
12773 l_adr_flexfield_segment_code VARCHAR2(30);
12774 l_adr_flex_value_set_id NUMBER;
12775 l_adr_value_type_code VARCHAR2(30);
12776 l_adr_value_combination_id NUMBER;
12777 l_adr_value_segment_code VARCHAR2(30);
12778
12779 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
12780 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
12781 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
12782 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
12783
12784 -- 4262811 Variables ------------------------------------------------------------------------------------------
12785 l_entered_amt_idx NUMBER;
12786 l_accted_amt_idx NUMBER;
12787 l_acc_rev_flag VARCHAR2(1);
12788 l_accrual_line_num NUMBER;
12789 l_tmp_amt NUMBER;
12790 l_acc_rev_natural_side_code VARCHAR2(1);
12791
12792 l_num_entries NUMBER;
12793 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
12794 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
12795 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
12796 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
12797 l_recog_line_1 NUMBER;
12798 l_recog_line_2 NUMBER;
12799
12800 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
12801 l_bflow_applied_to_amt NUMBER; -- 5132302
12802 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
12803
12804 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
12805
12806 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
12807 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
12808
12809 ---------------------------------------------------------------------------------------------------------------
12810
12811
12812 --
12813 -- bulk performance
12814 --
12815 l_balance_type_code VARCHAR2(1);
12816 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
12817 l_log_module VARCHAR2(240);
12818
12819 --
12820 -- Upgrade strategy
12821 --
12822 l_actual_upg_option VARCHAR2(1);
12823 l_enc_upg_option VARCHAR2(1);
12824
12825 --
12826 BEGIN
12827 --
12828 IF g_log_enabled THEN
12829 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_28';
12830 END IF;
12831 --
12832 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12833
12834 trace
12835 (p_msg => 'BEGIN of AcctLineType_28'
12836 ,p_level => C_LEVEL_PROCEDURE
12837 ,p_module => l_log_module);
12838
12839 END IF;
12840 --
12841 l_component_type := 'AMB_JLT';
12842 l_component_code := 'FV_REC_UPWARD_PYA_DR';
12843 l_component_type_code := 'S';
12844 l_component_appl_id := 707;
12845 l_amb_context_code := 'DEFAULT';
12846 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
12847 l_event_class_code := 'DELIVER_EXPENSE';
12848 l_event_type_code := 'DELIVER_EXPENSE_ALL';
12849 l_line_definition_owner_code := 'S';
12850 l_line_definition_code := 'FV_DELIVER_EXPENSE';
12851 --
12852 l_balance_type_code := 'A';
12853 l_segment := NULL;
12854 l_ccid := NULL;
12855 l_adr_transaction_coa_id := NULL;
12856 l_adr_accounting_coa_id := NULL;
12857 l_adr_flexfield_segment_code := NULL;
12858 l_adr_flex_value_set_id := NULL;
12859 l_adr_value_type_code := NULL;
12860 l_adr_value_combination_id := NULL;
12861 l_adr_value_segment_code := NULL;
12862
12863 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
12864 l_bflow_class_code := ''; -- 4219869 Business Flow
12865 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
12866 l_budgetary_control_flag := 'Y';
12867
12868 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12869 l_bflow_applied_to_amt := NULL; -- 5132302
12870 l_entered_amt_idx := NULL; -- 4262811
12871 l_accted_amt_idx := NULL; -- 4262811
12872 l_acc_rev_flag := NULL; -- 4262811
12873 l_accrual_line_num := NULL; -- 4262811
12874 l_tmp_amt := NULL; -- 4262811
12875 --
12876
12877 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
12878 l_balance_type_code <> 'B' THEN
12879 IF NVL(p_source_5,'
12880 ') = 'Y' AND
12881 NVL(
12882 xla_ae_sources_pkg.GetSystemSourceChar(
12883 p_source_code => 'XLA_EVENT_TYPE_CODE'
12884 , p_source_type_code => 'Y'
12885 , p_source_application_id => 602
12886 ),'
12887 ') = 'DELIVER_EXPENSE' AND
12888 NVL(p_source_6,'
12889 ') = 'Charge'
12890 THEN
12891
12892 --
12893 XLA_AE_LINES_PKG.SetNewLine;
12894
12895 p_balance_type_code := l_balance_type_code;
12896 -- set the flag so later we will know whether the gain loss line needs to be created
12897
12898 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
12899 p_actual_flag :='A';
12900 END IF;
12901
12902 --
12903 -- bulk performance
12904 --
12905 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
12906 p_header_num => 0); -- 4262811
12907 --
12908 -- set accounting line options
12909 --
12910 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
12911 p_natural_side_code => 'D'
12912 , p_gain_or_loss_flag => 'N'
12913 , p_gl_transfer_mode_code => 'S'
12914 , p_acct_entry_type_code => 'A'
12915 , p_switch_side_flag => 'N'
12916 , p_merge_duplicate_code => 'N'
12917 );
12918 --
12919 l_acc_rev_natural_side_code := 'C'; -- 4262811
12920 --
12921 --
12922 -- set accounting line type info
12923 --
12924 xla_ae_lines_pkg.SetAcctLineType
12925 (p_component_type => l_component_type
12926 ,p_event_type_code => l_event_type_code
12927 ,p_line_definition_owner_code => l_line_definition_owner_code
12928 ,p_line_definition_code => l_line_definition_code
12929 ,p_accounting_line_code => l_component_code
12930 ,p_accounting_line_type_code => l_component_type_code
12931 ,p_accounting_line_appl_id => l_component_appl_id
12932 ,p_amb_context_code => l_amb_context_code
12933 ,p_entity_code => l_entity_code
12934 ,p_event_class_code => l_event_class_code);
12935 --
12936 -- set accounting class
12937 --
12938 xla_ae_lines_pkg.SetAcctClass(
12939 p_accounting_class_code => 'FEDERAL_EXP'
12940 , p_ae_header_id => l_ae_header_id
12941 );
12942
12943 --
12944 -- set rounding class
12945 --
12946 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
12947 'FEDERAL_EXP';
12948
12949 --
12950 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
12951 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
12952 --
12953 -- bulk performance
12954 --
12955 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
12956
12957 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
12958 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
12959
12960 -- 4955764
12961 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12962 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
12963
12964 -- 4458381 Public Sector Enh
12965
12966 --
12967 -- set accounting attributes for the line type
12968 --
12969 l_entered_amt_idx := 17;
12970 l_accted_amt_idx := 22;
12971 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12972 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
12973 l_rec_acct_attrs.array_num_value(1) := p_source_7;
12974 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
12975 l_rec_acct_attrs.array_char_value(2) := p_source_8;
12976 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
12977 l_rec_acct_attrs.array_char_value(3) := p_source_9;
12978 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
12979 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
12980 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
12981 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
12982 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
12983 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
12984 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
12985 l_rec_acct_attrs.array_char_value(7) := p_source_13;
12986 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
12987 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
12988 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
12989 l_rec_acct_attrs.array_num_value(9) := p_source_14;
12990 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
12991 l_rec_acct_attrs.array_char_value(10) := p_source_15;
12992 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
12993 l_rec_acct_attrs.array_num_value(11) := p_source_16;
12994 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
12995 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
12996 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
12997 l_rec_acct_attrs.array_num_value(13) := p_source_14;
12998 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
12999 l_rec_acct_attrs.array_char_value(14) := p_source_15;
13000 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
13001 l_rec_acct_attrs.array_num_value(15) := p_source_16;
13002 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
13003 l_rec_acct_attrs.array_char_value(16) := p_source_17;
13004 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
13005 l_rec_acct_attrs.array_num_value(17) := p_source_27;
13006 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
13007 l_rec_acct_attrs.array_char_value(18) := p_source_15;
13008 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
13009 l_rec_acct_attrs.array_date_value(19) := p_source_19;
13010 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
13011 l_rec_acct_attrs.array_num_value(20) := p_source_20;
13012 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
13013 l_rec_acct_attrs.array_char_value(21) := p_source_21;
13014 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
13015 l_rec_acct_attrs.array_num_value(22) := p_source_27;
13016 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
13017 l_rec_acct_attrs.array_num_value(23) := p_source_22;
13018 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
13019 l_rec_acct_attrs.array_num_value(24) := p_source_22;
13020
13021 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
13022 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
13023
13024 ---------------------------------------------------------------------------------------------------------------
13025 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
13026 ---------------------------------------------------------------------------------------------------------------
13027 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
13028
13029 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13030 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13031
13032 IF xla_accounting_cache_pkg.GetValueChar
13033 (p_source_code => 'LEDGER_CATEGORY_CODE'
13034 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
13035 AND l_bflow_method_code = 'PRIOR_ENTRY'
13036 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
13037 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
13038 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
13039 )
13040 THEN
13041 xla_ae_lines_pkg.BflowUpgEntry
13042 (p_business_method_code => l_bflow_method_code
13043 ,p_business_class_code => l_bflow_class_code
13044 ,p_balance_type => l_balance_type_code);
13045 ELSE
13046 NULL;
13047 -- No business flow processing for business flow method of NONE.
13048 END IF;
13049
13050 --
13051 -- call analytical criteria
13052 --
13053
13054 --
13055 -- call description
13056 --
13057 -- No description or it is inherited.
13058 --
13059 -- call ADRs
13060 -- Bug 4922099
13061 --
13062 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13063 (NVL(l_actual_upg_option, 'N') = 'O') OR
13064 (NVL(l_enc_upg_option, 'N') = 'O')
13065 )
13066 THEN
13067 NULL;
13068 --
13069 --
13070
13071 l_ccid := AcctDerRule_11(
13072 p_application_id => p_application_id
13073 , p_ae_header_id => l_ae_header_id
13074 , p_source_3 => p_source_3
13075 , x_transaction_coa_id => l_adr_transaction_coa_id
13076 , x_accounting_coa_id => l_adr_accounting_coa_id
13077 , x_value_type_code => l_adr_value_type_code
13078 , p_side => 'NA'
13079 );
13080
13081 xla_ae_lines_pkg.set_ccid(
13082 p_code_combination_id => l_ccid
13083 , p_value_type_code => l_adr_value_type_code
13084 , p_transaction_coa_id => l_adr_transaction_coa_id
13085 , p_accounting_coa_id => l_adr_accounting_coa_id
13086 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
13087 , p_adr_type_code => 'S'
13088 , p_component_type => l_component_type
13089 , p_component_code => l_component_code
13090 , p_component_type_code => l_component_type_code
13091 , p_component_appl_id => l_component_appl_id
13092 , p_amb_context_code => l_amb_context_code
13093 , p_side => 'NA'
13094 );
13095
13096
13097 l_segment := AcctDerRule_9(
13098 p_application_id => p_application_id
13099 , p_ae_header_id => l_ae_header_id
13100 , x_transaction_coa_id => l_adr_transaction_coa_id
13101 , x_accounting_coa_id => l_adr_accounting_coa_id
13102 , x_flexfield_segment_code => l_adr_flexfield_segment_code
13103 , x_flex_value_set_id => l_adr_flex_value_set_id
13104 , x_value_type_code => l_adr_value_type_code
13105 , x_value_combination_id => l_adr_value_combination_id
13106 , x_value_segment_code => l_adr_value_segment_code
13107 , p_side => 'NA'
13108 , p_override_seg_flag => 'Y'
13109 );
13110
13111 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
13112
13113 xla_ae_lines_pkg.set_segment(
13114 p_to_segment_code => 'GL_ACCOUNT'
13115 , p_segment_value => l_segment
13116 , p_from_segment_code => l_adr_value_segment_code
13117 , p_from_combination_id => l_adr_value_combination_id
13118 , p_value_type_code => l_adr_value_type_code
13119 , p_transaction_coa_id => l_adr_transaction_coa_id
13120 , p_accounting_coa_id => l_adr_accounting_coa_id
13121 , p_flexfield_segment_code => l_adr_flexfield_segment_code
13122 , p_flex_value_set_id => l_adr_flex_value_set_id
13123 , p_adr_code => 'FV_490101'
13124 , p_adr_type_code => 'S'
13125 , p_component_type => l_component_type
13126 , p_component_code => l_component_code
13127 , p_component_type_code => l_component_type_code
13128 , p_component_appl_id => l_component_appl_id
13129 , p_amb_context_code => l_amb_context_code
13130 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
13131 , p_event_class_code => 'DELIVER_EXPENSE'
13132 , p_side => 'NA'
13133 );
13134
13135 END IF;
13136
13137 --
13138 --
13139 END IF;
13140 --
13141 -- Bug 4922099
13142 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
13143 (NVL(l_enc_upg_option, 'N') = 'O')
13144 ) AND
13145 (l_bflow_method_code = 'PRIOR_ENTRY')
13146 )
13147 THEN
13148 IF
13149 --
13150 1 = 2
13151 --
13152 THEN
13153 xla_accounting_err_pkg.build_message
13154 (p_appli_s_name => 'XLA'
13155 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13156 ,p_token_1 => 'LINE_NUMBER'
13157 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
13158 ,p_token_2 => 'LINE_TYPE_NAME'
13159 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
13160 l_component_type
13161 ,l_component_code
13162 ,l_component_type_code
13163 ,l_component_appl_id
13164 ,l_amb_context_code
13165 ,l_entity_code
13166 ,l_event_class_code
13167 )
13168 ,p_token_3 => 'OWNER'
13169 ,p_value_3 => xla_lookups_pkg.get_meaning(
13170 p_lookup_type => 'XLA_OWNER_TYPE'
13171 ,p_lookup_code => l_component_type_code
13172 )
13173 ,p_token_4 => 'PRODUCT_NAME'
13174 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
13175 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
13176 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
13177 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
13178 ,p_ae_header_id => NULL
13179 );
13180
13181 IF (C_LEVEL_ERROR>= g_log_level) THEN
13182 trace
13183 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13184 ,p_level => C_LEVEL_ERROR
13185 ,p_module => l_log_module);
13186 END IF;
13187 END IF;
13188 END IF;
13189 --
13190 --
13191 ------------------------------------------------------------------------------------------------
13192 -- 4219869 Business Flow
13193 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
13194 -- Prior Entry. Currently, the following code is always generated.
13195 ------------------------------------------------------------------------------------------------
13196 XLA_AE_LINES_PKG.ValidateCurrentLine;
13197
13198 ------------------------------------------------------------------------------------
13199 -- 4219869 Business Flow
13200 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
13201 ------------------------------------------------------------------------------------
13202 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13203
13204 ----------------------------------------------------------------------------------
13205 -- 4219869 Business Flow
13206 -- Update journal entry status -- Need to generate this within IF <condition>
13207 ----------------------------------------------------------------------------------
13208 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13209 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
13210 ,p_balance_type_code => l_balance_type_code
13211 );
13212
13213 -------------------------------------------------------------------------------------------
13214 -- 4262811 - Generate the Accrual Reversal lines
13215 -------------------------------------------------------------------------------------------
13216 BEGIN
13217 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
13218 (g_array_event(p_event_id).array_value_num('header_index'));
13219 IF l_acc_rev_flag IS NULL THEN
13220 l_acc_rev_flag := 'N';
13221 END IF;
13222 EXCEPTION
13223 WHEN OTHERS THEN
13224 l_acc_rev_flag := 'N';
13225 END;
13226 --
13227 IF (l_acc_rev_flag = 'Y') THEN
13228
13229 -- 4645092 ------------------------------------------------------------------------------
13230 -- To allow MPA report to determine if it should generate report process
13231 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
13232 ------------------------------------------------------------------------------------------
13233
13234 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
13235 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
13236 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
13237 -- call ADRs
13238 -- Bug 4922099
13239 --
13240 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13241 (NVL(l_actual_upg_option, 'N') = 'O') OR
13242 (NVL(l_enc_upg_option, 'N') = 'O')
13243 )
13244 THEN
13245 NULL;
13246 --
13247 --
13248
13249 l_ccid := AcctDerRule_11(
13250 p_application_id => p_application_id
13251 , p_ae_header_id => l_ae_header_id
13252 , p_source_3 => p_source_3
13253 , x_transaction_coa_id => l_adr_transaction_coa_id
13254 , x_accounting_coa_id => l_adr_accounting_coa_id
13255 , x_value_type_code => l_adr_value_type_code
13256 , p_side => 'NA'
13257 );
13258
13259 xla_ae_lines_pkg.set_ccid(
13260 p_code_combination_id => l_ccid
13261 , p_value_type_code => l_adr_value_type_code
13262 , p_transaction_coa_id => l_adr_transaction_coa_id
13263 , p_accounting_coa_id => l_adr_accounting_coa_id
13264 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
13265 , p_adr_type_code => 'S'
13266 , p_component_type => l_component_type
13267 , p_component_code => l_component_code
13268 , p_component_type_code => l_component_type_code
13269 , p_component_appl_id => l_component_appl_id
13270 , p_amb_context_code => l_amb_context_code
13271 , p_side => 'NA'
13272 );
13273
13274
13275 l_segment := AcctDerRule_9(
13276 p_application_id => p_application_id
13277 , p_ae_header_id => l_ae_header_id
13278 , x_transaction_coa_id => l_adr_transaction_coa_id
13279 , x_accounting_coa_id => l_adr_accounting_coa_id
13280 , x_flexfield_segment_code => l_adr_flexfield_segment_code
13281 , x_flex_value_set_id => l_adr_flex_value_set_id
13282 , x_value_type_code => l_adr_value_type_code
13283 , x_value_combination_id => l_adr_value_combination_id
13284 , x_value_segment_code => l_adr_value_segment_code
13285 , p_side => 'NA'
13286 , p_override_seg_flag => 'Y'
13287 );
13288
13289 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
13290
13291 xla_ae_lines_pkg.set_segment(
13292 p_to_segment_code => 'GL_ACCOUNT'
13293 , p_segment_value => l_segment
13294 , p_from_segment_code => l_adr_value_segment_code
13295 , p_from_combination_id => l_adr_value_combination_id
13296 , p_value_type_code => l_adr_value_type_code
13297 , p_transaction_coa_id => l_adr_transaction_coa_id
13298 , p_accounting_coa_id => l_adr_accounting_coa_id
13299 , p_flexfield_segment_code => l_adr_flexfield_segment_code
13300 , p_flex_value_set_id => l_adr_flex_value_set_id
13301 , p_adr_code => 'FV_490101'
13302 , p_adr_type_code => 'S'
13303 , p_component_type => l_component_type
13304 , p_component_code => l_component_code
13305 , p_component_type_code => l_component_type_code
13306 , p_component_appl_id => l_component_appl_id
13307 , p_amb_context_code => l_amb_context_code
13308 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
13309 , p_event_class_code => 'DELIVER_EXPENSE'
13310 , p_side => 'NA'
13311 );
13312
13313 END IF;
13314
13315 --
13316 --
13317 END IF;
13318
13319 --
13320 -- Update the line information that should be overwritten
13321 --
13322 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
13323 p_header_num => 1);
13324 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
13325
13326 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
13327
13328 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
13329 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
13330 END IF;
13331
13332 --
13333 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
13334 --
13335 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
13336 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
13337 ELSE
13338 ---------------------------------------------------------------------------------------------------
13339 -- 4262811a Switch Sign
13340 ---------------------------------------------------------------------------------------------------
13341 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
13342 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13343 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13344 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13345 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13346 -- 5132302
13347 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
13348 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13349
13350 END IF;
13351
13352 -- 4955764
13353 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13354 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
13355
13356
13357 XLA_AE_LINES_PKG.ValidateCurrentLine;
13358 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13359
13360 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13361 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
13362 ,p_balance_type_code => l_balance_type_code);
13363
13364 END IF;
13365
13366 -----------------------------------------------------------------------------------------
13367 -- 4262811 Multiperiod Accounting
13368 -----------------------------------------------------------------------------------------
13369 -- No MPA option is assigned.
13370
13371
13372 END IF;
13373 END IF;
13374 --
13375
13376 --
13377 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13378 trace
13379 (p_msg => 'END of AcctLineType_28'
13380 ,p_level => C_LEVEL_PROCEDURE
13381 ,p_module => l_log_module);
13382 END IF;
13383 --
13384 EXCEPTION
13385 WHEN xla_exceptions_pkg.application_exception THEN
13386 RAISE;
13387 WHEN OTHERS THEN
13388 xla_exceptions_pkg.raise_message
13389 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_28');
13390 END AcctLineType_28;
13391 --
13392
13393 ---------------------------------------
13394 --
13395 -- PRIVATE FUNCTION
13396 -- AcctLineType_29
13397 --
13398 ---------------------------------------
13399 PROCEDURE AcctLineType_29 (
13400 p_application_id IN NUMBER
13401 ,p_event_id IN NUMBER
13402 ,p_calculate_acctd_flag IN VARCHAR2
13403 ,p_calculate_g_l_flag IN VARCHAR2
13404 ,p_actual_flag IN OUT VARCHAR2
13405 ,p_balance_type_code OUT VARCHAR2
13406 ,p_gain_or_loss_ref OUT VARCHAR2
13407
13408 --Federal Fund Expired Status
13409 , p_source_1 IN VARCHAR2
13410 --Federal Fund Category
13411 , p_source_2 IN VARCHAR2
13412 --PO Budget Account
13413 , p_source_3 IN NUMBER
13414 --Federal Prior Year Flag
13415 , p_source_5 IN VARCHAR2
13416 --Applied to Application ID
13417 , p_source_7 IN NUMBER
13418 --Applied to Distribution Link Type
13419 , p_source_8 IN VARCHAR2
13420 --Applied to Entity Code
13421 , p_source_9 IN VARCHAR2
13422 --Applied To Purchase Document Identifier
13423 , p_source_11 IN NUMBER
13424 --DISTRIBUTION_IDENTIFIER
13425 , p_source_12 IN NUMBER
13426 --Distribution Type
13427 , p_source_13 IN VARCHAR2
13428 , p_source_13_meaning IN VARCHAR2
13429 --Encumbrance Reversal Amount Entered
13430 , p_source_14 IN NUMBER
13431 --Entered Currency Code
13432 , p_source_15 IN VARCHAR2
13433 --Transaction Encumbrance Reversal Amount
13434 , p_source_16 IN NUMBER
13435 --Costing Encumbrance Upgrade Option
13436 , p_source_17 IN VARCHAR2
13437 --Currency Conversion Date
13438 , p_source_19 IN DATE
13439 --Currency Conversion Rate
13440 , p_source_20 IN NUMBER
13441 --Currency Conversion Type
13442 , p_source_21 IN VARCHAR2
13443 --Purchasing Encumbrance Type Identifier
13444 , p_source_22 IN NUMBER
13445 --TXN_PO_DISTRIBUTION_ID
13446 , p_source_23 IN NUMBER
13447 --Federal Net Pya Adj Amt
13448 , p_source_27 IN NUMBER
13449 )
13450 IS
13451
13452 l_component_type VARCHAR2(80);
13453 l_component_code VARCHAR2(30);
13454 l_component_type_code VARCHAR2(1);
13455 l_component_appl_id INTEGER;
13456 l_amb_context_code VARCHAR2(30);
13457 l_entity_code VARCHAR2(30);
13458 l_event_class_code VARCHAR2(30);
13459 l_ae_header_id NUMBER;
13460 l_event_type_code VARCHAR2(30);
13461 l_line_definition_code VARCHAR2(30);
13462 l_line_definition_owner_code VARCHAR2(1);
13463 --
13464 -- adr variables
13465 l_segment VARCHAR2(30);
13466 l_ccid NUMBER;
13467 l_adr_transaction_coa_id NUMBER;
13468 l_adr_accounting_coa_id NUMBER;
13469 l_adr_flexfield_segment_code VARCHAR2(30);
13470 l_adr_flex_value_set_id NUMBER;
13471 l_adr_value_type_code VARCHAR2(30);
13472 l_adr_value_combination_id NUMBER;
13473 l_adr_value_segment_code VARCHAR2(30);
13474
13475 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
13476 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
13477 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
13478 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
13479
13480 -- 4262811 Variables ------------------------------------------------------------------------------------------
13481 l_entered_amt_idx NUMBER;
13482 l_accted_amt_idx NUMBER;
13483 l_acc_rev_flag VARCHAR2(1);
13484 l_accrual_line_num NUMBER;
13485 l_tmp_amt NUMBER;
13486 l_acc_rev_natural_side_code VARCHAR2(1);
13487
13488 l_num_entries NUMBER;
13489 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
13490 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
13491 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
13492 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
13493 l_recog_line_1 NUMBER;
13494 l_recog_line_2 NUMBER;
13495
13496 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
13497 l_bflow_applied_to_amt NUMBER; -- 5132302
13498 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
13499
13500 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
13501
13502 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
13503 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
13504
13505 ---------------------------------------------------------------------------------------------------------------
13506
13507
13508 --
13509 -- bulk performance
13510 --
13511 l_balance_type_code VARCHAR2(1);
13512 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
13513 l_log_module VARCHAR2(240);
13514
13515 --
13516 -- Upgrade strategy
13517 --
13518 l_actual_upg_option VARCHAR2(1);
13519 l_enc_upg_option VARCHAR2(1);
13520
13521 --
13522 BEGIN
13523 --
13524 IF g_log_enabled THEN
13525 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_29';
13526 END IF;
13527 --
13528 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13529
13530 trace
13531 (p_msg => 'BEGIN of AcctLineType_29'
13532 ,p_level => C_LEVEL_PROCEDURE
13533 ,p_module => l_log_module);
13534
13535 END IF;
13536 --
13537 l_component_type := 'AMB_JLT';
13538 l_component_code := 'FV_REC_UPWARD_PYA_DR_DTI';
13539 l_component_type_code := 'S';
13540 l_component_appl_id := 707;
13541 l_amb_context_code := 'DEFAULT';
13542 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
13543 l_event_class_code := 'PURCHASE_ORDER';
13544 l_event_type_code := 'PURCHASE_ORDER_ALL';
13545 l_line_definition_owner_code := 'S';
13546 l_line_definition_code := 'FV_PO_DEL_INV';
13547 --
13548 l_balance_type_code := 'A';
13549 l_segment := NULL;
13550 l_ccid := NULL;
13551 l_adr_transaction_coa_id := NULL;
13552 l_adr_accounting_coa_id := NULL;
13553 l_adr_flexfield_segment_code := NULL;
13554 l_adr_flex_value_set_id := NULL;
13555 l_adr_value_type_code := NULL;
13556 l_adr_value_combination_id := NULL;
13557 l_adr_value_segment_code := NULL;
13558
13559 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
13560 l_bflow_class_code := ''; -- 4219869 Business Flow
13561 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
13562 l_budgetary_control_flag := 'Y';
13563
13564 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13565 l_bflow_applied_to_amt := NULL; -- 5132302
13566 l_entered_amt_idx := NULL; -- 4262811
13567 l_accted_amt_idx := NULL; -- 4262811
13568 l_acc_rev_flag := NULL; -- 4262811
13569 l_accrual_line_num := NULL; -- 4262811
13570 l_tmp_amt := NULL; -- 4262811
13571 --
13572
13573 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
13574 l_balance_type_code <> 'B' THEN
13575 IF NVL(
13576 xla_ae_sources_pkg.GetSystemSourceChar(
13577 p_source_code => 'XLA_EVENT_TYPE_CODE'
13578 , p_source_type_code => 'Y'
13579 , p_source_application_id => 602
13580 ),'
13581 ') = 'PO_DEL_INV' AND
13582 NVL(p_source_5,'
13583 ') = 'Y'
13584 THEN
13585
13586 --
13587 XLA_AE_LINES_PKG.SetNewLine;
13588
13589 p_balance_type_code := l_balance_type_code;
13590 -- set the flag so later we will know whether the gain loss line needs to be created
13591
13592 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
13593 p_actual_flag :='A';
13594 END IF;
13595
13596 --
13597 -- bulk performance
13598 --
13599 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
13600 p_header_num => 0); -- 4262811
13601 --
13602 -- set accounting line options
13603 --
13604 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
13605 p_natural_side_code => 'D'
13606 , p_gain_or_loss_flag => 'N'
13607 , p_gl_transfer_mode_code => 'S'
13608 , p_acct_entry_type_code => 'A'
13609 , p_switch_side_flag => 'N'
13610 , p_merge_duplicate_code => 'N'
13611 );
13612 --
13613 l_acc_rev_natural_side_code := 'C'; -- 4262811
13614 --
13615 --
13616 -- set accounting line type info
13617 --
13618 xla_ae_lines_pkg.SetAcctLineType
13619 (p_component_type => l_component_type
13620 ,p_event_type_code => l_event_type_code
13621 ,p_line_definition_owner_code => l_line_definition_owner_code
13622 ,p_line_definition_code => l_line_definition_code
13623 ,p_accounting_line_code => l_component_code
13624 ,p_accounting_line_type_code => l_component_type_code
13625 ,p_accounting_line_appl_id => l_component_appl_id
13626 ,p_amb_context_code => l_amb_context_code
13627 ,p_entity_code => l_entity_code
13628 ,p_event_class_code => l_event_class_code);
13629 --
13630 -- set accounting class
13631 --
13632 xla_ae_lines_pkg.SetAcctClass(
13633 p_accounting_class_code => 'FEDERAL_INV'
13634 , p_ae_header_id => l_ae_header_id
13635 );
13636
13637 --
13638 -- set rounding class
13639 --
13640 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
13641 'FEDERAL_INV';
13642
13643 --
13644 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
13645 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
13646 --
13647 -- bulk performance
13648 --
13649 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
13650
13651 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
13652 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
13653
13654 -- 4955764
13655 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13656 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
13657
13658 -- 4458381 Public Sector Enh
13659
13660 --
13661 -- set accounting attributes for the line type
13662 --
13663 l_entered_amt_idx := 17;
13664 l_accted_amt_idx := 22;
13665 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13666 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
13667 l_rec_acct_attrs.array_num_value(1) := p_source_7;
13668 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
13669 l_rec_acct_attrs.array_char_value(2) := p_source_8;
13670 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
13671 l_rec_acct_attrs.array_char_value(3) := p_source_9;
13672 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
13673 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
13674 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
13675 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
13676 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
13677 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
13678 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
13679 l_rec_acct_attrs.array_char_value(7) := p_source_13;
13680 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
13681 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
13682 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
13683 l_rec_acct_attrs.array_num_value(9) := p_source_14;
13684 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
13685 l_rec_acct_attrs.array_char_value(10) := p_source_15;
13686 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
13687 l_rec_acct_attrs.array_num_value(11) := p_source_16;
13688 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
13689 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
13690 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
13691 l_rec_acct_attrs.array_num_value(13) := p_source_14;
13692 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
13693 l_rec_acct_attrs.array_char_value(14) := p_source_15;
13694 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
13695 l_rec_acct_attrs.array_num_value(15) := p_source_16;
13696 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
13697 l_rec_acct_attrs.array_char_value(16) := p_source_17;
13698 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
13699 l_rec_acct_attrs.array_num_value(17) := p_source_27;
13700 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
13701 l_rec_acct_attrs.array_char_value(18) := p_source_15;
13702 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
13703 l_rec_acct_attrs.array_date_value(19) := p_source_19;
13704 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
13705 l_rec_acct_attrs.array_num_value(20) := p_source_20;
13706 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
13707 l_rec_acct_attrs.array_char_value(21) := p_source_21;
13708 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
13709 l_rec_acct_attrs.array_num_value(22) := p_source_27;
13710 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
13711 l_rec_acct_attrs.array_num_value(23) := p_source_22;
13712 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
13713 l_rec_acct_attrs.array_num_value(24) := p_source_22;
13714
13715 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
13716 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
13717
13718 ---------------------------------------------------------------------------------------------------------------
13719 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
13720 ---------------------------------------------------------------------------------------------------------------
13721 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
13722
13723 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13724 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13725
13726 IF xla_accounting_cache_pkg.GetValueChar
13727 (p_source_code => 'LEDGER_CATEGORY_CODE'
13728 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
13729 AND l_bflow_method_code = 'PRIOR_ENTRY'
13730 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
13731 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
13732 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
13733 )
13734 THEN
13735 xla_ae_lines_pkg.BflowUpgEntry
13736 (p_business_method_code => l_bflow_method_code
13737 ,p_business_class_code => l_bflow_class_code
13738 ,p_balance_type => l_balance_type_code);
13739 ELSE
13740 NULL;
13741 -- No business flow processing for business flow method of NONE.
13742 END IF;
13743
13744 --
13745 -- call analytical criteria
13746 --
13747
13748 --
13749 -- call description
13750 --
13751 -- No description or it is inherited.
13752 --
13753 -- call ADRs
13754 -- Bug 4922099
13755 --
13756 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13757 (NVL(l_actual_upg_option, 'N') = 'O') OR
13758 (NVL(l_enc_upg_option, 'N') = 'O')
13759 )
13760 THEN
13761 NULL;
13762 --
13763 --
13764
13765 l_ccid := AcctDerRule_11(
13766 p_application_id => p_application_id
13767 , p_ae_header_id => l_ae_header_id
13768 , p_source_3 => p_source_3
13769 , x_transaction_coa_id => l_adr_transaction_coa_id
13770 , x_accounting_coa_id => l_adr_accounting_coa_id
13771 , x_value_type_code => l_adr_value_type_code
13772 , p_side => 'NA'
13773 );
13774
13775 xla_ae_lines_pkg.set_ccid(
13776 p_code_combination_id => l_ccid
13777 , p_value_type_code => l_adr_value_type_code
13778 , p_transaction_coa_id => l_adr_transaction_coa_id
13779 , p_accounting_coa_id => l_adr_accounting_coa_id
13780 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
13781 , p_adr_type_code => 'S'
13782 , p_component_type => l_component_type
13783 , p_component_code => l_component_code
13784 , p_component_type_code => l_component_type_code
13785 , p_component_appl_id => l_component_appl_id
13786 , p_amb_context_code => l_amb_context_code
13787 , p_side => 'NA'
13788 );
13789
13790
13791 l_segment := AcctDerRule_4(
13792 p_application_id => p_application_id
13793 , p_ae_header_id => l_ae_header_id
13794 , p_source_1 => p_source_1
13795 , p_source_2 => p_source_2
13796 , x_transaction_coa_id => l_adr_transaction_coa_id
13797 , x_accounting_coa_id => l_adr_accounting_coa_id
13798 , x_flexfield_segment_code => l_adr_flexfield_segment_code
13799 , x_flex_value_set_id => l_adr_flex_value_set_id
13800 , x_value_type_code => l_adr_value_type_code
13801 , x_value_combination_id => l_adr_value_combination_id
13802 , x_value_segment_code => l_adr_value_segment_code
13803 , p_side => 'NA'
13804 , p_override_seg_flag => 'Y'
13805 );
13806
13807 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
13808
13809 xla_ae_lines_pkg.set_segment(
13810 p_to_segment_code => 'GL_ACCOUNT'
13811 , p_segment_value => l_segment
13812 , p_from_segment_code => l_adr_value_segment_code
13813 , p_from_combination_id => l_adr_value_combination_id
13814 , p_value_type_code => l_adr_value_type_code
13815 , p_transaction_coa_id => l_adr_transaction_coa_id
13816 , p_accounting_coa_id => l_adr_accounting_coa_id
13817 , p_flexfield_segment_code => l_adr_flexfield_segment_code
13818 , p_flex_value_set_id => l_adr_flex_value_set_id
13819 , p_adr_code => 'FV_46X002'
13820 , p_adr_type_code => 'S'
13821 , p_component_type => l_component_type
13822 , p_component_code => l_component_code
13823 , p_component_type_code => l_component_type_code
13824 , p_component_appl_id => l_component_appl_id
13825 , p_amb_context_code => l_amb_context_code
13826 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
13827 , p_event_class_code => 'PURCHASE_ORDER'
13828 , p_side => 'NA'
13829 );
13830
13831 END IF;
13832
13833 --
13834 --
13835 END IF;
13836 --
13837 -- Bug 4922099
13838 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
13839 (NVL(l_enc_upg_option, 'N') = 'O')
13840 ) AND
13841 (l_bflow_method_code = 'PRIOR_ENTRY')
13842 )
13843 THEN
13844 IF
13845 --
13846 1 = 2
13847 --
13848 THEN
13849 xla_accounting_err_pkg.build_message
13850 (p_appli_s_name => 'XLA'
13851 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13852 ,p_token_1 => 'LINE_NUMBER'
13853 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
13854 ,p_token_2 => 'LINE_TYPE_NAME'
13855 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
13856 l_component_type
13857 ,l_component_code
13858 ,l_component_type_code
13859 ,l_component_appl_id
13860 ,l_amb_context_code
13861 ,l_entity_code
13862 ,l_event_class_code
13863 )
13864 ,p_token_3 => 'OWNER'
13865 ,p_value_3 => xla_lookups_pkg.get_meaning(
13866 p_lookup_type => 'XLA_OWNER_TYPE'
13867 ,p_lookup_code => l_component_type_code
13868 )
13869 ,p_token_4 => 'PRODUCT_NAME'
13870 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
13871 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
13872 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
13873 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
13874 ,p_ae_header_id => NULL
13875 );
13876
13877 IF (C_LEVEL_ERROR>= g_log_level) THEN
13878 trace
13879 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13880 ,p_level => C_LEVEL_ERROR
13881 ,p_module => l_log_module);
13882 END IF;
13883 END IF;
13884 END IF;
13885 --
13886 --
13887 ------------------------------------------------------------------------------------------------
13888 -- 4219869 Business Flow
13889 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
13890 -- Prior Entry. Currently, the following code is always generated.
13891 ------------------------------------------------------------------------------------------------
13892 XLA_AE_LINES_PKG.ValidateCurrentLine;
13893
13894 ------------------------------------------------------------------------------------
13895 -- 4219869 Business Flow
13896 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
13897 ------------------------------------------------------------------------------------
13898 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13899
13900 ----------------------------------------------------------------------------------
13901 -- 4219869 Business Flow
13902 -- Update journal entry status -- Need to generate this within IF <condition>
13903 ----------------------------------------------------------------------------------
13904 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13905 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
13906 ,p_balance_type_code => l_balance_type_code
13907 );
13908
13909 -------------------------------------------------------------------------------------------
13910 -- 4262811 - Generate the Accrual Reversal lines
13911 -------------------------------------------------------------------------------------------
13912 BEGIN
13913 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
13914 (g_array_event(p_event_id).array_value_num('header_index'));
13915 IF l_acc_rev_flag IS NULL THEN
13916 l_acc_rev_flag := 'N';
13917 END IF;
13918 EXCEPTION
13919 WHEN OTHERS THEN
13920 l_acc_rev_flag := 'N';
13921 END;
13922 --
13923 IF (l_acc_rev_flag = 'Y') THEN
13924
13925 -- 4645092 ------------------------------------------------------------------------------
13926 -- To allow MPA report to determine if it should generate report process
13927 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
13928 ------------------------------------------------------------------------------------------
13929
13930 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
13931 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
13932 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
13933 -- call ADRs
13934 -- Bug 4922099
13935 --
13936 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13937 (NVL(l_actual_upg_option, 'N') = 'O') OR
13938 (NVL(l_enc_upg_option, 'N') = 'O')
13939 )
13940 THEN
13941 NULL;
13942 --
13943 --
13944
13945 l_ccid := AcctDerRule_11(
13946 p_application_id => p_application_id
13947 , p_ae_header_id => l_ae_header_id
13948 , p_source_3 => p_source_3
13949 , x_transaction_coa_id => l_adr_transaction_coa_id
13950 , x_accounting_coa_id => l_adr_accounting_coa_id
13951 , x_value_type_code => l_adr_value_type_code
13952 , p_side => 'NA'
13953 );
13954
13955 xla_ae_lines_pkg.set_ccid(
13956 p_code_combination_id => l_ccid
13957 , p_value_type_code => l_adr_value_type_code
13958 , p_transaction_coa_id => l_adr_transaction_coa_id
13959 , p_accounting_coa_id => l_adr_accounting_coa_id
13960 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
13961 , p_adr_type_code => 'S'
13962 , p_component_type => l_component_type
13963 , p_component_code => l_component_code
13964 , p_component_type_code => l_component_type_code
13965 , p_component_appl_id => l_component_appl_id
13966 , p_amb_context_code => l_amb_context_code
13967 , p_side => 'NA'
13968 );
13969
13970
13971 l_segment := AcctDerRule_4(
13972 p_application_id => p_application_id
13973 , p_ae_header_id => l_ae_header_id
13974 , p_source_1 => p_source_1
13975 , p_source_2 => p_source_2
13976 , x_transaction_coa_id => l_adr_transaction_coa_id
13977 , x_accounting_coa_id => l_adr_accounting_coa_id
13978 , x_flexfield_segment_code => l_adr_flexfield_segment_code
13979 , x_flex_value_set_id => l_adr_flex_value_set_id
13980 , x_value_type_code => l_adr_value_type_code
13981 , x_value_combination_id => l_adr_value_combination_id
13982 , x_value_segment_code => l_adr_value_segment_code
13983 , p_side => 'NA'
13984 , p_override_seg_flag => 'Y'
13985 );
13986
13987 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
13988
13989 xla_ae_lines_pkg.set_segment(
13990 p_to_segment_code => 'GL_ACCOUNT'
13991 , p_segment_value => l_segment
13992 , p_from_segment_code => l_adr_value_segment_code
13993 , p_from_combination_id => l_adr_value_combination_id
13994 , p_value_type_code => l_adr_value_type_code
13995 , p_transaction_coa_id => l_adr_transaction_coa_id
13996 , p_accounting_coa_id => l_adr_accounting_coa_id
13997 , p_flexfield_segment_code => l_adr_flexfield_segment_code
13998 , p_flex_value_set_id => l_adr_flex_value_set_id
13999 , p_adr_code => 'FV_46X002'
14000 , p_adr_type_code => 'S'
14001 , p_component_type => l_component_type
14002 , p_component_code => l_component_code
14003 , p_component_type_code => l_component_type_code
14004 , p_component_appl_id => l_component_appl_id
14005 , p_amb_context_code => l_amb_context_code
14006 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
14007 , p_event_class_code => 'PURCHASE_ORDER'
14008 , p_side => 'NA'
14009 );
14010
14011 END IF;
14012
14013 --
14014 --
14015 END IF;
14016
14017 --
14018 -- Update the line information that should be overwritten
14019 --
14020 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
14021 p_header_num => 1);
14022 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
14023
14024 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
14025
14026 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
14027 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
14028 END IF;
14029
14030 --
14031 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
14032 --
14033 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
14034 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
14035 ELSE
14036 ---------------------------------------------------------------------------------------------------
14037 -- 4262811a Switch Sign
14038 ---------------------------------------------------------------------------------------------------
14039 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
14040 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14041 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14042 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14043 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14044 -- 5132302
14045 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
14046 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14047
14048 END IF;
14049
14050 -- 4955764
14051 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14052 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
14053
14054
14055 XLA_AE_LINES_PKG.ValidateCurrentLine;
14056 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14057
14058 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14059 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
14060 ,p_balance_type_code => l_balance_type_code);
14061
14062 END IF;
14063
14064 -----------------------------------------------------------------------------------------
14065 -- 4262811 Multiperiod Accounting
14066 -----------------------------------------------------------------------------------------
14067 -- No MPA option is assigned.
14068
14069
14070 END IF;
14071 END IF;
14072 --
14073
14074 --
14075 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14076 trace
14077 (p_msg => 'END of AcctLineType_29'
14078 ,p_level => C_LEVEL_PROCEDURE
14079 ,p_module => l_log_module);
14080 END IF;
14081 --
14082 EXCEPTION
14083 WHEN xla_exceptions_pkg.application_exception THEN
14084 RAISE;
14085 WHEN OTHERS THEN
14086 xla_exceptions_pkg.raise_message
14087 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_29');
14088 END AcctLineType_29;
14089 --
14090
14091 ---------------------------------------
14092 --
14093 -- PRIVATE FUNCTION
14094 -- AcctLineType_30
14095 --
14096 ---------------------------------------
14097 PROCEDURE AcctLineType_30 (
14098 p_application_id IN NUMBER
14099 ,p_event_id IN NUMBER
14100 ,p_calculate_acctd_flag IN VARCHAR2
14101 ,p_calculate_g_l_flag IN VARCHAR2
14102 ,p_actual_flag IN OUT VARCHAR2
14103 ,p_balance_type_code OUT VARCHAR2
14104 ,p_gain_or_loss_ref OUT VARCHAR2
14105
14106 --Federal Fund Expired Status
14107 , p_source_1 IN VARCHAR2
14108 --Federal Fund Category
14109 , p_source_2 IN VARCHAR2
14110 --PO Budget Account
14111 , p_source_3 IN NUMBER
14112 --Receiving Accounting Line Type
14113 , p_source_6 IN VARCHAR2
14114 --Applied to Application ID
14115 , p_source_7 IN NUMBER
14116 --Applied to Distribution Link Type
14117 , p_source_8 IN VARCHAR2
14118 --Applied to Entity Code
14119 , p_source_9 IN VARCHAR2
14120 --PO_DISTRIBUTION_ID
14121 , p_source_10 IN NUMBER
14122 --Applied To Purchase Document Identifier
14123 , p_source_11 IN NUMBER
14124 --DISTRIBUTION_IDENTIFIER
14125 , p_source_12 IN NUMBER
14126 --Distribution Type
14127 , p_source_13 IN VARCHAR2
14128 , p_source_13_meaning IN VARCHAR2
14129 --Encumbrance Reversal Amount Entered
14130 , p_source_14 IN NUMBER
14131 --Entered Currency Code
14132 , p_source_15 IN VARCHAR2
14133 --Transaction Encumbrance Reversal Amount
14134 , p_source_16 IN NUMBER
14135 --Costing Encumbrance Upgrade Option
14136 , p_source_17 IN VARCHAR2
14137 --Currency Conversion Date
14138 , p_source_19 IN DATE
14139 --Currency Conversion Rate
14140 , p_source_20 IN NUMBER
14141 --Currency Conversion Type
14142 , p_source_21 IN VARCHAR2
14143 --Purchasing Encumbrance Type Identifier
14144 , p_source_22 IN NUMBER
14145 --Entered Amount
14146 , p_source_25 IN NUMBER
14147 --Accounted Amount
14148 , p_source_26 IN NUMBER
14149 )
14150 IS
14151
14152 l_component_type VARCHAR2(80);
14153 l_component_code VARCHAR2(30);
14154 l_component_type_code VARCHAR2(1);
14155 l_component_appl_id INTEGER;
14156 l_amb_context_code VARCHAR2(30);
14157 l_entity_code VARCHAR2(30);
14158 l_event_class_code VARCHAR2(30);
14159 l_ae_header_id NUMBER;
14160 l_event_type_code VARCHAR2(30);
14161 l_line_definition_code VARCHAR2(30);
14162 l_line_definition_owner_code VARCHAR2(1);
14163 --
14164 -- adr variables
14165 l_segment VARCHAR2(30);
14166 l_ccid NUMBER;
14167 l_adr_transaction_coa_id NUMBER;
14168 l_adr_accounting_coa_id NUMBER;
14169 l_adr_flexfield_segment_code VARCHAR2(30);
14170 l_adr_flex_value_set_id NUMBER;
14171 l_adr_value_type_code VARCHAR2(30);
14172 l_adr_value_combination_id NUMBER;
14173 l_adr_value_segment_code VARCHAR2(30);
14174
14175 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
14176 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
14177 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
14178 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
14179
14180 -- 4262811 Variables ------------------------------------------------------------------------------------------
14181 l_entered_amt_idx NUMBER;
14182 l_accted_amt_idx NUMBER;
14183 l_acc_rev_flag VARCHAR2(1);
14184 l_accrual_line_num NUMBER;
14185 l_tmp_amt NUMBER;
14186 l_acc_rev_natural_side_code VARCHAR2(1);
14187
14188 l_num_entries NUMBER;
14189 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
14190 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
14191 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
14192 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
14193 l_recog_line_1 NUMBER;
14194 l_recog_line_2 NUMBER;
14195
14196 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
14197 l_bflow_applied_to_amt NUMBER; -- 5132302
14198 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
14199
14200 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
14201
14202 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
14203 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
14204
14205 ---------------------------------------------------------------------------------------------------------------
14206
14207
14208 --
14209 -- bulk performance
14210 --
14211 l_balance_type_code VARCHAR2(1);
14212 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
14213 l_log_module VARCHAR2(240);
14214
14215 --
14216 -- Upgrade strategy
14217 --
14218 l_actual_upg_option VARCHAR2(1);
14219 l_enc_upg_option VARCHAR2(1);
14220
14221 --
14222 BEGIN
14223 --
14224 IF g_log_enabled THEN
14225 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_30';
14226 END IF;
14227 --
14228 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14229
14230 trace
14231 (p_msg => 'BEGIN of AcctLineType_30'
14232 ,p_level => C_LEVEL_PROCEDURE
14233 ,p_module => l_log_module);
14234
14235 END IF;
14236 --
14237 l_component_type := 'AMB_JLT';
14238 l_component_code := 'FV_REINSTATE_PO_DR';
14239 l_component_type_code := 'S';
14240 l_component_appl_id := 707;
14241 l_amb_context_code := 'DEFAULT';
14242 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
14243 l_event_class_code := 'DELIVER_EXPENSE';
14244 l_event_type_code := 'DELIVER_EXPENSE_ALL';
14245 l_line_definition_owner_code := 'S';
14246 l_line_definition_code := 'FV_RETURN_TO_RECEIVING';
14247 --
14248 l_balance_type_code := 'A';
14249 l_segment := NULL;
14250 l_ccid := NULL;
14251 l_adr_transaction_coa_id := NULL;
14252 l_adr_accounting_coa_id := NULL;
14253 l_adr_flexfield_segment_code := NULL;
14254 l_adr_flex_value_set_id := NULL;
14255 l_adr_value_type_code := NULL;
14256 l_adr_value_combination_id := NULL;
14257 l_adr_value_segment_code := NULL;
14258
14259 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
14260 l_bflow_class_code := ''; -- 4219869 Business Flow
14261 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
14262 l_budgetary_control_flag := 'Y';
14263
14264 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14265 l_bflow_applied_to_amt := NULL; -- 5132302
14266 l_entered_amt_idx := NULL; -- 4262811
14267 l_accted_amt_idx := NULL; -- 4262811
14268 l_acc_rev_flag := NULL; -- 4262811
14269 l_accrual_line_num := NULL; -- 4262811
14270 l_tmp_amt := NULL; -- 4262811
14271 --
14272
14273 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
14274 l_balance_type_code <> 'B' THEN
14275 IF NVL(
14276 xla_ae_sources_pkg.GetSystemSourceChar(
14277 p_source_code => 'XLA_EVENT_TYPE_CODE'
14278 , p_source_type_code => 'Y'
14279 , p_source_application_id => 602
14280 ),'
14281 ') = 'RETURN_TO_RECEIVING' AND
14282 NVL(p_source_6,'
14283 ') = 'Charge'
14284 THEN
14285
14286 --
14287 XLA_AE_LINES_PKG.SetNewLine;
14288
14289 p_balance_type_code := l_balance_type_code;
14290 -- set the flag so later we will know whether the gain loss line needs to be created
14291
14292 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
14293 p_actual_flag :='A';
14294 END IF;
14295
14296 --
14297 -- bulk performance
14298 --
14299 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
14300 p_header_num => 0); -- 4262811
14301 --
14302 -- set accounting line options
14303 --
14304 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
14305 p_natural_side_code => 'D'
14306 , p_gain_or_loss_flag => 'N'
14307 , p_gl_transfer_mode_code => 'S'
14308 , p_acct_entry_type_code => 'A'
14309 , p_switch_side_flag => 'N'
14310 , p_merge_duplicate_code => 'N'
14311 );
14312 --
14313 l_acc_rev_natural_side_code := 'C'; -- 4262811
14314 --
14315 --
14316 -- set accounting line type info
14317 --
14318 xla_ae_lines_pkg.SetAcctLineType
14319 (p_component_type => l_component_type
14320 ,p_event_type_code => l_event_type_code
14321 ,p_line_definition_owner_code => l_line_definition_owner_code
14322 ,p_line_definition_code => l_line_definition_code
14323 ,p_accounting_line_code => l_component_code
14324 ,p_accounting_line_type_code => l_component_type_code
14325 ,p_accounting_line_appl_id => l_component_appl_id
14326 ,p_amb_context_code => l_amb_context_code
14327 ,p_entity_code => l_entity_code
14328 ,p_event_class_code => l_event_class_code);
14329 --
14330 -- set accounting class
14331 --
14332 xla_ae_lines_pkg.SetAcctClass(
14333 p_accounting_class_code => 'FEDERAL_EXP'
14334 , p_ae_header_id => l_ae_header_id
14335 );
14336
14337 --
14338 -- set rounding class
14339 --
14340 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
14341 'FEDERAL_EXP';
14342
14343 --
14344 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
14345 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
14346 --
14347 -- bulk performance
14348 --
14349 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
14350
14351 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
14352 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
14353
14354 -- 4955764
14355 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14356 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
14357
14358 -- 4458381 Public Sector Enh
14359
14360 --
14361 -- set accounting attributes for the line type
14362 --
14363 l_entered_amt_idx := 17;
14364 l_accted_amt_idx := 22;
14365 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14366 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
14367 l_rec_acct_attrs.array_num_value(1) := p_source_7;
14368 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
14369 l_rec_acct_attrs.array_char_value(2) := p_source_8;
14370 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
14371 l_rec_acct_attrs.array_char_value(3) := p_source_9;
14372 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
14373 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
14374 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
14375 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
14376 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
14377 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
14378 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
14379 l_rec_acct_attrs.array_char_value(7) := p_source_13;
14380 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
14381 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
14382 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
14383 l_rec_acct_attrs.array_num_value(9) := p_source_14;
14384 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
14385 l_rec_acct_attrs.array_char_value(10) := p_source_15;
14386 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
14387 l_rec_acct_attrs.array_num_value(11) := p_source_16;
14388 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
14389 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
14390 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
14391 l_rec_acct_attrs.array_num_value(13) := p_source_14;
14392 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
14393 l_rec_acct_attrs.array_char_value(14) := p_source_15;
14394 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
14395 l_rec_acct_attrs.array_num_value(15) := p_source_16;
14396 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
14397 l_rec_acct_attrs.array_char_value(16) := p_source_17;
14398 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
14399 l_rec_acct_attrs.array_num_value(17) := p_source_25;
14400 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
14401 l_rec_acct_attrs.array_char_value(18) := p_source_15;
14402 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
14403 l_rec_acct_attrs.array_date_value(19) := p_source_19;
14404 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
14405 l_rec_acct_attrs.array_num_value(20) := p_source_20;
14406 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
14407 l_rec_acct_attrs.array_char_value(21) := p_source_21;
14408 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
14409 l_rec_acct_attrs.array_num_value(22) := p_source_26;
14410 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
14411 l_rec_acct_attrs.array_num_value(23) := p_source_22;
14412 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
14413 l_rec_acct_attrs.array_num_value(24) := p_source_22;
14414
14415 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
14416 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
14417
14418 ---------------------------------------------------------------------------------------------------------------
14419 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
14420 ---------------------------------------------------------------------------------------------------------------
14421 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
14422
14423 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
14424 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
14425
14426 IF xla_accounting_cache_pkg.GetValueChar
14427 (p_source_code => 'LEDGER_CATEGORY_CODE'
14428 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
14429 AND l_bflow_method_code = 'PRIOR_ENTRY'
14430 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
14431 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
14432 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
14433 )
14434 THEN
14435 xla_ae_lines_pkg.BflowUpgEntry
14436 (p_business_method_code => l_bflow_method_code
14437 ,p_business_class_code => l_bflow_class_code
14438 ,p_balance_type => l_balance_type_code);
14439 ELSE
14440 NULL;
14441 -- No business flow processing for business flow method of NONE.
14442 END IF;
14443
14444 --
14445 -- call analytical criteria
14446 --
14447
14448 --
14449 -- call description
14450 --
14451 -- No description or it is inherited.
14452 --
14453 -- call ADRs
14454 -- Bug 4922099
14455 --
14456 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14457 (NVL(l_actual_upg_option, 'N') = 'O') OR
14458 (NVL(l_enc_upg_option, 'N') = 'O')
14459 )
14460 THEN
14461 NULL;
14462 --
14463 --
14464
14465 l_ccid := AcctDerRule_11(
14466 p_application_id => p_application_id
14467 , p_ae_header_id => l_ae_header_id
14468 , p_source_3 => p_source_3
14469 , x_transaction_coa_id => l_adr_transaction_coa_id
14470 , x_accounting_coa_id => l_adr_accounting_coa_id
14471 , x_value_type_code => l_adr_value_type_code
14472 , p_side => 'NA'
14473 );
14474
14475 xla_ae_lines_pkg.set_ccid(
14476 p_code_combination_id => l_ccid
14477 , p_value_type_code => l_adr_value_type_code
14478 , p_transaction_coa_id => l_adr_transaction_coa_id
14479 , p_accounting_coa_id => l_adr_accounting_coa_id
14480 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
14481 , p_adr_type_code => 'S'
14482 , p_component_type => l_component_type
14483 , p_component_code => l_component_code
14484 , p_component_type_code => l_component_type_code
14485 , p_component_appl_id => l_component_appl_id
14486 , p_amb_context_code => l_amb_context_code
14487 , p_side => 'NA'
14488 );
14489
14490
14491 l_segment := AcctDerRule_4(
14492 p_application_id => p_application_id
14493 , p_ae_header_id => l_ae_header_id
14494 , p_source_1 => p_source_1
14495 , p_source_2 => p_source_2
14496 , x_transaction_coa_id => l_adr_transaction_coa_id
14497 , x_accounting_coa_id => l_adr_accounting_coa_id
14498 , x_flexfield_segment_code => l_adr_flexfield_segment_code
14499 , x_flex_value_set_id => l_adr_flex_value_set_id
14500 , x_value_type_code => l_adr_value_type_code
14501 , x_value_combination_id => l_adr_value_combination_id
14502 , x_value_segment_code => l_adr_value_segment_code
14503 , p_side => 'NA'
14504 , p_override_seg_flag => 'Y'
14505 );
14506
14507 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
14508
14509 xla_ae_lines_pkg.set_segment(
14510 p_to_segment_code => 'GL_ACCOUNT'
14511 , p_segment_value => l_segment
14512 , p_from_segment_code => l_adr_value_segment_code
14513 , p_from_combination_id => l_adr_value_combination_id
14514 , p_value_type_code => l_adr_value_type_code
14515 , p_transaction_coa_id => l_adr_transaction_coa_id
14516 , p_accounting_coa_id => l_adr_accounting_coa_id
14517 , p_flexfield_segment_code => l_adr_flexfield_segment_code
14518 , p_flex_value_set_id => l_adr_flex_value_set_id
14519 , p_adr_code => 'FV_46X002'
14520 , p_adr_type_code => 'S'
14521 , p_component_type => l_component_type
14522 , p_component_code => l_component_code
14523 , p_component_type_code => l_component_type_code
14524 , p_component_appl_id => l_component_appl_id
14525 , p_amb_context_code => l_amb_context_code
14526 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
14527 , p_event_class_code => 'DELIVER_EXPENSE'
14528 , p_side => 'NA'
14529 );
14530
14531 END IF;
14532
14533 --
14534 --
14535 END IF;
14536 --
14537 -- Bug 4922099
14538 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
14539 (NVL(l_enc_upg_option, 'N') = 'O')
14540 ) AND
14541 (l_bflow_method_code = 'PRIOR_ENTRY')
14542 )
14543 THEN
14544 IF
14545 --
14546 1 = 2
14547 --
14548 THEN
14549 xla_accounting_err_pkg.build_message
14550 (p_appli_s_name => 'XLA'
14551 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14552 ,p_token_1 => 'LINE_NUMBER'
14553 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
14554 ,p_token_2 => 'LINE_TYPE_NAME'
14555 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
14556 l_component_type
14557 ,l_component_code
14558 ,l_component_type_code
14559 ,l_component_appl_id
14560 ,l_amb_context_code
14561 ,l_entity_code
14562 ,l_event_class_code
14563 )
14564 ,p_token_3 => 'OWNER'
14565 ,p_value_3 => xla_lookups_pkg.get_meaning(
14566 p_lookup_type => 'XLA_OWNER_TYPE'
14567 ,p_lookup_code => l_component_type_code
14568 )
14569 ,p_token_4 => 'PRODUCT_NAME'
14570 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
14571 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
14572 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
14573 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
14574 ,p_ae_header_id => NULL
14575 );
14576
14577 IF (C_LEVEL_ERROR>= g_log_level) THEN
14578 trace
14579 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14580 ,p_level => C_LEVEL_ERROR
14581 ,p_module => l_log_module);
14582 END IF;
14583 END IF;
14584 END IF;
14585 --
14586 --
14587 ------------------------------------------------------------------------------------------------
14588 -- 4219869 Business Flow
14589 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
14590 -- Prior Entry. Currently, the following code is always generated.
14591 ------------------------------------------------------------------------------------------------
14592 XLA_AE_LINES_PKG.ValidateCurrentLine;
14593
14594 ------------------------------------------------------------------------------------
14595 -- 4219869 Business Flow
14596 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
14597 ------------------------------------------------------------------------------------
14598 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14599
14600 ----------------------------------------------------------------------------------
14601 -- 4219869 Business Flow
14602 -- Update journal entry status -- Need to generate this within IF <condition>
14603 ----------------------------------------------------------------------------------
14604 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14605 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
14606 ,p_balance_type_code => l_balance_type_code
14607 );
14608
14609 -------------------------------------------------------------------------------------------
14610 -- 4262811 - Generate the Accrual Reversal lines
14611 -------------------------------------------------------------------------------------------
14612 BEGIN
14613 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
14614 (g_array_event(p_event_id).array_value_num('header_index'));
14615 IF l_acc_rev_flag IS NULL THEN
14616 l_acc_rev_flag := 'N';
14617 END IF;
14618 EXCEPTION
14619 WHEN OTHERS THEN
14620 l_acc_rev_flag := 'N';
14621 END;
14622 --
14623 IF (l_acc_rev_flag = 'Y') THEN
14624
14625 -- 4645092 ------------------------------------------------------------------------------
14626 -- To allow MPA report to determine if it should generate report process
14627 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
14628 ------------------------------------------------------------------------------------------
14629
14630 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
14631 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
14632 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
14633 -- call ADRs
14634 -- Bug 4922099
14635 --
14636 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14637 (NVL(l_actual_upg_option, 'N') = 'O') OR
14638 (NVL(l_enc_upg_option, 'N') = 'O')
14639 )
14640 THEN
14641 NULL;
14642 --
14643 --
14644
14645 l_ccid := AcctDerRule_11(
14646 p_application_id => p_application_id
14647 , p_ae_header_id => l_ae_header_id
14648 , p_source_3 => p_source_3
14649 , x_transaction_coa_id => l_adr_transaction_coa_id
14650 , x_accounting_coa_id => l_adr_accounting_coa_id
14651 , x_value_type_code => l_adr_value_type_code
14652 , p_side => 'NA'
14653 );
14654
14655 xla_ae_lines_pkg.set_ccid(
14656 p_code_combination_id => l_ccid
14657 , p_value_type_code => l_adr_value_type_code
14658 , p_transaction_coa_id => l_adr_transaction_coa_id
14659 , p_accounting_coa_id => l_adr_accounting_coa_id
14660 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
14661 , p_adr_type_code => 'S'
14662 , p_component_type => l_component_type
14663 , p_component_code => l_component_code
14664 , p_component_type_code => l_component_type_code
14665 , p_component_appl_id => l_component_appl_id
14666 , p_amb_context_code => l_amb_context_code
14667 , p_side => 'NA'
14668 );
14669
14670
14671 l_segment := AcctDerRule_4(
14672 p_application_id => p_application_id
14673 , p_ae_header_id => l_ae_header_id
14674 , p_source_1 => p_source_1
14675 , p_source_2 => p_source_2
14676 , x_transaction_coa_id => l_adr_transaction_coa_id
14677 , x_accounting_coa_id => l_adr_accounting_coa_id
14678 , x_flexfield_segment_code => l_adr_flexfield_segment_code
14679 , x_flex_value_set_id => l_adr_flex_value_set_id
14680 , x_value_type_code => l_adr_value_type_code
14681 , x_value_combination_id => l_adr_value_combination_id
14682 , x_value_segment_code => l_adr_value_segment_code
14683 , p_side => 'NA'
14684 , p_override_seg_flag => 'Y'
14685 );
14686
14687 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
14688
14689 xla_ae_lines_pkg.set_segment(
14690 p_to_segment_code => 'GL_ACCOUNT'
14691 , p_segment_value => l_segment
14692 , p_from_segment_code => l_adr_value_segment_code
14693 , p_from_combination_id => l_adr_value_combination_id
14694 , p_value_type_code => l_adr_value_type_code
14695 , p_transaction_coa_id => l_adr_transaction_coa_id
14696 , p_accounting_coa_id => l_adr_accounting_coa_id
14697 , p_flexfield_segment_code => l_adr_flexfield_segment_code
14698 , p_flex_value_set_id => l_adr_flex_value_set_id
14699 , p_adr_code => 'FV_46X002'
14700 , p_adr_type_code => 'S'
14701 , p_component_type => l_component_type
14702 , p_component_code => l_component_code
14703 , p_component_type_code => l_component_type_code
14704 , p_component_appl_id => l_component_appl_id
14705 , p_amb_context_code => l_amb_context_code
14706 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
14707 , p_event_class_code => 'DELIVER_EXPENSE'
14708 , p_side => 'NA'
14709 );
14710
14711 END IF;
14712
14713 --
14714 --
14715 END IF;
14716
14717 --
14718 -- Update the line information that should be overwritten
14719 --
14720 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
14721 p_header_num => 1);
14722 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
14723
14724 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
14725
14726 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
14727 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
14728 END IF;
14729
14730 --
14731 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
14732 --
14733 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
14734 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
14735 ELSE
14736 ---------------------------------------------------------------------------------------------------
14737 -- 4262811a Switch Sign
14738 ---------------------------------------------------------------------------------------------------
14739 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
14740 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14741 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14742 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14743 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14744 -- 5132302
14745 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
14746 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14747
14748 END IF;
14749
14750 -- 4955764
14751 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14752 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
14753
14754
14755 XLA_AE_LINES_PKG.ValidateCurrentLine;
14756 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14757
14758 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14759 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
14760 ,p_balance_type_code => l_balance_type_code);
14761
14762 END IF;
14763
14764 -----------------------------------------------------------------------------------------
14765 -- 4262811 Multiperiod Accounting
14766 -----------------------------------------------------------------------------------------
14767 -- No MPA option is assigned.
14768
14769
14770 END IF;
14771 END IF;
14772 --
14773
14774 --
14775 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14776 trace
14777 (p_msg => 'END of AcctLineType_30'
14778 ,p_level => C_LEVEL_PROCEDURE
14779 ,p_module => l_log_module);
14780 END IF;
14781 --
14782 EXCEPTION
14783 WHEN xla_exceptions_pkg.application_exception THEN
14784 RAISE;
14785 WHEN OTHERS THEN
14786 xla_exceptions_pkg.raise_message
14787 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_30');
14788 END AcctLineType_30;
14789 --
14790
14791 ---------------------------------------
14792 --
14793 -- PRIVATE FUNCTION
14794 -- AcctLineType_31
14795 --
14796 ---------------------------------------
14797 PROCEDURE AcctLineType_31 (
14798 p_application_id IN NUMBER
14799 ,p_event_id IN NUMBER
14800 ,p_calculate_acctd_flag IN VARCHAR2
14801 ,p_calculate_g_l_flag IN VARCHAR2
14802 ,p_actual_flag IN OUT VARCHAR2
14803 ,p_balance_type_code OUT VARCHAR2
14804 ,p_gain_or_loss_ref OUT VARCHAR2
14805
14806 --Federal Fund Expired Status
14807 , p_source_1 IN VARCHAR2
14808 --Federal Fund Category
14809 , p_source_2 IN VARCHAR2
14810 --PO Budget Account
14811 , p_source_3 IN NUMBER
14812 --Applied to Application ID
14813 , p_source_7 IN NUMBER
14814 --Applied to Distribution Link Type
14815 , p_source_8 IN VARCHAR2
14816 --Applied to Entity Code
14817 , p_source_9 IN VARCHAR2
14818 --Applied To Purchase Document Identifier
14819 , p_source_11 IN NUMBER
14820 --DISTRIBUTION_IDENTIFIER
14821 , p_source_12 IN NUMBER
14822 --Distribution Type
14823 , p_source_13 IN VARCHAR2
14824 , p_source_13_meaning IN VARCHAR2
14825 --Encumbrance Reversal Amount Entered
14826 , p_source_14 IN NUMBER
14827 --Entered Currency Code
14828 , p_source_15 IN VARCHAR2
14829 --Transaction Encumbrance Reversal Amount
14830 , p_source_16 IN NUMBER
14831 --Costing Encumbrance Upgrade Option
14832 , p_source_17 IN VARCHAR2
14833 --Currency Conversion Date
14834 , p_source_19 IN DATE
14835 --Currency Conversion Rate
14836 , p_source_20 IN NUMBER
14837 --Currency Conversion Type
14838 , p_source_21 IN VARCHAR2
14839 --Purchasing Encumbrance Type Identifier
14840 , p_source_22 IN NUMBER
14841 --TXN_PO_DISTRIBUTION_ID
14842 , p_source_23 IN NUMBER
14843 --Entered Amount
14844 , p_source_25 IN NUMBER
14845 --Accounted Amount
14846 , p_source_26 IN NUMBER
14847 )
14848 IS
14849
14850 l_component_type VARCHAR2(80);
14851 l_component_code VARCHAR2(30);
14852 l_component_type_code VARCHAR2(1);
14853 l_component_appl_id INTEGER;
14854 l_amb_context_code VARCHAR2(30);
14855 l_entity_code VARCHAR2(30);
14856 l_event_class_code VARCHAR2(30);
14857 l_ae_header_id NUMBER;
14858 l_event_type_code VARCHAR2(30);
14859 l_line_definition_code VARCHAR2(30);
14860 l_line_definition_owner_code VARCHAR2(1);
14861 --
14862 -- adr variables
14863 l_segment VARCHAR2(30);
14864 l_ccid NUMBER;
14865 l_adr_transaction_coa_id NUMBER;
14866 l_adr_accounting_coa_id NUMBER;
14867 l_adr_flexfield_segment_code VARCHAR2(30);
14868 l_adr_flex_value_set_id NUMBER;
14869 l_adr_value_type_code VARCHAR2(30);
14870 l_adr_value_combination_id NUMBER;
14871 l_adr_value_segment_code VARCHAR2(30);
14872
14873 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
14874 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
14875 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
14876 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
14877
14878 -- 4262811 Variables ------------------------------------------------------------------------------------------
14879 l_entered_amt_idx NUMBER;
14880 l_accted_amt_idx NUMBER;
14881 l_acc_rev_flag VARCHAR2(1);
14882 l_accrual_line_num NUMBER;
14883 l_tmp_amt NUMBER;
14884 l_acc_rev_natural_side_code VARCHAR2(1);
14885
14886 l_num_entries NUMBER;
14887 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
14888 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
14889 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
14890 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
14891 l_recog_line_1 NUMBER;
14892 l_recog_line_2 NUMBER;
14893
14894 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
14895 l_bflow_applied_to_amt NUMBER; -- 5132302
14896 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
14897
14898 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
14899
14900 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
14901 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
14902
14903 ---------------------------------------------------------------------------------------------------------------
14904
14905
14906 --
14907 -- bulk performance
14908 --
14909 l_balance_type_code VARCHAR2(1);
14910 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
14911 l_log_module VARCHAR2(240);
14912
14913 --
14914 -- Upgrade strategy
14915 --
14916 l_actual_upg_option VARCHAR2(1);
14917 l_enc_upg_option VARCHAR2(1);
14918
14919 --
14920 BEGIN
14921 --
14922 IF g_log_enabled THEN
14923 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_31';
14924 END IF;
14925 --
14926 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14927
14928 trace
14929 (p_msg => 'BEGIN of AcctLineType_31'
14930 ,p_level => C_LEVEL_PROCEDURE
14931 ,p_module => l_log_module);
14932
14933 END IF;
14934 --
14935 l_component_type := 'AMB_JLT';
14936 l_component_code := 'FV_REINSTATE_PO_DR_RTI';
14937 l_component_type_code := 'S';
14938 l_component_appl_id := 707;
14939 l_amb_context_code := 'DEFAULT';
14940 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
14941 l_event_class_code := 'PURCHASE_ORDER';
14942 l_event_type_code := 'PURCHASE_ORDER_ALL';
14943 l_line_definition_owner_code := 'S';
14944 l_line_definition_code := 'FV_RET_RI_INV';
14945 --
14946 l_balance_type_code := 'A';
14947 l_segment := NULL;
14948 l_ccid := NULL;
14949 l_adr_transaction_coa_id := NULL;
14950 l_adr_accounting_coa_id := NULL;
14951 l_adr_flexfield_segment_code := NULL;
14952 l_adr_flex_value_set_id := NULL;
14953 l_adr_value_type_code := NULL;
14954 l_adr_value_combination_id := NULL;
14955 l_adr_value_segment_code := NULL;
14956
14957 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
14958 l_bflow_class_code := ''; -- 4219869 Business Flow
14959 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
14960 l_budgetary_control_flag := 'Y';
14961
14962 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14963 l_bflow_applied_to_amt := NULL; -- 5132302
14964 l_entered_amt_idx := NULL; -- 4262811
14965 l_accted_amt_idx := NULL; -- 4262811
14966 l_acc_rev_flag := NULL; -- 4262811
14967 l_accrual_line_num := NULL; -- 4262811
14968 l_tmp_amt := NULL; -- 4262811
14969 --
14970
14971 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
14972 l_balance_type_code <> 'B' THEN
14973 IF NVL(
14974 xla_ae_sources_pkg.GetSystemSourceChar(
14975 p_source_code => 'XLA_EVENT_TYPE_CODE'
14976 , p_source_type_code => 'Y'
14977 , p_source_application_id => 602
14978 ),'
14979 ') = 'RET_RI_INV'
14980 THEN
14981
14982 --
14983 XLA_AE_LINES_PKG.SetNewLine;
14984
14985 p_balance_type_code := l_balance_type_code;
14986 -- set the flag so later we will know whether the gain loss line needs to be created
14987
14988 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
14989 p_actual_flag :='A';
14990 END IF;
14991
14992 --
14993 -- bulk performance
14994 --
14995 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
14996 p_header_num => 0); -- 4262811
14997 --
14998 -- set accounting line options
14999 --
15000 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
15001 p_natural_side_code => 'D'
15002 , p_gain_or_loss_flag => 'N'
15003 , p_gl_transfer_mode_code => 'S'
15004 , p_acct_entry_type_code => 'A'
15005 , p_switch_side_flag => 'N'
15006 , p_merge_duplicate_code => 'N'
15007 );
15008 --
15009 l_acc_rev_natural_side_code := 'C'; -- 4262811
15010 --
15011 --
15012 -- set accounting line type info
15013 --
15014 xla_ae_lines_pkg.SetAcctLineType
15015 (p_component_type => l_component_type
15016 ,p_event_type_code => l_event_type_code
15017 ,p_line_definition_owner_code => l_line_definition_owner_code
15018 ,p_line_definition_code => l_line_definition_code
15019 ,p_accounting_line_code => l_component_code
15020 ,p_accounting_line_type_code => l_component_type_code
15021 ,p_accounting_line_appl_id => l_component_appl_id
15022 ,p_amb_context_code => l_amb_context_code
15023 ,p_entity_code => l_entity_code
15024 ,p_event_class_code => l_event_class_code);
15025 --
15026 -- set accounting class
15027 --
15028 xla_ae_lines_pkg.SetAcctClass(
15029 p_accounting_class_code => 'FEDERAL_INV'
15030 , p_ae_header_id => l_ae_header_id
15031 );
15032
15033 --
15034 -- set rounding class
15035 --
15036 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
15037 'FEDERAL_INV';
15038
15039 --
15040 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
15041 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
15042 --
15043 -- bulk performance
15044 --
15045 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
15046
15047 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
15048 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
15049
15050 -- 4955764
15051 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15052 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
15053
15054 -- 4458381 Public Sector Enh
15055
15056 --
15057 -- set accounting attributes for the line type
15058 --
15059 l_entered_amt_idx := 17;
15060 l_accted_amt_idx := 22;
15061 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15062 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
15063 l_rec_acct_attrs.array_num_value(1) := p_source_7;
15064 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
15065 l_rec_acct_attrs.array_char_value(2) := p_source_8;
15066 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
15067 l_rec_acct_attrs.array_char_value(3) := p_source_9;
15068 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
15069 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
15070 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
15071 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
15072 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
15073 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
15074 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
15075 l_rec_acct_attrs.array_char_value(7) := p_source_13;
15076 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
15077 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
15078 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
15079 l_rec_acct_attrs.array_num_value(9) := p_source_14;
15080 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
15081 l_rec_acct_attrs.array_char_value(10) := p_source_15;
15082 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
15083 l_rec_acct_attrs.array_num_value(11) := p_source_16;
15084 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
15085 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
15086 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
15087 l_rec_acct_attrs.array_num_value(13) := p_source_14;
15088 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
15089 l_rec_acct_attrs.array_char_value(14) := p_source_15;
15090 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
15091 l_rec_acct_attrs.array_num_value(15) := p_source_16;
15092 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
15093 l_rec_acct_attrs.array_char_value(16) := p_source_17;
15094 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
15095 l_rec_acct_attrs.array_num_value(17) := p_source_25;
15096 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
15097 l_rec_acct_attrs.array_char_value(18) := p_source_15;
15098 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
15099 l_rec_acct_attrs.array_date_value(19) := p_source_19;
15100 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
15101 l_rec_acct_attrs.array_num_value(20) := p_source_20;
15102 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
15103 l_rec_acct_attrs.array_char_value(21) := p_source_21;
15104 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
15105 l_rec_acct_attrs.array_num_value(22) := p_source_26;
15106 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
15107 l_rec_acct_attrs.array_num_value(23) := p_source_22;
15108 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
15109 l_rec_acct_attrs.array_num_value(24) := p_source_22;
15110
15111 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
15112 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
15113
15114 ---------------------------------------------------------------------------------------------------------------
15115 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
15116 ---------------------------------------------------------------------------------------------------------------
15117 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
15118
15119 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15120 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15121
15122 IF xla_accounting_cache_pkg.GetValueChar
15123 (p_source_code => 'LEDGER_CATEGORY_CODE'
15124 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
15125 AND l_bflow_method_code = 'PRIOR_ENTRY'
15126 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
15127 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
15128 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
15129 )
15130 THEN
15131 xla_ae_lines_pkg.BflowUpgEntry
15132 (p_business_method_code => l_bflow_method_code
15133 ,p_business_class_code => l_bflow_class_code
15134 ,p_balance_type => l_balance_type_code);
15135 ELSE
15136 NULL;
15137 -- No business flow processing for business flow method of NONE.
15138 END IF;
15139
15140 --
15141 -- call analytical criteria
15142 --
15143
15144 --
15145 -- call description
15146 --
15147 -- No description or it is inherited.
15148 --
15149 -- call ADRs
15150 -- Bug 4922099
15151 --
15152 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15153 (NVL(l_actual_upg_option, 'N') = 'O') OR
15154 (NVL(l_enc_upg_option, 'N') = 'O')
15155 )
15156 THEN
15157 NULL;
15158 --
15159 --
15160
15161 l_ccid := AcctDerRule_11(
15162 p_application_id => p_application_id
15163 , p_ae_header_id => l_ae_header_id
15164 , p_source_3 => p_source_3
15165 , x_transaction_coa_id => l_adr_transaction_coa_id
15166 , x_accounting_coa_id => l_adr_accounting_coa_id
15167 , x_value_type_code => l_adr_value_type_code
15168 , p_side => 'NA'
15169 );
15170
15171 xla_ae_lines_pkg.set_ccid(
15172 p_code_combination_id => l_ccid
15173 , p_value_type_code => l_adr_value_type_code
15174 , p_transaction_coa_id => l_adr_transaction_coa_id
15175 , p_accounting_coa_id => l_adr_accounting_coa_id
15176 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
15177 , p_adr_type_code => 'S'
15178 , p_component_type => l_component_type
15179 , p_component_code => l_component_code
15180 , p_component_type_code => l_component_type_code
15181 , p_component_appl_id => l_component_appl_id
15182 , p_amb_context_code => l_amb_context_code
15183 , p_side => 'NA'
15184 );
15185
15186
15187 l_segment := AcctDerRule_4(
15188 p_application_id => p_application_id
15189 , p_ae_header_id => l_ae_header_id
15190 , p_source_1 => p_source_1
15191 , p_source_2 => p_source_2
15192 , x_transaction_coa_id => l_adr_transaction_coa_id
15193 , x_accounting_coa_id => l_adr_accounting_coa_id
15194 , x_flexfield_segment_code => l_adr_flexfield_segment_code
15195 , x_flex_value_set_id => l_adr_flex_value_set_id
15196 , x_value_type_code => l_adr_value_type_code
15197 , x_value_combination_id => l_adr_value_combination_id
15198 , x_value_segment_code => l_adr_value_segment_code
15199 , p_side => 'NA'
15200 , p_override_seg_flag => 'Y'
15201 );
15202
15203 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
15204
15205 xla_ae_lines_pkg.set_segment(
15206 p_to_segment_code => 'GL_ACCOUNT'
15207 , p_segment_value => l_segment
15208 , p_from_segment_code => l_adr_value_segment_code
15209 , p_from_combination_id => l_adr_value_combination_id
15210 , p_value_type_code => l_adr_value_type_code
15211 , p_transaction_coa_id => l_adr_transaction_coa_id
15212 , p_accounting_coa_id => l_adr_accounting_coa_id
15213 , p_flexfield_segment_code => l_adr_flexfield_segment_code
15214 , p_flex_value_set_id => l_adr_flex_value_set_id
15215 , p_adr_code => 'FV_46X002'
15216 , p_adr_type_code => 'S'
15217 , p_component_type => l_component_type
15218 , p_component_code => l_component_code
15219 , p_component_type_code => l_component_type_code
15220 , p_component_appl_id => l_component_appl_id
15221 , p_amb_context_code => l_amb_context_code
15222 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
15223 , p_event_class_code => 'PURCHASE_ORDER'
15224 , p_side => 'NA'
15225 );
15226
15227 END IF;
15228
15229 --
15230 --
15231 END IF;
15232 --
15233 -- Bug 4922099
15234 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
15235 (NVL(l_enc_upg_option, 'N') = 'O')
15236 ) AND
15237 (l_bflow_method_code = 'PRIOR_ENTRY')
15238 )
15239 THEN
15240 IF
15241 --
15242 1 = 2
15243 --
15244 THEN
15245 xla_accounting_err_pkg.build_message
15246 (p_appli_s_name => 'XLA'
15247 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15248 ,p_token_1 => 'LINE_NUMBER'
15249 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
15250 ,p_token_2 => 'LINE_TYPE_NAME'
15251 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
15252 l_component_type
15253 ,l_component_code
15254 ,l_component_type_code
15255 ,l_component_appl_id
15256 ,l_amb_context_code
15257 ,l_entity_code
15258 ,l_event_class_code
15259 )
15260 ,p_token_3 => 'OWNER'
15261 ,p_value_3 => xla_lookups_pkg.get_meaning(
15262 p_lookup_type => 'XLA_OWNER_TYPE'
15263 ,p_lookup_code => l_component_type_code
15264 )
15265 ,p_token_4 => 'PRODUCT_NAME'
15266 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
15267 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
15268 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
15269 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
15270 ,p_ae_header_id => NULL
15271 );
15272
15273 IF (C_LEVEL_ERROR>= g_log_level) THEN
15274 trace
15275 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15276 ,p_level => C_LEVEL_ERROR
15277 ,p_module => l_log_module);
15278 END IF;
15279 END IF;
15280 END IF;
15281 --
15282 --
15283 ------------------------------------------------------------------------------------------------
15284 -- 4219869 Business Flow
15285 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
15286 -- Prior Entry. Currently, the following code is always generated.
15287 ------------------------------------------------------------------------------------------------
15288 XLA_AE_LINES_PKG.ValidateCurrentLine;
15289
15290 ------------------------------------------------------------------------------------
15291 -- 4219869 Business Flow
15292 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
15293 ------------------------------------------------------------------------------------
15294 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15295
15296 ----------------------------------------------------------------------------------
15297 -- 4219869 Business Flow
15298 -- Update journal entry status -- Need to generate this within IF <condition>
15299 ----------------------------------------------------------------------------------
15300 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15301 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
15302 ,p_balance_type_code => l_balance_type_code
15303 );
15304
15305 -------------------------------------------------------------------------------------------
15306 -- 4262811 - Generate the Accrual Reversal lines
15307 -------------------------------------------------------------------------------------------
15308 BEGIN
15309 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
15310 (g_array_event(p_event_id).array_value_num('header_index'));
15311 IF l_acc_rev_flag IS NULL THEN
15312 l_acc_rev_flag := 'N';
15313 END IF;
15314 EXCEPTION
15315 WHEN OTHERS THEN
15316 l_acc_rev_flag := 'N';
15317 END;
15318 --
15319 IF (l_acc_rev_flag = 'Y') THEN
15320
15321 -- 4645092 ------------------------------------------------------------------------------
15322 -- To allow MPA report to determine if it should generate report process
15323 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
15324 ------------------------------------------------------------------------------------------
15325
15326 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
15327 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
15328 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
15329 -- call ADRs
15330 -- Bug 4922099
15331 --
15332 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15333 (NVL(l_actual_upg_option, 'N') = 'O') OR
15334 (NVL(l_enc_upg_option, 'N') = 'O')
15335 )
15336 THEN
15337 NULL;
15338 --
15339 --
15340
15341 l_ccid := AcctDerRule_11(
15342 p_application_id => p_application_id
15343 , p_ae_header_id => l_ae_header_id
15344 , p_source_3 => p_source_3
15345 , x_transaction_coa_id => l_adr_transaction_coa_id
15346 , x_accounting_coa_id => l_adr_accounting_coa_id
15347 , x_value_type_code => l_adr_value_type_code
15348 , p_side => 'NA'
15349 );
15350
15351 xla_ae_lines_pkg.set_ccid(
15352 p_code_combination_id => l_ccid
15353 , p_value_type_code => l_adr_value_type_code
15354 , p_transaction_coa_id => l_adr_transaction_coa_id
15355 , p_accounting_coa_id => l_adr_accounting_coa_id
15356 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
15357 , p_adr_type_code => 'S'
15358 , p_component_type => l_component_type
15359 , p_component_code => l_component_code
15360 , p_component_type_code => l_component_type_code
15361 , p_component_appl_id => l_component_appl_id
15362 , p_amb_context_code => l_amb_context_code
15363 , p_side => 'NA'
15364 );
15365
15366
15367 l_segment := AcctDerRule_4(
15368 p_application_id => p_application_id
15369 , p_ae_header_id => l_ae_header_id
15370 , p_source_1 => p_source_1
15371 , p_source_2 => p_source_2
15372 , x_transaction_coa_id => l_adr_transaction_coa_id
15373 , x_accounting_coa_id => l_adr_accounting_coa_id
15374 , x_flexfield_segment_code => l_adr_flexfield_segment_code
15375 , x_flex_value_set_id => l_adr_flex_value_set_id
15376 , x_value_type_code => l_adr_value_type_code
15377 , x_value_combination_id => l_adr_value_combination_id
15378 , x_value_segment_code => l_adr_value_segment_code
15379 , p_side => 'NA'
15380 , p_override_seg_flag => 'Y'
15381 );
15382
15383 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
15384
15385 xla_ae_lines_pkg.set_segment(
15386 p_to_segment_code => 'GL_ACCOUNT'
15387 , p_segment_value => l_segment
15388 , p_from_segment_code => l_adr_value_segment_code
15389 , p_from_combination_id => l_adr_value_combination_id
15390 , p_value_type_code => l_adr_value_type_code
15391 , p_transaction_coa_id => l_adr_transaction_coa_id
15392 , p_accounting_coa_id => l_adr_accounting_coa_id
15393 , p_flexfield_segment_code => l_adr_flexfield_segment_code
15394 , p_flex_value_set_id => l_adr_flex_value_set_id
15395 , p_adr_code => 'FV_46X002'
15396 , p_adr_type_code => 'S'
15397 , p_component_type => l_component_type
15398 , p_component_code => l_component_code
15399 , p_component_type_code => l_component_type_code
15400 , p_component_appl_id => l_component_appl_id
15401 , p_amb_context_code => l_amb_context_code
15402 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
15403 , p_event_class_code => 'PURCHASE_ORDER'
15404 , p_side => 'NA'
15405 );
15406
15407 END IF;
15408
15409 --
15410 --
15411 END IF;
15412
15413 --
15414 -- Update the line information that should be overwritten
15415 --
15416 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
15417 p_header_num => 1);
15418 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
15419
15420 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
15421
15422 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
15423 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
15424 END IF;
15425
15426 --
15427 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
15428 --
15429 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
15430 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
15431 ELSE
15432 ---------------------------------------------------------------------------------------------------
15433 -- 4262811a Switch Sign
15434 ---------------------------------------------------------------------------------------------------
15435 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
15436 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15437 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15438 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15439 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15440 -- 5132302
15441 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
15442 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15443
15444 END IF;
15445
15446 -- 4955764
15447 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15448 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
15449
15450
15451 XLA_AE_LINES_PKG.ValidateCurrentLine;
15452 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15453
15454 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15455 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
15456 ,p_balance_type_code => l_balance_type_code);
15457
15458 END IF;
15459
15460 -----------------------------------------------------------------------------------------
15461 -- 4262811 Multiperiod Accounting
15462 -----------------------------------------------------------------------------------------
15463 -- No MPA option is assigned.
15464
15465
15466 END IF;
15467 END IF;
15468 --
15469
15470 --
15471 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15472 trace
15473 (p_msg => 'END of AcctLineType_31'
15474 ,p_level => C_LEVEL_PROCEDURE
15475 ,p_module => l_log_module);
15476 END IF;
15477 --
15478 EXCEPTION
15479 WHEN xla_exceptions_pkg.application_exception THEN
15480 RAISE;
15481 WHEN OTHERS THEN
15482 xla_exceptions_pkg.raise_message
15483 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_31');
15484 END AcctLineType_31;
15485 --
15486
15487 ---------------------------------------
15488 --
15489 -- PRIVATE FUNCTION
15490 -- AcctLineType_32
15491 --
15492 ---------------------------------------
15493 PROCEDURE AcctLineType_32 (
15494 p_application_id IN NUMBER
15495 ,p_event_id IN NUMBER
15496 ,p_calculate_acctd_flag IN VARCHAR2
15497 ,p_calculate_g_l_flag IN VARCHAR2
15498 ,p_actual_flag IN OUT VARCHAR2
15499 ,p_balance_type_code OUT VARCHAR2
15500 ,p_gain_or_loss_ref OUT VARCHAR2
15501
15502 --PO Budget Account
15503 , p_source_3 IN NUMBER
15504 --Receiving Accounting Line Type
15505 , p_source_6 IN VARCHAR2
15506 --Applied to Application ID
15507 , p_source_7 IN NUMBER
15508 --Applied to Distribution Link Type
15509 , p_source_8 IN VARCHAR2
15510 --Applied to Entity Code
15511 , p_source_9 IN VARCHAR2
15512 --PO_DISTRIBUTION_ID
15513 , p_source_10 IN NUMBER
15514 --Applied To Purchase Document Identifier
15515 , p_source_11 IN NUMBER
15516 --DISTRIBUTION_IDENTIFIER
15517 , p_source_12 IN NUMBER
15518 --Distribution Type
15519 , p_source_13 IN VARCHAR2
15520 , p_source_13_meaning IN VARCHAR2
15521 --Encumbrance Reversal Amount Entered
15522 , p_source_14 IN NUMBER
15523 --Entered Currency Code
15524 , p_source_15 IN VARCHAR2
15525 --Transaction Encumbrance Reversal Amount
15526 , p_source_16 IN NUMBER
15527 --Costing Encumbrance Upgrade Option
15528 , p_source_17 IN VARCHAR2
15529 --Currency Conversion Date
15530 , p_source_19 IN DATE
15531 --Currency Conversion Rate
15532 , p_source_20 IN NUMBER
15533 --Currency Conversion Type
15534 , p_source_21 IN VARCHAR2
15535 --Purchasing Encumbrance Type Identifier
15536 , p_source_22 IN NUMBER
15537 --Federal Paid Unexpended Obligation Amount
15538 , p_source_28 IN NUMBER
15539 )
15540 IS
15541
15542 l_component_type VARCHAR2(80);
15543 l_component_code VARCHAR2(30);
15544 l_component_type_code VARCHAR2(1);
15545 l_component_appl_id INTEGER;
15546 l_amb_context_code VARCHAR2(30);
15547 l_entity_code VARCHAR2(30);
15548 l_event_class_code VARCHAR2(30);
15549 l_ae_header_id NUMBER;
15550 l_event_type_code VARCHAR2(30);
15551 l_line_definition_code VARCHAR2(30);
15552 l_line_definition_owner_code VARCHAR2(1);
15553 --
15554 -- adr variables
15555 l_segment VARCHAR2(30);
15556 l_ccid NUMBER;
15557 l_adr_transaction_coa_id NUMBER;
15558 l_adr_accounting_coa_id NUMBER;
15559 l_adr_flexfield_segment_code VARCHAR2(30);
15560 l_adr_flex_value_set_id NUMBER;
15561 l_adr_value_type_code VARCHAR2(30);
15562 l_adr_value_combination_id NUMBER;
15563 l_adr_value_segment_code VARCHAR2(30);
15564
15565 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
15566 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
15567 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
15568 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
15569
15570 -- 4262811 Variables ------------------------------------------------------------------------------------------
15571 l_entered_amt_idx NUMBER;
15572 l_accted_amt_idx NUMBER;
15573 l_acc_rev_flag VARCHAR2(1);
15574 l_accrual_line_num NUMBER;
15575 l_tmp_amt NUMBER;
15576 l_acc_rev_natural_side_code VARCHAR2(1);
15577
15578 l_num_entries NUMBER;
15579 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
15580 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
15581 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
15582 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
15583 l_recog_line_1 NUMBER;
15584 l_recog_line_2 NUMBER;
15585
15586 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
15587 l_bflow_applied_to_amt NUMBER; -- 5132302
15588 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
15589
15590 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
15591
15592 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
15593 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
15594
15595 ---------------------------------------------------------------------------------------------------------------
15596
15597
15598 --
15599 -- bulk performance
15600 --
15601 l_balance_type_code VARCHAR2(1);
15602 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
15603 l_log_module VARCHAR2(240);
15604
15605 --
15606 -- Upgrade strategy
15607 --
15608 l_actual_upg_option VARCHAR2(1);
15609 l_enc_upg_option VARCHAR2(1);
15610
15611 --
15612 BEGIN
15613 --
15614 IF g_log_enabled THEN
15615 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_32';
15616 END IF;
15617 --
15618 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15619
15620 trace
15621 (p_msg => 'BEGIN of AcctLineType_32'
15622 ,p_level => C_LEVEL_PROCEDURE
15623 ,p_module => l_log_module);
15624
15625 END IF;
15626 --
15627 l_component_type := 'AMB_JLT';
15628 l_component_code := 'FV_REINSTATE_PO_PAID_CR';
15629 l_component_type_code := 'S';
15630 l_component_appl_id := 707;
15631 l_amb_context_code := 'DEFAULT';
15632 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
15633 l_event_class_code := 'DELIVER_EXPENSE';
15634 l_event_type_code := 'DELIVER_EXPENSE_ALL';
15635 l_line_definition_owner_code := 'S';
15636 l_line_definition_code := 'FV_RETURN_TO_RECEIVING';
15637 --
15638 l_balance_type_code := 'A';
15639 l_segment := NULL;
15640 l_ccid := NULL;
15641 l_adr_transaction_coa_id := NULL;
15642 l_adr_accounting_coa_id := NULL;
15643 l_adr_flexfield_segment_code := NULL;
15644 l_adr_flex_value_set_id := NULL;
15645 l_adr_value_type_code := NULL;
15646 l_adr_value_combination_id := NULL;
15647 l_adr_value_segment_code := NULL;
15648
15649 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
15650 l_bflow_class_code := ''; -- 4219869 Business Flow
15651 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
15652 l_budgetary_control_flag := 'Y';
15653
15654 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15655 l_bflow_applied_to_amt := NULL; -- 5132302
15656 l_entered_amt_idx := NULL; -- 4262811
15657 l_accted_amt_idx := NULL; -- 4262811
15658 l_acc_rev_flag := NULL; -- 4262811
15659 l_accrual_line_num := NULL; -- 4262811
15660 l_tmp_amt := NULL; -- 4262811
15661 --
15662
15663 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
15664 l_balance_type_code <> 'B' THEN
15665 IF NVL(
15666 xla_ae_sources_pkg.GetSystemSourceChar(
15667 p_source_code => 'XLA_EVENT_TYPE_CODE'
15668 , p_source_type_code => 'Y'
15669 , p_source_application_id => 602
15670 ),'
15671 ') = 'RETURN_TO_RECEIVING' AND
15672 p_source_28 > 0 AND
15673 NVL(p_source_6,'
15674 ') = 'Charge'
15675 THEN
15676
15677 --
15678 XLA_AE_LINES_PKG.SetNewLine;
15679
15680 p_balance_type_code := l_balance_type_code;
15681 -- set the flag so later we will know whether the gain loss line needs to be created
15682
15683 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
15684 p_actual_flag :='A';
15685 END IF;
15686
15687 --
15688 -- bulk performance
15689 --
15690 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
15691 p_header_num => 0); -- 4262811
15692 --
15693 -- set accounting line options
15694 --
15695 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
15696 p_natural_side_code => 'C'
15697 , p_gain_or_loss_flag => 'N'
15698 , p_gl_transfer_mode_code => 'S'
15699 , p_acct_entry_type_code => 'A'
15700 , p_switch_side_flag => 'N'
15701 , p_merge_duplicate_code => 'N'
15702 );
15703 --
15704 l_acc_rev_natural_side_code := 'D'; -- 4262811
15705 --
15706 --
15707 -- set accounting line type info
15708 --
15709 xla_ae_lines_pkg.SetAcctLineType
15710 (p_component_type => l_component_type
15711 ,p_event_type_code => l_event_type_code
15712 ,p_line_definition_owner_code => l_line_definition_owner_code
15713 ,p_line_definition_code => l_line_definition_code
15714 ,p_accounting_line_code => l_component_code
15715 ,p_accounting_line_type_code => l_component_type_code
15716 ,p_accounting_line_appl_id => l_component_appl_id
15717 ,p_amb_context_code => l_amb_context_code
15718 ,p_entity_code => l_entity_code
15719 ,p_event_class_code => l_event_class_code);
15720 --
15721 -- set accounting class
15722 --
15723 xla_ae_lines_pkg.SetAcctClass(
15724 p_accounting_class_code => 'FEDERAL_EXP'
15725 , p_ae_header_id => l_ae_header_id
15726 );
15727
15728 --
15729 -- set rounding class
15730 --
15731 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
15732 'FEDERAL_EXP';
15733
15734 --
15735 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
15736 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
15737 --
15738 -- bulk performance
15739 --
15740 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
15741
15742 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
15743 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
15744
15745 -- 4955764
15746 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15747 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
15748
15749 -- 4458381 Public Sector Enh
15750
15751 --
15752 -- set accounting attributes for the line type
15753 --
15754 l_entered_amt_idx := 17;
15755 l_accted_amt_idx := 22;
15756 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15757 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
15758 l_rec_acct_attrs.array_num_value(1) := p_source_7;
15759 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
15760 l_rec_acct_attrs.array_char_value(2) := p_source_8;
15761 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
15762 l_rec_acct_attrs.array_char_value(3) := p_source_9;
15763 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
15764 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
15765 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
15766 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
15767 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
15768 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
15769 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
15770 l_rec_acct_attrs.array_char_value(7) := p_source_13;
15771 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
15772 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
15773 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
15774 l_rec_acct_attrs.array_num_value(9) := p_source_14;
15775 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
15776 l_rec_acct_attrs.array_char_value(10) := p_source_15;
15777 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
15778 l_rec_acct_attrs.array_num_value(11) := p_source_16;
15779 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
15780 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
15781 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
15782 l_rec_acct_attrs.array_num_value(13) := p_source_14;
15783 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
15784 l_rec_acct_attrs.array_char_value(14) := p_source_15;
15785 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
15786 l_rec_acct_attrs.array_num_value(15) := p_source_16;
15787 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
15788 l_rec_acct_attrs.array_char_value(16) := p_source_17;
15789 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
15790 l_rec_acct_attrs.array_num_value(17) := p_source_28;
15791 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
15792 l_rec_acct_attrs.array_char_value(18) := p_source_15;
15793 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
15794 l_rec_acct_attrs.array_date_value(19) := p_source_19;
15795 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
15796 l_rec_acct_attrs.array_num_value(20) := p_source_20;
15797 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
15798 l_rec_acct_attrs.array_char_value(21) := p_source_21;
15799 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
15800 l_rec_acct_attrs.array_num_value(22) := p_source_28;
15801 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
15802 l_rec_acct_attrs.array_num_value(23) := p_source_22;
15803 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
15804 l_rec_acct_attrs.array_num_value(24) := p_source_22;
15805
15806 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
15807 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
15808
15809 ---------------------------------------------------------------------------------------------------------------
15810 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
15811 ---------------------------------------------------------------------------------------------------------------
15812 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
15813
15814 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15815 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15816
15817 IF xla_accounting_cache_pkg.GetValueChar
15818 (p_source_code => 'LEDGER_CATEGORY_CODE'
15819 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
15820 AND l_bflow_method_code = 'PRIOR_ENTRY'
15821 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
15822 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
15823 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
15824 )
15825 THEN
15826 xla_ae_lines_pkg.BflowUpgEntry
15827 (p_business_method_code => l_bflow_method_code
15828 ,p_business_class_code => l_bflow_class_code
15829 ,p_balance_type => l_balance_type_code);
15830 ELSE
15831 NULL;
15832 -- No business flow processing for business flow method of NONE.
15833 END IF;
15834
15835 --
15836 -- call analytical criteria
15837 --
15838
15839 --
15840 -- call description
15841 --
15842 -- No description or it is inherited.
15843 --
15844 -- call ADRs
15845 -- Bug 4922099
15846 --
15847 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15848 (NVL(l_actual_upg_option, 'N') = 'O') OR
15849 (NVL(l_enc_upg_option, 'N') = 'O')
15850 )
15851 THEN
15852 NULL;
15853 --
15854 --
15855
15856 l_ccid := AcctDerRule_11(
15857 p_application_id => p_application_id
15858 , p_ae_header_id => l_ae_header_id
15859 , p_source_3 => p_source_3
15860 , x_transaction_coa_id => l_adr_transaction_coa_id
15861 , x_accounting_coa_id => l_adr_accounting_coa_id
15862 , x_value_type_code => l_adr_value_type_code
15863 , p_side => 'NA'
15864 );
15865
15866 xla_ae_lines_pkg.set_ccid(
15867 p_code_combination_id => l_ccid
15868 , p_value_type_code => l_adr_value_type_code
15869 , p_transaction_coa_id => l_adr_transaction_coa_id
15870 , p_accounting_coa_id => l_adr_accounting_coa_id
15871 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
15872 , p_adr_type_code => 'S'
15873 , p_component_type => l_component_type
15874 , p_component_code => l_component_code
15875 , p_component_type_code => l_component_type_code
15876 , p_component_appl_id => l_component_appl_id
15877 , p_amb_context_code => l_amb_context_code
15878 , p_side => 'NA'
15879 );
15880
15881
15882 l_segment := AcctDerRule_6(
15883 p_application_id => p_application_id
15884 , p_ae_header_id => l_ae_header_id
15885 , x_transaction_coa_id => l_adr_transaction_coa_id
15886 , x_accounting_coa_id => l_adr_accounting_coa_id
15887 , x_flexfield_segment_code => l_adr_flexfield_segment_code
15888 , x_flex_value_set_id => l_adr_flex_value_set_id
15889 , x_value_type_code => l_adr_value_type_code
15890 , x_value_combination_id => l_adr_value_combination_id
15891 , x_value_segment_code => l_adr_value_segment_code
15892 , p_side => 'NA'
15893 , p_override_seg_flag => 'Y'
15894 );
15895
15896 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
15897
15898 xla_ae_lines_pkg.set_segment(
15899 p_to_segment_code => 'GL_ACCOUNT'
15900 , p_segment_value => l_segment
15901 , p_from_segment_code => l_adr_value_segment_code
15902 , p_from_combination_id => l_adr_value_combination_id
15903 , p_value_type_code => l_adr_value_type_code
15904 , p_transaction_coa_id => l_adr_transaction_coa_id
15905 , p_accounting_coa_id => l_adr_accounting_coa_id
15906 , p_flexfield_segment_code => l_adr_flexfield_segment_code
15907 , p_flex_value_set_id => l_adr_flex_value_set_id
15908 , p_adr_code => 'FV_480201'
15909 , p_adr_type_code => 'S'
15910 , p_component_type => l_component_type
15911 , p_component_code => l_component_code
15912 , p_component_type_code => l_component_type_code
15913 , p_component_appl_id => l_component_appl_id
15914 , p_amb_context_code => l_amb_context_code
15915 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
15916 , p_event_class_code => 'DELIVER_EXPENSE'
15917 , p_side => 'NA'
15918 );
15919
15920 END IF;
15921
15922 --
15923 --
15924 END IF;
15925 --
15926 -- Bug 4922099
15927 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
15928 (NVL(l_enc_upg_option, 'N') = 'O')
15929 ) AND
15930 (l_bflow_method_code = 'PRIOR_ENTRY')
15931 )
15932 THEN
15933 IF
15934 --
15935 1 = 2
15936 --
15937 THEN
15938 xla_accounting_err_pkg.build_message
15939 (p_appli_s_name => 'XLA'
15940 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15941 ,p_token_1 => 'LINE_NUMBER'
15942 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
15943 ,p_token_2 => 'LINE_TYPE_NAME'
15944 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
15945 l_component_type
15946 ,l_component_code
15947 ,l_component_type_code
15948 ,l_component_appl_id
15949 ,l_amb_context_code
15950 ,l_entity_code
15951 ,l_event_class_code
15952 )
15953 ,p_token_3 => 'OWNER'
15954 ,p_value_3 => xla_lookups_pkg.get_meaning(
15955 p_lookup_type => 'XLA_OWNER_TYPE'
15956 ,p_lookup_code => l_component_type_code
15957 )
15958 ,p_token_4 => 'PRODUCT_NAME'
15959 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
15960 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
15961 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
15962 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
15963 ,p_ae_header_id => NULL
15964 );
15965
15966 IF (C_LEVEL_ERROR>= g_log_level) THEN
15967 trace
15968 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15969 ,p_level => C_LEVEL_ERROR
15970 ,p_module => l_log_module);
15971 END IF;
15972 END IF;
15973 END IF;
15974 --
15975 --
15976 ------------------------------------------------------------------------------------------------
15977 -- 4219869 Business Flow
15978 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
15979 -- Prior Entry. Currently, the following code is always generated.
15980 ------------------------------------------------------------------------------------------------
15981 XLA_AE_LINES_PKG.ValidateCurrentLine;
15982
15983 ------------------------------------------------------------------------------------
15984 -- 4219869 Business Flow
15985 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
15986 ------------------------------------------------------------------------------------
15987 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15988
15989 ----------------------------------------------------------------------------------
15990 -- 4219869 Business Flow
15991 -- Update journal entry status -- Need to generate this within IF <condition>
15992 ----------------------------------------------------------------------------------
15993 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15994 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
15995 ,p_balance_type_code => l_balance_type_code
15996 );
15997
15998 -------------------------------------------------------------------------------------------
15999 -- 4262811 - Generate the Accrual Reversal lines
16000 -------------------------------------------------------------------------------------------
16001 BEGIN
16002 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
16003 (g_array_event(p_event_id).array_value_num('header_index'));
16004 IF l_acc_rev_flag IS NULL THEN
16005 l_acc_rev_flag := 'N';
16006 END IF;
16007 EXCEPTION
16008 WHEN OTHERS THEN
16009 l_acc_rev_flag := 'N';
16010 END;
16011 --
16012 IF (l_acc_rev_flag = 'Y') THEN
16013
16014 -- 4645092 ------------------------------------------------------------------------------
16015 -- To allow MPA report to determine if it should generate report process
16016 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
16017 ------------------------------------------------------------------------------------------
16018
16019 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
16020 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
16021 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
16022 -- call ADRs
16023 -- Bug 4922099
16024 --
16025 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
16026 (NVL(l_actual_upg_option, 'N') = 'O') OR
16027 (NVL(l_enc_upg_option, 'N') = 'O')
16028 )
16029 THEN
16030 NULL;
16031 --
16032 --
16033
16034 l_ccid := AcctDerRule_11(
16035 p_application_id => p_application_id
16036 , p_ae_header_id => l_ae_header_id
16037 , p_source_3 => p_source_3
16038 , x_transaction_coa_id => l_adr_transaction_coa_id
16039 , x_accounting_coa_id => l_adr_accounting_coa_id
16040 , x_value_type_code => l_adr_value_type_code
16041 , p_side => 'NA'
16042 );
16043
16044 xla_ae_lines_pkg.set_ccid(
16045 p_code_combination_id => l_ccid
16046 , p_value_type_code => l_adr_value_type_code
16047 , p_transaction_coa_id => l_adr_transaction_coa_id
16048 , p_accounting_coa_id => l_adr_accounting_coa_id
16049 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
16050 , p_adr_type_code => 'S'
16051 , p_component_type => l_component_type
16052 , p_component_code => l_component_code
16053 , p_component_type_code => l_component_type_code
16054 , p_component_appl_id => l_component_appl_id
16055 , p_amb_context_code => l_amb_context_code
16056 , p_side => 'NA'
16057 );
16058
16059
16060 l_segment := AcctDerRule_6(
16061 p_application_id => p_application_id
16062 , p_ae_header_id => l_ae_header_id
16063 , x_transaction_coa_id => l_adr_transaction_coa_id
16064 , x_accounting_coa_id => l_adr_accounting_coa_id
16065 , x_flexfield_segment_code => l_adr_flexfield_segment_code
16066 , x_flex_value_set_id => l_adr_flex_value_set_id
16067 , x_value_type_code => l_adr_value_type_code
16068 , x_value_combination_id => l_adr_value_combination_id
16069 , x_value_segment_code => l_adr_value_segment_code
16070 , p_side => 'NA'
16071 , p_override_seg_flag => 'Y'
16072 );
16073
16074 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
16075
16076 xla_ae_lines_pkg.set_segment(
16077 p_to_segment_code => 'GL_ACCOUNT'
16078 , p_segment_value => l_segment
16079 , p_from_segment_code => l_adr_value_segment_code
16080 , p_from_combination_id => l_adr_value_combination_id
16081 , p_value_type_code => l_adr_value_type_code
16082 , p_transaction_coa_id => l_adr_transaction_coa_id
16083 , p_accounting_coa_id => l_adr_accounting_coa_id
16084 , p_flexfield_segment_code => l_adr_flexfield_segment_code
16085 , p_flex_value_set_id => l_adr_flex_value_set_id
16086 , p_adr_code => 'FV_480201'
16087 , p_adr_type_code => 'S'
16088 , p_component_type => l_component_type
16089 , p_component_code => l_component_code
16090 , p_component_type_code => l_component_type_code
16091 , p_component_appl_id => l_component_appl_id
16092 , p_amb_context_code => l_amb_context_code
16093 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
16094 , p_event_class_code => 'DELIVER_EXPENSE'
16095 , p_side => 'NA'
16096 );
16097
16098 END IF;
16099
16100 --
16101 --
16102 END IF;
16103
16104 --
16105 -- Update the line information that should be overwritten
16106 --
16107 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
16108 p_header_num => 1);
16109 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
16110
16111 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
16112
16113 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
16114 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
16115 END IF;
16116
16117 --
16118 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
16119 --
16120 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
16121 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
16122 ELSE
16123 ---------------------------------------------------------------------------------------------------
16124 -- 4262811a Switch Sign
16125 ---------------------------------------------------------------------------------------------------
16126 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
16127 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
16128 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16129 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
16130 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16131 -- 5132302
16132 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
16133 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16134
16135 END IF;
16136
16137 -- 4955764
16138 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16139 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
16140
16141
16142 XLA_AE_LINES_PKG.ValidateCurrentLine;
16143 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
16144
16145 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
16146 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
16147 ,p_balance_type_code => l_balance_type_code);
16148
16149 END IF;
16150
16151 -----------------------------------------------------------------------------------------
16152 -- 4262811 Multiperiod Accounting
16153 -----------------------------------------------------------------------------------------
16154 -- No MPA option is assigned.
16155
16156
16157 END IF;
16158 END IF;
16159 --
16160
16161 --
16162 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16163 trace
16164 (p_msg => 'END of AcctLineType_32'
16165 ,p_level => C_LEVEL_PROCEDURE
16166 ,p_module => l_log_module);
16167 END IF;
16168 --
16169 EXCEPTION
16170 WHEN xla_exceptions_pkg.application_exception THEN
16171 RAISE;
16172 WHEN OTHERS THEN
16173 xla_exceptions_pkg.raise_message
16174 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_32');
16175 END AcctLineType_32;
16176 --
16177
16178 ---------------------------------------
16179 --
16180 -- PRIVATE FUNCTION
16181 -- AcctLineType_33
16182 --
16183 ---------------------------------------
16184 PROCEDURE AcctLineType_33 (
16185 p_application_id IN NUMBER
16186 ,p_event_id IN NUMBER
16187 ,p_calculate_acctd_flag IN VARCHAR2
16188 ,p_calculate_g_l_flag IN VARCHAR2
16189 ,p_actual_flag IN OUT VARCHAR2
16190 ,p_balance_type_code OUT VARCHAR2
16191 ,p_gain_or_loss_ref OUT VARCHAR2
16192
16193 --PO Budget Account
16194 , p_source_3 IN NUMBER
16195 --Applied to Application ID
16196 , p_source_7 IN NUMBER
16197 --Applied to Distribution Link Type
16198 , p_source_8 IN VARCHAR2
16199 --Applied to Entity Code
16200 , p_source_9 IN VARCHAR2
16201 --Applied To Purchase Document Identifier
16202 , p_source_11 IN NUMBER
16203 --DISTRIBUTION_IDENTIFIER
16204 , p_source_12 IN NUMBER
16205 --Distribution Type
16206 , p_source_13 IN VARCHAR2
16207 , p_source_13_meaning IN VARCHAR2
16208 --Encumbrance Reversal Amount Entered
16209 , p_source_14 IN NUMBER
16210 --Entered Currency Code
16211 , p_source_15 IN VARCHAR2
16212 --Transaction Encumbrance Reversal Amount
16213 , p_source_16 IN NUMBER
16214 --Costing Encumbrance Upgrade Option
16215 , p_source_17 IN VARCHAR2
16216 --Currency Conversion Date
16217 , p_source_19 IN DATE
16218 --Currency Conversion Rate
16219 , p_source_20 IN NUMBER
16220 --Currency Conversion Type
16221 , p_source_21 IN VARCHAR2
16222 --Purchasing Encumbrance Type Identifier
16223 , p_source_22 IN NUMBER
16224 --TXN_PO_DISTRIBUTION_ID
16225 , p_source_23 IN NUMBER
16226 --Federal Paid Unexpended Obligation Amount
16227 , p_source_28 IN NUMBER
16228 )
16229 IS
16230
16231 l_component_type VARCHAR2(80);
16232 l_component_code VARCHAR2(30);
16233 l_component_type_code VARCHAR2(1);
16234 l_component_appl_id INTEGER;
16235 l_amb_context_code VARCHAR2(30);
16236 l_entity_code VARCHAR2(30);
16237 l_event_class_code VARCHAR2(30);
16238 l_ae_header_id NUMBER;
16239 l_event_type_code VARCHAR2(30);
16240 l_line_definition_code VARCHAR2(30);
16241 l_line_definition_owner_code VARCHAR2(1);
16242 --
16243 -- adr variables
16244 l_segment VARCHAR2(30);
16245 l_ccid NUMBER;
16246 l_adr_transaction_coa_id NUMBER;
16247 l_adr_accounting_coa_id NUMBER;
16248 l_adr_flexfield_segment_code VARCHAR2(30);
16249 l_adr_flex_value_set_id NUMBER;
16250 l_adr_value_type_code VARCHAR2(30);
16251 l_adr_value_combination_id NUMBER;
16252 l_adr_value_segment_code VARCHAR2(30);
16253
16254 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
16255 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
16256 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
16257 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
16258
16259 -- 4262811 Variables ------------------------------------------------------------------------------------------
16260 l_entered_amt_idx NUMBER;
16261 l_accted_amt_idx NUMBER;
16262 l_acc_rev_flag VARCHAR2(1);
16263 l_accrual_line_num NUMBER;
16264 l_tmp_amt NUMBER;
16265 l_acc_rev_natural_side_code VARCHAR2(1);
16266
16267 l_num_entries NUMBER;
16268 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
16269 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
16270 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
16271 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
16272 l_recog_line_1 NUMBER;
16273 l_recog_line_2 NUMBER;
16274
16275 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
16276 l_bflow_applied_to_amt NUMBER; -- 5132302
16277 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
16278
16279 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
16280
16281 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
16282 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
16283
16284 ---------------------------------------------------------------------------------------------------------------
16285
16286
16287 --
16288 -- bulk performance
16289 --
16290 l_balance_type_code VARCHAR2(1);
16291 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
16292 l_log_module VARCHAR2(240);
16293
16294 --
16295 -- Upgrade strategy
16296 --
16297 l_actual_upg_option VARCHAR2(1);
16298 l_enc_upg_option VARCHAR2(1);
16299
16300 --
16301 BEGIN
16302 --
16303 IF g_log_enabled THEN
16304 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_33';
16305 END IF;
16306 --
16307 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16308
16309 trace
16310 (p_msg => 'BEGIN of AcctLineType_33'
16311 ,p_level => C_LEVEL_PROCEDURE
16312 ,p_module => l_log_module);
16313
16314 END IF;
16315 --
16316 l_component_type := 'AMB_JLT';
16317 l_component_code := 'FV_REINSTATE_PO_PAID_CR_RTI';
16318 l_component_type_code := 'S';
16319 l_component_appl_id := 707;
16320 l_amb_context_code := 'DEFAULT';
16321 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
16322 l_event_class_code := 'PURCHASE_ORDER';
16323 l_event_type_code := 'PURCHASE_ORDER_ALL';
16324 l_line_definition_owner_code := 'S';
16325 l_line_definition_code := 'FV_RET_RI_INV';
16326 --
16327 l_balance_type_code := 'A';
16328 l_segment := NULL;
16329 l_ccid := NULL;
16330 l_adr_transaction_coa_id := NULL;
16331 l_adr_accounting_coa_id := NULL;
16332 l_adr_flexfield_segment_code := NULL;
16333 l_adr_flex_value_set_id := NULL;
16334 l_adr_value_type_code := NULL;
16335 l_adr_value_combination_id := NULL;
16336 l_adr_value_segment_code := NULL;
16337
16338 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
16339 l_bflow_class_code := ''; -- 4219869 Business Flow
16340 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
16341 l_budgetary_control_flag := 'Y';
16342
16343 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16344 l_bflow_applied_to_amt := NULL; -- 5132302
16345 l_entered_amt_idx := NULL; -- 4262811
16346 l_accted_amt_idx := NULL; -- 4262811
16347 l_acc_rev_flag := NULL; -- 4262811
16348 l_accrual_line_num := NULL; -- 4262811
16349 l_tmp_amt := NULL; -- 4262811
16350 --
16351
16352 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
16353 l_balance_type_code <> 'B' THEN
16354 IF NVL(
16355 xla_ae_sources_pkg.GetSystemSourceChar(
16356 p_source_code => 'XLA_EVENT_TYPE_CODE'
16357 , p_source_type_code => 'Y'
16358 , p_source_application_id => 602
16359 ),'
16360 ') = 'RET_RI_INV' AND
16361 p_source_28 > 0
16362 THEN
16363
16364 --
16365 XLA_AE_LINES_PKG.SetNewLine;
16366
16367 p_balance_type_code := l_balance_type_code;
16368 -- set the flag so later we will know whether the gain loss line needs to be created
16369
16370 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
16371 p_actual_flag :='A';
16372 END IF;
16373
16374 --
16375 -- bulk performance
16376 --
16377 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
16378 p_header_num => 0); -- 4262811
16379 --
16380 -- set accounting line options
16381 --
16382 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
16383 p_natural_side_code => 'C'
16384 , p_gain_or_loss_flag => 'N'
16385 , p_gl_transfer_mode_code => 'S'
16386 , p_acct_entry_type_code => 'A'
16387 , p_switch_side_flag => 'N'
16388 , p_merge_duplicate_code => 'N'
16389 );
16390 --
16391 l_acc_rev_natural_side_code := 'D'; -- 4262811
16392 --
16393 --
16394 -- set accounting line type info
16395 --
16396 xla_ae_lines_pkg.SetAcctLineType
16397 (p_component_type => l_component_type
16398 ,p_event_type_code => l_event_type_code
16399 ,p_line_definition_owner_code => l_line_definition_owner_code
16400 ,p_line_definition_code => l_line_definition_code
16401 ,p_accounting_line_code => l_component_code
16402 ,p_accounting_line_type_code => l_component_type_code
16403 ,p_accounting_line_appl_id => l_component_appl_id
16404 ,p_amb_context_code => l_amb_context_code
16405 ,p_entity_code => l_entity_code
16406 ,p_event_class_code => l_event_class_code);
16407 --
16408 -- set accounting class
16409 --
16410 xla_ae_lines_pkg.SetAcctClass(
16411 p_accounting_class_code => 'FEDERAL_INV'
16412 , p_ae_header_id => l_ae_header_id
16413 );
16414
16415 --
16416 -- set rounding class
16417 --
16418 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
16419 'FEDERAL_INV';
16420
16421 --
16422 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
16423 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
16424 --
16425 -- bulk performance
16426 --
16427 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
16428
16429 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
16430 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
16431
16432 -- 4955764
16433 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16434 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
16435
16436 -- 4458381 Public Sector Enh
16437
16438 --
16439 -- set accounting attributes for the line type
16440 --
16441 l_entered_amt_idx := 17;
16442 l_accted_amt_idx := 22;
16443 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16444 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
16445 l_rec_acct_attrs.array_num_value(1) := p_source_7;
16446 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
16447 l_rec_acct_attrs.array_char_value(2) := p_source_8;
16448 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
16449 l_rec_acct_attrs.array_char_value(3) := p_source_9;
16450 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
16451 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
16452 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
16453 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
16454 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
16455 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
16456 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
16457 l_rec_acct_attrs.array_char_value(7) := p_source_13;
16458 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
16459 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
16460 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
16461 l_rec_acct_attrs.array_num_value(9) := p_source_14;
16462 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
16463 l_rec_acct_attrs.array_char_value(10) := p_source_15;
16464 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
16465 l_rec_acct_attrs.array_num_value(11) := p_source_16;
16466 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
16467 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
16468 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
16469 l_rec_acct_attrs.array_num_value(13) := p_source_14;
16470 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
16471 l_rec_acct_attrs.array_char_value(14) := p_source_15;
16472 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
16473 l_rec_acct_attrs.array_num_value(15) := p_source_16;
16474 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
16475 l_rec_acct_attrs.array_char_value(16) := p_source_17;
16476 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
16477 l_rec_acct_attrs.array_num_value(17) := p_source_28;
16478 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
16479 l_rec_acct_attrs.array_char_value(18) := p_source_15;
16480 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
16481 l_rec_acct_attrs.array_date_value(19) := p_source_19;
16482 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
16483 l_rec_acct_attrs.array_num_value(20) := p_source_20;
16484 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
16485 l_rec_acct_attrs.array_char_value(21) := p_source_21;
16486 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
16487 l_rec_acct_attrs.array_num_value(22) := p_source_28;
16488 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
16489 l_rec_acct_attrs.array_num_value(23) := p_source_22;
16490 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
16491 l_rec_acct_attrs.array_num_value(24) := p_source_22;
16492
16493 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
16494 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
16495
16496 ---------------------------------------------------------------------------------------------------------------
16497 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
16498 ---------------------------------------------------------------------------------------------------------------
16499 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
16500
16501 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16502 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16503
16504 IF xla_accounting_cache_pkg.GetValueChar
16505 (p_source_code => 'LEDGER_CATEGORY_CODE'
16506 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
16507 AND l_bflow_method_code = 'PRIOR_ENTRY'
16508 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
16509 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
16510 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
16511 )
16512 THEN
16513 xla_ae_lines_pkg.BflowUpgEntry
16514 (p_business_method_code => l_bflow_method_code
16515 ,p_business_class_code => l_bflow_class_code
16516 ,p_balance_type => l_balance_type_code);
16517 ELSE
16518 NULL;
16519 -- No business flow processing for business flow method of NONE.
16520 END IF;
16521
16522 --
16523 -- call analytical criteria
16524 --
16525
16526 --
16527 -- call description
16528 --
16529 -- No description or it is inherited.
16530 --
16531 -- call ADRs
16532 -- Bug 4922099
16533 --
16534 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
16535 (NVL(l_actual_upg_option, 'N') = 'O') OR
16536 (NVL(l_enc_upg_option, 'N') = 'O')
16537 )
16538 THEN
16539 NULL;
16540 --
16541 --
16542
16543 l_ccid := AcctDerRule_11(
16544 p_application_id => p_application_id
16545 , p_ae_header_id => l_ae_header_id
16546 , p_source_3 => p_source_3
16547 , x_transaction_coa_id => l_adr_transaction_coa_id
16548 , x_accounting_coa_id => l_adr_accounting_coa_id
16549 , x_value_type_code => l_adr_value_type_code
16550 , p_side => 'NA'
16551 );
16552
16553 xla_ae_lines_pkg.set_ccid(
16554 p_code_combination_id => l_ccid
16555 , p_value_type_code => l_adr_value_type_code
16556 , p_transaction_coa_id => l_adr_transaction_coa_id
16557 , p_accounting_coa_id => l_adr_accounting_coa_id
16558 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
16559 , p_adr_type_code => 'S'
16560 , p_component_type => l_component_type
16561 , p_component_code => l_component_code
16562 , p_component_type_code => l_component_type_code
16563 , p_component_appl_id => l_component_appl_id
16564 , p_amb_context_code => l_amb_context_code
16565 , p_side => 'NA'
16566 );
16567
16568
16569 l_segment := AcctDerRule_6(
16570 p_application_id => p_application_id
16571 , p_ae_header_id => l_ae_header_id
16572 , x_transaction_coa_id => l_adr_transaction_coa_id
16573 , x_accounting_coa_id => l_adr_accounting_coa_id
16574 , x_flexfield_segment_code => l_adr_flexfield_segment_code
16575 , x_flex_value_set_id => l_adr_flex_value_set_id
16576 , x_value_type_code => l_adr_value_type_code
16577 , x_value_combination_id => l_adr_value_combination_id
16578 , x_value_segment_code => l_adr_value_segment_code
16579 , p_side => 'NA'
16580 , p_override_seg_flag => 'Y'
16581 );
16582
16583 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
16584
16585 xla_ae_lines_pkg.set_segment(
16586 p_to_segment_code => 'GL_ACCOUNT'
16587 , p_segment_value => l_segment
16588 , p_from_segment_code => l_adr_value_segment_code
16589 , p_from_combination_id => l_adr_value_combination_id
16590 , p_value_type_code => l_adr_value_type_code
16591 , p_transaction_coa_id => l_adr_transaction_coa_id
16592 , p_accounting_coa_id => l_adr_accounting_coa_id
16593 , p_flexfield_segment_code => l_adr_flexfield_segment_code
16594 , p_flex_value_set_id => l_adr_flex_value_set_id
16595 , p_adr_code => 'FV_480201'
16596 , p_adr_type_code => 'S'
16597 , p_component_type => l_component_type
16598 , p_component_code => l_component_code
16599 , p_component_type_code => l_component_type_code
16600 , p_component_appl_id => l_component_appl_id
16601 , p_amb_context_code => l_amb_context_code
16602 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
16603 , p_event_class_code => 'PURCHASE_ORDER'
16604 , p_side => 'NA'
16605 );
16606
16607 END IF;
16608
16609 --
16610 --
16611 END IF;
16612 --
16613 -- Bug 4922099
16614 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
16615 (NVL(l_enc_upg_option, 'N') = 'O')
16616 ) AND
16617 (l_bflow_method_code = 'PRIOR_ENTRY')
16618 )
16619 THEN
16620 IF
16621 --
16622 1 = 2
16623 --
16624 THEN
16625 xla_accounting_err_pkg.build_message
16626 (p_appli_s_name => 'XLA'
16627 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16628 ,p_token_1 => 'LINE_NUMBER'
16629 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
16630 ,p_token_2 => 'LINE_TYPE_NAME'
16631 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
16632 l_component_type
16633 ,l_component_code
16634 ,l_component_type_code
16635 ,l_component_appl_id
16636 ,l_amb_context_code
16637 ,l_entity_code
16638 ,l_event_class_code
16639 )
16640 ,p_token_3 => 'OWNER'
16641 ,p_value_3 => xla_lookups_pkg.get_meaning(
16642 p_lookup_type => 'XLA_OWNER_TYPE'
16643 ,p_lookup_code => l_component_type_code
16644 )
16645 ,p_token_4 => 'PRODUCT_NAME'
16646 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
16647 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
16648 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
16649 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
16650 ,p_ae_header_id => NULL
16651 );
16652
16653 IF (C_LEVEL_ERROR>= g_log_level) THEN
16654 trace
16655 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16656 ,p_level => C_LEVEL_ERROR
16657 ,p_module => l_log_module);
16658 END IF;
16659 END IF;
16660 END IF;
16661 --
16662 --
16663 ------------------------------------------------------------------------------------------------
16664 -- 4219869 Business Flow
16665 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
16666 -- Prior Entry. Currently, the following code is always generated.
16667 ------------------------------------------------------------------------------------------------
16668 XLA_AE_LINES_PKG.ValidateCurrentLine;
16669
16670 ------------------------------------------------------------------------------------
16671 -- 4219869 Business Flow
16672 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
16673 ------------------------------------------------------------------------------------
16674 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
16675
16676 ----------------------------------------------------------------------------------
16677 -- 4219869 Business Flow
16678 -- Update journal entry status -- Need to generate this within IF <condition>
16679 ----------------------------------------------------------------------------------
16680 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
16681 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
16682 ,p_balance_type_code => l_balance_type_code
16683 );
16684
16685 -------------------------------------------------------------------------------------------
16686 -- 4262811 - Generate the Accrual Reversal lines
16687 -------------------------------------------------------------------------------------------
16688 BEGIN
16689 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
16690 (g_array_event(p_event_id).array_value_num('header_index'));
16691 IF l_acc_rev_flag IS NULL THEN
16692 l_acc_rev_flag := 'N';
16693 END IF;
16694 EXCEPTION
16695 WHEN OTHERS THEN
16696 l_acc_rev_flag := 'N';
16697 END;
16698 --
16699 IF (l_acc_rev_flag = 'Y') THEN
16700
16701 -- 4645092 ------------------------------------------------------------------------------
16702 -- To allow MPA report to determine if it should generate report process
16703 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
16704 ------------------------------------------------------------------------------------------
16705
16706 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
16707 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
16708 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
16709 -- call ADRs
16710 -- Bug 4922099
16711 --
16712 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
16713 (NVL(l_actual_upg_option, 'N') = 'O') OR
16714 (NVL(l_enc_upg_option, 'N') = 'O')
16715 )
16716 THEN
16717 NULL;
16718 --
16719 --
16720
16721 l_ccid := AcctDerRule_11(
16722 p_application_id => p_application_id
16723 , p_ae_header_id => l_ae_header_id
16724 , p_source_3 => p_source_3
16725 , x_transaction_coa_id => l_adr_transaction_coa_id
16726 , x_accounting_coa_id => l_adr_accounting_coa_id
16727 , x_value_type_code => l_adr_value_type_code
16728 , p_side => 'NA'
16729 );
16730
16731 xla_ae_lines_pkg.set_ccid(
16732 p_code_combination_id => l_ccid
16733 , p_value_type_code => l_adr_value_type_code
16734 , p_transaction_coa_id => l_adr_transaction_coa_id
16735 , p_accounting_coa_id => l_adr_accounting_coa_id
16736 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
16737 , p_adr_type_code => 'S'
16738 , p_component_type => l_component_type
16739 , p_component_code => l_component_code
16740 , p_component_type_code => l_component_type_code
16741 , p_component_appl_id => l_component_appl_id
16742 , p_amb_context_code => l_amb_context_code
16743 , p_side => 'NA'
16744 );
16745
16746
16747 l_segment := AcctDerRule_6(
16748 p_application_id => p_application_id
16749 , p_ae_header_id => l_ae_header_id
16750 , x_transaction_coa_id => l_adr_transaction_coa_id
16751 , x_accounting_coa_id => l_adr_accounting_coa_id
16752 , x_flexfield_segment_code => l_adr_flexfield_segment_code
16753 , x_flex_value_set_id => l_adr_flex_value_set_id
16754 , x_value_type_code => l_adr_value_type_code
16755 , x_value_combination_id => l_adr_value_combination_id
16756 , x_value_segment_code => l_adr_value_segment_code
16757 , p_side => 'NA'
16758 , p_override_seg_flag => 'Y'
16759 );
16760
16761 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
16762
16763 xla_ae_lines_pkg.set_segment(
16764 p_to_segment_code => 'GL_ACCOUNT'
16765 , p_segment_value => l_segment
16766 , p_from_segment_code => l_adr_value_segment_code
16767 , p_from_combination_id => l_adr_value_combination_id
16768 , p_value_type_code => l_adr_value_type_code
16769 , p_transaction_coa_id => l_adr_transaction_coa_id
16770 , p_accounting_coa_id => l_adr_accounting_coa_id
16771 , p_flexfield_segment_code => l_adr_flexfield_segment_code
16772 , p_flex_value_set_id => l_adr_flex_value_set_id
16773 , p_adr_code => 'FV_480201'
16774 , p_adr_type_code => 'S'
16775 , p_component_type => l_component_type
16776 , p_component_code => l_component_code
16777 , p_component_type_code => l_component_type_code
16778 , p_component_appl_id => l_component_appl_id
16779 , p_amb_context_code => l_amb_context_code
16780 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
16781 , p_event_class_code => 'PURCHASE_ORDER'
16782 , p_side => 'NA'
16783 );
16784
16785 END IF;
16786
16787 --
16788 --
16789 END IF;
16790
16791 --
16792 -- Update the line information that should be overwritten
16793 --
16794 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
16795 p_header_num => 1);
16796 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
16797
16798 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
16799
16800 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
16801 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
16802 END IF;
16803
16804 --
16805 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
16806 --
16807 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
16808 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
16809 ELSE
16810 ---------------------------------------------------------------------------------------------------
16811 -- 4262811a Switch Sign
16812 ---------------------------------------------------------------------------------------------------
16813 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
16814 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
16815 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16816 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
16817 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16818 -- 5132302
16819 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
16820 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16821
16822 END IF;
16823
16824 -- 4955764
16825 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16826 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
16827
16828
16829 XLA_AE_LINES_PKG.ValidateCurrentLine;
16830 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
16831
16832 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
16833 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
16834 ,p_balance_type_code => l_balance_type_code);
16835
16836 END IF;
16837
16838 -----------------------------------------------------------------------------------------
16839 -- 4262811 Multiperiod Accounting
16840 -----------------------------------------------------------------------------------------
16841 -- No MPA option is assigned.
16842
16843
16844 END IF;
16845 END IF;
16846 --
16847
16848 --
16849 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16850 trace
16851 (p_msg => 'END of AcctLineType_33'
16852 ,p_level => C_LEVEL_PROCEDURE
16853 ,p_module => l_log_module);
16854 END IF;
16855 --
16856 EXCEPTION
16857 WHEN xla_exceptions_pkg.application_exception THEN
16858 RAISE;
16859 WHEN OTHERS THEN
16860 xla_exceptions_pkg.raise_message
16861 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_33');
16862 END AcctLineType_33;
16863 --
16864
16865 ---------------------------------------
16866 --
16867 -- PRIVATE FUNCTION
16868 -- AcctLineType_34
16869 --
16870 ---------------------------------------
16871 PROCEDURE AcctLineType_34 (
16872 p_application_id IN NUMBER
16873 ,p_event_id IN NUMBER
16874 ,p_calculate_acctd_flag IN VARCHAR2
16875 ,p_calculate_g_l_flag IN VARCHAR2
16876 ,p_actual_flag IN OUT VARCHAR2
16877 ,p_balance_type_code OUT VARCHAR2
16878 ,p_gain_or_loss_ref OUT VARCHAR2
16879
16880 --PO Budget Account
16881 , p_source_3 IN NUMBER
16882 --Receiving Accounting Line Type
16883 , p_source_6 IN VARCHAR2
16884 --Applied to Application ID
16885 , p_source_7 IN NUMBER
16886 --Applied to Distribution Link Type
16887 , p_source_8 IN VARCHAR2
16888 --Applied to Entity Code
16889 , p_source_9 IN VARCHAR2
16890 --PO_DISTRIBUTION_ID
16891 , p_source_10 IN NUMBER
16892 --Applied To Purchase Document Identifier
16893 , p_source_11 IN NUMBER
16894 --DISTRIBUTION_IDENTIFIER
16895 , p_source_12 IN NUMBER
16896 --Distribution Type
16897 , p_source_13 IN VARCHAR2
16898 , p_source_13_meaning IN VARCHAR2
16899 --Encumbrance Reversal Amount Entered
16900 , p_source_14 IN NUMBER
16901 --Entered Currency Code
16902 , p_source_15 IN VARCHAR2
16903 --Transaction Encumbrance Reversal Amount
16904 , p_source_16 IN NUMBER
16905 --Costing Encumbrance Upgrade Option
16906 , p_source_17 IN VARCHAR2
16907 --Currency Conversion Date
16908 , p_source_19 IN DATE
16909 --Currency Conversion Rate
16910 , p_source_20 IN NUMBER
16911 --Currency Conversion Type
16912 , p_source_21 IN VARCHAR2
16913 --Purchasing Encumbrance Type Identifier
16914 , p_source_22 IN NUMBER
16915 --Federal Unpaid Unexpended Obligation Amount
16916 , p_source_29 IN NUMBER
16917 )
16918 IS
16919
16920 l_component_type VARCHAR2(80);
16921 l_component_code VARCHAR2(30);
16922 l_component_type_code VARCHAR2(1);
16923 l_component_appl_id INTEGER;
16924 l_amb_context_code VARCHAR2(30);
16925 l_entity_code VARCHAR2(30);
16926 l_event_class_code VARCHAR2(30);
16927 l_ae_header_id NUMBER;
16928 l_event_type_code VARCHAR2(30);
16929 l_line_definition_code VARCHAR2(30);
16930 l_line_definition_owner_code VARCHAR2(1);
16931 --
16932 -- adr variables
16933 l_segment VARCHAR2(30);
16934 l_ccid NUMBER;
16935 l_adr_transaction_coa_id NUMBER;
16936 l_adr_accounting_coa_id NUMBER;
16937 l_adr_flexfield_segment_code VARCHAR2(30);
16938 l_adr_flex_value_set_id NUMBER;
16939 l_adr_value_type_code VARCHAR2(30);
16940 l_adr_value_combination_id NUMBER;
16941 l_adr_value_segment_code VARCHAR2(30);
16942
16943 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
16944 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
16945 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
16946 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
16947
16948 -- 4262811 Variables ------------------------------------------------------------------------------------------
16949 l_entered_amt_idx NUMBER;
16950 l_accted_amt_idx NUMBER;
16951 l_acc_rev_flag VARCHAR2(1);
16952 l_accrual_line_num NUMBER;
16953 l_tmp_amt NUMBER;
16954 l_acc_rev_natural_side_code VARCHAR2(1);
16955
16956 l_num_entries NUMBER;
16957 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
16958 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
16959 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
16960 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
16961 l_recog_line_1 NUMBER;
16962 l_recog_line_2 NUMBER;
16963
16964 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
16965 l_bflow_applied_to_amt NUMBER; -- 5132302
16966 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
16967
16968 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
16969
16970 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
16971 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
16972
16973 ---------------------------------------------------------------------------------------------------------------
16974
16975
16976 --
16977 -- bulk performance
16978 --
16979 l_balance_type_code VARCHAR2(1);
16980 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
16981 l_log_module VARCHAR2(240);
16982
16983 --
16984 -- Upgrade strategy
16985 --
16986 l_actual_upg_option VARCHAR2(1);
16987 l_enc_upg_option VARCHAR2(1);
16988
16989 --
16990 BEGIN
16991 --
16992 IF g_log_enabled THEN
16993 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_34';
16994 END IF;
16995 --
16996 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16997
16998 trace
16999 (p_msg => 'BEGIN of AcctLineType_34'
17000 ,p_level => C_LEVEL_PROCEDURE
17001 ,p_module => l_log_module);
17002
17003 END IF;
17004 --
17005 l_component_type := 'AMB_JLT';
17006 l_component_code := 'FV_REINSTATE_UNPAID_PO_CR';
17007 l_component_type_code := 'S';
17008 l_component_appl_id := 707;
17009 l_amb_context_code := 'DEFAULT';
17010 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
17011 l_event_class_code := 'DELIVER_EXPENSE';
17012 l_event_type_code := 'DELIVER_EXPENSE_ALL';
17013 l_line_definition_owner_code := 'S';
17014 l_line_definition_code := 'FV_RETURN_TO_RECEIVING';
17015 --
17016 l_balance_type_code := 'A';
17017 l_segment := NULL;
17018 l_ccid := NULL;
17019 l_adr_transaction_coa_id := NULL;
17020 l_adr_accounting_coa_id := NULL;
17021 l_adr_flexfield_segment_code := NULL;
17022 l_adr_flex_value_set_id := NULL;
17023 l_adr_value_type_code := NULL;
17024 l_adr_value_combination_id := NULL;
17025 l_adr_value_segment_code := NULL;
17026
17027 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
17028 l_bflow_class_code := ''; -- 4219869 Business Flow
17029 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
17030 l_budgetary_control_flag := 'Y';
17031
17032 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17033 l_bflow_applied_to_amt := NULL; -- 5132302
17034 l_entered_amt_idx := NULL; -- 4262811
17035 l_accted_amt_idx := NULL; -- 4262811
17036 l_acc_rev_flag := NULL; -- 4262811
17037 l_accrual_line_num := NULL; -- 4262811
17038 l_tmp_amt := NULL; -- 4262811
17039 --
17040
17041 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
17042 l_balance_type_code <> 'B' THEN
17043 IF NVL(
17044 xla_ae_sources_pkg.GetSystemSourceChar(
17045 p_source_code => 'XLA_EVENT_TYPE_CODE'
17046 , p_source_type_code => 'Y'
17047 , p_source_application_id => 602
17048 ),'
17049 ') = 'RETURN_TO_RECEIVING' AND
17050 p_source_29 > 0 AND
17051 NVL(p_source_6,'
17052 ') = 'Charge'
17053 THEN
17054
17055 --
17056 XLA_AE_LINES_PKG.SetNewLine;
17057
17058 p_balance_type_code := l_balance_type_code;
17059 -- set the flag so later we will know whether the gain loss line needs to be created
17060
17061 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
17062 p_actual_flag :='A';
17063 END IF;
17064
17065 --
17066 -- bulk performance
17067 --
17068 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
17069 p_header_num => 0); -- 4262811
17070 --
17071 -- set accounting line options
17072 --
17073 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
17074 p_natural_side_code => 'C'
17075 , p_gain_or_loss_flag => 'N'
17076 , p_gl_transfer_mode_code => 'S'
17077 , p_acct_entry_type_code => 'A'
17078 , p_switch_side_flag => 'N'
17079 , p_merge_duplicate_code => 'N'
17080 );
17081 --
17082 l_acc_rev_natural_side_code := 'D'; -- 4262811
17083 --
17084 --
17085 -- set accounting line type info
17086 --
17087 xla_ae_lines_pkg.SetAcctLineType
17088 (p_component_type => l_component_type
17089 ,p_event_type_code => l_event_type_code
17090 ,p_line_definition_owner_code => l_line_definition_owner_code
17091 ,p_line_definition_code => l_line_definition_code
17092 ,p_accounting_line_code => l_component_code
17093 ,p_accounting_line_type_code => l_component_type_code
17094 ,p_accounting_line_appl_id => l_component_appl_id
17095 ,p_amb_context_code => l_amb_context_code
17096 ,p_entity_code => l_entity_code
17097 ,p_event_class_code => l_event_class_code);
17098 --
17099 -- set accounting class
17100 --
17101 xla_ae_lines_pkg.SetAcctClass(
17102 p_accounting_class_code => 'FEDERAL_EXP'
17103 , p_ae_header_id => l_ae_header_id
17104 );
17105
17106 --
17107 -- set rounding class
17108 --
17109 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
17110 'FEDERAL_EXP';
17111
17112 --
17113 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
17114 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
17115 --
17116 -- bulk performance
17117 --
17118 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
17119
17120 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
17121 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
17122
17123 -- 4955764
17124 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17125 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
17126
17127 -- 4458381 Public Sector Enh
17128
17129 --
17130 -- set accounting attributes for the line type
17131 --
17132 l_entered_amt_idx := 17;
17133 l_accted_amt_idx := 22;
17134 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17135 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
17136 l_rec_acct_attrs.array_num_value(1) := p_source_7;
17137 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
17138 l_rec_acct_attrs.array_char_value(2) := p_source_8;
17139 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
17140 l_rec_acct_attrs.array_char_value(3) := p_source_9;
17141 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
17142 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
17143 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
17144 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
17145 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
17146 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
17147 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
17148 l_rec_acct_attrs.array_char_value(7) := p_source_13;
17149 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
17150 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
17151 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
17152 l_rec_acct_attrs.array_num_value(9) := p_source_14;
17153 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
17154 l_rec_acct_attrs.array_char_value(10) := p_source_15;
17155 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
17156 l_rec_acct_attrs.array_num_value(11) := p_source_16;
17157 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
17158 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
17159 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
17160 l_rec_acct_attrs.array_num_value(13) := p_source_14;
17161 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
17162 l_rec_acct_attrs.array_char_value(14) := p_source_15;
17163 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
17164 l_rec_acct_attrs.array_num_value(15) := p_source_16;
17165 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
17166 l_rec_acct_attrs.array_char_value(16) := p_source_17;
17167 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
17168 l_rec_acct_attrs.array_num_value(17) := p_source_29;
17169 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
17170 l_rec_acct_attrs.array_char_value(18) := p_source_15;
17171 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
17172 l_rec_acct_attrs.array_date_value(19) := p_source_19;
17173 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
17174 l_rec_acct_attrs.array_num_value(20) := p_source_20;
17175 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
17176 l_rec_acct_attrs.array_char_value(21) := p_source_21;
17177 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
17178 l_rec_acct_attrs.array_num_value(22) := p_source_29;
17179 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
17180 l_rec_acct_attrs.array_num_value(23) := p_source_22;
17181 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
17182 l_rec_acct_attrs.array_num_value(24) := p_source_22;
17183
17184 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
17185 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
17186
17187 ---------------------------------------------------------------------------------------------------------------
17188 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
17189 ---------------------------------------------------------------------------------------------------------------
17190 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
17191
17192 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17193 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17194
17195 IF xla_accounting_cache_pkg.GetValueChar
17196 (p_source_code => 'LEDGER_CATEGORY_CODE'
17197 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
17198 AND l_bflow_method_code = 'PRIOR_ENTRY'
17199 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
17200 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
17201 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
17202 )
17203 THEN
17204 xla_ae_lines_pkg.BflowUpgEntry
17205 (p_business_method_code => l_bflow_method_code
17206 ,p_business_class_code => l_bflow_class_code
17207 ,p_balance_type => l_balance_type_code);
17208 ELSE
17209 NULL;
17210 -- No business flow processing for business flow method of NONE.
17211 END IF;
17212
17213 --
17214 -- call analytical criteria
17215 --
17216
17217 --
17218 -- call description
17219 --
17220 -- No description or it is inherited.
17221 --
17222 -- call ADRs
17223 -- Bug 4922099
17224 --
17225 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17226 (NVL(l_actual_upg_option, 'N') = 'O') OR
17227 (NVL(l_enc_upg_option, 'N') = 'O')
17228 )
17229 THEN
17230 NULL;
17231 --
17232 --
17233
17234 l_ccid := AcctDerRule_11(
17235 p_application_id => p_application_id
17236 , p_ae_header_id => l_ae_header_id
17237 , p_source_3 => p_source_3
17238 , x_transaction_coa_id => l_adr_transaction_coa_id
17239 , x_accounting_coa_id => l_adr_accounting_coa_id
17240 , x_value_type_code => l_adr_value_type_code
17241 , p_side => 'NA'
17242 );
17243
17244 xla_ae_lines_pkg.set_ccid(
17245 p_code_combination_id => l_ccid
17246 , p_value_type_code => l_adr_value_type_code
17247 , p_transaction_coa_id => l_adr_transaction_coa_id
17248 , p_accounting_coa_id => l_adr_accounting_coa_id
17249 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
17250 , p_adr_type_code => 'S'
17251 , p_component_type => l_component_type
17252 , p_component_code => l_component_code
17253 , p_component_type_code => l_component_type_code
17254 , p_component_appl_id => l_component_appl_id
17255 , p_amb_context_code => l_amb_context_code
17256 , p_side => 'NA'
17257 );
17258
17259
17260 l_segment := AcctDerRule_5(
17261 p_application_id => p_application_id
17262 , p_ae_header_id => l_ae_header_id
17263 , x_transaction_coa_id => l_adr_transaction_coa_id
17264 , x_accounting_coa_id => l_adr_accounting_coa_id
17265 , x_flexfield_segment_code => l_adr_flexfield_segment_code
17266 , x_flex_value_set_id => l_adr_flex_value_set_id
17267 , x_value_type_code => l_adr_value_type_code
17268 , x_value_combination_id => l_adr_value_combination_id
17269 , x_value_segment_code => l_adr_value_segment_code
17270 , p_side => 'NA'
17271 , p_override_seg_flag => 'Y'
17272 );
17273
17274 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
17275
17276 xla_ae_lines_pkg.set_segment(
17277 p_to_segment_code => 'GL_ACCOUNT'
17278 , p_segment_value => l_segment
17279 , p_from_segment_code => l_adr_value_segment_code
17280 , p_from_combination_id => l_adr_value_combination_id
17281 , p_value_type_code => l_adr_value_type_code
17282 , p_transaction_coa_id => l_adr_transaction_coa_id
17283 , p_accounting_coa_id => l_adr_accounting_coa_id
17284 , p_flexfield_segment_code => l_adr_flexfield_segment_code
17285 , p_flex_value_set_id => l_adr_flex_value_set_id
17286 , p_adr_code => 'FV_480101'
17287 , p_adr_type_code => 'S'
17288 , p_component_type => l_component_type
17289 , p_component_code => l_component_code
17290 , p_component_type_code => l_component_type_code
17291 , p_component_appl_id => l_component_appl_id
17292 , p_amb_context_code => l_amb_context_code
17293 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
17294 , p_event_class_code => 'DELIVER_EXPENSE'
17295 , p_side => 'NA'
17296 );
17297
17298 END IF;
17299
17300 --
17301 --
17302 END IF;
17303 --
17304 -- Bug 4922099
17305 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
17306 (NVL(l_enc_upg_option, 'N') = 'O')
17307 ) AND
17308 (l_bflow_method_code = 'PRIOR_ENTRY')
17309 )
17310 THEN
17311 IF
17312 --
17313 1 = 2
17314 --
17315 THEN
17316 xla_accounting_err_pkg.build_message
17317 (p_appli_s_name => 'XLA'
17318 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
17319 ,p_token_1 => 'LINE_NUMBER'
17320 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
17321 ,p_token_2 => 'LINE_TYPE_NAME'
17322 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
17323 l_component_type
17324 ,l_component_code
17325 ,l_component_type_code
17326 ,l_component_appl_id
17327 ,l_amb_context_code
17328 ,l_entity_code
17329 ,l_event_class_code
17330 )
17331 ,p_token_3 => 'OWNER'
17332 ,p_value_3 => xla_lookups_pkg.get_meaning(
17333 p_lookup_type => 'XLA_OWNER_TYPE'
17334 ,p_lookup_code => l_component_type_code
17335 )
17336 ,p_token_4 => 'PRODUCT_NAME'
17337 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
17338 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
17339 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
17340 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
17341 ,p_ae_header_id => NULL
17342 );
17343
17344 IF (C_LEVEL_ERROR>= g_log_level) THEN
17345 trace
17346 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
17347 ,p_level => C_LEVEL_ERROR
17348 ,p_module => l_log_module);
17349 END IF;
17350 END IF;
17351 END IF;
17352 --
17353 --
17354 ------------------------------------------------------------------------------------------------
17355 -- 4219869 Business Flow
17356 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
17357 -- Prior Entry. Currently, the following code is always generated.
17358 ------------------------------------------------------------------------------------------------
17359 XLA_AE_LINES_PKG.ValidateCurrentLine;
17360
17361 ------------------------------------------------------------------------------------
17362 -- 4219869 Business Flow
17363 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
17364 ------------------------------------------------------------------------------------
17365 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17366
17367 ----------------------------------------------------------------------------------
17368 -- 4219869 Business Flow
17369 -- Update journal entry status -- Need to generate this within IF <condition>
17370 ----------------------------------------------------------------------------------
17371 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17372 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
17373 ,p_balance_type_code => l_balance_type_code
17374 );
17375
17376 -------------------------------------------------------------------------------------------
17377 -- 4262811 - Generate the Accrual Reversal lines
17378 -------------------------------------------------------------------------------------------
17379 BEGIN
17380 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
17381 (g_array_event(p_event_id).array_value_num('header_index'));
17382 IF l_acc_rev_flag IS NULL THEN
17383 l_acc_rev_flag := 'N';
17384 END IF;
17385 EXCEPTION
17386 WHEN OTHERS THEN
17387 l_acc_rev_flag := 'N';
17388 END;
17389 --
17390 IF (l_acc_rev_flag = 'Y') THEN
17391
17392 -- 4645092 ------------------------------------------------------------------------------
17393 -- To allow MPA report to determine if it should generate report process
17394 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
17395 ------------------------------------------------------------------------------------------
17396
17397 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
17398 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
17399 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
17400 -- call ADRs
17401 -- Bug 4922099
17402 --
17403 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17404 (NVL(l_actual_upg_option, 'N') = 'O') OR
17405 (NVL(l_enc_upg_option, 'N') = 'O')
17406 )
17407 THEN
17408 NULL;
17409 --
17410 --
17411
17412 l_ccid := AcctDerRule_11(
17413 p_application_id => p_application_id
17414 , p_ae_header_id => l_ae_header_id
17415 , p_source_3 => p_source_3
17416 , x_transaction_coa_id => l_adr_transaction_coa_id
17417 , x_accounting_coa_id => l_adr_accounting_coa_id
17418 , x_value_type_code => l_adr_value_type_code
17419 , p_side => 'NA'
17420 );
17421
17422 xla_ae_lines_pkg.set_ccid(
17423 p_code_combination_id => l_ccid
17424 , p_value_type_code => l_adr_value_type_code
17425 , p_transaction_coa_id => l_adr_transaction_coa_id
17426 , p_accounting_coa_id => l_adr_accounting_coa_id
17427 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
17428 , p_adr_type_code => 'S'
17429 , p_component_type => l_component_type
17430 , p_component_code => l_component_code
17431 , p_component_type_code => l_component_type_code
17432 , p_component_appl_id => l_component_appl_id
17433 , p_amb_context_code => l_amb_context_code
17434 , p_side => 'NA'
17435 );
17436
17437
17438 l_segment := AcctDerRule_5(
17439 p_application_id => p_application_id
17440 , p_ae_header_id => l_ae_header_id
17441 , x_transaction_coa_id => l_adr_transaction_coa_id
17442 , x_accounting_coa_id => l_adr_accounting_coa_id
17443 , x_flexfield_segment_code => l_adr_flexfield_segment_code
17444 , x_flex_value_set_id => l_adr_flex_value_set_id
17445 , x_value_type_code => l_adr_value_type_code
17446 , x_value_combination_id => l_adr_value_combination_id
17447 , x_value_segment_code => l_adr_value_segment_code
17448 , p_side => 'NA'
17449 , p_override_seg_flag => 'Y'
17450 );
17451
17452 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
17453
17454 xla_ae_lines_pkg.set_segment(
17455 p_to_segment_code => 'GL_ACCOUNT'
17456 , p_segment_value => l_segment
17457 , p_from_segment_code => l_adr_value_segment_code
17458 , p_from_combination_id => l_adr_value_combination_id
17459 , p_value_type_code => l_adr_value_type_code
17460 , p_transaction_coa_id => l_adr_transaction_coa_id
17461 , p_accounting_coa_id => l_adr_accounting_coa_id
17462 , p_flexfield_segment_code => l_adr_flexfield_segment_code
17463 , p_flex_value_set_id => l_adr_flex_value_set_id
17464 , p_adr_code => 'FV_480101'
17465 , p_adr_type_code => 'S'
17466 , p_component_type => l_component_type
17467 , p_component_code => l_component_code
17468 , p_component_type_code => l_component_type_code
17469 , p_component_appl_id => l_component_appl_id
17470 , p_amb_context_code => l_amb_context_code
17471 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
17472 , p_event_class_code => 'DELIVER_EXPENSE'
17473 , p_side => 'NA'
17474 );
17475
17476 END IF;
17477
17478 --
17479 --
17480 END IF;
17481
17482 --
17483 -- Update the line information that should be overwritten
17484 --
17485 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
17486 p_header_num => 1);
17487 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
17488
17489 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
17490
17491 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
17492 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
17493 END IF;
17494
17495 --
17496 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
17497 --
17498 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
17499 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
17500 ELSE
17501 ---------------------------------------------------------------------------------------------------
17502 -- 4262811a Switch Sign
17503 ---------------------------------------------------------------------------------------------------
17504 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
17505 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17506 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17507 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17508 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17509 -- 5132302
17510 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
17511 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17512
17513 END IF;
17514
17515 -- 4955764
17516 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17517 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
17518
17519
17520 XLA_AE_LINES_PKG.ValidateCurrentLine;
17521 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17522
17523 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17524 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
17525 ,p_balance_type_code => l_balance_type_code);
17526
17527 END IF;
17528
17529 -----------------------------------------------------------------------------------------
17530 -- 4262811 Multiperiod Accounting
17531 -----------------------------------------------------------------------------------------
17532 -- No MPA option is assigned.
17533
17534
17535 END IF;
17536 END IF;
17537 --
17538
17539 --
17540 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17541 trace
17542 (p_msg => 'END of AcctLineType_34'
17543 ,p_level => C_LEVEL_PROCEDURE
17544 ,p_module => l_log_module);
17545 END IF;
17546 --
17547 EXCEPTION
17548 WHEN xla_exceptions_pkg.application_exception THEN
17549 RAISE;
17550 WHEN OTHERS THEN
17551 xla_exceptions_pkg.raise_message
17552 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_34');
17553 END AcctLineType_34;
17554 --
17555
17556 ---------------------------------------
17557 --
17558 -- PRIVATE FUNCTION
17559 -- AcctLineType_35
17560 --
17561 ---------------------------------------
17562 PROCEDURE AcctLineType_35 (
17563 p_application_id IN NUMBER
17564 ,p_event_id IN NUMBER
17565 ,p_calculate_acctd_flag IN VARCHAR2
17566 ,p_calculate_g_l_flag IN VARCHAR2
17567 ,p_actual_flag IN OUT VARCHAR2
17568 ,p_balance_type_code OUT VARCHAR2
17569 ,p_gain_or_loss_ref OUT VARCHAR2
17570
17571 --PO Budget Account
17572 , p_source_3 IN NUMBER
17573 --Applied to Application ID
17574 , p_source_7 IN NUMBER
17575 --Applied to Distribution Link Type
17576 , p_source_8 IN VARCHAR2
17577 --Applied to Entity Code
17578 , p_source_9 IN VARCHAR2
17579 --Applied To Purchase Document Identifier
17580 , p_source_11 IN NUMBER
17581 --DISTRIBUTION_IDENTIFIER
17582 , p_source_12 IN NUMBER
17583 --Distribution Type
17584 , p_source_13 IN VARCHAR2
17585 , p_source_13_meaning IN VARCHAR2
17586 --Encumbrance Reversal Amount Entered
17587 , p_source_14 IN NUMBER
17588 --Entered Currency Code
17589 , p_source_15 IN VARCHAR2
17590 --Transaction Encumbrance Reversal Amount
17591 , p_source_16 IN NUMBER
17592 --Costing Encumbrance Upgrade Option
17593 , p_source_17 IN VARCHAR2
17594 --Currency Conversion Date
17595 , p_source_19 IN DATE
17596 --Currency Conversion Rate
17597 , p_source_20 IN NUMBER
17598 --Currency Conversion Type
17599 , p_source_21 IN VARCHAR2
17600 --Purchasing Encumbrance Type Identifier
17601 , p_source_22 IN NUMBER
17602 --TXN_PO_DISTRIBUTION_ID
17603 , p_source_23 IN NUMBER
17604 --Federal Unpaid Unexpended Obligation Amount
17605 , p_source_29 IN NUMBER
17606 )
17607 IS
17608
17609 l_component_type VARCHAR2(80);
17610 l_component_code VARCHAR2(30);
17611 l_component_type_code VARCHAR2(1);
17612 l_component_appl_id INTEGER;
17613 l_amb_context_code VARCHAR2(30);
17614 l_entity_code VARCHAR2(30);
17615 l_event_class_code VARCHAR2(30);
17616 l_ae_header_id NUMBER;
17617 l_event_type_code VARCHAR2(30);
17618 l_line_definition_code VARCHAR2(30);
17619 l_line_definition_owner_code VARCHAR2(1);
17620 --
17621 -- adr variables
17622 l_segment VARCHAR2(30);
17623 l_ccid NUMBER;
17624 l_adr_transaction_coa_id NUMBER;
17625 l_adr_accounting_coa_id NUMBER;
17626 l_adr_flexfield_segment_code VARCHAR2(30);
17627 l_adr_flex_value_set_id NUMBER;
17628 l_adr_value_type_code VARCHAR2(30);
17629 l_adr_value_combination_id NUMBER;
17630 l_adr_value_segment_code VARCHAR2(30);
17631
17632 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
17633 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
17634 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
17635 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
17636
17637 -- 4262811 Variables ------------------------------------------------------------------------------------------
17638 l_entered_amt_idx NUMBER;
17639 l_accted_amt_idx NUMBER;
17640 l_acc_rev_flag VARCHAR2(1);
17641 l_accrual_line_num NUMBER;
17642 l_tmp_amt NUMBER;
17643 l_acc_rev_natural_side_code VARCHAR2(1);
17644
17645 l_num_entries NUMBER;
17646 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
17647 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
17648 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
17649 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
17650 l_recog_line_1 NUMBER;
17651 l_recog_line_2 NUMBER;
17652
17653 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
17654 l_bflow_applied_to_amt NUMBER; -- 5132302
17655 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
17656
17657 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
17658
17659 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
17660 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
17661
17662 ---------------------------------------------------------------------------------------------------------------
17663
17664
17665 --
17666 -- bulk performance
17667 --
17668 l_balance_type_code VARCHAR2(1);
17669 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
17670 l_log_module VARCHAR2(240);
17671
17672 --
17673 -- Upgrade strategy
17674 --
17675 l_actual_upg_option VARCHAR2(1);
17676 l_enc_upg_option VARCHAR2(1);
17677
17678 --
17679 BEGIN
17680 --
17681 IF g_log_enabled THEN
17682 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_35';
17683 END IF;
17684 --
17685 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17686
17687 trace
17688 (p_msg => 'BEGIN of AcctLineType_35'
17689 ,p_level => C_LEVEL_PROCEDURE
17690 ,p_module => l_log_module);
17691
17692 END IF;
17693 --
17694 l_component_type := 'AMB_JLT';
17695 l_component_code := 'FV_REINSTATE_UNPAID_PO_CR_RTI';
17696 l_component_type_code := 'S';
17697 l_component_appl_id := 707;
17698 l_amb_context_code := 'DEFAULT';
17699 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
17700 l_event_class_code := 'PURCHASE_ORDER';
17701 l_event_type_code := 'PURCHASE_ORDER_ALL';
17702 l_line_definition_owner_code := 'S';
17703 l_line_definition_code := 'FV_RET_RI_INV';
17704 --
17705 l_balance_type_code := 'A';
17706 l_segment := NULL;
17707 l_ccid := NULL;
17708 l_adr_transaction_coa_id := NULL;
17709 l_adr_accounting_coa_id := NULL;
17710 l_adr_flexfield_segment_code := NULL;
17711 l_adr_flex_value_set_id := NULL;
17712 l_adr_value_type_code := NULL;
17713 l_adr_value_combination_id := NULL;
17714 l_adr_value_segment_code := NULL;
17715
17716 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
17717 l_bflow_class_code := ''; -- 4219869 Business Flow
17718 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
17719 l_budgetary_control_flag := 'Y';
17720
17721 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17722 l_bflow_applied_to_amt := NULL; -- 5132302
17723 l_entered_amt_idx := NULL; -- 4262811
17724 l_accted_amt_idx := NULL; -- 4262811
17725 l_acc_rev_flag := NULL; -- 4262811
17726 l_accrual_line_num := NULL; -- 4262811
17727 l_tmp_amt := NULL; -- 4262811
17728 --
17729
17730 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
17731 l_balance_type_code <> 'B' THEN
17732 IF NVL(
17733 xla_ae_sources_pkg.GetSystemSourceChar(
17734 p_source_code => 'XLA_EVENT_TYPE_CODE'
17735 , p_source_type_code => 'Y'
17736 , p_source_application_id => 602
17737 ),'
17738 ') = 'RET_RI_INV' AND
17739 p_source_29 > 0
17740 THEN
17741
17742 --
17743 XLA_AE_LINES_PKG.SetNewLine;
17744
17745 p_balance_type_code := l_balance_type_code;
17746 -- set the flag so later we will know whether the gain loss line needs to be created
17747
17748 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
17749 p_actual_flag :='A';
17750 END IF;
17751
17752 --
17753 -- bulk performance
17754 --
17755 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
17756 p_header_num => 0); -- 4262811
17757 --
17758 -- set accounting line options
17759 --
17760 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
17761 p_natural_side_code => 'C'
17762 , p_gain_or_loss_flag => 'N'
17763 , p_gl_transfer_mode_code => 'S'
17764 , p_acct_entry_type_code => 'A'
17765 , p_switch_side_flag => 'N'
17766 , p_merge_duplicate_code => 'N'
17767 );
17768 --
17769 l_acc_rev_natural_side_code := 'D'; -- 4262811
17770 --
17771 --
17772 -- set accounting line type info
17773 --
17774 xla_ae_lines_pkg.SetAcctLineType
17775 (p_component_type => l_component_type
17776 ,p_event_type_code => l_event_type_code
17777 ,p_line_definition_owner_code => l_line_definition_owner_code
17778 ,p_line_definition_code => l_line_definition_code
17779 ,p_accounting_line_code => l_component_code
17780 ,p_accounting_line_type_code => l_component_type_code
17781 ,p_accounting_line_appl_id => l_component_appl_id
17782 ,p_amb_context_code => l_amb_context_code
17783 ,p_entity_code => l_entity_code
17784 ,p_event_class_code => l_event_class_code);
17785 --
17786 -- set accounting class
17787 --
17788 xla_ae_lines_pkg.SetAcctClass(
17789 p_accounting_class_code => 'FEDERAL_INV'
17790 , p_ae_header_id => l_ae_header_id
17791 );
17792
17793 --
17794 -- set rounding class
17795 --
17796 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
17797 'FEDERAL_INV';
17798
17799 --
17800 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
17801 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
17802 --
17803 -- bulk performance
17804 --
17805 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
17806
17807 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
17808 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
17809
17810 -- 4955764
17811 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17812 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
17813
17814 -- 4458381 Public Sector Enh
17815
17816 --
17817 -- set accounting attributes for the line type
17818 --
17819 l_entered_amt_idx := 17;
17820 l_accted_amt_idx := 22;
17821 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17822 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
17823 l_rec_acct_attrs.array_num_value(1) := p_source_7;
17824 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
17825 l_rec_acct_attrs.array_char_value(2) := p_source_8;
17826 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
17827 l_rec_acct_attrs.array_char_value(3) := p_source_9;
17828 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
17829 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
17830 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
17831 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
17832 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
17833 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
17834 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
17835 l_rec_acct_attrs.array_char_value(7) := p_source_13;
17836 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
17837 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
17838 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
17839 l_rec_acct_attrs.array_num_value(9) := p_source_14;
17840 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
17841 l_rec_acct_attrs.array_char_value(10) := p_source_15;
17842 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
17843 l_rec_acct_attrs.array_num_value(11) := p_source_16;
17844 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
17845 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
17846 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
17847 l_rec_acct_attrs.array_num_value(13) := p_source_14;
17848 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
17849 l_rec_acct_attrs.array_char_value(14) := p_source_15;
17850 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
17851 l_rec_acct_attrs.array_num_value(15) := p_source_16;
17852 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
17853 l_rec_acct_attrs.array_char_value(16) := p_source_17;
17854 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
17855 l_rec_acct_attrs.array_num_value(17) := p_source_29;
17856 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
17857 l_rec_acct_attrs.array_char_value(18) := p_source_15;
17858 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
17859 l_rec_acct_attrs.array_date_value(19) := p_source_19;
17860 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
17861 l_rec_acct_attrs.array_num_value(20) := p_source_20;
17862 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
17863 l_rec_acct_attrs.array_char_value(21) := p_source_21;
17864 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
17865 l_rec_acct_attrs.array_num_value(22) := p_source_29;
17866 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
17867 l_rec_acct_attrs.array_num_value(23) := p_source_22;
17868 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
17869 l_rec_acct_attrs.array_num_value(24) := p_source_22;
17870
17871 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
17872 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
17873
17874 ---------------------------------------------------------------------------------------------------------------
17875 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
17876 ---------------------------------------------------------------------------------------------------------------
17877 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
17878
17879 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17880 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17881
17882 IF xla_accounting_cache_pkg.GetValueChar
17883 (p_source_code => 'LEDGER_CATEGORY_CODE'
17884 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
17885 AND l_bflow_method_code = 'PRIOR_ENTRY'
17886 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
17887 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
17888 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
17889 )
17890 THEN
17891 xla_ae_lines_pkg.BflowUpgEntry
17892 (p_business_method_code => l_bflow_method_code
17893 ,p_business_class_code => l_bflow_class_code
17894 ,p_balance_type => l_balance_type_code);
17895 ELSE
17896 NULL;
17897 -- No business flow processing for business flow method of NONE.
17898 END IF;
17899
17900 --
17901 -- call analytical criteria
17902 --
17903
17904 --
17905 -- call description
17906 --
17907 -- No description or it is inherited.
17908 --
17909 -- call ADRs
17910 -- Bug 4922099
17911 --
17912 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17913 (NVL(l_actual_upg_option, 'N') = 'O') OR
17914 (NVL(l_enc_upg_option, 'N') = 'O')
17915 )
17916 THEN
17917 NULL;
17918 --
17919 --
17920
17921 l_ccid := AcctDerRule_11(
17922 p_application_id => p_application_id
17923 , p_ae_header_id => l_ae_header_id
17924 , p_source_3 => p_source_3
17925 , x_transaction_coa_id => l_adr_transaction_coa_id
17926 , x_accounting_coa_id => l_adr_accounting_coa_id
17927 , x_value_type_code => l_adr_value_type_code
17928 , p_side => 'NA'
17929 );
17930
17931 xla_ae_lines_pkg.set_ccid(
17932 p_code_combination_id => l_ccid
17933 , p_value_type_code => l_adr_value_type_code
17934 , p_transaction_coa_id => l_adr_transaction_coa_id
17935 , p_accounting_coa_id => l_adr_accounting_coa_id
17936 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
17937 , p_adr_type_code => 'S'
17938 , p_component_type => l_component_type
17939 , p_component_code => l_component_code
17940 , p_component_type_code => l_component_type_code
17941 , p_component_appl_id => l_component_appl_id
17942 , p_amb_context_code => l_amb_context_code
17943 , p_side => 'NA'
17944 );
17945
17946
17947 l_segment := AcctDerRule_5(
17948 p_application_id => p_application_id
17949 , p_ae_header_id => l_ae_header_id
17950 , x_transaction_coa_id => l_adr_transaction_coa_id
17951 , x_accounting_coa_id => l_adr_accounting_coa_id
17952 , x_flexfield_segment_code => l_adr_flexfield_segment_code
17953 , x_flex_value_set_id => l_adr_flex_value_set_id
17954 , x_value_type_code => l_adr_value_type_code
17955 , x_value_combination_id => l_adr_value_combination_id
17956 , x_value_segment_code => l_adr_value_segment_code
17957 , p_side => 'NA'
17958 , p_override_seg_flag => 'Y'
17959 );
17960
17961 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
17962
17963 xla_ae_lines_pkg.set_segment(
17964 p_to_segment_code => 'GL_ACCOUNT'
17965 , p_segment_value => l_segment
17966 , p_from_segment_code => l_adr_value_segment_code
17967 , p_from_combination_id => l_adr_value_combination_id
17968 , p_value_type_code => l_adr_value_type_code
17969 , p_transaction_coa_id => l_adr_transaction_coa_id
17970 , p_accounting_coa_id => l_adr_accounting_coa_id
17971 , p_flexfield_segment_code => l_adr_flexfield_segment_code
17972 , p_flex_value_set_id => l_adr_flex_value_set_id
17973 , p_adr_code => 'FV_480101'
17974 , p_adr_type_code => 'S'
17975 , p_component_type => l_component_type
17976 , p_component_code => l_component_code
17977 , p_component_type_code => l_component_type_code
17978 , p_component_appl_id => l_component_appl_id
17979 , p_amb_context_code => l_amb_context_code
17980 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
17981 , p_event_class_code => 'PURCHASE_ORDER'
17982 , p_side => 'NA'
17983 );
17984
17985 END IF;
17986
17987 --
17988 --
17989 END IF;
17990 --
17991 -- Bug 4922099
17992 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
17993 (NVL(l_enc_upg_option, 'N') = 'O')
17994 ) AND
17995 (l_bflow_method_code = 'PRIOR_ENTRY')
17996 )
17997 THEN
17998 IF
17999 --
18000 1 = 2
18001 --
18002 THEN
18003 xla_accounting_err_pkg.build_message
18004 (p_appli_s_name => 'XLA'
18005 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18006 ,p_token_1 => 'LINE_NUMBER'
18007 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
18008 ,p_token_2 => 'LINE_TYPE_NAME'
18009 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
18010 l_component_type
18011 ,l_component_code
18012 ,l_component_type_code
18013 ,l_component_appl_id
18014 ,l_amb_context_code
18015 ,l_entity_code
18016 ,l_event_class_code
18017 )
18018 ,p_token_3 => 'OWNER'
18019 ,p_value_3 => xla_lookups_pkg.get_meaning(
18020 p_lookup_type => 'XLA_OWNER_TYPE'
18021 ,p_lookup_code => l_component_type_code
18022 )
18023 ,p_token_4 => 'PRODUCT_NAME'
18024 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
18025 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
18026 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
18027 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
18028 ,p_ae_header_id => NULL
18029 );
18030
18031 IF (C_LEVEL_ERROR>= g_log_level) THEN
18032 trace
18033 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18034 ,p_level => C_LEVEL_ERROR
18035 ,p_module => l_log_module);
18036 END IF;
18037 END IF;
18038 END IF;
18039 --
18040 --
18041 ------------------------------------------------------------------------------------------------
18042 -- 4219869 Business Flow
18043 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
18044 -- Prior Entry. Currently, the following code is always generated.
18045 ------------------------------------------------------------------------------------------------
18046 XLA_AE_LINES_PKG.ValidateCurrentLine;
18047
18048 ------------------------------------------------------------------------------------
18049 -- 4219869 Business Flow
18050 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
18051 ------------------------------------------------------------------------------------
18052 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18053
18054 ----------------------------------------------------------------------------------
18055 -- 4219869 Business Flow
18056 -- Update journal entry status -- Need to generate this within IF <condition>
18057 ----------------------------------------------------------------------------------
18058 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18059 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
18060 ,p_balance_type_code => l_balance_type_code
18061 );
18062
18063 -------------------------------------------------------------------------------------------
18064 -- 4262811 - Generate the Accrual Reversal lines
18065 -------------------------------------------------------------------------------------------
18066 BEGIN
18067 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
18068 (g_array_event(p_event_id).array_value_num('header_index'));
18069 IF l_acc_rev_flag IS NULL THEN
18070 l_acc_rev_flag := 'N';
18071 END IF;
18072 EXCEPTION
18073 WHEN OTHERS THEN
18074 l_acc_rev_flag := 'N';
18075 END;
18076 --
18077 IF (l_acc_rev_flag = 'Y') THEN
18078
18079 -- 4645092 ------------------------------------------------------------------------------
18080 -- To allow MPA report to determine if it should generate report process
18081 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
18082 ------------------------------------------------------------------------------------------
18083
18084 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
18085 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
18086 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
18087 -- call ADRs
18088 -- Bug 4922099
18089 --
18090 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18091 (NVL(l_actual_upg_option, 'N') = 'O') OR
18092 (NVL(l_enc_upg_option, 'N') = 'O')
18093 )
18094 THEN
18095 NULL;
18096 --
18097 --
18098
18099 l_ccid := AcctDerRule_11(
18100 p_application_id => p_application_id
18101 , p_ae_header_id => l_ae_header_id
18102 , p_source_3 => p_source_3
18103 , x_transaction_coa_id => l_adr_transaction_coa_id
18104 , x_accounting_coa_id => l_adr_accounting_coa_id
18105 , x_value_type_code => l_adr_value_type_code
18106 , p_side => 'NA'
18107 );
18108
18109 xla_ae_lines_pkg.set_ccid(
18110 p_code_combination_id => l_ccid
18111 , p_value_type_code => l_adr_value_type_code
18112 , p_transaction_coa_id => l_adr_transaction_coa_id
18113 , p_accounting_coa_id => l_adr_accounting_coa_id
18114 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
18115 , p_adr_type_code => 'S'
18116 , p_component_type => l_component_type
18117 , p_component_code => l_component_code
18118 , p_component_type_code => l_component_type_code
18119 , p_component_appl_id => l_component_appl_id
18120 , p_amb_context_code => l_amb_context_code
18121 , p_side => 'NA'
18122 );
18123
18124
18125 l_segment := AcctDerRule_5(
18126 p_application_id => p_application_id
18127 , p_ae_header_id => l_ae_header_id
18128 , x_transaction_coa_id => l_adr_transaction_coa_id
18129 , x_accounting_coa_id => l_adr_accounting_coa_id
18130 , x_flexfield_segment_code => l_adr_flexfield_segment_code
18131 , x_flex_value_set_id => l_adr_flex_value_set_id
18132 , x_value_type_code => l_adr_value_type_code
18133 , x_value_combination_id => l_adr_value_combination_id
18134 , x_value_segment_code => l_adr_value_segment_code
18135 , p_side => 'NA'
18136 , p_override_seg_flag => 'Y'
18137 );
18138
18139 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
18140
18141 xla_ae_lines_pkg.set_segment(
18142 p_to_segment_code => 'GL_ACCOUNT'
18143 , p_segment_value => l_segment
18144 , p_from_segment_code => l_adr_value_segment_code
18145 , p_from_combination_id => l_adr_value_combination_id
18146 , p_value_type_code => l_adr_value_type_code
18147 , p_transaction_coa_id => l_adr_transaction_coa_id
18148 , p_accounting_coa_id => l_adr_accounting_coa_id
18149 , p_flexfield_segment_code => l_adr_flexfield_segment_code
18150 , p_flex_value_set_id => l_adr_flex_value_set_id
18151 , p_adr_code => 'FV_480101'
18152 , p_adr_type_code => 'S'
18153 , p_component_type => l_component_type
18154 , p_component_code => l_component_code
18155 , p_component_type_code => l_component_type_code
18156 , p_component_appl_id => l_component_appl_id
18157 , p_amb_context_code => l_amb_context_code
18158 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
18159 , p_event_class_code => 'PURCHASE_ORDER'
18160 , p_side => 'NA'
18161 );
18162
18163 END IF;
18164
18165 --
18166 --
18167 END IF;
18168
18169 --
18170 -- Update the line information that should be overwritten
18171 --
18172 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
18173 p_header_num => 1);
18174 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
18175
18176 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
18177
18178 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
18179 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
18180 END IF;
18181
18182 --
18183 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
18184 --
18185 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
18186 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
18187 ELSE
18188 ---------------------------------------------------------------------------------------------------
18189 -- 4262811a Switch Sign
18190 ---------------------------------------------------------------------------------------------------
18191 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
18192 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18193 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18194 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18195 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18196 -- 5132302
18197 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
18198 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18199
18200 END IF;
18201
18202 -- 4955764
18203 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18204 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
18205
18206
18207 XLA_AE_LINES_PKG.ValidateCurrentLine;
18208 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18209
18210 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18211 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
18212 ,p_balance_type_code => l_balance_type_code);
18213
18214 END IF;
18215
18216 -----------------------------------------------------------------------------------------
18217 -- 4262811 Multiperiod Accounting
18218 -----------------------------------------------------------------------------------------
18219 -- No MPA option is assigned.
18220
18221
18222 END IF;
18223 END IF;
18224 --
18225
18226 --
18227 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18228 trace
18229 (p_msg => 'END of AcctLineType_35'
18230 ,p_level => C_LEVEL_PROCEDURE
18231 ,p_module => l_log_module);
18232 END IF;
18233 --
18234 EXCEPTION
18235 WHEN xla_exceptions_pkg.application_exception THEN
18236 RAISE;
18237 WHEN OTHERS THEN
18238 xla_exceptions_pkg.raise_message
18239 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_35');
18240 END AcctLineType_35;
18241 --
18242
18243 ---------------------------------------
18244 --
18245 -- PRIVATE FUNCTION
18246 -- AcctLineType_36
18247 --
18248 ---------------------------------------
18249 PROCEDURE AcctLineType_36 (
18250 p_application_id IN NUMBER
18251 ,p_event_id IN NUMBER
18252 ,p_calculate_acctd_flag IN VARCHAR2
18253 ,p_calculate_g_l_flag IN VARCHAR2
18254 ,p_actual_flag IN OUT VARCHAR2
18255 ,p_balance_type_code OUT VARCHAR2
18256 ,p_gain_or_loss_ref OUT VARCHAR2
18257
18258 --PO Budget Account
18259 , p_source_3 IN NUMBER
18260 --Receiving Accounting Line Type
18261 , p_source_6 IN VARCHAR2
18262 --DISTRIBUTION_IDENTIFIER
18263 , p_source_12 IN NUMBER
18264 --Distribution Type
18265 , p_source_13 IN VARCHAR2
18266 , p_source_13_meaning IN VARCHAR2
18267 --Encumbrance Reversal Amount Entered
18268 , p_source_14 IN NUMBER
18269 --Entered Currency Code
18270 , p_source_15 IN VARCHAR2
18271 --Transaction Encumbrance Reversal Amount
18272 , p_source_16 IN NUMBER
18273 --Costing Encumbrance Upgrade Option
18274 , p_source_17 IN VARCHAR2
18275 --Purchasing Encumbrance Type Identifier
18276 , p_source_22 IN NUMBER
18277 --Entered Amount
18278 , p_source_25 IN NUMBER
18279 --Accounted Amount
18280 , p_source_26 IN NUMBER
18281 --FEDERAL_RCV_SUB_LEDGER_ID
18282 , p_source_32 IN NUMBER
18283 --PARENT_TRANSACTION_ID
18284 , p_source_33 IN NUMBER
18285 )
18286 IS
18287
18288 l_component_type VARCHAR2(80);
18289 l_component_code VARCHAR2(30);
18290 l_component_type_code VARCHAR2(1);
18291 l_component_appl_id INTEGER;
18292 l_amb_context_code VARCHAR2(30);
18293 l_entity_code VARCHAR2(30);
18294 l_event_class_code VARCHAR2(30);
18295 l_ae_header_id NUMBER;
18296 l_event_type_code VARCHAR2(30);
18297 l_line_definition_code VARCHAR2(30);
18298 l_line_definition_owner_code VARCHAR2(1);
18299 --
18300 -- adr variables
18301 l_segment VARCHAR2(30);
18302 l_ccid NUMBER;
18303 l_adr_transaction_coa_id NUMBER;
18304 l_adr_accounting_coa_id NUMBER;
18305 l_adr_flexfield_segment_code VARCHAR2(30);
18306 l_adr_flex_value_set_id NUMBER;
18307 l_adr_value_type_code VARCHAR2(30);
18308 l_adr_value_combination_id NUMBER;
18309 l_adr_value_segment_code VARCHAR2(30);
18310
18311 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
18312 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
18313 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
18314 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
18315
18316 -- 4262811 Variables ------------------------------------------------------------------------------------------
18317 l_entered_amt_idx NUMBER;
18318 l_accted_amt_idx NUMBER;
18319 l_acc_rev_flag VARCHAR2(1);
18320 l_accrual_line_num NUMBER;
18321 l_tmp_amt NUMBER;
18322 l_acc_rev_natural_side_code VARCHAR2(1);
18323
18324 l_num_entries NUMBER;
18325 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
18326 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
18327 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
18328 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
18329 l_recog_line_1 NUMBER;
18330 l_recog_line_2 NUMBER;
18331
18332 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
18333 l_bflow_applied_to_amt NUMBER; -- 5132302
18334 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
18335
18336 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
18337
18338 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
18339 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
18340
18341 ---------------------------------------------------------------------------------------------------------------
18342
18343
18344 --
18345 -- bulk performance
18346 --
18347 l_balance_type_code VARCHAR2(1);
18348 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
18349 l_log_module VARCHAR2(240);
18350
18351 --
18352 -- Upgrade strategy
18353 --
18354 l_actual_upg_option VARCHAR2(1);
18355 l_enc_upg_option VARCHAR2(1);
18356
18357 --
18358 BEGIN
18359 --
18360 IF g_log_enabled THEN
18361 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_36';
18362 END IF;
18363 --
18364 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18365
18366 trace
18367 (p_msg => 'BEGIN of AcctLineType_36'
18368 ,p_level => C_LEVEL_PROCEDURE
18369 ,p_module => l_log_module);
18370
18371 END IF;
18372 --
18373 l_component_type := 'AMB_JLT';
18374 l_component_code := 'FV_REVERSE_RECEIPT _EXP_CR';
18375 l_component_type_code := 'S';
18376 l_component_appl_id := 707;
18377 l_amb_context_code := 'DEFAULT';
18378 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
18379 l_event_class_code := 'DELIVER_EXPENSE';
18380 l_event_type_code := 'DELIVER_EXPENSE_ALL';
18381 l_line_definition_owner_code := 'S';
18382 l_line_definition_code := 'FV_RETURN_TO_RECEIVING';
18383 --
18384 l_balance_type_code := 'A';
18385 l_segment := NULL;
18386 l_ccid := NULL;
18387 l_adr_transaction_coa_id := NULL;
18388 l_adr_accounting_coa_id := NULL;
18389 l_adr_flexfield_segment_code := NULL;
18390 l_adr_flex_value_set_id := NULL;
18391 l_adr_value_type_code := NULL;
18392 l_adr_value_combination_id := NULL;
18393 l_adr_value_segment_code := NULL;
18394
18395 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
18396 l_bflow_class_code := 'FV_REC_DR'; -- 4219869 Business Flow
18397 l_inherit_desc_flag := 'Y'; -- 4219869 Business Flow
18398 l_budgetary_control_flag := 'Y';
18399
18400 l_bflow_applied_to_amt_idx := NULL; -- 5132302
18401 l_bflow_applied_to_amt := NULL; -- 5132302
18402 l_entered_amt_idx := NULL; -- 4262811
18403 l_accted_amt_idx := NULL; -- 4262811
18404 l_acc_rev_flag := NULL; -- 4262811
18405 l_accrual_line_num := NULL; -- 4262811
18406 l_tmp_amt := NULL; -- 4262811
18407 --
18408
18409 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
18410 l_balance_type_code <> 'B' THEN
18411 IF NVL(
18412 xla_ae_sources_pkg.GetSystemSourceChar(
18413 p_source_code => 'XLA_EVENT_TYPE_CODE'
18414 , p_source_type_code => 'Y'
18415 , p_source_application_id => 602
18416 ),'
18417 ') = 'RETURN_TO_RECEIVING' AND
18418 NVL(p_source_6,'
18419 ') = 'Charge'
18420 THEN
18421
18422 --
18423 XLA_AE_LINES_PKG.SetNewLine;
18424
18425 p_balance_type_code := l_balance_type_code;
18426 -- set the flag so later we will know whether the gain loss line needs to be created
18427
18428 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
18429 p_actual_flag :='A';
18430 END IF;
18431
18432 --
18433 -- bulk performance
18434 --
18435 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
18436 p_header_num => 0); -- 4262811
18437 --
18438 -- set accounting line options
18439 --
18440 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
18441 p_natural_side_code => 'C'
18442 , p_gain_or_loss_flag => 'N'
18443 , p_gl_transfer_mode_code => 'S'
18444 , p_acct_entry_type_code => 'A'
18445 , p_switch_side_flag => 'N'
18446 , p_merge_duplicate_code => 'N'
18447 );
18448 --
18449 l_acc_rev_natural_side_code := 'D'; -- 4262811
18450 --
18451 --
18452 -- set accounting line type info
18453 --
18454 xla_ae_lines_pkg.SetAcctLineType
18455 (p_component_type => l_component_type
18456 ,p_event_type_code => l_event_type_code
18457 ,p_line_definition_owner_code => l_line_definition_owner_code
18458 ,p_line_definition_code => l_line_definition_code
18459 ,p_accounting_line_code => l_component_code
18460 ,p_accounting_line_type_code => l_component_type_code
18461 ,p_accounting_line_appl_id => l_component_appl_id
18462 ,p_amb_context_code => l_amb_context_code
18463 ,p_entity_code => l_entity_code
18464 ,p_event_class_code => l_event_class_code);
18465 --
18466 -- set accounting class
18467 --
18468 xla_ae_lines_pkg.SetAcctClass(
18469 p_accounting_class_code => 'FEDERAL_EXP'
18470 , p_ae_header_id => l_ae_header_id
18471 );
18472
18473 --
18474 -- set rounding class
18475 --
18476 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
18477 'FEDERAL_EXP';
18478
18479 --
18480 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
18481 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
18482 --
18483 -- bulk performance
18484 --
18485 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
18486
18487 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
18488 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
18489
18490 -- 4955764
18491 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18492 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
18493
18494 -- 4458381 Public Sector Enh
18495
18496 --
18497 -- set accounting attributes for the line type
18498 --
18499 l_entered_amt_idx := 17;
18500 l_accted_amt_idx := 19;
18501 l_bflow_applied_to_amt_idx := NULL; -- 5132302
18502 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
18503 l_rec_acct_attrs.array_num_value(1) :=
18504 xla_ae_sources_pkg.GetSystemSourceNum(
18505 p_source_code => 'XLA_EVENT_APPL_ID'
18506 , p_source_type_code => 'Y'
18507 , p_source_application_id => 602
18508 );
18509 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
18510 l_rec_acct_attrs.array_char_value(2) := p_source_13;
18511 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
18512 l_rec_acct_attrs.array_char_value(3) :=
18513 xla_ae_sources_pkg.GetSystemSourceChar(
18514 p_source_code => 'XLA_ENTITY_CODE'
18515 , p_source_type_code => 'Y'
18516 , p_source_application_id => 602
18517 );
18518 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
18519 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_32);
18520 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
18521 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_33);
18522 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
18523 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
18524 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
18525 l_rec_acct_attrs.array_char_value(7) := p_source_13;
18526 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
18527 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
18528 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
18529 l_rec_acct_attrs.array_num_value(9) := p_source_14;
18530 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
18531 l_rec_acct_attrs.array_char_value(10) := p_source_15;
18532 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
18533 l_rec_acct_attrs.array_num_value(11) := p_source_16;
18534 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
18535 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
18536 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
18537 l_rec_acct_attrs.array_num_value(13) := p_source_14;
18538 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
18539 l_rec_acct_attrs.array_char_value(14) := p_source_15;
18540 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
18541 l_rec_acct_attrs.array_num_value(15) := p_source_16;
18542 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
18543 l_rec_acct_attrs.array_char_value(16) := p_source_17;
18544 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
18545 l_rec_acct_attrs.array_num_value(17) := p_source_25;
18546 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
18547 l_rec_acct_attrs.array_char_value(18) := p_source_15;
18548 l_rec_acct_attrs.array_acct_attr_code(19) := 'LEDGER_AMOUNT';
18549 l_rec_acct_attrs.array_num_value(19) := p_source_26;
18550 l_rec_acct_attrs.array_acct_attr_code(20) := 'UPG_CR_ENC_TYPE_ID';
18551 l_rec_acct_attrs.array_num_value(20) := p_source_22;
18552 l_rec_acct_attrs.array_acct_attr_code(21) := 'UPG_DR_ENC_TYPE_ID';
18553 l_rec_acct_attrs.array_num_value(21) := p_source_22;
18554
18555 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
18556 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
18557
18558 ---------------------------------------------------------------------------------------------------------------
18559 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
18560 ---------------------------------------------------------------------------------------------------------------
18561 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
18562
18563 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18564 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18565
18566 IF xla_accounting_cache_pkg.GetValueChar
18567 (p_source_code => 'LEDGER_CATEGORY_CODE'
18568 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
18569 AND l_bflow_method_code = 'PRIOR_ENTRY'
18570 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
18571 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
18572 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
18573 )
18574 THEN
18575 xla_ae_lines_pkg.BflowUpgEntry
18576 (p_business_method_code => l_bflow_method_code
18577 ,p_business_class_code => l_bflow_class_code
18578 ,p_balance_type => l_balance_type_code);
18579 ELSE
18580 NULL;
18581 XLA_AE_LINES_PKG.business_flow_validation(
18582 p_business_method_code => l_bflow_method_code
18583 ,p_business_class_code => l_bflow_class_code
18584 ,p_inherit_description_flag => l_inherit_desc_flag);
18585 END IF;
18586
18587 --
18588 -- call analytical criteria
18589 --
18590 -- Inherited Analytical Criteria for business flow method of Prior Entry.
18591 --
18592 -- call description
18593 --
18594 -- No description or it is inherited.
18595 --
18596 -- call ADRs
18597 -- Bug 4922099
18598 --
18599 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18600 (NVL(l_actual_upg_option, 'N') = 'O') OR
18601 (NVL(l_enc_upg_option, 'N') = 'O')
18602 )
18603 THEN
18604 NULL;
18605 --
18606 --
18607
18608 --
18609 --
18610 END IF;
18611 --
18612 -- Bug 4922099
18613 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
18614 (NVL(l_enc_upg_option, 'N') = 'O')
18615 ) AND
18616 (l_bflow_method_code = 'PRIOR_ENTRY')
18617 )
18618 THEN
18619 IF
18620 --
18621 1 = 1
18622 --
18623 THEN
18624 xla_accounting_err_pkg.build_message
18625 (p_appli_s_name => 'XLA'
18626 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18627 ,p_token_1 => 'LINE_NUMBER'
18628 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
18629 ,p_token_2 => 'LINE_TYPE_NAME'
18630 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
18631 l_component_type
18632 ,l_component_code
18633 ,l_component_type_code
18634 ,l_component_appl_id
18635 ,l_amb_context_code
18636 ,l_entity_code
18637 ,l_event_class_code
18638 )
18639 ,p_token_3 => 'OWNER'
18640 ,p_value_3 => xla_lookups_pkg.get_meaning(
18641 p_lookup_type => 'XLA_OWNER_TYPE'
18642 ,p_lookup_code => l_component_type_code
18643 )
18644 ,p_token_4 => 'PRODUCT_NAME'
18645 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
18646 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
18647 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
18648 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
18649 ,p_ae_header_id => NULL
18650 );
18651
18652 IF (C_LEVEL_ERROR>= g_log_level) THEN
18653 trace
18654 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18655 ,p_level => C_LEVEL_ERROR
18656 ,p_module => l_log_module);
18657 END IF;
18658 END IF;
18659 END IF;
18660 --
18661 --
18662 ------------------------------------------------------------------------------------------------
18663 -- 4219869 Business Flow
18664 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
18665 -- Prior Entry. Currently, the following code is always generated.
18666 ------------------------------------------------------------------------------------------------
18667 -- No ValidateCurrentLine for business flow method of Prior Entry
18668
18669 ------------------------------------------------------------------------------------
18670 -- 4219869 Business Flow
18671 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
18672 ------------------------------------------------------------------------------------
18673 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18674
18675 ----------------------------------------------------------------------------------
18676 -- 4219869 Business Flow
18677 -- Update journal entry status -- Need to generate this within IF <condition>
18678 ----------------------------------------------------------------------------------
18679 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18680 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
18681 ,p_balance_type_code => l_balance_type_code
18682 );
18683
18684 -------------------------------------------------------------------------------------------
18685 -- 4262811 - Generate the Accrual Reversal lines
18686 -------------------------------------------------------------------------------------------
18687 BEGIN
18688 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
18689 (g_array_event(p_event_id).array_value_num('header_index'));
18690 IF l_acc_rev_flag IS NULL THEN
18691 l_acc_rev_flag := 'N';
18692 END IF;
18693 EXCEPTION
18694 WHEN OTHERS THEN
18695 l_acc_rev_flag := 'N';
18696 END;
18697 --
18698 IF (l_acc_rev_flag = 'Y') THEN
18699
18700 -- 4645092 ------------------------------------------------------------------------------
18701 -- To allow MPA report to determine if it should generate report process
18702 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
18703 ------------------------------------------------------------------------------------------
18704
18705 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
18706 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
18707 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
18708 -- call ADRs
18709 -- Bug 4922099
18710 --
18711 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18712 (NVL(l_actual_upg_option, 'N') = 'O') OR
18713 (NVL(l_enc_upg_option, 'N') = 'O')
18714 )
18715 THEN
18716 NULL;
18717 --
18718 --
18719
18720 --
18721 --
18722 END IF;
18723
18724 --
18725 -- Update the line information that should be overwritten
18726 --
18727 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
18728 p_header_num => 1);
18729 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
18730
18731 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
18732
18733 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
18734 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
18735 END IF;
18736
18737 --
18738 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
18739 --
18740 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
18741 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
18742 ELSE
18743 ---------------------------------------------------------------------------------------------------
18744 -- 4262811a Switch Sign
18745 ---------------------------------------------------------------------------------------------------
18746 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
18747 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18748 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18749 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18750 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18751 -- 5132302
18752 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
18753 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18754
18755 END IF;
18756
18757 -- 4955764
18758 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18759 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
18760
18761
18762 XLA_AE_LINES_PKG.ValidateCurrentLine;
18763 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18764
18765 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18766 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
18767 ,p_balance_type_code => l_balance_type_code);
18768
18769 END IF;
18770
18771 -----------------------------------------------------------------------------------------
18772 -- 4262811 Multiperiod Accounting
18773 -----------------------------------------------------------------------------------------
18774 -- No MPA option is assigned.
18775
18776
18777 END IF;
18778 END IF;
18779 --
18780
18781 --
18782 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18783 trace
18784 (p_msg => 'END of AcctLineType_36'
18785 ,p_level => C_LEVEL_PROCEDURE
18786 ,p_module => l_log_module);
18787 END IF;
18788 --
18789 EXCEPTION
18790 WHEN xla_exceptions_pkg.application_exception THEN
18791 RAISE;
18792 WHEN OTHERS THEN
18793 xla_exceptions_pkg.raise_message
18794 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_36');
18795 END AcctLineType_36;
18796 --
18797
18798 ---------------------------------------
18799 --
18800 -- PRIVATE FUNCTION
18801 -- AcctLineType_37
18802 --
18803 ---------------------------------------
18804 PROCEDURE AcctLineType_37 (
18805 p_application_id IN NUMBER
18806 ,p_event_id IN NUMBER
18807 ,p_calculate_acctd_flag IN VARCHAR2
18808 ,p_calculate_g_l_flag IN VARCHAR2
18809 ,p_actual_flag IN OUT VARCHAR2
18810 ,p_balance_type_code OUT VARCHAR2
18811 ,p_gain_or_loss_ref OUT VARCHAR2
18812
18813 --PO Budget Account
18814 , p_source_3 IN NUMBER
18815 --DISTRIBUTION_IDENTIFIER
18816 , p_source_12 IN NUMBER
18817 --Distribution Type
18818 , p_source_13 IN VARCHAR2
18819 , p_source_13_meaning IN VARCHAR2
18820 --Encumbrance Reversal Amount Entered
18821 , p_source_14 IN NUMBER
18822 --Entered Currency Code
18823 , p_source_15 IN VARCHAR2
18824 --Transaction Encumbrance Reversal Amount
18825 , p_source_16 IN NUMBER
18826 --Costing Encumbrance Upgrade Option
18827 , p_source_17 IN VARCHAR2
18828 --Purchasing Encumbrance Type Identifier
18829 , p_source_22 IN NUMBER
18830 --Entered Amount
18831 , p_source_25 IN NUMBER
18832 --Accounted Amount
18833 , p_source_26 IN NUMBER
18834 --FEDERAL_RCV_SUB_LEDGER_ID
18835 , p_source_32 IN NUMBER
18836 --PARENT_TRANSACTION_ID
18837 , p_source_33 IN NUMBER
18838 )
18839 IS
18840
18841 l_component_type VARCHAR2(80);
18842 l_component_code VARCHAR2(30);
18843 l_component_type_code VARCHAR2(1);
18844 l_component_appl_id INTEGER;
18845 l_amb_context_code VARCHAR2(30);
18846 l_entity_code VARCHAR2(30);
18847 l_event_class_code VARCHAR2(30);
18848 l_ae_header_id NUMBER;
18849 l_event_type_code VARCHAR2(30);
18850 l_line_definition_code VARCHAR2(30);
18851 l_line_definition_owner_code VARCHAR2(1);
18852 --
18853 -- adr variables
18854 l_segment VARCHAR2(30);
18855 l_ccid NUMBER;
18856 l_adr_transaction_coa_id NUMBER;
18857 l_adr_accounting_coa_id NUMBER;
18858 l_adr_flexfield_segment_code VARCHAR2(30);
18859 l_adr_flex_value_set_id NUMBER;
18860 l_adr_value_type_code VARCHAR2(30);
18861 l_adr_value_combination_id NUMBER;
18862 l_adr_value_segment_code VARCHAR2(30);
18863
18864 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
18865 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
18866 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
18867 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
18868
18869 -- 4262811 Variables ------------------------------------------------------------------------------------------
18870 l_entered_amt_idx NUMBER;
18871 l_accted_amt_idx NUMBER;
18872 l_acc_rev_flag VARCHAR2(1);
18873 l_accrual_line_num NUMBER;
18874 l_tmp_amt NUMBER;
18875 l_acc_rev_natural_side_code VARCHAR2(1);
18876
18877 l_num_entries NUMBER;
18878 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
18879 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
18880 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
18881 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
18882 l_recog_line_1 NUMBER;
18883 l_recog_line_2 NUMBER;
18884
18885 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
18886 l_bflow_applied_to_amt NUMBER; -- 5132302
18887 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
18888
18889 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
18890
18891 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
18892 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
18893
18894 ---------------------------------------------------------------------------------------------------------------
18895
18896
18897 --
18898 -- bulk performance
18899 --
18900 l_balance_type_code VARCHAR2(1);
18901 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
18902 l_log_module VARCHAR2(240);
18903
18904 --
18905 -- Upgrade strategy
18906 --
18907 l_actual_upg_option VARCHAR2(1);
18908 l_enc_upg_option VARCHAR2(1);
18909
18910 --
18911 BEGIN
18912 --
18913 IF g_log_enabled THEN
18914 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_37';
18915 END IF;
18916 --
18917 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18918
18919 trace
18920 (p_msg => 'BEGIN of AcctLineType_37'
18921 ,p_level => C_LEVEL_PROCEDURE
18922 ,p_module => l_log_module);
18923
18924 END IF;
18925 --
18926 l_component_type := 'AMB_JLT';
18927 l_component_code := 'FV_REVERSE_RECEIPT_EXP_CR_RTI';
18928 l_component_type_code := 'S';
18929 l_component_appl_id := 707;
18930 l_amb_context_code := 'DEFAULT';
18931 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
18932 l_event_class_code := 'PURCHASE_ORDER';
18933 l_event_type_code := 'PURCHASE_ORDER_ALL';
18934 l_line_definition_owner_code := 'S';
18935 l_line_definition_code := 'FV_RET_RI_INV';
18936 --
18937 l_balance_type_code := 'A';
18938 l_segment := NULL;
18939 l_ccid := NULL;
18940 l_adr_transaction_coa_id := NULL;
18941 l_adr_accounting_coa_id := NULL;
18942 l_adr_flexfield_segment_code := NULL;
18943 l_adr_flex_value_set_id := NULL;
18944 l_adr_value_type_code := NULL;
18945 l_adr_value_combination_id := NULL;
18946 l_adr_value_segment_code := NULL;
18947
18948 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
18949 l_bflow_class_code := 'FV_INV_REC_DR'; -- 4219869 Business Flow
18950 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
18951 l_budgetary_control_flag := 'Y';
18952
18953 l_bflow_applied_to_amt_idx := NULL; -- 5132302
18954 l_bflow_applied_to_amt := NULL; -- 5132302
18955 l_entered_amt_idx := NULL; -- 4262811
18956 l_accted_amt_idx := NULL; -- 4262811
18957 l_acc_rev_flag := NULL; -- 4262811
18958 l_accrual_line_num := NULL; -- 4262811
18959 l_tmp_amt := NULL; -- 4262811
18960 --
18961
18962 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
18963 l_balance_type_code <> 'B' THEN
18964 IF NVL(
18965 xla_ae_sources_pkg.GetSystemSourceChar(
18966 p_source_code => 'XLA_EVENT_TYPE_CODE'
18967 , p_source_type_code => 'Y'
18968 , p_source_application_id => 602
18969 ),'
18970 ') = 'RET_RI_INV'
18971 THEN
18972
18973 --
18974 XLA_AE_LINES_PKG.SetNewLine;
18975
18976 p_balance_type_code := l_balance_type_code;
18977 -- set the flag so later we will know whether the gain loss line needs to be created
18978
18979 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
18980 p_actual_flag :='A';
18981 END IF;
18982
18983 --
18984 -- bulk performance
18985 --
18986 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
18987 p_header_num => 0); -- 4262811
18988 --
18989 -- set accounting line options
18990 --
18991 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
18992 p_natural_side_code => 'C'
18993 , p_gain_or_loss_flag => 'N'
18994 , p_gl_transfer_mode_code => 'S'
18995 , p_acct_entry_type_code => 'A'
18996 , p_switch_side_flag => 'N'
18997 , p_merge_duplicate_code => 'N'
18998 );
18999 --
19000 l_acc_rev_natural_side_code := 'D'; -- 4262811
19001 --
19002 --
19003 -- set accounting line type info
19004 --
19005 xla_ae_lines_pkg.SetAcctLineType
19006 (p_component_type => l_component_type
19007 ,p_event_type_code => l_event_type_code
19008 ,p_line_definition_owner_code => l_line_definition_owner_code
19009 ,p_line_definition_code => l_line_definition_code
19010 ,p_accounting_line_code => l_component_code
19011 ,p_accounting_line_type_code => l_component_type_code
19012 ,p_accounting_line_appl_id => l_component_appl_id
19013 ,p_amb_context_code => l_amb_context_code
19014 ,p_entity_code => l_entity_code
19015 ,p_event_class_code => l_event_class_code);
19016 --
19017 -- set accounting class
19018 --
19019 xla_ae_lines_pkg.SetAcctClass(
19020 p_accounting_class_code => 'FEDERAL_INV'
19021 , p_ae_header_id => l_ae_header_id
19022 );
19023
19024 --
19025 -- set rounding class
19026 --
19027 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
19028 'FEDERAL_INV';
19029
19030 --
19031 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
19032 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
19033 --
19034 -- bulk performance
19035 --
19036 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
19037
19038 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
19039 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
19040
19041 -- 4955764
19042 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19043 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
19044
19045 -- 4458381 Public Sector Enh
19046
19047 --
19048 -- set accounting attributes for the line type
19049 --
19050 l_entered_amt_idx := 17;
19051 l_accted_amt_idx := 19;
19052 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19053 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
19054 l_rec_acct_attrs.array_num_value(1) :=
19055 xla_ae_sources_pkg.GetSystemSourceNum(
19056 p_source_code => 'XLA_EVENT_APPL_ID'
19057 , p_source_type_code => 'Y'
19058 , p_source_application_id => 602
19059 );
19060 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
19061 l_rec_acct_attrs.array_char_value(2) := p_source_13;
19062 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
19063 l_rec_acct_attrs.array_char_value(3) :=
19064 xla_ae_sources_pkg.GetSystemSourceChar(
19065 p_source_code => 'XLA_ENTITY_CODE'
19066 , p_source_type_code => 'Y'
19067 , p_source_application_id => 602
19068 );
19069 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
19070 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_32);
19071 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
19072 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_33);
19073 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
19074 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
19075 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
19076 l_rec_acct_attrs.array_char_value(7) := p_source_13;
19077 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
19078 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
19079 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
19080 l_rec_acct_attrs.array_num_value(9) := p_source_14;
19081 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
19082 l_rec_acct_attrs.array_char_value(10) := p_source_15;
19083 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
19084 l_rec_acct_attrs.array_num_value(11) := p_source_16;
19085 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
19086 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
19087 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
19088 l_rec_acct_attrs.array_num_value(13) := p_source_14;
19089 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
19090 l_rec_acct_attrs.array_char_value(14) := p_source_15;
19091 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
19092 l_rec_acct_attrs.array_num_value(15) := p_source_16;
19093 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
19094 l_rec_acct_attrs.array_char_value(16) := p_source_17;
19095 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
19096 l_rec_acct_attrs.array_num_value(17) := p_source_25;
19097 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
19098 l_rec_acct_attrs.array_char_value(18) := p_source_15;
19099 l_rec_acct_attrs.array_acct_attr_code(19) := 'LEDGER_AMOUNT';
19100 l_rec_acct_attrs.array_num_value(19) := p_source_26;
19101 l_rec_acct_attrs.array_acct_attr_code(20) := 'UPG_CR_ENC_TYPE_ID';
19102 l_rec_acct_attrs.array_num_value(20) := p_source_22;
19103 l_rec_acct_attrs.array_acct_attr_code(21) := 'UPG_DR_ENC_TYPE_ID';
19104 l_rec_acct_attrs.array_num_value(21) := p_source_22;
19105
19106 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
19107 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
19108
19109 ---------------------------------------------------------------------------------------------------------------
19110 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
19111 ---------------------------------------------------------------------------------------------------------------
19112 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
19113
19114 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19115 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19116
19117 IF xla_accounting_cache_pkg.GetValueChar
19118 (p_source_code => 'LEDGER_CATEGORY_CODE'
19119 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
19120 AND l_bflow_method_code = 'PRIOR_ENTRY'
19121 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
19122 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
19123 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
19124 )
19125 THEN
19126 xla_ae_lines_pkg.BflowUpgEntry
19127 (p_business_method_code => l_bflow_method_code
19128 ,p_business_class_code => l_bflow_class_code
19129 ,p_balance_type => l_balance_type_code);
19130 ELSE
19131 NULL;
19132 XLA_AE_LINES_PKG.business_flow_validation(
19133 p_business_method_code => l_bflow_method_code
19134 ,p_business_class_code => l_bflow_class_code
19135 ,p_inherit_description_flag => l_inherit_desc_flag);
19136 END IF;
19137
19138 --
19139 -- call analytical criteria
19140 --
19141 -- Inherited Analytical Criteria for business flow method of Prior Entry.
19142 --
19143 -- call description
19144 --
19145 -- No description or it is inherited.
19146 --
19147 -- call ADRs
19148 -- Bug 4922099
19149 --
19150 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19151 (NVL(l_actual_upg_option, 'N') = 'O') OR
19152 (NVL(l_enc_upg_option, 'N') = 'O')
19153 )
19154 THEN
19155 NULL;
19156 --
19157 --
19158
19159 --
19160 --
19161 END IF;
19162 --
19163 -- Bug 4922099
19164 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
19165 (NVL(l_enc_upg_option, 'N') = 'O')
19166 ) AND
19167 (l_bflow_method_code = 'PRIOR_ENTRY')
19168 )
19169 THEN
19170 IF
19171 --
19172 1 = 1
19173 --
19174 THEN
19175 xla_accounting_err_pkg.build_message
19176 (p_appli_s_name => 'XLA'
19177 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19178 ,p_token_1 => 'LINE_NUMBER'
19179 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
19180 ,p_token_2 => 'LINE_TYPE_NAME'
19181 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
19182 l_component_type
19183 ,l_component_code
19184 ,l_component_type_code
19185 ,l_component_appl_id
19186 ,l_amb_context_code
19187 ,l_entity_code
19188 ,l_event_class_code
19189 )
19190 ,p_token_3 => 'OWNER'
19191 ,p_value_3 => xla_lookups_pkg.get_meaning(
19192 p_lookup_type => 'XLA_OWNER_TYPE'
19193 ,p_lookup_code => l_component_type_code
19194 )
19195 ,p_token_4 => 'PRODUCT_NAME'
19196 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
19197 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
19198 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
19199 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
19200 ,p_ae_header_id => NULL
19201 );
19202
19203 IF (C_LEVEL_ERROR>= g_log_level) THEN
19204 trace
19205 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19206 ,p_level => C_LEVEL_ERROR
19207 ,p_module => l_log_module);
19208 END IF;
19209 END IF;
19210 END IF;
19211 --
19212 --
19213 ------------------------------------------------------------------------------------------------
19214 -- 4219869 Business Flow
19215 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
19216 -- Prior Entry. Currently, the following code is always generated.
19217 ------------------------------------------------------------------------------------------------
19218 -- No ValidateCurrentLine for business flow method of Prior Entry
19219
19220 ------------------------------------------------------------------------------------
19221 -- 4219869 Business Flow
19222 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
19223 ------------------------------------------------------------------------------------
19224 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19225
19226 ----------------------------------------------------------------------------------
19227 -- 4219869 Business Flow
19228 -- Update journal entry status -- Need to generate this within IF <condition>
19229 ----------------------------------------------------------------------------------
19230 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19231 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
19232 ,p_balance_type_code => l_balance_type_code
19233 );
19234
19235 -------------------------------------------------------------------------------------------
19236 -- 4262811 - Generate the Accrual Reversal lines
19237 -------------------------------------------------------------------------------------------
19238 BEGIN
19239 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
19240 (g_array_event(p_event_id).array_value_num('header_index'));
19241 IF l_acc_rev_flag IS NULL THEN
19242 l_acc_rev_flag := 'N';
19243 END IF;
19244 EXCEPTION
19245 WHEN OTHERS THEN
19246 l_acc_rev_flag := 'N';
19247 END;
19248 --
19249 IF (l_acc_rev_flag = 'Y') THEN
19250
19251 -- 4645092 ------------------------------------------------------------------------------
19252 -- To allow MPA report to determine if it should generate report process
19253 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
19254 ------------------------------------------------------------------------------------------
19255
19256 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
19257 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
19258 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
19259 -- call ADRs
19260 -- Bug 4922099
19261 --
19262 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19263 (NVL(l_actual_upg_option, 'N') = 'O') OR
19264 (NVL(l_enc_upg_option, 'N') = 'O')
19265 )
19266 THEN
19267 NULL;
19268 --
19269 --
19270
19271 --
19272 --
19273 END IF;
19274
19275 --
19276 -- Update the line information that should be overwritten
19277 --
19278 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
19279 p_header_num => 1);
19280 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
19281
19282 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
19283
19284 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
19285 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
19286 END IF;
19287
19288 --
19289 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
19290 --
19291 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
19292 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
19293 ELSE
19294 ---------------------------------------------------------------------------------------------------
19295 -- 4262811a Switch Sign
19296 ---------------------------------------------------------------------------------------------------
19297 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
19298 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19299 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19300 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19301 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19302 -- 5132302
19303 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
19304 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19305
19306 END IF;
19307
19308 -- 4955764
19309 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19310 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
19311
19312
19313 XLA_AE_LINES_PKG.ValidateCurrentLine;
19314 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19315
19316 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19317 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
19318 ,p_balance_type_code => l_balance_type_code);
19319
19320 END IF;
19321
19322 -----------------------------------------------------------------------------------------
19323 -- 4262811 Multiperiod Accounting
19324 -----------------------------------------------------------------------------------------
19325 -- No MPA option is assigned.
19326
19327
19328 END IF;
19329 END IF;
19330 --
19331
19332 --
19333 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19334 trace
19335 (p_msg => 'END of AcctLineType_37'
19336 ,p_level => C_LEVEL_PROCEDURE
19337 ,p_module => l_log_module);
19338 END IF;
19339 --
19340 EXCEPTION
19341 WHEN xla_exceptions_pkg.application_exception THEN
19342 RAISE;
19343 WHEN OTHERS THEN
19344 xla_exceptions_pkg.raise_message
19345 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_37');
19346 END AcctLineType_37;
19347 --
19348
19349 ---------------------------------------
19350 --
19351 -- PRIVATE FUNCTION
19352 -- AcctLineType_38
19353 --
19354 ---------------------------------------
19355 PROCEDURE AcctLineType_38 (
19356 p_application_id IN NUMBER
19357 ,p_event_id IN NUMBER
19358 ,p_calculate_acctd_flag IN VARCHAR2
19359 ,p_calculate_g_l_flag IN VARCHAR2
19360 ,p_actual_flag IN OUT VARCHAR2
19361 ,p_balance_type_code OUT VARCHAR2
19362 ,p_gain_or_loss_ref OUT VARCHAR2
19363
19364 --PO Budget Account
19365 , p_source_3 IN NUMBER
19366 --Receiving Accounting Line Type
19367 , p_source_6 IN VARCHAR2
19368 --DISTRIBUTION_IDENTIFIER
19369 , p_source_12 IN NUMBER
19370 --Distribution Type
19371 , p_source_13 IN VARCHAR2
19372 , p_source_13_meaning IN VARCHAR2
19373 --Encumbrance Reversal Amount Entered
19374 , p_source_14 IN NUMBER
19375 --Entered Currency Code
19376 , p_source_15 IN VARCHAR2
19377 --Transaction Encumbrance Reversal Amount
19378 , p_source_16 IN NUMBER
19379 --Costing Encumbrance Upgrade Option
19380 , p_source_17 IN VARCHAR2
19381 --Purchasing Encumbrance Type Identifier
19382 , p_source_22 IN NUMBER
19383 --Entered Amount
19384 , p_source_25 IN NUMBER
19385 --Accounted Amount
19386 , p_source_26 IN NUMBER
19387 --FEDERAL_RCV_SUB_LEDGER_ID
19388 , p_source_32 IN NUMBER
19389 --PARENT_TRANSACTION_ID
19390 , p_source_33 IN NUMBER
19391 )
19392 IS
19393
19394 l_component_type VARCHAR2(80);
19395 l_component_code VARCHAR2(30);
19396 l_component_type_code VARCHAR2(1);
19397 l_component_appl_id INTEGER;
19398 l_amb_context_code VARCHAR2(30);
19399 l_entity_code VARCHAR2(30);
19400 l_event_class_code VARCHAR2(30);
19401 l_ae_header_id NUMBER;
19402 l_event_type_code VARCHAR2(30);
19403 l_line_definition_code VARCHAR2(30);
19404 l_line_definition_owner_code VARCHAR2(1);
19405 --
19406 -- adr variables
19407 l_segment VARCHAR2(30);
19408 l_ccid NUMBER;
19409 l_adr_transaction_coa_id NUMBER;
19410 l_adr_accounting_coa_id NUMBER;
19411 l_adr_flexfield_segment_code VARCHAR2(30);
19412 l_adr_flex_value_set_id NUMBER;
19413 l_adr_value_type_code VARCHAR2(30);
19414 l_adr_value_combination_id NUMBER;
19415 l_adr_value_segment_code VARCHAR2(30);
19416
19417 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
19418 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
19419 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
19420 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
19421
19422 -- 4262811 Variables ------------------------------------------------------------------------------------------
19423 l_entered_amt_idx NUMBER;
19424 l_accted_amt_idx NUMBER;
19425 l_acc_rev_flag VARCHAR2(1);
19426 l_accrual_line_num NUMBER;
19427 l_tmp_amt NUMBER;
19428 l_acc_rev_natural_side_code VARCHAR2(1);
19429
19430 l_num_entries NUMBER;
19431 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
19432 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
19433 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
19434 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
19435 l_recog_line_1 NUMBER;
19436 l_recog_line_2 NUMBER;
19437
19438 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
19439 l_bflow_applied_to_amt NUMBER; -- 5132302
19440 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
19441
19442 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
19443
19444 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
19445 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
19446
19447 ---------------------------------------------------------------------------------------------------------------
19448
19449
19450 --
19451 -- bulk performance
19452 --
19453 l_balance_type_code VARCHAR2(1);
19454 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
19455 l_log_module VARCHAR2(240);
19456
19457 --
19458 -- Upgrade strategy
19459 --
19460 l_actual_upg_option VARCHAR2(1);
19461 l_enc_upg_option VARCHAR2(1);
19462
19463 --
19464 BEGIN
19465 --
19466 IF g_log_enabled THEN
19467 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_38';
19468 END IF;
19469 --
19470 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19471
19472 trace
19473 (p_msg => 'BEGIN of AcctLineType_38'
19474 ,p_level => C_LEVEL_PROCEDURE
19475 ,p_module => l_log_module);
19476
19477 END IF;
19478 --
19479 l_component_type := 'AMB_JLT';
19480 l_component_code := 'FV_REV_EXPENDED_DR';
19481 l_component_type_code := 'S';
19482 l_component_appl_id := 707;
19483 l_amb_context_code := 'DEFAULT';
19484 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
19485 l_event_class_code := 'DELIVER_EXPENSE';
19486 l_event_type_code := 'DELIVER_EXPENSE_ALL';
19487 l_line_definition_owner_code := 'S';
19488 l_line_definition_code := 'FV_RETURN_TO_RECEIVING';
19489 --
19490 l_balance_type_code := 'A';
19491 l_segment := NULL;
19492 l_ccid := NULL;
19493 l_adr_transaction_coa_id := NULL;
19494 l_adr_accounting_coa_id := NULL;
19495 l_adr_flexfield_segment_code := NULL;
19496 l_adr_flex_value_set_id := NULL;
19497 l_adr_value_type_code := NULL;
19498 l_adr_value_combination_id := NULL;
19499 l_adr_value_segment_code := NULL;
19500
19501 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
19502 l_bflow_class_code := 'FV_REC_CR'; -- 4219869 Business Flow
19503 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
19504 l_budgetary_control_flag := 'Y';
19505
19506 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19507 l_bflow_applied_to_amt := NULL; -- 5132302
19508 l_entered_amt_idx := NULL; -- 4262811
19509 l_accted_amt_idx := NULL; -- 4262811
19510 l_acc_rev_flag := NULL; -- 4262811
19511 l_accrual_line_num := NULL; -- 4262811
19512 l_tmp_amt := NULL; -- 4262811
19513 --
19514
19515 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
19516 l_balance_type_code <> 'B' THEN
19517 IF NVL(
19518 xla_ae_sources_pkg.GetSystemSourceChar(
19519 p_source_code => 'XLA_EVENT_TYPE_CODE'
19520 , p_source_type_code => 'Y'
19521 , p_source_application_id => 602
19522 ),'
19523 ') = 'RETURN_TO_RECEIVING' AND
19524 NVL(p_source_6,'
19525 ') = 'Charge'
19526 THEN
19527
19528 --
19529 XLA_AE_LINES_PKG.SetNewLine;
19530
19531 p_balance_type_code := l_balance_type_code;
19532 -- set the flag so later we will know whether the gain loss line needs to be created
19533
19534 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
19535 p_actual_flag :='A';
19536 END IF;
19537
19538 --
19539 -- bulk performance
19540 --
19541 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
19542 p_header_num => 0); -- 4262811
19543 --
19544 -- set accounting line options
19545 --
19546 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
19547 p_natural_side_code => 'D'
19548 , p_gain_or_loss_flag => 'N'
19549 , p_gl_transfer_mode_code => 'S'
19550 , p_acct_entry_type_code => 'A'
19551 , p_switch_side_flag => 'N'
19552 , p_merge_duplicate_code => 'N'
19553 );
19554 --
19555 l_acc_rev_natural_side_code := 'C'; -- 4262811
19556 --
19557 --
19558 -- set accounting line type info
19559 --
19560 xla_ae_lines_pkg.SetAcctLineType
19561 (p_component_type => l_component_type
19562 ,p_event_type_code => l_event_type_code
19563 ,p_line_definition_owner_code => l_line_definition_owner_code
19564 ,p_line_definition_code => l_line_definition_code
19565 ,p_accounting_line_code => l_component_code
19566 ,p_accounting_line_type_code => l_component_type_code
19567 ,p_accounting_line_appl_id => l_component_appl_id
19568 ,p_amb_context_code => l_amb_context_code
19569 ,p_entity_code => l_entity_code
19570 ,p_event_class_code => l_event_class_code);
19571 --
19572 -- set accounting class
19573 --
19574 xla_ae_lines_pkg.SetAcctClass(
19575 p_accounting_class_code => 'FEDERAL_EXP'
19576 , p_ae_header_id => l_ae_header_id
19577 );
19578
19579 --
19580 -- set rounding class
19581 --
19582 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
19583 'FEDERAL_EXP';
19584
19585 --
19586 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
19587 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
19588 --
19589 -- bulk performance
19590 --
19591 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
19592
19593 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
19594 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
19595
19596 -- 4955764
19597 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19598 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
19599
19600 -- 4458381 Public Sector Enh
19601
19602 --
19603 -- set accounting attributes for the line type
19604 --
19605 l_entered_amt_idx := 17;
19606 l_accted_amt_idx := 19;
19607 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19608 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
19609 l_rec_acct_attrs.array_num_value(1) :=
19610 xla_ae_sources_pkg.GetSystemSourceNum(
19611 p_source_code => 'XLA_EVENT_APPL_ID'
19612 , p_source_type_code => 'Y'
19613 , p_source_application_id => 602
19614 );
19615 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
19616 l_rec_acct_attrs.array_char_value(2) := p_source_13;
19617 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
19618 l_rec_acct_attrs.array_char_value(3) :=
19619 xla_ae_sources_pkg.GetSystemSourceChar(
19620 p_source_code => 'XLA_ENTITY_CODE'
19621 , p_source_type_code => 'Y'
19622 , p_source_application_id => 602
19623 );
19624 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
19625 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_32);
19626 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
19627 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_33);
19628 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
19629 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
19630 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
19631 l_rec_acct_attrs.array_char_value(7) := p_source_13;
19632 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
19633 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
19634 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
19635 l_rec_acct_attrs.array_num_value(9) := p_source_14;
19636 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
19637 l_rec_acct_attrs.array_char_value(10) := p_source_15;
19638 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
19639 l_rec_acct_attrs.array_num_value(11) := p_source_16;
19640 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
19641 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
19642 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
19643 l_rec_acct_attrs.array_num_value(13) := p_source_14;
19644 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
19645 l_rec_acct_attrs.array_char_value(14) := p_source_15;
19646 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
19647 l_rec_acct_attrs.array_num_value(15) := p_source_16;
19648 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
19649 l_rec_acct_attrs.array_char_value(16) := p_source_17;
19650 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
19651 l_rec_acct_attrs.array_num_value(17) := p_source_25;
19652 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
19653 l_rec_acct_attrs.array_char_value(18) := p_source_15;
19654 l_rec_acct_attrs.array_acct_attr_code(19) := 'LEDGER_AMOUNT';
19655 l_rec_acct_attrs.array_num_value(19) := p_source_26;
19656 l_rec_acct_attrs.array_acct_attr_code(20) := 'UPG_CR_ENC_TYPE_ID';
19657 l_rec_acct_attrs.array_num_value(20) := p_source_22;
19658 l_rec_acct_attrs.array_acct_attr_code(21) := 'UPG_DR_ENC_TYPE_ID';
19659 l_rec_acct_attrs.array_num_value(21) := p_source_22;
19660
19661 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
19662 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
19663
19664 ---------------------------------------------------------------------------------------------------------------
19665 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
19666 ---------------------------------------------------------------------------------------------------------------
19667 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
19668
19669 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19670 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19671
19672 IF xla_accounting_cache_pkg.GetValueChar
19673 (p_source_code => 'LEDGER_CATEGORY_CODE'
19674 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
19675 AND l_bflow_method_code = 'PRIOR_ENTRY'
19676 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
19677 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
19678 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
19679 )
19680 THEN
19681 xla_ae_lines_pkg.BflowUpgEntry
19682 (p_business_method_code => l_bflow_method_code
19683 ,p_business_class_code => l_bflow_class_code
19684 ,p_balance_type => l_balance_type_code);
19685 ELSE
19686 NULL;
19687 XLA_AE_LINES_PKG.business_flow_validation(
19688 p_business_method_code => l_bflow_method_code
19689 ,p_business_class_code => l_bflow_class_code
19690 ,p_inherit_description_flag => l_inherit_desc_flag);
19691 END IF;
19692
19693 --
19694 -- call analytical criteria
19695 --
19696 -- Inherited Analytical Criteria for business flow method of Prior Entry.
19697 --
19698 -- call description
19699 --
19700 -- No description or it is inherited.
19701 --
19702 -- call ADRs
19703 -- Bug 4922099
19704 --
19705 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19706 (NVL(l_actual_upg_option, 'N') = 'O') OR
19707 (NVL(l_enc_upg_option, 'N') = 'O')
19708 )
19709 THEN
19710 NULL;
19711 --
19712 --
19713
19714 --
19715 --
19716 END IF;
19717 --
19718 -- Bug 4922099
19719 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
19720 (NVL(l_enc_upg_option, 'N') = 'O')
19721 ) AND
19722 (l_bflow_method_code = 'PRIOR_ENTRY')
19723 )
19724 THEN
19725 IF
19726 --
19727 1 = 1
19728 --
19729 THEN
19730 xla_accounting_err_pkg.build_message
19731 (p_appli_s_name => 'XLA'
19732 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19733 ,p_token_1 => 'LINE_NUMBER'
19734 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
19735 ,p_token_2 => 'LINE_TYPE_NAME'
19736 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
19737 l_component_type
19738 ,l_component_code
19739 ,l_component_type_code
19740 ,l_component_appl_id
19741 ,l_amb_context_code
19742 ,l_entity_code
19743 ,l_event_class_code
19744 )
19745 ,p_token_3 => 'OWNER'
19746 ,p_value_3 => xla_lookups_pkg.get_meaning(
19747 p_lookup_type => 'XLA_OWNER_TYPE'
19748 ,p_lookup_code => l_component_type_code
19749 )
19750 ,p_token_4 => 'PRODUCT_NAME'
19751 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
19752 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
19753 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
19754 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
19755 ,p_ae_header_id => NULL
19756 );
19757
19758 IF (C_LEVEL_ERROR>= g_log_level) THEN
19759 trace
19760 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19761 ,p_level => C_LEVEL_ERROR
19762 ,p_module => l_log_module);
19763 END IF;
19764 END IF;
19765 END IF;
19766 --
19767 --
19768 ------------------------------------------------------------------------------------------------
19769 -- 4219869 Business Flow
19770 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
19771 -- Prior Entry. Currently, the following code is always generated.
19772 ------------------------------------------------------------------------------------------------
19773 -- No ValidateCurrentLine for business flow method of Prior Entry
19774
19775 ------------------------------------------------------------------------------------
19776 -- 4219869 Business Flow
19777 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
19778 ------------------------------------------------------------------------------------
19779 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19780
19781 ----------------------------------------------------------------------------------
19782 -- 4219869 Business Flow
19783 -- Update journal entry status -- Need to generate this within IF <condition>
19784 ----------------------------------------------------------------------------------
19785 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19786 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
19787 ,p_balance_type_code => l_balance_type_code
19788 );
19789
19790 -------------------------------------------------------------------------------------------
19791 -- 4262811 - Generate the Accrual Reversal lines
19792 -------------------------------------------------------------------------------------------
19793 BEGIN
19794 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
19795 (g_array_event(p_event_id).array_value_num('header_index'));
19796 IF l_acc_rev_flag IS NULL THEN
19797 l_acc_rev_flag := 'N';
19798 END IF;
19799 EXCEPTION
19800 WHEN OTHERS THEN
19801 l_acc_rev_flag := 'N';
19802 END;
19803 --
19804 IF (l_acc_rev_flag = 'Y') THEN
19805
19806 -- 4645092 ------------------------------------------------------------------------------
19807 -- To allow MPA report to determine if it should generate report process
19808 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
19809 ------------------------------------------------------------------------------------------
19810
19811 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
19812 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
19813 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
19814 -- call ADRs
19815 -- Bug 4922099
19816 --
19817 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19818 (NVL(l_actual_upg_option, 'N') = 'O') OR
19819 (NVL(l_enc_upg_option, 'N') = 'O')
19820 )
19821 THEN
19822 NULL;
19823 --
19824 --
19825
19826 --
19827 --
19828 END IF;
19829
19830 --
19831 -- Update the line information that should be overwritten
19832 --
19833 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
19834 p_header_num => 1);
19835 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
19836
19837 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
19838
19839 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
19840 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
19841 END IF;
19842
19843 --
19844 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
19845 --
19846 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
19847 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
19848 ELSE
19849 ---------------------------------------------------------------------------------------------------
19850 -- 4262811a Switch Sign
19851 ---------------------------------------------------------------------------------------------------
19852 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
19853 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19854 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19855 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19856 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19857 -- 5132302
19858 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
19859 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19860
19861 END IF;
19862
19863 -- 4955764
19864 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19865 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
19866
19867
19868 XLA_AE_LINES_PKG.ValidateCurrentLine;
19869 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19870
19871 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19872 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
19873 ,p_balance_type_code => l_balance_type_code);
19874
19875 END IF;
19876
19877 -----------------------------------------------------------------------------------------
19878 -- 4262811 Multiperiod Accounting
19879 -----------------------------------------------------------------------------------------
19880 -- No MPA option is assigned.
19881
19882
19883 END IF;
19884 END IF;
19885 --
19886
19887 --
19888 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19889 trace
19890 (p_msg => 'END of AcctLineType_38'
19891 ,p_level => C_LEVEL_PROCEDURE
19892 ,p_module => l_log_module);
19893 END IF;
19894 --
19895 EXCEPTION
19896 WHEN xla_exceptions_pkg.application_exception THEN
19897 RAISE;
19898 WHEN OTHERS THEN
19899 xla_exceptions_pkg.raise_message
19900 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_38');
19901 END AcctLineType_38;
19902 --
19903
19904 ---------------------------------------
19905 --
19906 -- PRIVATE FUNCTION
19907 -- AcctLineType_39
19908 --
19909 ---------------------------------------
19910 PROCEDURE AcctLineType_39 (
19911 p_application_id IN NUMBER
19912 ,p_event_id IN NUMBER
19913 ,p_calculate_acctd_flag IN VARCHAR2
19914 ,p_calculate_g_l_flag IN VARCHAR2
19915 ,p_actual_flag IN OUT VARCHAR2
19916 ,p_balance_type_code OUT VARCHAR2
19917 ,p_gain_or_loss_ref OUT VARCHAR2
19918
19919 --PO Budget Account
19920 , p_source_3 IN NUMBER
19921 --DISTRIBUTION_IDENTIFIER
19922 , p_source_12 IN NUMBER
19923 --Distribution Type
19924 , p_source_13 IN VARCHAR2
19925 , p_source_13_meaning IN VARCHAR2
19926 --Encumbrance Reversal Amount Entered
19927 , p_source_14 IN NUMBER
19928 --Entered Currency Code
19929 , p_source_15 IN VARCHAR2
19930 --Transaction Encumbrance Reversal Amount
19931 , p_source_16 IN NUMBER
19932 --Costing Encumbrance Upgrade Option
19933 , p_source_17 IN VARCHAR2
19934 --Purchasing Encumbrance Type Identifier
19935 , p_source_22 IN NUMBER
19936 --Entered Amount
19937 , p_source_25 IN NUMBER
19938 --Accounted Amount
19939 , p_source_26 IN NUMBER
19940 --FEDERAL_RCV_SUB_LEDGER_ID
19941 , p_source_32 IN NUMBER
19942 --PARENT_TRANSACTION_ID
19943 , p_source_33 IN NUMBER
19944 )
19945 IS
19946
19947 l_component_type VARCHAR2(80);
19948 l_component_code VARCHAR2(30);
19949 l_component_type_code VARCHAR2(1);
19950 l_component_appl_id INTEGER;
19951 l_amb_context_code VARCHAR2(30);
19952 l_entity_code VARCHAR2(30);
19953 l_event_class_code VARCHAR2(30);
19954 l_ae_header_id NUMBER;
19955 l_event_type_code VARCHAR2(30);
19956 l_line_definition_code VARCHAR2(30);
19957 l_line_definition_owner_code VARCHAR2(1);
19958 --
19959 -- adr variables
19960 l_segment VARCHAR2(30);
19961 l_ccid NUMBER;
19962 l_adr_transaction_coa_id NUMBER;
19963 l_adr_accounting_coa_id NUMBER;
19964 l_adr_flexfield_segment_code VARCHAR2(30);
19965 l_adr_flex_value_set_id NUMBER;
19966 l_adr_value_type_code VARCHAR2(30);
19967 l_adr_value_combination_id NUMBER;
19968 l_adr_value_segment_code VARCHAR2(30);
19969
19970 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
19971 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
19972 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
19973 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
19974
19975 -- 4262811 Variables ------------------------------------------------------------------------------------------
19976 l_entered_amt_idx NUMBER;
19977 l_accted_amt_idx NUMBER;
19978 l_acc_rev_flag VARCHAR2(1);
19979 l_accrual_line_num NUMBER;
19980 l_tmp_amt NUMBER;
19981 l_acc_rev_natural_side_code VARCHAR2(1);
19982
19983 l_num_entries NUMBER;
19984 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
19985 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
19986 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
19987 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
19988 l_recog_line_1 NUMBER;
19989 l_recog_line_2 NUMBER;
19990
19991 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
19992 l_bflow_applied_to_amt NUMBER; -- 5132302
19993 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
19994
19995 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
19996
19997 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
19998 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
19999
20000 ---------------------------------------------------------------------------------------------------------------
20001
20002
20003 --
20004 -- bulk performance
20005 --
20006 l_balance_type_code VARCHAR2(1);
20007 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
20008 l_log_module VARCHAR2(240);
20009
20010 --
20011 -- Upgrade strategy
20012 --
20013 l_actual_upg_option VARCHAR2(1);
20014 l_enc_upg_option VARCHAR2(1);
20015
20016 --
20017 BEGIN
20018 --
20019 IF g_log_enabled THEN
20020 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_39';
20021 END IF;
20022 --
20023 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20024
20025 trace
20026 (p_msg => 'BEGIN of AcctLineType_39'
20027 ,p_level => C_LEVEL_PROCEDURE
20028 ,p_module => l_log_module);
20029
20030 END IF;
20031 --
20032 l_component_type := 'AMB_JLT';
20033 l_component_code := 'FV_REV_EXPENDED_DR_RTI';
20034 l_component_type_code := 'S';
20035 l_component_appl_id := 707;
20036 l_amb_context_code := 'DEFAULT';
20037 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
20038 l_event_class_code := 'PURCHASE_ORDER';
20039 l_event_type_code := 'PURCHASE_ORDER_ALL';
20040 l_line_definition_owner_code := 'S';
20041 l_line_definition_code := 'FV_RET_RI_INV';
20042 --
20043 l_balance_type_code := 'A';
20044 l_segment := NULL;
20045 l_ccid := NULL;
20046 l_adr_transaction_coa_id := NULL;
20047 l_adr_accounting_coa_id := NULL;
20048 l_adr_flexfield_segment_code := NULL;
20049 l_adr_flex_value_set_id := NULL;
20050 l_adr_value_type_code := NULL;
20051 l_adr_value_combination_id := NULL;
20052 l_adr_value_segment_code := NULL;
20053
20054 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
20055 l_bflow_class_code := 'FV_INV_REC_CR'; -- 4219869 Business Flow
20056 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
20057 l_budgetary_control_flag := 'Y';
20058
20059 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20060 l_bflow_applied_to_amt := NULL; -- 5132302
20061 l_entered_amt_idx := NULL; -- 4262811
20062 l_accted_amt_idx := NULL; -- 4262811
20063 l_acc_rev_flag := NULL; -- 4262811
20064 l_accrual_line_num := NULL; -- 4262811
20065 l_tmp_amt := NULL; -- 4262811
20066 --
20067
20068 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
20069 l_balance_type_code <> 'B' THEN
20070 IF NVL(
20071 xla_ae_sources_pkg.GetSystemSourceChar(
20072 p_source_code => 'XLA_EVENT_TYPE_CODE'
20073 , p_source_type_code => 'Y'
20074 , p_source_application_id => 602
20075 ),'
20076 ') = 'RET_RI_INV'
20077 THEN
20078
20079 --
20080 XLA_AE_LINES_PKG.SetNewLine;
20081
20082 p_balance_type_code := l_balance_type_code;
20083 -- set the flag so later we will know whether the gain loss line needs to be created
20084
20085 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
20086 p_actual_flag :='A';
20087 END IF;
20088
20089 --
20090 -- bulk performance
20091 --
20092 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
20093 p_header_num => 0); -- 4262811
20094 --
20095 -- set accounting line options
20096 --
20097 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
20098 p_natural_side_code => 'D'
20099 , p_gain_or_loss_flag => 'N'
20100 , p_gl_transfer_mode_code => 'S'
20101 , p_acct_entry_type_code => 'A'
20102 , p_switch_side_flag => 'N'
20103 , p_merge_duplicate_code => 'N'
20104 );
20105 --
20106 l_acc_rev_natural_side_code := 'C'; -- 4262811
20107 --
20108 --
20109 -- set accounting line type info
20110 --
20111 xla_ae_lines_pkg.SetAcctLineType
20112 (p_component_type => l_component_type
20113 ,p_event_type_code => l_event_type_code
20114 ,p_line_definition_owner_code => l_line_definition_owner_code
20115 ,p_line_definition_code => l_line_definition_code
20116 ,p_accounting_line_code => l_component_code
20117 ,p_accounting_line_type_code => l_component_type_code
20118 ,p_accounting_line_appl_id => l_component_appl_id
20119 ,p_amb_context_code => l_amb_context_code
20120 ,p_entity_code => l_entity_code
20121 ,p_event_class_code => l_event_class_code);
20122 --
20123 -- set accounting class
20124 --
20125 xla_ae_lines_pkg.SetAcctClass(
20126 p_accounting_class_code => 'FEDERAL_INV'
20127 , p_ae_header_id => l_ae_header_id
20128 );
20129
20130 --
20131 -- set rounding class
20132 --
20133 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
20134 'FEDERAL_INV';
20135
20136 --
20137 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
20138 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
20139 --
20140 -- bulk performance
20141 --
20142 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
20143
20144 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
20145 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
20146
20147 -- 4955764
20148 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20149 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
20150
20151 -- 4458381 Public Sector Enh
20152
20153 --
20154 -- set accounting attributes for the line type
20155 --
20156 l_entered_amt_idx := 17;
20157 l_accted_amt_idx := 19;
20158 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20159 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
20160 l_rec_acct_attrs.array_num_value(1) :=
20161 xla_ae_sources_pkg.GetSystemSourceNum(
20162 p_source_code => 'XLA_EVENT_APPL_ID'
20163 , p_source_type_code => 'Y'
20164 , p_source_application_id => 602
20165 );
20166 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
20167 l_rec_acct_attrs.array_char_value(2) := p_source_13;
20168 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
20169 l_rec_acct_attrs.array_char_value(3) :=
20170 xla_ae_sources_pkg.GetSystemSourceChar(
20171 p_source_code => 'XLA_ENTITY_CODE'
20172 , p_source_type_code => 'Y'
20173 , p_source_application_id => 602
20174 );
20175 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
20176 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_32);
20177 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
20178 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_33);
20179 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
20180 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
20181 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
20182 l_rec_acct_attrs.array_char_value(7) := p_source_13;
20183 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
20184 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
20185 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
20186 l_rec_acct_attrs.array_num_value(9) := p_source_14;
20187 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
20188 l_rec_acct_attrs.array_char_value(10) := p_source_15;
20189 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
20190 l_rec_acct_attrs.array_num_value(11) := p_source_16;
20191 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
20192 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
20193 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
20194 l_rec_acct_attrs.array_num_value(13) := p_source_14;
20195 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
20196 l_rec_acct_attrs.array_char_value(14) := p_source_15;
20197 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
20198 l_rec_acct_attrs.array_num_value(15) := p_source_16;
20199 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
20200 l_rec_acct_attrs.array_char_value(16) := p_source_17;
20201 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
20202 l_rec_acct_attrs.array_num_value(17) := p_source_25;
20203 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
20204 l_rec_acct_attrs.array_char_value(18) := p_source_15;
20205 l_rec_acct_attrs.array_acct_attr_code(19) := 'LEDGER_AMOUNT';
20206 l_rec_acct_attrs.array_num_value(19) := p_source_26;
20207 l_rec_acct_attrs.array_acct_attr_code(20) := 'UPG_CR_ENC_TYPE_ID';
20208 l_rec_acct_attrs.array_num_value(20) := p_source_22;
20209 l_rec_acct_attrs.array_acct_attr_code(21) := 'UPG_DR_ENC_TYPE_ID';
20210 l_rec_acct_attrs.array_num_value(21) := p_source_22;
20211
20212 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
20213 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
20214
20215 ---------------------------------------------------------------------------------------------------------------
20216 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
20217 ---------------------------------------------------------------------------------------------------------------
20218 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
20219
20220 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20221 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20222
20223 IF xla_accounting_cache_pkg.GetValueChar
20224 (p_source_code => 'LEDGER_CATEGORY_CODE'
20225 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
20226 AND l_bflow_method_code = 'PRIOR_ENTRY'
20227 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
20228 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
20229 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
20230 )
20231 THEN
20232 xla_ae_lines_pkg.BflowUpgEntry
20233 (p_business_method_code => l_bflow_method_code
20234 ,p_business_class_code => l_bflow_class_code
20235 ,p_balance_type => l_balance_type_code);
20236 ELSE
20237 NULL;
20238 XLA_AE_LINES_PKG.business_flow_validation(
20239 p_business_method_code => l_bflow_method_code
20240 ,p_business_class_code => l_bflow_class_code
20241 ,p_inherit_description_flag => l_inherit_desc_flag);
20242 END IF;
20243
20244 --
20245 -- call analytical criteria
20246 --
20247 -- Inherited Analytical Criteria for business flow method of Prior Entry.
20248 --
20249 -- call description
20250 --
20251 -- No description or it is inherited.
20252 --
20253 -- call ADRs
20254 -- Bug 4922099
20255 --
20256 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20257 (NVL(l_actual_upg_option, 'N') = 'O') OR
20258 (NVL(l_enc_upg_option, 'N') = 'O')
20259 )
20260 THEN
20261 NULL;
20262 --
20263 --
20264
20265 --
20266 --
20267 END IF;
20268 --
20269 -- Bug 4922099
20270 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
20271 (NVL(l_enc_upg_option, 'N') = 'O')
20272 ) AND
20273 (l_bflow_method_code = 'PRIOR_ENTRY')
20274 )
20275 THEN
20276 IF
20277 --
20278 1 = 1
20279 --
20280 THEN
20281 xla_accounting_err_pkg.build_message
20282 (p_appli_s_name => 'XLA'
20283 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20284 ,p_token_1 => 'LINE_NUMBER'
20285 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
20286 ,p_token_2 => 'LINE_TYPE_NAME'
20287 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
20288 l_component_type
20289 ,l_component_code
20290 ,l_component_type_code
20291 ,l_component_appl_id
20292 ,l_amb_context_code
20293 ,l_entity_code
20294 ,l_event_class_code
20295 )
20296 ,p_token_3 => 'OWNER'
20297 ,p_value_3 => xla_lookups_pkg.get_meaning(
20298 p_lookup_type => 'XLA_OWNER_TYPE'
20299 ,p_lookup_code => l_component_type_code
20300 )
20301 ,p_token_4 => 'PRODUCT_NAME'
20302 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
20303 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
20304 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
20305 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
20306 ,p_ae_header_id => NULL
20307 );
20308
20309 IF (C_LEVEL_ERROR>= g_log_level) THEN
20310 trace
20311 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20312 ,p_level => C_LEVEL_ERROR
20313 ,p_module => l_log_module);
20314 END IF;
20315 END IF;
20316 END IF;
20317 --
20318 --
20319 ------------------------------------------------------------------------------------------------
20320 -- 4219869 Business Flow
20321 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
20322 -- Prior Entry. Currently, the following code is always generated.
20323 ------------------------------------------------------------------------------------------------
20324 -- No ValidateCurrentLine for business flow method of Prior Entry
20325
20326 ------------------------------------------------------------------------------------
20327 -- 4219869 Business Flow
20328 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
20329 ------------------------------------------------------------------------------------
20330 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20331
20332 ----------------------------------------------------------------------------------
20333 -- 4219869 Business Flow
20334 -- Update journal entry status -- Need to generate this within IF <condition>
20335 ----------------------------------------------------------------------------------
20336 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20337 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
20338 ,p_balance_type_code => l_balance_type_code
20339 );
20340
20341 -------------------------------------------------------------------------------------------
20342 -- 4262811 - Generate the Accrual Reversal lines
20343 -------------------------------------------------------------------------------------------
20344 BEGIN
20345 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
20346 (g_array_event(p_event_id).array_value_num('header_index'));
20347 IF l_acc_rev_flag IS NULL THEN
20348 l_acc_rev_flag := 'N';
20349 END IF;
20350 EXCEPTION
20351 WHEN OTHERS THEN
20352 l_acc_rev_flag := 'N';
20353 END;
20354 --
20355 IF (l_acc_rev_flag = 'Y') THEN
20356
20357 -- 4645092 ------------------------------------------------------------------------------
20358 -- To allow MPA report to determine if it should generate report process
20359 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
20360 ------------------------------------------------------------------------------------------
20361
20362 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
20363 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
20364 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
20365 -- call ADRs
20366 -- Bug 4922099
20367 --
20368 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20369 (NVL(l_actual_upg_option, 'N') = 'O') OR
20370 (NVL(l_enc_upg_option, 'N') = 'O')
20371 )
20372 THEN
20373 NULL;
20374 --
20375 --
20376
20377 --
20378 --
20379 END IF;
20380
20381 --
20382 -- Update the line information that should be overwritten
20383 --
20384 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
20385 p_header_num => 1);
20386 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
20387
20388 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
20389
20390 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
20391 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
20392 END IF;
20393
20394 --
20395 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
20396 --
20397 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
20398 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
20399 ELSE
20400 ---------------------------------------------------------------------------------------------------
20401 -- 4262811a Switch Sign
20402 ---------------------------------------------------------------------------------------------------
20403 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
20404 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
20405 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20406 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
20407 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20408 -- 5132302
20409 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
20410 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20411
20412 END IF;
20413
20414 -- 4955764
20415 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20416 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
20417
20418
20419 XLA_AE_LINES_PKG.ValidateCurrentLine;
20420 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20421
20422 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20423 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
20424 ,p_balance_type_code => l_balance_type_code);
20425
20426 END IF;
20427
20428 -----------------------------------------------------------------------------------------
20429 -- 4262811 Multiperiod Accounting
20430 -----------------------------------------------------------------------------------------
20431 -- No MPA option is assigned.
20432
20433
20434 END IF;
20435 END IF;
20436 --
20437
20438 --
20439 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20440 trace
20441 (p_msg => 'END of AcctLineType_39'
20442 ,p_level => C_LEVEL_PROCEDURE
20443 ,p_module => l_log_module);
20444 END IF;
20445 --
20446 EXCEPTION
20447 WHEN xla_exceptions_pkg.application_exception THEN
20448 RAISE;
20449 WHEN OTHERS THEN
20450 xla_exceptions_pkg.raise_message
20451 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_39');
20452 END AcctLineType_39;
20453 --
20454
20455 ---------------------------------------
20456 --
20457 -- PRIVATE FUNCTION
20458 -- AcctLineType_40
20459 --
20460 ---------------------------------------
20461 PROCEDURE AcctLineType_40 (
20462 p_application_id IN NUMBER
20463 ,p_event_id IN NUMBER
20464 ,p_calculate_acctd_flag IN VARCHAR2
20465 ,p_calculate_g_l_flag IN VARCHAR2
20466 ,p_actual_flag IN OUT VARCHAR2
20467 ,p_balance_type_code OUT VARCHAR2
20468 ,p_gain_or_loss_ref OUT VARCHAR2
20469
20470 --Federal Fund Expired Status
20471 , p_source_1 IN VARCHAR2
20472 --Federal Fund Category
20473 , p_source_2 IN VARCHAR2
20474 --PO Budget Account
20475 , p_source_3 IN NUMBER
20476 --Federal Prior Year Flag
20477 , p_source_5 IN VARCHAR2
20478 --Receiving Accounting Line Type
20479 , p_source_6 IN VARCHAR2
20480 --Applied to Application ID
20481 , p_source_7 IN NUMBER
20482 --Applied to Distribution Link Type
20483 , p_source_8 IN VARCHAR2
20484 --Applied to Entity Code
20485 , p_source_9 IN VARCHAR2
20486 --PO_DISTRIBUTION_ID
20487 , p_source_10 IN NUMBER
20488 --Applied To Purchase Document Identifier
20489 , p_source_11 IN NUMBER
20490 --DISTRIBUTION_IDENTIFIER
20491 , p_source_12 IN NUMBER
20492 --Distribution Type
20493 , p_source_13 IN VARCHAR2
20494 , p_source_13_meaning IN VARCHAR2
20495 --Encumbrance Reversal Amount Entered
20496 , p_source_14 IN NUMBER
20497 --Entered Currency Code
20498 , p_source_15 IN VARCHAR2
20499 --Transaction Encumbrance Reversal Amount
20500 , p_source_16 IN NUMBER
20501 --Costing Encumbrance Upgrade Option
20502 , p_source_17 IN VARCHAR2
20503 --Currency Conversion Date
20504 , p_source_19 IN DATE
20505 --Currency Conversion Rate
20506 , p_source_20 IN NUMBER
20507 --Currency Conversion Type
20508 , p_source_21 IN VARCHAR2
20509 --Purchasing Encumbrance Type Identifier
20510 , p_source_22 IN NUMBER
20511 --Accounted Amount
20512 , p_source_26 IN NUMBER
20513 --Federal Paid Unexpended Obligation Amount
20514 , p_source_28 IN NUMBER
20515 --Federal Unexpended Obligation Amount
20516 , p_source_34 IN NUMBER
20517 )
20518 IS
20519
20520 l_component_type VARCHAR2(80);
20521 l_component_code VARCHAR2(30);
20522 l_component_type_code VARCHAR2(1);
20523 l_component_appl_id INTEGER;
20524 l_amb_context_code VARCHAR2(30);
20525 l_entity_code VARCHAR2(30);
20526 l_event_class_code VARCHAR2(30);
20527 l_ae_header_id NUMBER;
20528 l_event_type_code VARCHAR2(30);
20529 l_line_definition_code VARCHAR2(30);
20530 l_line_definition_owner_code VARCHAR2(1);
20531 --
20532 -- adr variables
20533 l_segment VARCHAR2(30);
20534 l_ccid NUMBER;
20535 l_adr_transaction_coa_id NUMBER;
20536 l_adr_accounting_coa_id NUMBER;
20537 l_adr_flexfield_segment_code VARCHAR2(30);
20538 l_adr_flex_value_set_id NUMBER;
20539 l_adr_value_type_code VARCHAR2(30);
20540 l_adr_value_combination_id NUMBER;
20541 l_adr_value_segment_code VARCHAR2(30);
20542
20543 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
20544 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
20545 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
20546 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
20547
20548 -- 4262811 Variables ------------------------------------------------------------------------------------------
20549 l_entered_amt_idx NUMBER;
20550 l_accted_amt_idx NUMBER;
20551 l_acc_rev_flag VARCHAR2(1);
20552 l_accrual_line_num NUMBER;
20553 l_tmp_amt NUMBER;
20554 l_acc_rev_natural_side_code VARCHAR2(1);
20555
20556 l_num_entries NUMBER;
20557 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
20558 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
20559 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
20560 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
20561 l_recog_line_1 NUMBER;
20562 l_recog_line_2 NUMBER;
20563
20564 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
20565 l_bflow_applied_to_amt NUMBER; -- 5132302
20566 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
20567
20568 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
20569
20570 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
20571 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
20572
20573 ---------------------------------------------------------------------------------------------------------------
20574
20575
20576 --
20577 -- bulk performance
20578 --
20579 l_balance_type_code VARCHAR2(1);
20580 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
20581 l_log_module VARCHAR2(240);
20582
20583 --
20584 -- Upgrade strategy
20585 --
20586 l_actual_upg_option VARCHAR2(1);
20587 l_enc_upg_option VARCHAR2(1);
20588
20589 --
20590 BEGIN
20591 --
20592 IF g_log_enabled THEN
20593 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_40';
20594 END IF;
20595 --
20596 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20597
20598 trace
20599 (p_msg => 'BEGIN of AcctLineType_40'
20600 ,p_level => C_LEVEL_PROCEDURE
20601 ,p_module => l_log_module);
20602
20603 END IF;
20604 --
20605 l_component_type := 'AMB_JLT';
20606 l_component_code := 'FV_REV_PAID_PO_ALLOTMENT_CR';
20607 l_component_type_code := 'S';
20608 l_component_appl_id := 707;
20609 l_amb_context_code := 'DEFAULT';
20610 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
20611 l_event_class_code := 'DELIVER_EXPENSE';
20612 l_event_type_code := 'DELIVER_EXPENSE_ALL';
20613 l_line_definition_owner_code := 'S';
20614 l_line_definition_code := 'FV_DELIVER_EXPENSE';
20615 --
20616 l_balance_type_code := 'A';
20617 l_segment := NULL;
20618 l_ccid := NULL;
20619 l_adr_transaction_coa_id := NULL;
20620 l_adr_accounting_coa_id := NULL;
20621 l_adr_flexfield_segment_code := NULL;
20622 l_adr_flex_value_set_id := NULL;
20623 l_adr_value_type_code := NULL;
20624 l_adr_value_combination_id := NULL;
20625 l_adr_value_segment_code := NULL;
20626
20627 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
20628 l_bflow_class_code := ''; -- 4219869 Business Flow
20629 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
20630 l_budgetary_control_flag := 'Y';
20631
20632 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20633 l_bflow_applied_to_amt := NULL; -- 5132302
20634 l_entered_amt_idx := NULL; -- 4262811
20635 l_accted_amt_idx := NULL; -- 4262811
20636 l_acc_rev_flag := NULL; -- 4262811
20637 l_accrual_line_num := NULL; -- 4262811
20638 l_tmp_amt := NULL; -- 4262811
20639 --
20640
20641 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
20642 l_balance_type_code <> 'B' THEN
20643 IF (p_source_26 <= p_source_34 OR
20644 NVL(p_source_5,'
20645 ') = 'Y') AND
20646 NVL(
20647 xla_ae_sources_pkg.GetSystemSourceChar(
20648 p_source_code => 'XLA_EVENT_TYPE_CODE'
20649 , p_source_type_code => 'Y'
20650 , p_source_application_id => 602
20651 ),'
20652 ') = 'DELIVER_EXPENSE' AND
20653 NVL(p_source_6,'
20654 ') = 'Charge' AND
20655 p_source_28 > 0
20656 THEN
20657
20658 --
20659 XLA_AE_LINES_PKG.SetNewLine;
20660
20661 p_balance_type_code := l_balance_type_code;
20662 -- set the flag so later we will know whether the gain loss line needs to be created
20663
20664 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
20665 p_actual_flag :='A';
20666 END IF;
20667
20668 --
20669 -- bulk performance
20670 --
20671 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
20672 p_header_num => 0); -- 4262811
20673 --
20674 -- set accounting line options
20675 --
20676 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
20677 p_natural_side_code => 'C'
20678 , p_gain_or_loss_flag => 'N'
20679 , p_gl_transfer_mode_code => 'S'
20680 , p_acct_entry_type_code => 'A'
20681 , p_switch_side_flag => 'N'
20682 , p_merge_duplicate_code => 'N'
20683 );
20684 --
20685 l_acc_rev_natural_side_code := 'D'; -- 4262811
20686 --
20687 --
20688 -- set accounting line type info
20689 --
20690 xla_ae_lines_pkg.SetAcctLineType
20691 (p_component_type => l_component_type
20692 ,p_event_type_code => l_event_type_code
20693 ,p_line_definition_owner_code => l_line_definition_owner_code
20694 ,p_line_definition_code => l_line_definition_code
20695 ,p_accounting_line_code => l_component_code
20696 ,p_accounting_line_type_code => l_component_type_code
20697 ,p_accounting_line_appl_id => l_component_appl_id
20698 ,p_amb_context_code => l_amb_context_code
20699 ,p_entity_code => l_entity_code
20700 ,p_event_class_code => l_event_class_code);
20701 --
20702 -- set accounting class
20703 --
20704 xla_ae_lines_pkg.SetAcctClass(
20705 p_accounting_class_code => 'FEDERAL_EXP'
20706 , p_ae_header_id => l_ae_header_id
20707 );
20708
20709 --
20710 -- set rounding class
20711 --
20712 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
20713 'FEDERAL_EXP';
20714
20715 --
20716 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
20717 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
20718 --
20719 -- bulk performance
20720 --
20721 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
20722
20723 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
20724 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
20725
20726 -- 4955764
20727 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20728 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
20729
20730 -- 4458381 Public Sector Enh
20731
20732 --
20733 -- set accounting attributes for the line type
20734 --
20735 l_entered_amt_idx := 17;
20736 l_accted_amt_idx := 22;
20737 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20738 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
20739 l_rec_acct_attrs.array_num_value(1) := p_source_7;
20740 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
20741 l_rec_acct_attrs.array_char_value(2) := p_source_8;
20742 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
20743 l_rec_acct_attrs.array_char_value(3) := p_source_9;
20744 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
20745 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
20746 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
20747 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
20748 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
20749 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
20750 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
20751 l_rec_acct_attrs.array_char_value(7) := p_source_13;
20752 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
20753 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
20754 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
20755 l_rec_acct_attrs.array_num_value(9) := p_source_14;
20756 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
20757 l_rec_acct_attrs.array_char_value(10) := p_source_15;
20758 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
20759 l_rec_acct_attrs.array_num_value(11) := p_source_16;
20760 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
20761 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
20762 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
20763 l_rec_acct_attrs.array_num_value(13) := p_source_14;
20764 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
20765 l_rec_acct_attrs.array_char_value(14) := p_source_15;
20766 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
20767 l_rec_acct_attrs.array_num_value(15) := p_source_16;
20768 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
20769 l_rec_acct_attrs.array_char_value(16) := p_source_17;
20770 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
20771 l_rec_acct_attrs.array_num_value(17) := p_source_34;
20772 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
20773 l_rec_acct_attrs.array_char_value(18) := p_source_15;
20774 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
20775 l_rec_acct_attrs.array_date_value(19) := p_source_19;
20776 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
20777 l_rec_acct_attrs.array_num_value(20) := p_source_20;
20778 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
20779 l_rec_acct_attrs.array_char_value(21) := p_source_21;
20780 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
20781 l_rec_acct_attrs.array_num_value(22) := p_source_28;
20782 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
20783 l_rec_acct_attrs.array_num_value(23) := p_source_22;
20784 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
20785 l_rec_acct_attrs.array_num_value(24) := p_source_22;
20786
20787 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
20788 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
20789
20790 ---------------------------------------------------------------------------------------------------------------
20791 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
20792 ---------------------------------------------------------------------------------------------------------------
20793 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
20794
20795 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20796 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20797
20798 IF xla_accounting_cache_pkg.GetValueChar
20799 (p_source_code => 'LEDGER_CATEGORY_CODE'
20800 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
20801 AND l_bflow_method_code = 'PRIOR_ENTRY'
20802 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
20803 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
20804 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
20805 )
20806 THEN
20807 xla_ae_lines_pkg.BflowUpgEntry
20808 (p_business_method_code => l_bflow_method_code
20809 ,p_business_class_code => l_bflow_class_code
20810 ,p_balance_type => l_balance_type_code);
20811 ELSE
20812 NULL;
20813 -- No business flow processing for business flow method of NONE.
20814 END IF;
20815
20816 --
20817 -- call analytical criteria
20818 --
20819
20820 --
20821 -- call description
20822 --
20823 -- No description or it is inherited.
20824 --
20825 -- call ADRs
20826 -- Bug 4922099
20827 --
20828 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20829 (NVL(l_actual_upg_option, 'N') = 'O') OR
20830 (NVL(l_enc_upg_option, 'N') = 'O')
20831 )
20832 THEN
20833 NULL;
20834 --
20835 --
20836
20837 l_ccid := AcctDerRule_11(
20838 p_application_id => p_application_id
20839 , p_ae_header_id => l_ae_header_id
20840 , p_source_3 => p_source_3
20841 , x_transaction_coa_id => l_adr_transaction_coa_id
20842 , x_accounting_coa_id => l_adr_accounting_coa_id
20843 , x_value_type_code => l_adr_value_type_code
20844 , p_side => 'NA'
20845 );
20846
20847 xla_ae_lines_pkg.set_ccid(
20848 p_code_combination_id => l_ccid
20849 , p_value_type_code => l_adr_value_type_code
20850 , p_transaction_coa_id => l_adr_transaction_coa_id
20851 , p_accounting_coa_id => l_adr_accounting_coa_id
20852 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
20853 , p_adr_type_code => 'S'
20854 , p_component_type => l_component_type
20855 , p_component_code => l_component_code
20856 , p_component_type_code => l_component_type_code
20857 , p_component_appl_id => l_component_appl_id
20858 , p_amb_context_code => l_amb_context_code
20859 , p_side => 'NA'
20860 );
20861
20862
20863 l_segment := AcctDerRule_4(
20864 p_application_id => p_application_id
20865 , p_ae_header_id => l_ae_header_id
20866 , p_source_1 => p_source_1
20867 , p_source_2 => p_source_2
20868 , x_transaction_coa_id => l_adr_transaction_coa_id
20869 , x_accounting_coa_id => l_adr_accounting_coa_id
20870 , x_flexfield_segment_code => l_adr_flexfield_segment_code
20871 , x_flex_value_set_id => l_adr_flex_value_set_id
20872 , x_value_type_code => l_adr_value_type_code
20873 , x_value_combination_id => l_adr_value_combination_id
20874 , x_value_segment_code => l_adr_value_segment_code
20875 , p_side => 'NA'
20876 , p_override_seg_flag => 'Y'
20877 );
20878
20879 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
20880
20881 xla_ae_lines_pkg.set_segment(
20882 p_to_segment_code => 'GL_ACCOUNT'
20883 , p_segment_value => l_segment
20884 , p_from_segment_code => l_adr_value_segment_code
20885 , p_from_combination_id => l_adr_value_combination_id
20886 , p_value_type_code => l_adr_value_type_code
20887 , p_transaction_coa_id => l_adr_transaction_coa_id
20888 , p_accounting_coa_id => l_adr_accounting_coa_id
20889 , p_flexfield_segment_code => l_adr_flexfield_segment_code
20890 , p_flex_value_set_id => l_adr_flex_value_set_id
20891 , p_adr_code => 'FV_46X002'
20892 , p_adr_type_code => 'S'
20893 , p_component_type => l_component_type
20894 , p_component_code => l_component_code
20895 , p_component_type_code => l_component_type_code
20896 , p_component_appl_id => l_component_appl_id
20897 , p_amb_context_code => l_amb_context_code
20898 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
20899 , p_event_class_code => 'DELIVER_EXPENSE'
20900 , p_side => 'NA'
20901 );
20902
20903 END IF;
20904
20905 --
20906 --
20907 END IF;
20908 --
20909 -- Bug 4922099
20910 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
20911 (NVL(l_enc_upg_option, 'N') = 'O')
20912 ) AND
20913 (l_bflow_method_code = 'PRIOR_ENTRY')
20914 )
20915 THEN
20916 IF
20917 --
20918 1 = 2
20919 --
20920 THEN
20921 xla_accounting_err_pkg.build_message
20922 (p_appli_s_name => 'XLA'
20923 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20924 ,p_token_1 => 'LINE_NUMBER'
20925 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
20926 ,p_token_2 => 'LINE_TYPE_NAME'
20927 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
20928 l_component_type
20929 ,l_component_code
20930 ,l_component_type_code
20931 ,l_component_appl_id
20932 ,l_amb_context_code
20933 ,l_entity_code
20934 ,l_event_class_code
20935 )
20936 ,p_token_3 => 'OWNER'
20937 ,p_value_3 => xla_lookups_pkg.get_meaning(
20938 p_lookup_type => 'XLA_OWNER_TYPE'
20939 ,p_lookup_code => l_component_type_code
20940 )
20941 ,p_token_4 => 'PRODUCT_NAME'
20942 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
20943 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
20944 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
20945 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
20946 ,p_ae_header_id => NULL
20947 );
20948
20949 IF (C_LEVEL_ERROR>= g_log_level) THEN
20950 trace
20951 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20952 ,p_level => C_LEVEL_ERROR
20953 ,p_module => l_log_module);
20954 END IF;
20955 END IF;
20956 END IF;
20957 --
20958 --
20959 ------------------------------------------------------------------------------------------------
20960 -- 4219869 Business Flow
20961 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
20962 -- Prior Entry. Currently, the following code is always generated.
20963 ------------------------------------------------------------------------------------------------
20964 XLA_AE_LINES_PKG.ValidateCurrentLine;
20965
20966 ------------------------------------------------------------------------------------
20967 -- 4219869 Business Flow
20968 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
20969 ------------------------------------------------------------------------------------
20970 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20971
20972 ----------------------------------------------------------------------------------
20973 -- 4219869 Business Flow
20974 -- Update journal entry status -- Need to generate this within IF <condition>
20975 ----------------------------------------------------------------------------------
20976 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20977 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
20978 ,p_balance_type_code => l_balance_type_code
20979 );
20980
20981 -------------------------------------------------------------------------------------------
20982 -- 4262811 - Generate the Accrual Reversal lines
20983 -------------------------------------------------------------------------------------------
20984 BEGIN
20985 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
20986 (g_array_event(p_event_id).array_value_num('header_index'));
20987 IF l_acc_rev_flag IS NULL THEN
20988 l_acc_rev_flag := 'N';
20989 END IF;
20990 EXCEPTION
20991 WHEN OTHERS THEN
20992 l_acc_rev_flag := 'N';
20993 END;
20994 --
20995 IF (l_acc_rev_flag = 'Y') THEN
20996
20997 -- 4645092 ------------------------------------------------------------------------------
20998 -- To allow MPA report to determine if it should generate report process
20999 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
21000 ------------------------------------------------------------------------------------------
21001
21002 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
21003 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
21004 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
21005 -- call ADRs
21006 -- Bug 4922099
21007 --
21008 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21009 (NVL(l_actual_upg_option, 'N') = 'O') OR
21010 (NVL(l_enc_upg_option, 'N') = 'O')
21011 )
21012 THEN
21013 NULL;
21014 --
21015 --
21016
21017 l_ccid := AcctDerRule_11(
21018 p_application_id => p_application_id
21019 , p_ae_header_id => l_ae_header_id
21020 , p_source_3 => p_source_3
21021 , x_transaction_coa_id => l_adr_transaction_coa_id
21022 , x_accounting_coa_id => l_adr_accounting_coa_id
21023 , x_value_type_code => l_adr_value_type_code
21024 , p_side => 'NA'
21025 );
21026
21027 xla_ae_lines_pkg.set_ccid(
21028 p_code_combination_id => l_ccid
21029 , p_value_type_code => l_adr_value_type_code
21030 , p_transaction_coa_id => l_adr_transaction_coa_id
21031 , p_accounting_coa_id => l_adr_accounting_coa_id
21032 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
21033 , p_adr_type_code => 'S'
21034 , p_component_type => l_component_type
21035 , p_component_code => l_component_code
21036 , p_component_type_code => l_component_type_code
21037 , p_component_appl_id => l_component_appl_id
21038 , p_amb_context_code => l_amb_context_code
21039 , p_side => 'NA'
21040 );
21041
21042
21043 l_segment := AcctDerRule_4(
21044 p_application_id => p_application_id
21045 , p_ae_header_id => l_ae_header_id
21046 , p_source_1 => p_source_1
21047 , p_source_2 => p_source_2
21048 , x_transaction_coa_id => l_adr_transaction_coa_id
21049 , x_accounting_coa_id => l_adr_accounting_coa_id
21050 , x_flexfield_segment_code => l_adr_flexfield_segment_code
21051 , x_flex_value_set_id => l_adr_flex_value_set_id
21052 , x_value_type_code => l_adr_value_type_code
21053 , x_value_combination_id => l_adr_value_combination_id
21054 , x_value_segment_code => l_adr_value_segment_code
21055 , p_side => 'NA'
21056 , p_override_seg_flag => 'Y'
21057 );
21058
21059 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
21060
21061 xla_ae_lines_pkg.set_segment(
21062 p_to_segment_code => 'GL_ACCOUNT'
21063 , p_segment_value => l_segment
21064 , p_from_segment_code => l_adr_value_segment_code
21065 , p_from_combination_id => l_adr_value_combination_id
21066 , p_value_type_code => l_adr_value_type_code
21067 , p_transaction_coa_id => l_adr_transaction_coa_id
21068 , p_accounting_coa_id => l_adr_accounting_coa_id
21069 , p_flexfield_segment_code => l_adr_flexfield_segment_code
21070 , p_flex_value_set_id => l_adr_flex_value_set_id
21071 , p_adr_code => 'FV_46X002'
21072 , p_adr_type_code => 'S'
21073 , p_component_type => l_component_type
21074 , p_component_code => l_component_code
21075 , p_component_type_code => l_component_type_code
21076 , p_component_appl_id => l_component_appl_id
21077 , p_amb_context_code => l_amb_context_code
21078 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
21079 , p_event_class_code => 'DELIVER_EXPENSE'
21080 , p_side => 'NA'
21081 );
21082
21083 END IF;
21084
21085 --
21086 --
21087 END IF;
21088
21089 --
21090 -- Update the line information that should be overwritten
21091 --
21092 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
21093 p_header_num => 1);
21094 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
21095
21096 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
21097
21098 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
21099 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
21100 END IF;
21101
21102 --
21103 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
21104 --
21105 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
21106 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
21107 ELSE
21108 ---------------------------------------------------------------------------------------------------
21109 -- 4262811a Switch Sign
21110 ---------------------------------------------------------------------------------------------------
21111 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
21112 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21113 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21114 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21115 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21116 -- 5132302
21117 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
21118 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21119
21120 END IF;
21121
21122 -- 4955764
21123 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21124 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
21125
21126
21127 XLA_AE_LINES_PKG.ValidateCurrentLine;
21128 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21129
21130 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21131 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
21132 ,p_balance_type_code => l_balance_type_code);
21133
21134 END IF;
21135
21136 -----------------------------------------------------------------------------------------
21137 -- 4262811 Multiperiod Accounting
21138 -----------------------------------------------------------------------------------------
21139 -- No MPA option is assigned.
21140
21141
21142 END IF;
21143 END IF;
21144 --
21145
21146 --
21147 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21148 trace
21149 (p_msg => 'END of AcctLineType_40'
21150 ,p_level => C_LEVEL_PROCEDURE
21151 ,p_module => l_log_module);
21152 END IF;
21153 --
21154 EXCEPTION
21155 WHEN xla_exceptions_pkg.application_exception THEN
21156 RAISE;
21157 WHEN OTHERS THEN
21158 xla_exceptions_pkg.raise_message
21159 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_40');
21160 END AcctLineType_40;
21161 --
21162
21163 ---------------------------------------
21164 --
21165 -- PRIVATE FUNCTION
21166 -- AcctLineType_41
21167 --
21168 ---------------------------------------
21169 PROCEDURE AcctLineType_41 (
21170 p_application_id IN NUMBER
21171 ,p_event_id IN NUMBER
21172 ,p_calculate_acctd_flag IN VARCHAR2
21173 ,p_calculate_g_l_flag IN VARCHAR2
21174 ,p_actual_flag IN OUT VARCHAR2
21175 ,p_balance_type_code OUT VARCHAR2
21176 ,p_gain_or_loss_ref OUT VARCHAR2
21177
21178 --Federal Fund Expired Status
21179 , p_source_1 IN VARCHAR2
21180 --Federal Fund Category
21181 , p_source_2 IN VARCHAR2
21182 --PO Budget Account
21183 , p_source_3 IN NUMBER
21184 --Federal Prior Year Flag
21185 , p_source_5 IN VARCHAR2
21186 --Receiving Accounting Line Type
21187 , p_source_6 IN VARCHAR2
21188 --Applied to Application ID
21189 , p_source_7 IN NUMBER
21190 --Applied to Distribution Link Type
21191 , p_source_8 IN VARCHAR2
21192 --Applied to Entity Code
21193 , p_source_9 IN VARCHAR2
21194 --PO_DISTRIBUTION_ID
21195 , p_source_10 IN NUMBER
21196 --Applied To Purchase Document Identifier
21197 , p_source_11 IN NUMBER
21198 --DISTRIBUTION_IDENTIFIER
21199 , p_source_12 IN NUMBER
21200 --Distribution Type
21201 , p_source_13 IN VARCHAR2
21202 , p_source_13_meaning IN VARCHAR2
21203 --Encumbrance Reversal Amount Entered
21204 , p_source_14 IN NUMBER
21205 --Entered Currency Code
21206 , p_source_15 IN VARCHAR2
21207 --Transaction Encumbrance Reversal Amount
21208 , p_source_16 IN NUMBER
21209 --Costing Encumbrance Upgrade Option
21210 , p_source_17 IN VARCHAR2
21211 --Currency Conversion Date
21212 , p_source_19 IN DATE
21213 --Currency Conversion Rate
21214 , p_source_20 IN NUMBER
21215 --Currency Conversion Type
21216 , p_source_21 IN VARCHAR2
21217 --Purchasing Encumbrance Type Identifier
21218 , p_source_22 IN NUMBER
21219 --Accounted Amount
21220 , p_source_26 IN NUMBER
21221 --Federal Unpaid Unexpended Obligation Amount
21222 , p_source_29 IN NUMBER
21223 --Federal Unexpended Obligation Amount
21224 , p_source_34 IN NUMBER
21225 )
21226 IS
21227
21228 l_component_type VARCHAR2(80);
21229 l_component_code VARCHAR2(30);
21230 l_component_type_code VARCHAR2(1);
21231 l_component_appl_id INTEGER;
21232 l_amb_context_code VARCHAR2(30);
21233 l_entity_code VARCHAR2(30);
21234 l_event_class_code VARCHAR2(30);
21235 l_ae_header_id NUMBER;
21236 l_event_type_code VARCHAR2(30);
21237 l_line_definition_code VARCHAR2(30);
21238 l_line_definition_owner_code VARCHAR2(1);
21239 --
21240 -- adr variables
21241 l_segment VARCHAR2(30);
21242 l_ccid NUMBER;
21243 l_adr_transaction_coa_id NUMBER;
21244 l_adr_accounting_coa_id NUMBER;
21245 l_adr_flexfield_segment_code VARCHAR2(30);
21246 l_adr_flex_value_set_id NUMBER;
21247 l_adr_value_type_code VARCHAR2(30);
21248 l_adr_value_combination_id NUMBER;
21249 l_adr_value_segment_code VARCHAR2(30);
21250
21251 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
21252 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
21253 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
21254 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
21255
21256 -- 4262811 Variables ------------------------------------------------------------------------------------------
21257 l_entered_amt_idx NUMBER;
21258 l_accted_amt_idx NUMBER;
21259 l_acc_rev_flag VARCHAR2(1);
21260 l_accrual_line_num NUMBER;
21261 l_tmp_amt NUMBER;
21262 l_acc_rev_natural_side_code VARCHAR2(1);
21263
21264 l_num_entries NUMBER;
21265 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
21266 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
21267 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
21268 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
21269 l_recog_line_1 NUMBER;
21270 l_recog_line_2 NUMBER;
21271
21272 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
21273 l_bflow_applied_to_amt NUMBER; -- 5132302
21274 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
21275
21276 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
21277
21278 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
21279 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
21280
21281 ---------------------------------------------------------------------------------------------------------------
21282
21283
21284 --
21285 -- bulk performance
21286 --
21287 l_balance_type_code VARCHAR2(1);
21288 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
21289 l_log_module VARCHAR2(240);
21290
21291 --
21292 -- Upgrade strategy
21293 --
21294 l_actual_upg_option VARCHAR2(1);
21295 l_enc_upg_option VARCHAR2(1);
21296
21297 --
21298 BEGIN
21299 --
21300 IF g_log_enabled THEN
21301 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_41';
21302 END IF;
21303 --
21304 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21305
21306 trace
21307 (p_msg => 'BEGIN of AcctLineType_41'
21308 ,p_level => C_LEVEL_PROCEDURE
21309 ,p_module => l_log_module);
21310
21311 END IF;
21312 --
21313 l_component_type := 'AMB_JLT';
21314 l_component_code := 'FV_REV_PO_ALLOTMENT_CR';
21315 l_component_type_code := 'S';
21316 l_component_appl_id := 707;
21317 l_amb_context_code := 'DEFAULT';
21318 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
21319 l_event_class_code := 'DELIVER_EXPENSE';
21320 l_event_type_code := 'DELIVER_EXPENSE_ALL';
21321 l_line_definition_owner_code := 'S';
21322 l_line_definition_code := 'FV_DELIVER_EXPENSE';
21323 --
21324 l_balance_type_code := 'A';
21325 l_segment := NULL;
21326 l_ccid := NULL;
21327 l_adr_transaction_coa_id := NULL;
21328 l_adr_accounting_coa_id := NULL;
21329 l_adr_flexfield_segment_code := NULL;
21330 l_adr_flex_value_set_id := NULL;
21331 l_adr_value_type_code := NULL;
21332 l_adr_value_combination_id := NULL;
21333 l_adr_value_segment_code := NULL;
21334
21335 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
21336 l_bflow_class_code := ''; -- 4219869 Business Flow
21337 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
21338 l_budgetary_control_flag := 'Y';
21339
21340 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21341 l_bflow_applied_to_amt := NULL; -- 5132302
21342 l_entered_amt_idx := NULL; -- 4262811
21343 l_accted_amt_idx := NULL; -- 4262811
21344 l_acc_rev_flag := NULL; -- 4262811
21345 l_accrual_line_num := NULL; -- 4262811
21346 l_tmp_amt := NULL; -- 4262811
21347 --
21348
21349 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
21350 l_balance_type_code <> 'B' THEN
21351 IF (p_source_26 <= p_source_34 OR
21352 NVL(p_source_5,'
21353 ') = 'Y') AND
21354 NVL(
21355 xla_ae_sources_pkg.GetSystemSourceChar(
21356 p_source_code => 'XLA_EVENT_TYPE_CODE'
21357 , p_source_type_code => 'Y'
21358 , p_source_application_id => 602
21359 ),'
21360 ') = 'DELIVER_EXPENSE' AND
21361 NVL(p_source_6,'
21362 ') = 'Charge' AND
21363 p_source_29 > 0
21364 THEN
21365
21366 --
21367 XLA_AE_LINES_PKG.SetNewLine;
21368
21369 p_balance_type_code := l_balance_type_code;
21370 -- set the flag so later we will know whether the gain loss line needs to be created
21371
21372 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
21373 p_actual_flag :='A';
21374 END IF;
21375
21376 --
21377 -- bulk performance
21378 --
21379 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
21380 p_header_num => 0); -- 4262811
21381 --
21382 -- set accounting line options
21383 --
21384 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
21385 p_natural_side_code => 'C'
21386 , p_gain_or_loss_flag => 'N'
21387 , p_gl_transfer_mode_code => 'S'
21388 , p_acct_entry_type_code => 'A'
21389 , p_switch_side_flag => 'N'
21390 , p_merge_duplicate_code => 'N'
21391 );
21392 --
21393 l_acc_rev_natural_side_code := 'D'; -- 4262811
21394 --
21395 --
21396 -- set accounting line type info
21397 --
21398 xla_ae_lines_pkg.SetAcctLineType
21399 (p_component_type => l_component_type
21400 ,p_event_type_code => l_event_type_code
21401 ,p_line_definition_owner_code => l_line_definition_owner_code
21402 ,p_line_definition_code => l_line_definition_code
21403 ,p_accounting_line_code => l_component_code
21404 ,p_accounting_line_type_code => l_component_type_code
21405 ,p_accounting_line_appl_id => l_component_appl_id
21406 ,p_amb_context_code => l_amb_context_code
21407 ,p_entity_code => l_entity_code
21408 ,p_event_class_code => l_event_class_code);
21409 --
21410 -- set accounting class
21411 --
21412 xla_ae_lines_pkg.SetAcctClass(
21413 p_accounting_class_code => 'FEDERAL_EXP'
21414 , p_ae_header_id => l_ae_header_id
21415 );
21416
21417 --
21418 -- set rounding class
21419 --
21420 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
21421 'FEDERAL_EXP';
21422
21423 --
21424 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
21425 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
21426 --
21427 -- bulk performance
21428 --
21429 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
21430
21431 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
21432 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
21433
21434 -- 4955764
21435 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21436 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
21437
21438 -- 4458381 Public Sector Enh
21439
21440 --
21441 -- set accounting attributes for the line type
21442 --
21443 l_entered_amt_idx := 17;
21444 l_accted_amt_idx := 22;
21445 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21446 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
21447 l_rec_acct_attrs.array_num_value(1) := p_source_7;
21448 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
21449 l_rec_acct_attrs.array_char_value(2) := p_source_8;
21450 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
21451 l_rec_acct_attrs.array_char_value(3) := p_source_9;
21452 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
21453 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
21454 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
21455 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
21456 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
21457 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
21458 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
21459 l_rec_acct_attrs.array_char_value(7) := p_source_13;
21460 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
21461 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
21462 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
21463 l_rec_acct_attrs.array_num_value(9) := p_source_14;
21464 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
21465 l_rec_acct_attrs.array_char_value(10) := p_source_15;
21466 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
21467 l_rec_acct_attrs.array_num_value(11) := p_source_16;
21468 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
21469 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
21470 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
21471 l_rec_acct_attrs.array_num_value(13) := p_source_14;
21472 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
21473 l_rec_acct_attrs.array_char_value(14) := p_source_15;
21474 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
21475 l_rec_acct_attrs.array_num_value(15) := p_source_16;
21476 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
21477 l_rec_acct_attrs.array_char_value(16) := p_source_17;
21478 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
21479 l_rec_acct_attrs.array_num_value(17) := p_source_34;
21480 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
21481 l_rec_acct_attrs.array_char_value(18) := p_source_15;
21482 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
21483 l_rec_acct_attrs.array_date_value(19) := p_source_19;
21484 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
21485 l_rec_acct_attrs.array_num_value(20) := p_source_20;
21486 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
21487 l_rec_acct_attrs.array_char_value(21) := p_source_21;
21488 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
21489 l_rec_acct_attrs.array_num_value(22) := p_source_29;
21490 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
21491 l_rec_acct_attrs.array_num_value(23) := p_source_22;
21492 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
21493 l_rec_acct_attrs.array_num_value(24) := p_source_22;
21494
21495 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
21496 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
21497
21498 ---------------------------------------------------------------------------------------------------------------
21499 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
21500 ---------------------------------------------------------------------------------------------------------------
21501 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
21502
21503 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21504 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21505
21506 IF xla_accounting_cache_pkg.GetValueChar
21507 (p_source_code => 'LEDGER_CATEGORY_CODE'
21508 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
21509 AND l_bflow_method_code = 'PRIOR_ENTRY'
21510 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
21511 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
21512 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
21513 )
21514 THEN
21515 xla_ae_lines_pkg.BflowUpgEntry
21516 (p_business_method_code => l_bflow_method_code
21517 ,p_business_class_code => l_bflow_class_code
21518 ,p_balance_type => l_balance_type_code);
21519 ELSE
21520 NULL;
21521 -- No business flow processing for business flow method of NONE.
21522 END IF;
21523
21524 --
21525 -- call analytical criteria
21526 --
21527
21528 --
21529 -- call description
21530 --
21531 -- No description or it is inherited.
21532 --
21533 -- call ADRs
21534 -- Bug 4922099
21535 --
21536 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21537 (NVL(l_actual_upg_option, 'N') = 'O') OR
21538 (NVL(l_enc_upg_option, 'N') = 'O')
21539 )
21540 THEN
21541 NULL;
21542 --
21543 --
21544
21545 l_ccid := AcctDerRule_11(
21546 p_application_id => p_application_id
21547 , p_ae_header_id => l_ae_header_id
21548 , p_source_3 => p_source_3
21549 , x_transaction_coa_id => l_adr_transaction_coa_id
21550 , x_accounting_coa_id => l_adr_accounting_coa_id
21551 , x_value_type_code => l_adr_value_type_code
21552 , p_side => 'NA'
21553 );
21554
21555 xla_ae_lines_pkg.set_ccid(
21556 p_code_combination_id => l_ccid
21557 , p_value_type_code => l_adr_value_type_code
21558 , p_transaction_coa_id => l_adr_transaction_coa_id
21559 , p_accounting_coa_id => l_adr_accounting_coa_id
21560 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
21561 , p_adr_type_code => 'S'
21562 , p_component_type => l_component_type
21563 , p_component_code => l_component_code
21564 , p_component_type_code => l_component_type_code
21565 , p_component_appl_id => l_component_appl_id
21566 , p_amb_context_code => l_amb_context_code
21567 , p_side => 'NA'
21568 );
21569
21570
21571 l_segment := AcctDerRule_4(
21572 p_application_id => p_application_id
21573 , p_ae_header_id => l_ae_header_id
21574 , p_source_1 => p_source_1
21575 , p_source_2 => p_source_2
21576 , x_transaction_coa_id => l_adr_transaction_coa_id
21577 , x_accounting_coa_id => l_adr_accounting_coa_id
21578 , x_flexfield_segment_code => l_adr_flexfield_segment_code
21579 , x_flex_value_set_id => l_adr_flex_value_set_id
21580 , x_value_type_code => l_adr_value_type_code
21581 , x_value_combination_id => l_adr_value_combination_id
21582 , x_value_segment_code => l_adr_value_segment_code
21583 , p_side => 'NA'
21584 , p_override_seg_flag => 'Y'
21585 );
21586
21587 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
21588
21589 xla_ae_lines_pkg.set_segment(
21590 p_to_segment_code => 'GL_ACCOUNT'
21591 , p_segment_value => l_segment
21592 , p_from_segment_code => l_adr_value_segment_code
21593 , p_from_combination_id => l_adr_value_combination_id
21594 , p_value_type_code => l_adr_value_type_code
21595 , p_transaction_coa_id => l_adr_transaction_coa_id
21596 , p_accounting_coa_id => l_adr_accounting_coa_id
21597 , p_flexfield_segment_code => l_adr_flexfield_segment_code
21598 , p_flex_value_set_id => l_adr_flex_value_set_id
21599 , p_adr_code => 'FV_46X002'
21600 , p_adr_type_code => 'S'
21601 , p_component_type => l_component_type
21602 , p_component_code => l_component_code
21603 , p_component_type_code => l_component_type_code
21604 , p_component_appl_id => l_component_appl_id
21605 , p_amb_context_code => l_amb_context_code
21606 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
21607 , p_event_class_code => 'DELIVER_EXPENSE'
21608 , p_side => 'NA'
21609 );
21610
21611 END IF;
21612
21613 --
21614 --
21615 END IF;
21616 --
21617 -- Bug 4922099
21618 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
21619 (NVL(l_enc_upg_option, 'N') = 'O')
21620 ) AND
21621 (l_bflow_method_code = 'PRIOR_ENTRY')
21622 )
21623 THEN
21624 IF
21625 --
21626 1 = 2
21627 --
21628 THEN
21629 xla_accounting_err_pkg.build_message
21630 (p_appli_s_name => 'XLA'
21631 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
21632 ,p_token_1 => 'LINE_NUMBER'
21633 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
21634 ,p_token_2 => 'LINE_TYPE_NAME'
21635 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
21636 l_component_type
21637 ,l_component_code
21638 ,l_component_type_code
21639 ,l_component_appl_id
21640 ,l_amb_context_code
21641 ,l_entity_code
21642 ,l_event_class_code
21643 )
21644 ,p_token_3 => 'OWNER'
21645 ,p_value_3 => xla_lookups_pkg.get_meaning(
21646 p_lookup_type => 'XLA_OWNER_TYPE'
21647 ,p_lookup_code => l_component_type_code
21648 )
21649 ,p_token_4 => 'PRODUCT_NAME'
21650 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
21651 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
21652 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
21653 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
21654 ,p_ae_header_id => NULL
21655 );
21656
21657 IF (C_LEVEL_ERROR>= g_log_level) THEN
21658 trace
21659 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
21660 ,p_level => C_LEVEL_ERROR
21661 ,p_module => l_log_module);
21662 END IF;
21663 END IF;
21664 END IF;
21665 --
21666 --
21667 ------------------------------------------------------------------------------------------------
21668 -- 4219869 Business Flow
21669 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
21670 -- Prior Entry. Currently, the following code is always generated.
21671 ------------------------------------------------------------------------------------------------
21672 XLA_AE_LINES_PKG.ValidateCurrentLine;
21673
21674 ------------------------------------------------------------------------------------
21675 -- 4219869 Business Flow
21676 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
21677 ------------------------------------------------------------------------------------
21678 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21679
21680 ----------------------------------------------------------------------------------
21681 -- 4219869 Business Flow
21682 -- Update journal entry status -- Need to generate this within IF <condition>
21683 ----------------------------------------------------------------------------------
21684 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21685 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
21686 ,p_balance_type_code => l_balance_type_code
21687 );
21688
21689 -------------------------------------------------------------------------------------------
21690 -- 4262811 - Generate the Accrual Reversal lines
21691 -------------------------------------------------------------------------------------------
21692 BEGIN
21693 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
21694 (g_array_event(p_event_id).array_value_num('header_index'));
21695 IF l_acc_rev_flag IS NULL THEN
21696 l_acc_rev_flag := 'N';
21697 END IF;
21698 EXCEPTION
21699 WHEN OTHERS THEN
21700 l_acc_rev_flag := 'N';
21701 END;
21702 --
21703 IF (l_acc_rev_flag = 'Y') THEN
21704
21705 -- 4645092 ------------------------------------------------------------------------------
21706 -- To allow MPA report to determine if it should generate report process
21707 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
21708 ------------------------------------------------------------------------------------------
21709
21710 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
21711 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
21712 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
21713 -- call ADRs
21714 -- Bug 4922099
21715 --
21716 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21717 (NVL(l_actual_upg_option, 'N') = 'O') OR
21718 (NVL(l_enc_upg_option, 'N') = 'O')
21719 )
21720 THEN
21721 NULL;
21722 --
21723 --
21724
21725 l_ccid := AcctDerRule_11(
21726 p_application_id => p_application_id
21727 , p_ae_header_id => l_ae_header_id
21728 , p_source_3 => p_source_3
21729 , x_transaction_coa_id => l_adr_transaction_coa_id
21730 , x_accounting_coa_id => l_adr_accounting_coa_id
21731 , x_value_type_code => l_adr_value_type_code
21732 , p_side => 'NA'
21733 );
21734
21735 xla_ae_lines_pkg.set_ccid(
21736 p_code_combination_id => l_ccid
21737 , p_value_type_code => l_adr_value_type_code
21738 , p_transaction_coa_id => l_adr_transaction_coa_id
21739 , p_accounting_coa_id => l_adr_accounting_coa_id
21740 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
21741 , p_adr_type_code => 'S'
21742 , p_component_type => l_component_type
21743 , p_component_code => l_component_code
21744 , p_component_type_code => l_component_type_code
21745 , p_component_appl_id => l_component_appl_id
21746 , p_amb_context_code => l_amb_context_code
21747 , p_side => 'NA'
21748 );
21749
21750
21751 l_segment := AcctDerRule_4(
21752 p_application_id => p_application_id
21753 , p_ae_header_id => l_ae_header_id
21754 , p_source_1 => p_source_1
21755 , p_source_2 => p_source_2
21756 , x_transaction_coa_id => l_adr_transaction_coa_id
21757 , x_accounting_coa_id => l_adr_accounting_coa_id
21758 , x_flexfield_segment_code => l_adr_flexfield_segment_code
21759 , x_flex_value_set_id => l_adr_flex_value_set_id
21760 , x_value_type_code => l_adr_value_type_code
21761 , x_value_combination_id => l_adr_value_combination_id
21762 , x_value_segment_code => l_adr_value_segment_code
21763 , p_side => 'NA'
21764 , p_override_seg_flag => 'Y'
21765 );
21766
21767 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
21768
21769 xla_ae_lines_pkg.set_segment(
21770 p_to_segment_code => 'GL_ACCOUNT'
21771 , p_segment_value => l_segment
21772 , p_from_segment_code => l_adr_value_segment_code
21773 , p_from_combination_id => l_adr_value_combination_id
21774 , p_value_type_code => l_adr_value_type_code
21775 , p_transaction_coa_id => l_adr_transaction_coa_id
21776 , p_accounting_coa_id => l_adr_accounting_coa_id
21777 , p_flexfield_segment_code => l_adr_flexfield_segment_code
21778 , p_flex_value_set_id => l_adr_flex_value_set_id
21779 , p_adr_code => 'FV_46X002'
21780 , p_adr_type_code => 'S'
21781 , p_component_type => l_component_type
21782 , p_component_code => l_component_code
21783 , p_component_type_code => l_component_type_code
21784 , p_component_appl_id => l_component_appl_id
21785 , p_amb_context_code => l_amb_context_code
21786 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
21787 , p_event_class_code => 'DELIVER_EXPENSE'
21788 , p_side => 'NA'
21789 );
21790
21791 END IF;
21792
21793 --
21794 --
21795 END IF;
21796
21797 --
21798 -- Update the line information that should be overwritten
21799 --
21800 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
21801 p_header_num => 1);
21802 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
21803
21804 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
21805
21806 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
21807 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
21808 END IF;
21809
21810 --
21811 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
21812 --
21813 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
21814 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
21815 ELSE
21816 ---------------------------------------------------------------------------------------------------
21817 -- 4262811a Switch Sign
21818 ---------------------------------------------------------------------------------------------------
21819 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
21820 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21821 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21822 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21823 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21824 -- 5132302
21825 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
21826 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21827
21828 END IF;
21829
21830 -- 4955764
21831 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21832 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
21833
21834
21835 XLA_AE_LINES_PKG.ValidateCurrentLine;
21836 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21837
21838 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21839 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
21840 ,p_balance_type_code => l_balance_type_code);
21841
21842 END IF;
21843
21844 -----------------------------------------------------------------------------------------
21845 -- 4262811 Multiperiod Accounting
21846 -----------------------------------------------------------------------------------------
21847 -- No MPA option is assigned.
21848
21849
21850 END IF;
21851 END IF;
21852 --
21853
21854 --
21855 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21856 trace
21857 (p_msg => 'END of AcctLineType_41'
21858 ,p_level => C_LEVEL_PROCEDURE
21859 ,p_module => l_log_module);
21860 END IF;
21861 --
21862 EXCEPTION
21863 WHEN xla_exceptions_pkg.application_exception THEN
21864 RAISE;
21865 WHEN OTHERS THEN
21866 xla_exceptions_pkg.raise_message
21867 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_41');
21868 END AcctLineType_41;
21869 --
21870
21871 ---------------------------------------
21872 --
21873 -- PRIVATE FUNCTION
21874 -- AcctLineType_42
21875 --
21876 ---------------------------------------
21877 PROCEDURE AcctLineType_42 (
21878 p_application_id IN NUMBER
21879 ,p_event_id IN NUMBER
21880 ,p_calculate_acctd_flag IN VARCHAR2
21881 ,p_calculate_g_l_flag IN VARCHAR2
21882 ,p_actual_flag IN OUT VARCHAR2
21883 ,p_balance_type_code OUT VARCHAR2
21884 ,p_gain_or_loss_ref OUT VARCHAR2
21885
21886 --Federal Fund Expired Status
21887 , p_source_1 IN VARCHAR2
21888 --Federal Fund Category
21889 , p_source_2 IN VARCHAR2
21890 --PO Budget Account
21891 , p_source_3 IN NUMBER
21892 --Federal Prior Year Flag
21893 , p_source_5 IN VARCHAR2
21894 --Applied to Application ID
21895 , p_source_7 IN NUMBER
21896 --Applied to Distribution Link Type
21897 , p_source_8 IN VARCHAR2
21898 --Applied to Entity Code
21899 , p_source_9 IN VARCHAR2
21900 --Applied To Purchase Document Identifier
21901 , p_source_11 IN NUMBER
21902 --DISTRIBUTION_IDENTIFIER
21903 , p_source_12 IN NUMBER
21904 --Distribution Type
21905 , p_source_13 IN VARCHAR2
21906 , p_source_13_meaning IN VARCHAR2
21907 --Encumbrance Reversal Amount Entered
21908 , p_source_14 IN NUMBER
21909 --Entered Currency Code
21910 , p_source_15 IN VARCHAR2
21911 --Transaction Encumbrance Reversal Amount
21912 , p_source_16 IN NUMBER
21913 --Costing Encumbrance Upgrade Option
21914 , p_source_17 IN VARCHAR2
21915 --Currency Conversion Date
21916 , p_source_19 IN DATE
21917 --Currency Conversion Rate
21918 , p_source_20 IN NUMBER
21919 --Currency Conversion Type
21920 , p_source_21 IN VARCHAR2
21921 --Purchasing Encumbrance Type Identifier
21922 , p_source_22 IN NUMBER
21923 --TXN_PO_DISTRIBUTION_ID
21924 , p_source_23 IN NUMBER
21925 --Entered Amount
21926 , p_source_25 IN NUMBER
21927 --Accounted Amount
21928 , p_source_26 IN NUMBER
21929 --Federal Unexpended Obligation Amount
21930 , p_source_34 IN NUMBER
21931 )
21932 IS
21933
21934 l_component_type VARCHAR2(80);
21935 l_component_code VARCHAR2(30);
21936 l_component_type_code VARCHAR2(1);
21937 l_component_appl_id INTEGER;
21938 l_amb_context_code VARCHAR2(30);
21939 l_entity_code VARCHAR2(30);
21940 l_event_class_code VARCHAR2(30);
21941 l_ae_header_id NUMBER;
21942 l_event_type_code VARCHAR2(30);
21943 l_line_definition_code VARCHAR2(30);
21944 l_line_definition_owner_code VARCHAR2(1);
21945 --
21946 -- adr variables
21947 l_segment VARCHAR2(30);
21948 l_ccid NUMBER;
21949 l_adr_transaction_coa_id NUMBER;
21950 l_adr_accounting_coa_id NUMBER;
21951 l_adr_flexfield_segment_code VARCHAR2(30);
21952 l_adr_flex_value_set_id NUMBER;
21953 l_adr_value_type_code VARCHAR2(30);
21954 l_adr_value_combination_id NUMBER;
21955 l_adr_value_segment_code VARCHAR2(30);
21956
21957 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
21958 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
21959 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
21960 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
21961
21962 -- 4262811 Variables ------------------------------------------------------------------------------------------
21963 l_entered_amt_idx NUMBER;
21964 l_accted_amt_idx NUMBER;
21965 l_acc_rev_flag VARCHAR2(1);
21966 l_accrual_line_num NUMBER;
21967 l_tmp_amt NUMBER;
21968 l_acc_rev_natural_side_code VARCHAR2(1);
21969
21970 l_num_entries NUMBER;
21971 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
21972 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
21973 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
21974 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
21975 l_recog_line_1 NUMBER;
21976 l_recog_line_2 NUMBER;
21977
21978 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
21979 l_bflow_applied_to_amt NUMBER; -- 5132302
21980 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
21981
21982 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
21983
21984 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
21985 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
21986
21987 ---------------------------------------------------------------------------------------------------------------
21988
21989
21990 --
21991 -- bulk performance
21992 --
21993 l_balance_type_code VARCHAR2(1);
21994 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
21995 l_log_module VARCHAR2(240);
21996
21997 --
21998 -- Upgrade strategy
21999 --
22000 l_actual_upg_option VARCHAR2(1);
22001 l_enc_upg_option VARCHAR2(1);
22002
22003 --
22004 BEGIN
22005 --
22006 IF g_log_enabled THEN
22007 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_42';
22008 END IF;
22009 --
22010 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22011
22012 trace
22013 (p_msg => 'BEGIN of AcctLineType_42'
22014 ,p_level => C_LEVEL_PROCEDURE
22015 ,p_module => l_log_module);
22016
22017 END IF;
22018 --
22019 l_component_type := 'AMB_JLT';
22020 l_component_code := 'FV_REV_PO_ALLOTMENT_CR_DTI';
22021 l_component_type_code := 'S';
22022 l_component_appl_id := 707;
22023 l_amb_context_code := 'DEFAULT';
22024 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
22025 l_event_class_code := 'PURCHASE_ORDER';
22026 l_event_type_code := 'PURCHASE_ORDER_ALL';
22027 l_line_definition_owner_code := 'S';
22028 l_line_definition_code := 'FV_PO_DEL_INV';
22029 --
22030 l_balance_type_code := 'A';
22031 l_segment := NULL;
22032 l_ccid := NULL;
22033 l_adr_transaction_coa_id := NULL;
22034 l_adr_accounting_coa_id := NULL;
22035 l_adr_flexfield_segment_code := NULL;
22036 l_adr_flex_value_set_id := NULL;
22037 l_adr_value_type_code := NULL;
22038 l_adr_value_combination_id := NULL;
22039 l_adr_value_segment_code := NULL;
22040
22041 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
22042 l_bflow_class_code := ''; -- 4219869 Business Flow
22043 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
22044 l_budgetary_control_flag := 'Y';
22045
22046 l_bflow_applied_to_amt_idx := NULL; -- 5132302
22047 l_bflow_applied_to_amt := NULL; -- 5132302
22048 l_entered_amt_idx := NULL; -- 4262811
22049 l_accted_amt_idx := NULL; -- 4262811
22050 l_acc_rev_flag := NULL; -- 4262811
22051 l_accrual_line_num := NULL; -- 4262811
22052 l_tmp_amt := NULL; -- 4262811
22053 --
22054
22055 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
22056 l_balance_type_code <> 'B' THEN
22057 IF NVL(
22058 xla_ae_sources_pkg.GetSystemSourceChar(
22059 p_source_code => 'XLA_EVENT_TYPE_CODE'
22060 , p_source_type_code => 'Y'
22061 , p_source_application_id => 602
22062 ),'
22063 ') = 'PO_DEL_INV' AND
22064 (p_source_26 <= p_source_34 OR
22065 NVL(p_source_5,'
22066 ') = 'Y')
22067 THEN
22068
22069 --
22070 XLA_AE_LINES_PKG.SetNewLine;
22071
22072 p_balance_type_code := l_balance_type_code;
22073 -- set the flag so later we will know whether the gain loss line needs to be created
22074
22075 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
22076 p_actual_flag :='A';
22077 END IF;
22078
22079 --
22080 -- bulk performance
22081 --
22082 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
22083 p_header_num => 0); -- 4262811
22084 --
22085 -- set accounting line options
22086 --
22087 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
22088 p_natural_side_code => 'C'
22089 , p_gain_or_loss_flag => 'N'
22090 , p_gl_transfer_mode_code => 'S'
22091 , p_acct_entry_type_code => 'A'
22092 , p_switch_side_flag => 'N'
22093 , p_merge_duplicate_code => 'N'
22094 );
22095 --
22096 l_acc_rev_natural_side_code := 'D'; -- 4262811
22097 --
22098 --
22099 -- set accounting line type info
22100 --
22101 xla_ae_lines_pkg.SetAcctLineType
22102 (p_component_type => l_component_type
22103 ,p_event_type_code => l_event_type_code
22104 ,p_line_definition_owner_code => l_line_definition_owner_code
22105 ,p_line_definition_code => l_line_definition_code
22106 ,p_accounting_line_code => l_component_code
22107 ,p_accounting_line_type_code => l_component_type_code
22108 ,p_accounting_line_appl_id => l_component_appl_id
22109 ,p_amb_context_code => l_amb_context_code
22110 ,p_entity_code => l_entity_code
22111 ,p_event_class_code => l_event_class_code);
22112 --
22113 -- set accounting class
22114 --
22115 xla_ae_lines_pkg.SetAcctClass(
22116 p_accounting_class_code => 'FEDERAL_INV'
22117 , p_ae_header_id => l_ae_header_id
22118 );
22119
22120 --
22121 -- set rounding class
22122 --
22123 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
22124 'FEDERAL_INV';
22125
22126 --
22127 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
22128 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
22129 --
22130 -- bulk performance
22131 --
22132 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
22133
22134 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
22135 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
22136
22137 -- 4955764
22138 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22139 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
22140
22141 -- 4458381 Public Sector Enh
22142
22143 --
22144 -- set accounting attributes for the line type
22145 --
22146 l_entered_amt_idx := 17;
22147 l_accted_amt_idx := 22;
22148 l_bflow_applied_to_amt_idx := NULL; -- 5132302
22149 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
22150 l_rec_acct_attrs.array_num_value(1) := p_source_7;
22151 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
22152 l_rec_acct_attrs.array_char_value(2) := p_source_8;
22153 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
22154 l_rec_acct_attrs.array_char_value(3) := p_source_9;
22155 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
22156 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
22157 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
22158 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
22159 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
22160 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
22161 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
22162 l_rec_acct_attrs.array_char_value(7) := p_source_13;
22163 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
22164 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
22165 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
22166 l_rec_acct_attrs.array_num_value(9) := p_source_14;
22167 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
22168 l_rec_acct_attrs.array_char_value(10) := p_source_15;
22169 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
22170 l_rec_acct_attrs.array_num_value(11) := p_source_16;
22171 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
22172 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
22173 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
22174 l_rec_acct_attrs.array_num_value(13) := p_source_14;
22175 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
22176 l_rec_acct_attrs.array_char_value(14) := p_source_15;
22177 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
22178 l_rec_acct_attrs.array_num_value(15) := p_source_16;
22179 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
22180 l_rec_acct_attrs.array_char_value(16) := p_source_17;
22181 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
22182 l_rec_acct_attrs.array_num_value(17) := p_source_25;
22183 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
22184 l_rec_acct_attrs.array_char_value(18) := p_source_15;
22185 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
22186 l_rec_acct_attrs.array_date_value(19) := p_source_19;
22187 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
22188 l_rec_acct_attrs.array_num_value(20) := p_source_20;
22189 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
22190 l_rec_acct_attrs.array_char_value(21) := p_source_21;
22191 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
22192 l_rec_acct_attrs.array_num_value(22) := p_source_26;
22193 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
22194 l_rec_acct_attrs.array_num_value(23) := p_source_22;
22195 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
22196 l_rec_acct_attrs.array_num_value(24) := p_source_22;
22197
22198 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
22199 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
22200
22201 ---------------------------------------------------------------------------------------------------------------
22202 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
22203 ---------------------------------------------------------------------------------------------------------------
22204 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
22205
22206 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22207 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22208
22209 IF xla_accounting_cache_pkg.GetValueChar
22210 (p_source_code => 'LEDGER_CATEGORY_CODE'
22211 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
22212 AND l_bflow_method_code = 'PRIOR_ENTRY'
22213 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
22214 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
22215 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
22216 )
22217 THEN
22218 xla_ae_lines_pkg.BflowUpgEntry
22219 (p_business_method_code => l_bflow_method_code
22220 ,p_business_class_code => l_bflow_class_code
22221 ,p_balance_type => l_balance_type_code);
22222 ELSE
22223 NULL;
22224 -- No business flow processing for business flow method of NONE.
22225 END IF;
22226
22227 --
22228 -- call analytical criteria
22229 --
22230
22231 --
22232 -- call description
22233 --
22234 -- No description or it is inherited.
22235 --
22236 -- call ADRs
22237 -- Bug 4922099
22238 --
22239 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22240 (NVL(l_actual_upg_option, 'N') = 'O') OR
22241 (NVL(l_enc_upg_option, 'N') = 'O')
22242 )
22243 THEN
22244 NULL;
22245 --
22246 --
22247
22248 l_ccid := AcctDerRule_11(
22249 p_application_id => p_application_id
22250 , p_ae_header_id => l_ae_header_id
22251 , p_source_3 => p_source_3
22252 , x_transaction_coa_id => l_adr_transaction_coa_id
22253 , x_accounting_coa_id => l_adr_accounting_coa_id
22254 , x_value_type_code => l_adr_value_type_code
22255 , p_side => 'NA'
22256 );
22257
22258 xla_ae_lines_pkg.set_ccid(
22259 p_code_combination_id => l_ccid
22260 , p_value_type_code => l_adr_value_type_code
22261 , p_transaction_coa_id => l_adr_transaction_coa_id
22262 , p_accounting_coa_id => l_adr_accounting_coa_id
22263 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
22264 , p_adr_type_code => 'S'
22265 , p_component_type => l_component_type
22266 , p_component_code => l_component_code
22267 , p_component_type_code => l_component_type_code
22268 , p_component_appl_id => l_component_appl_id
22269 , p_amb_context_code => l_amb_context_code
22270 , p_side => 'NA'
22271 );
22272
22273
22274 l_segment := AcctDerRule_4(
22275 p_application_id => p_application_id
22276 , p_ae_header_id => l_ae_header_id
22277 , p_source_1 => p_source_1
22278 , p_source_2 => p_source_2
22279 , x_transaction_coa_id => l_adr_transaction_coa_id
22280 , x_accounting_coa_id => l_adr_accounting_coa_id
22281 , x_flexfield_segment_code => l_adr_flexfield_segment_code
22282 , x_flex_value_set_id => l_adr_flex_value_set_id
22283 , x_value_type_code => l_adr_value_type_code
22284 , x_value_combination_id => l_adr_value_combination_id
22285 , x_value_segment_code => l_adr_value_segment_code
22286 , p_side => 'NA'
22287 , p_override_seg_flag => 'Y'
22288 );
22289
22290 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
22291
22292 xla_ae_lines_pkg.set_segment(
22293 p_to_segment_code => 'GL_ACCOUNT'
22294 , p_segment_value => l_segment
22295 , p_from_segment_code => l_adr_value_segment_code
22296 , p_from_combination_id => l_adr_value_combination_id
22297 , p_value_type_code => l_adr_value_type_code
22298 , p_transaction_coa_id => l_adr_transaction_coa_id
22299 , p_accounting_coa_id => l_adr_accounting_coa_id
22300 , p_flexfield_segment_code => l_adr_flexfield_segment_code
22301 , p_flex_value_set_id => l_adr_flex_value_set_id
22302 , p_adr_code => 'FV_46X002'
22303 , p_adr_type_code => 'S'
22304 , p_component_type => l_component_type
22305 , p_component_code => l_component_code
22306 , p_component_type_code => l_component_type_code
22307 , p_component_appl_id => l_component_appl_id
22308 , p_amb_context_code => l_amb_context_code
22309 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
22310 , p_event_class_code => 'PURCHASE_ORDER'
22311 , p_side => 'NA'
22312 );
22313
22314 END IF;
22315
22316 --
22317 --
22318 END IF;
22319 --
22320 -- Bug 4922099
22321 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
22322 (NVL(l_enc_upg_option, 'N') = 'O')
22323 ) AND
22324 (l_bflow_method_code = 'PRIOR_ENTRY')
22325 )
22326 THEN
22327 IF
22328 --
22329 1 = 2
22330 --
22331 THEN
22332 xla_accounting_err_pkg.build_message
22333 (p_appli_s_name => 'XLA'
22334 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22335 ,p_token_1 => 'LINE_NUMBER'
22336 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
22337 ,p_token_2 => 'LINE_TYPE_NAME'
22338 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
22339 l_component_type
22340 ,l_component_code
22341 ,l_component_type_code
22342 ,l_component_appl_id
22343 ,l_amb_context_code
22344 ,l_entity_code
22345 ,l_event_class_code
22346 )
22347 ,p_token_3 => 'OWNER'
22348 ,p_value_3 => xla_lookups_pkg.get_meaning(
22349 p_lookup_type => 'XLA_OWNER_TYPE'
22350 ,p_lookup_code => l_component_type_code
22351 )
22352 ,p_token_4 => 'PRODUCT_NAME'
22353 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
22354 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
22355 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
22356 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
22357 ,p_ae_header_id => NULL
22358 );
22359
22360 IF (C_LEVEL_ERROR>= g_log_level) THEN
22361 trace
22362 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22363 ,p_level => C_LEVEL_ERROR
22364 ,p_module => l_log_module);
22365 END IF;
22366 END IF;
22367 END IF;
22368 --
22369 --
22370 ------------------------------------------------------------------------------------------------
22371 -- 4219869 Business Flow
22372 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
22373 -- Prior Entry. Currently, the following code is always generated.
22374 ------------------------------------------------------------------------------------------------
22375 XLA_AE_LINES_PKG.ValidateCurrentLine;
22376
22377 ------------------------------------------------------------------------------------
22378 -- 4219869 Business Flow
22379 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
22380 ------------------------------------------------------------------------------------
22381 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22382
22383 ----------------------------------------------------------------------------------
22384 -- 4219869 Business Flow
22385 -- Update journal entry status -- Need to generate this within IF <condition>
22386 ----------------------------------------------------------------------------------
22387 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22388 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
22389 ,p_balance_type_code => l_balance_type_code
22390 );
22391
22392 -------------------------------------------------------------------------------------------
22393 -- 4262811 - Generate the Accrual Reversal lines
22394 -------------------------------------------------------------------------------------------
22395 BEGIN
22396 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
22397 (g_array_event(p_event_id).array_value_num('header_index'));
22398 IF l_acc_rev_flag IS NULL THEN
22399 l_acc_rev_flag := 'N';
22400 END IF;
22401 EXCEPTION
22402 WHEN OTHERS THEN
22403 l_acc_rev_flag := 'N';
22404 END;
22405 --
22406 IF (l_acc_rev_flag = 'Y') THEN
22407
22408 -- 4645092 ------------------------------------------------------------------------------
22409 -- To allow MPA report to determine if it should generate report process
22410 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
22411 ------------------------------------------------------------------------------------------
22412
22413 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
22414 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
22415 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
22416 -- call ADRs
22417 -- Bug 4922099
22418 --
22419 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22420 (NVL(l_actual_upg_option, 'N') = 'O') OR
22421 (NVL(l_enc_upg_option, 'N') = 'O')
22422 )
22423 THEN
22424 NULL;
22425 --
22426 --
22427
22428 l_ccid := AcctDerRule_11(
22429 p_application_id => p_application_id
22430 , p_ae_header_id => l_ae_header_id
22431 , p_source_3 => p_source_3
22432 , x_transaction_coa_id => l_adr_transaction_coa_id
22433 , x_accounting_coa_id => l_adr_accounting_coa_id
22434 , x_value_type_code => l_adr_value_type_code
22435 , p_side => 'NA'
22436 );
22437
22438 xla_ae_lines_pkg.set_ccid(
22439 p_code_combination_id => l_ccid
22440 , p_value_type_code => l_adr_value_type_code
22441 , p_transaction_coa_id => l_adr_transaction_coa_id
22442 , p_accounting_coa_id => l_adr_accounting_coa_id
22443 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
22444 , p_adr_type_code => 'S'
22445 , p_component_type => l_component_type
22446 , p_component_code => l_component_code
22447 , p_component_type_code => l_component_type_code
22448 , p_component_appl_id => l_component_appl_id
22449 , p_amb_context_code => l_amb_context_code
22450 , p_side => 'NA'
22451 );
22452
22453
22454 l_segment := AcctDerRule_4(
22455 p_application_id => p_application_id
22456 , p_ae_header_id => l_ae_header_id
22457 , p_source_1 => p_source_1
22458 , p_source_2 => p_source_2
22459 , x_transaction_coa_id => l_adr_transaction_coa_id
22460 , x_accounting_coa_id => l_adr_accounting_coa_id
22461 , x_flexfield_segment_code => l_adr_flexfield_segment_code
22462 , x_flex_value_set_id => l_adr_flex_value_set_id
22463 , x_value_type_code => l_adr_value_type_code
22464 , x_value_combination_id => l_adr_value_combination_id
22465 , x_value_segment_code => l_adr_value_segment_code
22466 , p_side => 'NA'
22467 , p_override_seg_flag => 'Y'
22468 );
22469
22470 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
22471
22472 xla_ae_lines_pkg.set_segment(
22473 p_to_segment_code => 'GL_ACCOUNT'
22474 , p_segment_value => l_segment
22475 , p_from_segment_code => l_adr_value_segment_code
22476 , p_from_combination_id => l_adr_value_combination_id
22477 , p_value_type_code => l_adr_value_type_code
22478 , p_transaction_coa_id => l_adr_transaction_coa_id
22479 , p_accounting_coa_id => l_adr_accounting_coa_id
22480 , p_flexfield_segment_code => l_adr_flexfield_segment_code
22481 , p_flex_value_set_id => l_adr_flex_value_set_id
22482 , p_adr_code => 'FV_46X002'
22483 , p_adr_type_code => 'S'
22484 , p_component_type => l_component_type
22485 , p_component_code => l_component_code
22486 , p_component_type_code => l_component_type_code
22487 , p_component_appl_id => l_component_appl_id
22488 , p_amb_context_code => l_amb_context_code
22489 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
22490 , p_event_class_code => 'PURCHASE_ORDER'
22491 , p_side => 'NA'
22492 );
22493
22494 END IF;
22495
22496 --
22497 --
22498 END IF;
22499
22500 --
22501 -- Update the line information that should be overwritten
22502 --
22503 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
22504 p_header_num => 1);
22505 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
22506
22507 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
22508
22509 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
22510 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
22511 END IF;
22512
22513 --
22514 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
22515 --
22516 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
22517 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
22518 ELSE
22519 ---------------------------------------------------------------------------------------------------
22520 -- 4262811a Switch Sign
22521 ---------------------------------------------------------------------------------------------------
22522 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
22523 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22524 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22525 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22526 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22527 -- 5132302
22528 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
22529 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22530
22531 END IF;
22532
22533 -- 4955764
22534 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22535 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
22536
22537
22538 XLA_AE_LINES_PKG.ValidateCurrentLine;
22539 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22540
22541 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22542 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
22543 ,p_balance_type_code => l_balance_type_code);
22544
22545 END IF;
22546
22547 -----------------------------------------------------------------------------------------
22548 -- 4262811 Multiperiod Accounting
22549 -----------------------------------------------------------------------------------------
22550 -- No MPA option is assigned.
22551
22552
22553 END IF;
22554 END IF;
22555 --
22556
22557 --
22558 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22559 trace
22560 (p_msg => 'END of AcctLineType_42'
22561 ,p_level => C_LEVEL_PROCEDURE
22562 ,p_module => l_log_module);
22563 END IF;
22564 --
22565 EXCEPTION
22566 WHEN xla_exceptions_pkg.application_exception THEN
22567 RAISE;
22568 WHEN OTHERS THEN
22569 xla_exceptions_pkg.raise_message
22570 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_42');
22571 END AcctLineType_42;
22572 --
22573
22574 ---------------------------------------
22575 --
22576 -- PRIVATE FUNCTION
22577 -- AcctLineType_43
22578 --
22579 ---------------------------------------
22580 PROCEDURE AcctLineType_43 (
22581 p_application_id IN NUMBER
22582 ,p_event_id IN NUMBER
22583 ,p_calculate_acctd_flag IN VARCHAR2
22584 ,p_calculate_g_l_flag IN VARCHAR2
22585 ,p_actual_flag IN OUT VARCHAR2
22586 ,p_balance_type_code OUT VARCHAR2
22587 ,p_gain_or_loss_ref OUT VARCHAR2
22588
22589 --Federal Fund Expired Status
22590 , p_source_1 IN VARCHAR2
22591 --Federal Fund Category
22592 , p_source_2 IN VARCHAR2
22593 --PO Budget Account
22594 , p_source_3 IN NUMBER
22595 --Federal Prior Year Flag
22596 , p_source_5 IN VARCHAR2
22597 --Receiving Accounting Line Type
22598 , p_source_6 IN VARCHAR2
22599 --Applied to Application ID
22600 , p_source_7 IN NUMBER
22601 --Applied to Distribution Link Type
22602 , p_source_8 IN VARCHAR2
22603 --Applied to Entity Code
22604 , p_source_9 IN VARCHAR2
22605 --PO_DISTRIBUTION_ID
22606 , p_source_10 IN NUMBER
22607 --Applied To Purchase Document Identifier
22608 , p_source_11 IN NUMBER
22609 --DISTRIBUTION_IDENTIFIER
22610 , p_source_12 IN NUMBER
22611 --Distribution Type
22612 , p_source_13 IN VARCHAR2
22613 , p_source_13_meaning IN VARCHAR2
22614 --Encumbrance Reversal Amount Entered
22615 , p_source_14 IN NUMBER
22616 --Entered Currency Code
22617 , p_source_15 IN VARCHAR2
22618 --Transaction Encumbrance Reversal Amount
22619 , p_source_16 IN NUMBER
22620 --Costing Encumbrance Upgrade Option
22621 , p_source_17 IN VARCHAR2
22622 --Currency Conversion Date
22623 , p_source_19 IN DATE
22624 --Currency Conversion Rate
22625 , p_source_20 IN NUMBER
22626 --Currency Conversion Type
22627 , p_source_21 IN VARCHAR2
22628 --Purchasing Encumbrance Type Identifier
22629 , p_source_22 IN NUMBER
22630 --Accounted Amount
22631 , p_source_26 IN NUMBER
22632 --Federal Unexpended Obligation Amount
22633 , p_source_34 IN NUMBER
22634 )
22635 IS
22636
22637 l_component_type VARCHAR2(80);
22638 l_component_code VARCHAR2(30);
22639 l_component_type_code VARCHAR2(1);
22640 l_component_appl_id INTEGER;
22641 l_amb_context_code VARCHAR2(30);
22642 l_entity_code VARCHAR2(30);
22643 l_event_class_code VARCHAR2(30);
22644 l_ae_header_id NUMBER;
22645 l_event_type_code VARCHAR2(30);
22646 l_line_definition_code VARCHAR2(30);
22647 l_line_definition_owner_code VARCHAR2(1);
22648 --
22649 -- adr variables
22650 l_segment VARCHAR2(30);
22651 l_ccid NUMBER;
22652 l_adr_transaction_coa_id NUMBER;
22653 l_adr_accounting_coa_id NUMBER;
22654 l_adr_flexfield_segment_code VARCHAR2(30);
22655 l_adr_flex_value_set_id NUMBER;
22656 l_adr_value_type_code VARCHAR2(30);
22657 l_adr_value_combination_id NUMBER;
22658 l_adr_value_segment_code VARCHAR2(30);
22659
22660 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
22661 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
22662 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
22663 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
22664
22665 -- 4262811 Variables ------------------------------------------------------------------------------------------
22666 l_entered_amt_idx NUMBER;
22667 l_accted_amt_idx NUMBER;
22668 l_acc_rev_flag VARCHAR2(1);
22669 l_accrual_line_num NUMBER;
22670 l_tmp_amt NUMBER;
22671 l_acc_rev_natural_side_code VARCHAR2(1);
22672
22673 l_num_entries NUMBER;
22674 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
22675 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
22676 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
22677 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
22678 l_recog_line_1 NUMBER;
22679 l_recog_line_2 NUMBER;
22680
22681 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
22682 l_bflow_applied_to_amt NUMBER; -- 5132302
22683 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
22684
22685 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
22686
22687 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
22688 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
22689
22690 ---------------------------------------------------------------------------------------------------------------
22691
22692
22693 --
22694 -- bulk performance
22695 --
22696 l_balance_type_code VARCHAR2(1);
22697 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
22698 l_log_module VARCHAR2(240);
22699
22700 --
22701 -- Upgrade strategy
22702 --
22703 l_actual_upg_option VARCHAR2(1);
22704 l_enc_upg_option VARCHAR2(1);
22705
22706 --
22707 BEGIN
22708 --
22709 IF g_log_enabled THEN
22710 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_43';
22711 END IF;
22712 --
22713 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22714
22715 trace
22716 (p_msg => 'BEGIN of AcctLineType_43'
22717 ,p_level => C_LEVEL_PROCEDURE
22718 ,p_module => l_log_module);
22719
22720 END IF;
22721 --
22722 l_component_type := 'AMB_JLT';
22723 l_component_code := 'FV_REV_PO_ALLOT_OVERFLOW_CR';
22724 l_component_type_code := 'S';
22725 l_component_appl_id := 707;
22726 l_amb_context_code := 'DEFAULT';
22727 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
22728 l_event_class_code := 'DELIVER_EXPENSE';
22729 l_event_type_code := 'DELIVER_EXPENSE_ALL';
22730 l_line_definition_owner_code := 'S';
22731 l_line_definition_code := 'FV_DELIVER_EXPENSE';
22732 --
22733 l_balance_type_code := 'A';
22734 l_segment := NULL;
22735 l_ccid := NULL;
22736 l_adr_transaction_coa_id := NULL;
22737 l_adr_accounting_coa_id := NULL;
22738 l_adr_flexfield_segment_code := NULL;
22739 l_adr_flex_value_set_id := NULL;
22740 l_adr_value_type_code := NULL;
22741 l_adr_value_combination_id := NULL;
22742 l_adr_value_segment_code := NULL;
22743
22744 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
22745 l_bflow_class_code := ''; -- 4219869 Business Flow
22746 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
22747 l_budgetary_control_flag := 'Y';
22748
22749 l_bflow_applied_to_amt_idx := NULL; -- 5132302
22750 l_bflow_applied_to_amt := NULL; -- 5132302
22751 l_entered_amt_idx := NULL; -- 4262811
22752 l_accted_amt_idx := NULL; -- 4262811
22753 l_acc_rev_flag := NULL; -- 4262811
22754 l_accrual_line_num := NULL; -- 4262811
22755 l_tmp_amt := NULL; -- 4262811
22756 --
22757
22758 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
22759 l_balance_type_code <> 'B' THEN
22760 IF p_source_26 > p_source_34 AND
22761 NVL(p_source_5,'
22762 ') = 'N' AND
22763 NVL(
22764 xla_ae_sources_pkg.GetSystemSourceChar(
22765 p_source_code => 'XLA_EVENT_TYPE_CODE'
22766 , p_source_type_code => 'Y'
22767 , p_source_application_id => 602
22768 ),'
22769 ') = 'DELIVER_EXPENSE' AND
22770 NVL(p_source_6,'
22771 ') = 'Charge'
22772 THEN
22773
22774 --
22775 XLA_AE_LINES_PKG.SetNewLine;
22776
22777 p_balance_type_code := l_balance_type_code;
22778 -- set the flag so later we will know whether the gain loss line needs to be created
22779
22780 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
22781 p_actual_flag :='A';
22782 END IF;
22783
22784 --
22785 -- bulk performance
22786 --
22787 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
22788 p_header_num => 0); -- 4262811
22789 --
22790 -- set accounting line options
22791 --
22792 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
22793 p_natural_side_code => 'C'
22794 , p_gain_or_loss_flag => 'N'
22795 , p_gl_transfer_mode_code => 'S'
22796 , p_acct_entry_type_code => 'A'
22797 , p_switch_side_flag => 'N'
22798 , p_merge_duplicate_code => 'N'
22799 );
22800 --
22801 l_acc_rev_natural_side_code := 'D'; -- 4262811
22802 --
22803 --
22804 -- set accounting line type info
22805 --
22806 xla_ae_lines_pkg.SetAcctLineType
22807 (p_component_type => l_component_type
22808 ,p_event_type_code => l_event_type_code
22809 ,p_line_definition_owner_code => l_line_definition_owner_code
22810 ,p_line_definition_code => l_line_definition_code
22811 ,p_accounting_line_code => l_component_code
22812 ,p_accounting_line_type_code => l_component_type_code
22813 ,p_accounting_line_appl_id => l_component_appl_id
22814 ,p_amb_context_code => l_amb_context_code
22815 ,p_entity_code => l_entity_code
22816 ,p_event_class_code => l_event_class_code);
22817 --
22818 -- set accounting class
22819 --
22820 xla_ae_lines_pkg.SetAcctClass(
22821 p_accounting_class_code => 'FEDERAL_EXP'
22822 , p_ae_header_id => l_ae_header_id
22823 );
22824
22825 --
22826 -- set rounding class
22827 --
22828 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
22829 'FEDERAL_EXP';
22830
22831 --
22832 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
22833 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
22834 --
22835 -- bulk performance
22836 --
22837 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
22838
22839 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
22840 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
22841
22842 -- 4955764
22843 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22844 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
22845
22846 -- 4458381 Public Sector Enh
22847
22848 --
22849 -- set accounting attributes for the line type
22850 --
22851 l_entered_amt_idx := 17;
22852 l_accted_amt_idx := 22;
22853 l_bflow_applied_to_amt_idx := NULL; -- 5132302
22854 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
22855 l_rec_acct_attrs.array_num_value(1) := p_source_7;
22856 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
22857 l_rec_acct_attrs.array_char_value(2) := p_source_8;
22858 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
22859 l_rec_acct_attrs.array_char_value(3) := p_source_9;
22860 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
22861 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
22862 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
22863 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
22864 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
22865 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
22866 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
22867 l_rec_acct_attrs.array_char_value(7) := p_source_13;
22868 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
22869 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
22870 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
22871 l_rec_acct_attrs.array_num_value(9) := p_source_14;
22872 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
22873 l_rec_acct_attrs.array_char_value(10) := p_source_15;
22874 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
22875 l_rec_acct_attrs.array_num_value(11) := p_source_16;
22876 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
22877 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
22878 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
22879 l_rec_acct_attrs.array_num_value(13) := p_source_14;
22880 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
22881 l_rec_acct_attrs.array_char_value(14) := p_source_15;
22882 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
22883 l_rec_acct_attrs.array_num_value(15) := p_source_16;
22884 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
22885 l_rec_acct_attrs.array_char_value(16) := p_source_17;
22886 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
22887 l_rec_acct_attrs.array_num_value(17) := p_source_34;
22888 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
22889 l_rec_acct_attrs.array_char_value(18) := p_source_15;
22890 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
22891 l_rec_acct_attrs.array_date_value(19) := p_source_19;
22892 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
22893 l_rec_acct_attrs.array_num_value(20) := p_source_20;
22894 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
22895 l_rec_acct_attrs.array_char_value(21) := p_source_21;
22896 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
22897 l_rec_acct_attrs.array_num_value(22) := p_source_34;
22898 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
22899 l_rec_acct_attrs.array_num_value(23) := p_source_22;
22900 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
22901 l_rec_acct_attrs.array_num_value(24) := p_source_22;
22902
22903 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
22904 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
22905
22906 ---------------------------------------------------------------------------------------------------------------
22907 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
22908 ---------------------------------------------------------------------------------------------------------------
22909 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
22910
22911 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22912 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22913
22914 IF xla_accounting_cache_pkg.GetValueChar
22915 (p_source_code => 'LEDGER_CATEGORY_CODE'
22916 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
22917 AND l_bflow_method_code = 'PRIOR_ENTRY'
22918 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
22919 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
22920 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
22921 )
22922 THEN
22923 xla_ae_lines_pkg.BflowUpgEntry
22924 (p_business_method_code => l_bflow_method_code
22925 ,p_business_class_code => l_bflow_class_code
22926 ,p_balance_type => l_balance_type_code);
22927 ELSE
22928 NULL;
22929 -- No business flow processing for business flow method of NONE.
22930 END IF;
22931
22932 --
22933 -- call analytical criteria
22934 --
22935
22936 --
22937 -- call description
22938 --
22939 -- No description or it is inherited.
22940 --
22941 -- call ADRs
22942 -- Bug 4922099
22943 --
22944 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22945 (NVL(l_actual_upg_option, 'N') = 'O') OR
22946 (NVL(l_enc_upg_option, 'N') = 'O')
22947 )
22948 THEN
22949 NULL;
22950 --
22951 --
22952
22953 l_ccid := AcctDerRule_11(
22954 p_application_id => p_application_id
22955 , p_ae_header_id => l_ae_header_id
22956 , p_source_3 => p_source_3
22957 , x_transaction_coa_id => l_adr_transaction_coa_id
22958 , x_accounting_coa_id => l_adr_accounting_coa_id
22959 , x_value_type_code => l_adr_value_type_code
22960 , p_side => 'NA'
22961 );
22962
22963 xla_ae_lines_pkg.set_ccid(
22964 p_code_combination_id => l_ccid
22965 , p_value_type_code => l_adr_value_type_code
22966 , p_transaction_coa_id => l_adr_transaction_coa_id
22967 , p_accounting_coa_id => l_adr_accounting_coa_id
22968 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
22969 , p_adr_type_code => 'S'
22970 , p_component_type => l_component_type
22971 , p_component_code => l_component_code
22972 , p_component_type_code => l_component_type_code
22973 , p_component_appl_id => l_component_appl_id
22974 , p_amb_context_code => l_amb_context_code
22975 , p_side => 'NA'
22976 );
22977
22978
22979 l_segment := AcctDerRule_4(
22980 p_application_id => p_application_id
22981 , p_ae_header_id => l_ae_header_id
22982 , p_source_1 => p_source_1
22983 , p_source_2 => p_source_2
22984 , x_transaction_coa_id => l_adr_transaction_coa_id
22985 , x_accounting_coa_id => l_adr_accounting_coa_id
22986 , x_flexfield_segment_code => l_adr_flexfield_segment_code
22987 , x_flex_value_set_id => l_adr_flex_value_set_id
22988 , x_value_type_code => l_adr_value_type_code
22989 , x_value_combination_id => l_adr_value_combination_id
22990 , x_value_segment_code => l_adr_value_segment_code
22991 , p_side => 'NA'
22992 , p_override_seg_flag => 'Y'
22993 );
22994
22995 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
22996
22997 xla_ae_lines_pkg.set_segment(
22998 p_to_segment_code => 'GL_ACCOUNT'
22999 , p_segment_value => l_segment
23000 , p_from_segment_code => l_adr_value_segment_code
23001 , p_from_combination_id => l_adr_value_combination_id
23002 , p_value_type_code => l_adr_value_type_code
23003 , p_transaction_coa_id => l_adr_transaction_coa_id
23004 , p_accounting_coa_id => l_adr_accounting_coa_id
23005 , p_flexfield_segment_code => l_adr_flexfield_segment_code
23006 , p_flex_value_set_id => l_adr_flex_value_set_id
23007 , p_adr_code => 'FV_46X002'
23008 , p_adr_type_code => 'S'
23009 , p_component_type => l_component_type
23010 , p_component_code => l_component_code
23011 , p_component_type_code => l_component_type_code
23012 , p_component_appl_id => l_component_appl_id
23013 , p_amb_context_code => l_amb_context_code
23014 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
23015 , p_event_class_code => 'DELIVER_EXPENSE'
23016 , p_side => 'NA'
23017 );
23018
23019 END IF;
23020
23021 --
23022 --
23023 END IF;
23024 --
23025 -- Bug 4922099
23026 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
23027 (NVL(l_enc_upg_option, 'N') = 'O')
23028 ) AND
23029 (l_bflow_method_code = 'PRIOR_ENTRY')
23030 )
23031 THEN
23032 IF
23033 --
23034 1 = 2
23035 --
23036 THEN
23037 xla_accounting_err_pkg.build_message
23038 (p_appli_s_name => 'XLA'
23039 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23040 ,p_token_1 => 'LINE_NUMBER'
23041 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
23042 ,p_token_2 => 'LINE_TYPE_NAME'
23043 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
23044 l_component_type
23045 ,l_component_code
23046 ,l_component_type_code
23047 ,l_component_appl_id
23048 ,l_amb_context_code
23049 ,l_entity_code
23050 ,l_event_class_code
23051 )
23052 ,p_token_3 => 'OWNER'
23053 ,p_value_3 => xla_lookups_pkg.get_meaning(
23054 p_lookup_type => 'XLA_OWNER_TYPE'
23055 ,p_lookup_code => l_component_type_code
23056 )
23057 ,p_token_4 => 'PRODUCT_NAME'
23058 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
23059 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
23060 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
23061 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
23062 ,p_ae_header_id => NULL
23063 );
23064
23065 IF (C_LEVEL_ERROR>= g_log_level) THEN
23066 trace
23067 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23068 ,p_level => C_LEVEL_ERROR
23069 ,p_module => l_log_module);
23070 END IF;
23071 END IF;
23072 END IF;
23073 --
23074 --
23075 ------------------------------------------------------------------------------------------------
23076 -- 4219869 Business Flow
23077 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
23078 -- Prior Entry. Currently, the following code is always generated.
23079 ------------------------------------------------------------------------------------------------
23080 XLA_AE_LINES_PKG.ValidateCurrentLine;
23081
23082 ------------------------------------------------------------------------------------
23083 -- 4219869 Business Flow
23084 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
23085 ------------------------------------------------------------------------------------
23086 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23087
23088 ----------------------------------------------------------------------------------
23089 -- 4219869 Business Flow
23090 -- Update journal entry status -- Need to generate this within IF <condition>
23091 ----------------------------------------------------------------------------------
23092 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23093 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
23094 ,p_balance_type_code => l_balance_type_code
23095 );
23096
23097 -------------------------------------------------------------------------------------------
23098 -- 4262811 - Generate the Accrual Reversal lines
23099 -------------------------------------------------------------------------------------------
23100 BEGIN
23101 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
23102 (g_array_event(p_event_id).array_value_num('header_index'));
23103 IF l_acc_rev_flag IS NULL THEN
23104 l_acc_rev_flag := 'N';
23105 END IF;
23106 EXCEPTION
23107 WHEN OTHERS THEN
23108 l_acc_rev_flag := 'N';
23109 END;
23110 --
23111 IF (l_acc_rev_flag = 'Y') THEN
23112
23113 -- 4645092 ------------------------------------------------------------------------------
23114 -- To allow MPA report to determine if it should generate report process
23115 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
23116 ------------------------------------------------------------------------------------------
23117
23118 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
23119 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
23120 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
23121 -- call ADRs
23122 -- Bug 4922099
23123 --
23124 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23125 (NVL(l_actual_upg_option, 'N') = 'O') OR
23126 (NVL(l_enc_upg_option, 'N') = 'O')
23127 )
23128 THEN
23129 NULL;
23130 --
23131 --
23132
23133 l_ccid := AcctDerRule_11(
23134 p_application_id => p_application_id
23135 , p_ae_header_id => l_ae_header_id
23136 , p_source_3 => p_source_3
23137 , x_transaction_coa_id => l_adr_transaction_coa_id
23138 , x_accounting_coa_id => l_adr_accounting_coa_id
23139 , x_value_type_code => l_adr_value_type_code
23140 , p_side => 'NA'
23141 );
23142
23143 xla_ae_lines_pkg.set_ccid(
23144 p_code_combination_id => l_ccid
23145 , p_value_type_code => l_adr_value_type_code
23146 , p_transaction_coa_id => l_adr_transaction_coa_id
23147 , p_accounting_coa_id => l_adr_accounting_coa_id
23148 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
23149 , p_adr_type_code => 'S'
23150 , p_component_type => l_component_type
23151 , p_component_code => l_component_code
23152 , p_component_type_code => l_component_type_code
23153 , p_component_appl_id => l_component_appl_id
23154 , p_amb_context_code => l_amb_context_code
23155 , p_side => 'NA'
23156 );
23157
23158
23159 l_segment := AcctDerRule_4(
23160 p_application_id => p_application_id
23161 , p_ae_header_id => l_ae_header_id
23162 , p_source_1 => p_source_1
23163 , p_source_2 => p_source_2
23164 , x_transaction_coa_id => l_adr_transaction_coa_id
23165 , x_accounting_coa_id => l_adr_accounting_coa_id
23166 , x_flexfield_segment_code => l_adr_flexfield_segment_code
23167 , x_flex_value_set_id => l_adr_flex_value_set_id
23168 , x_value_type_code => l_adr_value_type_code
23169 , x_value_combination_id => l_adr_value_combination_id
23170 , x_value_segment_code => l_adr_value_segment_code
23171 , p_side => 'NA'
23172 , p_override_seg_flag => 'Y'
23173 );
23174
23175 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
23176
23177 xla_ae_lines_pkg.set_segment(
23178 p_to_segment_code => 'GL_ACCOUNT'
23179 , p_segment_value => l_segment
23180 , p_from_segment_code => l_adr_value_segment_code
23181 , p_from_combination_id => l_adr_value_combination_id
23182 , p_value_type_code => l_adr_value_type_code
23183 , p_transaction_coa_id => l_adr_transaction_coa_id
23184 , p_accounting_coa_id => l_adr_accounting_coa_id
23185 , p_flexfield_segment_code => l_adr_flexfield_segment_code
23186 , p_flex_value_set_id => l_adr_flex_value_set_id
23187 , p_adr_code => 'FV_46X002'
23188 , p_adr_type_code => 'S'
23189 , p_component_type => l_component_type
23190 , p_component_code => l_component_code
23191 , p_component_type_code => l_component_type_code
23192 , p_component_appl_id => l_component_appl_id
23193 , p_amb_context_code => l_amb_context_code
23194 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
23195 , p_event_class_code => 'DELIVER_EXPENSE'
23196 , p_side => 'NA'
23197 );
23198
23199 END IF;
23200
23201 --
23202 --
23203 END IF;
23204
23205 --
23206 -- Update the line information that should be overwritten
23207 --
23208 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
23209 p_header_num => 1);
23210 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
23211
23212 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
23213
23214 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
23215 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
23216 END IF;
23217
23218 --
23219 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
23220 --
23221 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
23222 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
23223 ELSE
23224 ---------------------------------------------------------------------------------------------------
23225 -- 4262811a Switch Sign
23226 ---------------------------------------------------------------------------------------------------
23227 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
23228 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23229 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23230 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23231 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23232 -- 5132302
23233 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
23234 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23235
23236 END IF;
23237
23238 -- 4955764
23239 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23240 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
23241
23242
23243 XLA_AE_LINES_PKG.ValidateCurrentLine;
23244 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23245
23246 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23247 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
23248 ,p_balance_type_code => l_balance_type_code);
23249
23250 END IF;
23251
23252 -----------------------------------------------------------------------------------------
23253 -- 4262811 Multiperiod Accounting
23254 -----------------------------------------------------------------------------------------
23255 -- No MPA option is assigned.
23256
23257
23258 END IF;
23259 END IF;
23260 --
23261
23262 --
23263 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23264 trace
23265 (p_msg => 'END of AcctLineType_43'
23266 ,p_level => C_LEVEL_PROCEDURE
23267 ,p_module => l_log_module);
23268 END IF;
23269 --
23270 EXCEPTION
23271 WHEN xla_exceptions_pkg.application_exception THEN
23272 RAISE;
23273 WHEN OTHERS THEN
23274 xla_exceptions_pkg.raise_message
23275 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_43');
23276 END AcctLineType_43;
23277 --
23278
23279 ---------------------------------------
23280 --
23281 -- PRIVATE FUNCTION
23282 -- AcctLineType_44
23283 --
23284 ---------------------------------------
23285 PROCEDURE AcctLineType_44 (
23286 p_application_id IN NUMBER
23287 ,p_event_id IN NUMBER
23288 ,p_calculate_acctd_flag IN VARCHAR2
23289 ,p_calculate_g_l_flag IN VARCHAR2
23290 ,p_actual_flag IN OUT VARCHAR2
23291 ,p_balance_type_code OUT VARCHAR2
23292 ,p_gain_or_loss_ref OUT VARCHAR2
23293
23294 --Federal Fund Expired Status
23295 , p_source_1 IN VARCHAR2
23296 --Federal Fund Category
23297 , p_source_2 IN VARCHAR2
23298 --PO Budget Account
23299 , p_source_3 IN NUMBER
23300 --Federal Prior Year Flag
23301 , p_source_5 IN VARCHAR2
23302 --Applied to Application ID
23303 , p_source_7 IN NUMBER
23304 --Applied to Distribution Link Type
23305 , p_source_8 IN VARCHAR2
23306 --Applied to Entity Code
23307 , p_source_9 IN VARCHAR2
23308 --Applied To Purchase Document Identifier
23309 , p_source_11 IN NUMBER
23310 --DISTRIBUTION_IDENTIFIER
23311 , p_source_12 IN NUMBER
23312 --Distribution Type
23313 , p_source_13 IN VARCHAR2
23314 , p_source_13_meaning IN VARCHAR2
23315 --Encumbrance Reversal Amount Entered
23316 , p_source_14 IN NUMBER
23317 --Entered Currency Code
23318 , p_source_15 IN VARCHAR2
23319 --Transaction Encumbrance Reversal Amount
23320 , p_source_16 IN NUMBER
23321 --Costing Encumbrance Upgrade Option
23322 , p_source_17 IN VARCHAR2
23323 --Currency Conversion Date
23324 , p_source_19 IN DATE
23325 --Currency Conversion Rate
23326 , p_source_20 IN NUMBER
23327 --Currency Conversion Type
23328 , p_source_21 IN VARCHAR2
23329 --Purchasing Encumbrance Type Identifier
23330 , p_source_22 IN NUMBER
23331 --TXN_PO_DISTRIBUTION_ID
23332 , p_source_23 IN NUMBER
23333 --Accounted Amount
23334 , p_source_26 IN NUMBER
23335 --Federal Unexpended Obligation Amount
23336 , p_source_34 IN NUMBER
23337 )
23338 IS
23339
23340 l_component_type VARCHAR2(80);
23341 l_component_code VARCHAR2(30);
23342 l_component_type_code VARCHAR2(1);
23343 l_component_appl_id INTEGER;
23344 l_amb_context_code VARCHAR2(30);
23345 l_entity_code VARCHAR2(30);
23346 l_event_class_code VARCHAR2(30);
23347 l_ae_header_id NUMBER;
23348 l_event_type_code VARCHAR2(30);
23349 l_line_definition_code VARCHAR2(30);
23350 l_line_definition_owner_code VARCHAR2(1);
23351 --
23352 -- adr variables
23353 l_segment VARCHAR2(30);
23354 l_ccid NUMBER;
23355 l_adr_transaction_coa_id NUMBER;
23356 l_adr_accounting_coa_id NUMBER;
23357 l_adr_flexfield_segment_code VARCHAR2(30);
23358 l_adr_flex_value_set_id NUMBER;
23359 l_adr_value_type_code VARCHAR2(30);
23360 l_adr_value_combination_id NUMBER;
23361 l_adr_value_segment_code VARCHAR2(30);
23362
23363 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
23364 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
23365 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
23366 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
23367
23368 -- 4262811 Variables ------------------------------------------------------------------------------------------
23369 l_entered_amt_idx NUMBER;
23370 l_accted_amt_idx NUMBER;
23371 l_acc_rev_flag VARCHAR2(1);
23372 l_accrual_line_num NUMBER;
23373 l_tmp_amt NUMBER;
23374 l_acc_rev_natural_side_code VARCHAR2(1);
23375
23376 l_num_entries NUMBER;
23377 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
23378 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
23379 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
23380 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
23381 l_recog_line_1 NUMBER;
23382 l_recog_line_2 NUMBER;
23383
23384 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
23385 l_bflow_applied_to_amt NUMBER; -- 5132302
23386 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
23387
23388 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
23389
23390 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
23391 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
23392
23393 ---------------------------------------------------------------------------------------------------------------
23394
23395
23396 --
23397 -- bulk performance
23398 --
23399 l_balance_type_code VARCHAR2(1);
23400 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
23401 l_log_module VARCHAR2(240);
23402
23403 --
23404 -- Upgrade strategy
23405 --
23406 l_actual_upg_option VARCHAR2(1);
23407 l_enc_upg_option VARCHAR2(1);
23408
23409 --
23410 BEGIN
23411 --
23412 IF g_log_enabled THEN
23413 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_44';
23414 END IF;
23415 --
23416 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23417
23418 trace
23419 (p_msg => 'BEGIN of AcctLineType_44'
23420 ,p_level => C_LEVEL_PROCEDURE
23421 ,p_module => l_log_module);
23422
23423 END IF;
23424 --
23425 l_component_type := 'AMB_JLT';
23426 l_component_code := 'FV_REV_PO_ALLOT_OVERFLW_CR_DTI';
23427 l_component_type_code := 'S';
23428 l_component_appl_id := 707;
23429 l_amb_context_code := 'DEFAULT';
23430 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
23431 l_event_class_code := 'PURCHASE_ORDER';
23432 l_event_type_code := 'PURCHASE_ORDER_ALL';
23433 l_line_definition_owner_code := 'S';
23434 l_line_definition_code := 'FV_PO_DEL_INV';
23435 --
23436 l_balance_type_code := 'A';
23437 l_segment := NULL;
23438 l_ccid := NULL;
23439 l_adr_transaction_coa_id := NULL;
23440 l_adr_accounting_coa_id := NULL;
23441 l_adr_flexfield_segment_code := NULL;
23442 l_adr_flex_value_set_id := NULL;
23443 l_adr_value_type_code := NULL;
23444 l_adr_value_combination_id := NULL;
23445 l_adr_value_segment_code := NULL;
23446
23447 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
23448 l_bflow_class_code := ''; -- 4219869 Business Flow
23449 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
23450 l_budgetary_control_flag := 'Y';
23451
23452 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23453 l_bflow_applied_to_amt := NULL; -- 5132302
23454 l_entered_amt_idx := NULL; -- 4262811
23455 l_accted_amt_idx := NULL; -- 4262811
23456 l_acc_rev_flag := NULL; -- 4262811
23457 l_accrual_line_num := NULL; -- 4262811
23458 l_tmp_amt := NULL; -- 4262811
23459 --
23460
23461 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
23462 l_balance_type_code <> 'B' THEN
23463 IF NVL(
23464 xla_ae_sources_pkg.GetSystemSourceChar(
23465 p_source_code => 'XLA_EVENT_TYPE_CODE'
23466 , p_source_type_code => 'Y'
23467 , p_source_application_id => 602
23468 ),'
23469 ') = 'PO_DEL_INV' AND
23470 p_source_26 > p_source_34 AND
23471 NVL(p_source_5,'
23472 ') = 'N'
23473 THEN
23474
23475 --
23476 XLA_AE_LINES_PKG.SetNewLine;
23477
23478 p_balance_type_code := l_balance_type_code;
23479 -- set the flag so later we will know whether the gain loss line needs to be created
23480
23481 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
23482 p_actual_flag :='A';
23483 END IF;
23484
23485 --
23486 -- bulk performance
23487 --
23488 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
23489 p_header_num => 0); -- 4262811
23490 --
23491 -- set accounting line options
23492 --
23493 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
23494 p_natural_side_code => 'C'
23495 , p_gain_or_loss_flag => 'N'
23496 , p_gl_transfer_mode_code => 'S'
23497 , p_acct_entry_type_code => 'A'
23498 , p_switch_side_flag => 'N'
23499 , p_merge_duplicate_code => 'N'
23500 );
23501 --
23502 l_acc_rev_natural_side_code := 'D'; -- 4262811
23503 --
23504 --
23505 -- set accounting line type info
23506 --
23507 xla_ae_lines_pkg.SetAcctLineType
23508 (p_component_type => l_component_type
23509 ,p_event_type_code => l_event_type_code
23510 ,p_line_definition_owner_code => l_line_definition_owner_code
23511 ,p_line_definition_code => l_line_definition_code
23512 ,p_accounting_line_code => l_component_code
23513 ,p_accounting_line_type_code => l_component_type_code
23514 ,p_accounting_line_appl_id => l_component_appl_id
23515 ,p_amb_context_code => l_amb_context_code
23516 ,p_entity_code => l_entity_code
23517 ,p_event_class_code => l_event_class_code);
23518 --
23519 -- set accounting class
23520 --
23521 xla_ae_lines_pkg.SetAcctClass(
23522 p_accounting_class_code => 'FEDERAL_INV'
23523 , p_ae_header_id => l_ae_header_id
23524 );
23525
23526 --
23527 -- set rounding class
23528 --
23529 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
23530 'FEDERAL_INV';
23531
23532 --
23533 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
23534 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
23535 --
23536 -- bulk performance
23537 --
23538 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
23539
23540 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
23541 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
23542
23543 -- 4955764
23544 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23545 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
23546
23547 -- 4458381 Public Sector Enh
23548
23549 --
23550 -- set accounting attributes for the line type
23551 --
23552 l_entered_amt_idx := 17;
23553 l_accted_amt_idx := 22;
23554 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23555 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
23556 l_rec_acct_attrs.array_num_value(1) := p_source_7;
23557 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
23558 l_rec_acct_attrs.array_char_value(2) := p_source_8;
23559 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
23560 l_rec_acct_attrs.array_char_value(3) := p_source_9;
23561 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
23562 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
23563 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
23564 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
23565 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
23566 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
23567 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
23568 l_rec_acct_attrs.array_char_value(7) := p_source_13;
23569 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
23570 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
23571 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
23572 l_rec_acct_attrs.array_num_value(9) := p_source_14;
23573 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
23574 l_rec_acct_attrs.array_char_value(10) := p_source_15;
23575 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
23576 l_rec_acct_attrs.array_num_value(11) := p_source_16;
23577 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
23578 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
23579 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
23580 l_rec_acct_attrs.array_num_value(13) := p_source_14;
23581 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
23582 l_rec_acct_attrs.array_char_value(14) := p_source_15;
23583 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
23584 l_rec_acct_attrs.array_num_value(15) := p_source_16;
23585 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
23586 l_rec_acct_attrs.array_char_value(16) := p_source_17;
23587 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
23588 l_rec_acct_attrs.array_num_value(17) := p_source_34;
23589 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
23590 l_rec_acct_attrs.array_char_value(18) := p_source_15;
23591 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
23592 l_rec_acct_attrs.array_date_value(19) := p_source_19;
23593 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
23594 l_rec_acct_attrs.array_num_value(20) := p_source_20;
23595 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
23596 l_rec_acct_attrs.array_char_value(21) := p_source_21;
23597 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
23598 l_rec_acct_attrs.array_num_value(22) := p_source_34;
23599 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
23600 l_rec_acct_attrs.array_num_value(23) := p_source_22;
23601 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
23602 l_rec_acct_attrs.array_num_value(24) := p_source_22;
23603
23604 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
23605 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
23606
23607 ---------------------------------------------------------------------------------------------------------------
23608 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
23609 ---------------------------------------------------------------------------------------------------------------
23610 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
23611
23612 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23613 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23614
23615 IF xla_accounting_cache_pkg.GetValueChar
23616 (p_source_code => 'LEDGER_CATEGORY_CODE'
23617 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
23618 AND l_bflow_method_code = 'PRIOR_ENTRY'
23619 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
23620 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
23621 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
23622 )
23623 THEN
23624 xla_ae_lines_pkg.BflowUpgEntry
23625 (p_business_method_code => l_bflow_method_code
23626 ,p_business_class_code => l_bflow_class_code
23627 ,p_balance_type => l_balance_type_code);
23628 ELSE
23629 NULL;
23630 -- No business flow processing for business flow method of NONE.
23631 END IF;
23632
23633 --
23634 -- call analytical criteria
23635 --
23636
23637 --
23638 -- call description
23639 --
23640 -- No description or it is inherited.
23641 --
23642 -- call ADRs
23643 -- Bug 4922099
23644 --
23645 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23646 (NVL(l_actual_upg_option, 'N') = 'O') OR
23647 (NVL(l_enc_upg_option, 'N') = 'O')
23648 )
23649 THEN
23650 NULL;
23651 --
23652 --
23653
23654 l_ccid := AcctDerRule_11(
23655 p_application_id => p_application_id
23656 , p_ae_header_id => l_ae_header_id
23657 , p_source_3 => p_source_3
23658 , x_transaction_coa_id => l_adr_transaction_coa_id
23659 , x_accounting_coa_id => l_adr_accounting_coa_id
23660 , x_value_type_code => l_adr_value_type_code
23661 , p_side => 'NA'
23662 );
23663
23664 xla_ae_lines_pkg.set_ccid(
23665 p_code_combination_id => l_ccid
23666 , p_value_type_code => l_adr_value_type_code
23667 , p_transaction_coa_id => l_adr_transaction_coa_id
23668 , p_accounting_coa_id => l_adr_accounting_coa_id
23669 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
23670 , p_adr_type_code => 'S'
23671 , p_component_type => l_component_type
23672 , p_component_code => l_component_code
23673 , p_component_type_code => l_component_type_code
23674 , p_component_appl_id => l_component_appl_id
23675 , p_amb_context_code => l_amb_context_code
23676 , p_side => 'NA'
23677 );
23678
23679
23680 l_segment := AcctDerRule_4(
23681 p_application_id => p_application_id
23682 , p_ae_header_id => l_ae_header_id
23683 , p_source_1 => p_source_1
23684 , p_source_2 => p_source_2
23685 , x_transaction_coa_id => l_adr_transaction_coa_id
23686 , x_accounting_coa_id => l_adr_accounting_coa_id
23687 , x_flexfield_segment_code => l_adr_flexfield_segment_code
23688 , x_flex_value_set_id => l_adr_flex_value_set_id
23689 , x_value_type_code => l_adr_value_type_code
23690 , x_value_combination_id => l_adr_value_combination_id
23691 , x_value_segment_code => l_adr_value_segment_code
23692 , p_side => 'NA'
23693 , p_override_seg_flag => 'Y'
23694 );
23695
23696 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
23697
23698 xla_ae_lines_pkg.set_segment(
23699 p_to_segment_code => 'GL_ACCOUNT'
23700 , p_segment_value => l_segment
23701 , p_from_segment_code => l_adr_value_segment_code
23702 , p_from_combination_id => l_adr_value_combination_id
23703 , p_value_type_code => l_adr_value_type_code
23704 , p_transaction_coa_id => l_adr_transaction_coa_id
23705 , p_accounting_coa_id => l_adr_accounting_coa_id
23706 , p_flexfield_segment_code => l_adr_flexfield_segment_code
23707 , p_flex_value_set_id => l_adr_flex_value_set_id
23708 , p_adr_code => 'FV_46X002'
23709 , p_adr_type_code => 'S'
23710 , p_component_type => l_component_type
23711 , p_component_code => l_component_code
23712 , p_component_type_code => l_component_type_code
23713 , p_component_appl_id => l_component_appl_id
23714 , p_amb_context_code => l_amb_context_code
23715 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
23716 , p_event_class_code => 'PURCHASE_ORDER'
23717 , p_side => 'NA'
23718 );
23719
23720 END IF;
23721
23722 --
23723 --
23724 END IF;
23725 --
23726 -- Bug 4922099
23727 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
23728 (NVL(l_enc_upg_option, 'N') = 'O')
23729 ) AND
23730 (l_bflow_method_code = 'PRIOR_ENTRY')
23731 )
23732 THEN
23733 IF
23734 --
23735 1 = 2
23736 --
23737 THEN
23738 xla_accounting_err_pkg.build_message
23739 (p_appli_s_name => 'XLA'
23740 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23741 ,p_token_1 => 'LINE_NUMBER'
23742 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
23743 ,p_token_2 => 'LINE_TYPE_NAME'
23744 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
23745 l_component_type
23746 ,l_component_code
23747 ,l_component_type_code
23748 ,l_component_appl_id
23749 ,l_amb_context_code
23750 ,l_entity_code
23751 ,l_event_class_code
23752 )
23753 ,p_token_3 => 'OWNER'
23754 ,p_value_3 => xla_lookups_pkg.get_meaning(
23755 p_lookup_type => 'XLA_OWNER_TYPE'
23756 ,p_lookup_code => l_component_type_code
23757 )
23758 ,p_token_4 => 'PRODUCT_NAME'
23759 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
23760 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
23761 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
23762 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
23763 ,p_ae_header_id => NULL
23764 );
23765
23766 IF (C_LEVEL_ERROR>= g_log_level) THEN
23767 trace
23768 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23769 ,p_level => C_LEVEL_ERROR
23770 ,p_module => l_log_module);
23771 END IF;
23772 END IF;
23773 END IF;
23774 --
23775 --
23776 ------------------------------------------------------------------------------------------------
23777 -- 4219869 Business Flow
23778 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
23779 -- Prior Entry. Currently, the following code is always generated.
23780 ------------------------------------------------------------------------------------------------
23781 XLA_AE_LINES_PKG.ValidateCurrentLine;
23782
23783 ------------------------------------------------------------------------------------
23784 -- 4219869 Business Flow
23785 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
23786 ------------------------------------------------------------------------------------
23787 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23788
23789 ----------------------------------------------------------------------------------
23790 -- 4219869 Business Flow
23791 -- Update journal entry status -- Need to generate this within IF <condition>
23792 ----------------------------------------------------------------------------------
23793 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23794 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
23795 ,p_balance_type_code => l_balance_type_code
23796 );
23797
23798 -------------------------------------------------------------------------------------------
23799 -- 4262811 - Generate the Accrual Reversal lines
23800 -------------------------------------------------------------------------------------------
23801 BEGIN
23802 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
23803 (g_array_event(p_event_id).array_value_num('header_index'));
23804 IF l_acc_rev_flag IS NULL THEN
23805 l_acc_rev_flag := 'N';
23806 END IF;
23807 EXCEPTION
23808 WHEN OTHERS THEN
23809 l_acc_rev_flag := 'N';
23810 END;
23811 --
23812 IF (l_acc_rev_flag = 'Y') THEN
23813
23814 -- 4645092 ------------------------------------------------------------------------------
23815 -- To allow MPA report to determine if it should generate report process
23816 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
23817 ------------------------------------------------------------------------------------------
23818
23819 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
23820 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
23821 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
23822 -- call ADRs
23823 -- Bug 4922099
23824 --
23825 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23826 (NVL(l_actual_upg_option, 'N') = 'O') OR
23827 (NVL(l_enc_upg_option, 'N') = 'O')
23828 )
23829 THEN
23830 NULL;
23831 --
23832 --
23833
23834 l_ccid := AcctDerRule_11(
23835 p_application_id => p_application_id
23836 , p_ae_header_id => l_ae_header_id
23837 , p_source_3 => p_source_3
23838 , x_transaction_coa_id => l_adr_transaction_coa_id
23839 , x_accounting_coa_id => l_adr_accounting_coa_id
23840 , x_value_type_code => l_adr_value_type_code
23841 , p_side => 'NA'
23842 );
23843
23844 xla_ae_lines_pkg.set_ccid(
23845 p_code_combination_id => l_ccid
23846 , p_value_type_code => l_adr_value_type_code
23847 , p_transaction_coa_id => l_adr_transaction_coa_id
23848 , p_accounting_coa_id => l_adr_accounting_coa_id
23849 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
23850 , p_adr_type_code => 'S'
23851 , p_component_type => l_component_type
23852 , p_component_code => l_component_code
23853 , p_component_type_code => l_component_type_code
23854 , p_component_appl_id => l_component_appl_id
23855 , p_amb_context_code => l_amb_context_code
23856 , p_side => 'NA'
23857 );
23858
23859
23860 l_segment := AcctDerRule_4(
23861 p_application_id => p_application_id
23862 , p_ae_header_id => l_ae_header_id
23863 , p_source_1 => p_source_1
23864 , p_source_2 => p_source_2
23865 , x_transaction_coa_id => l_adr_transaction_coa_id
23866 , x_accounting_coa_id => l_adr_accounting_coa_id
23867 , x_flexfield_segment_code => l_adr_flexfield_segment_code
23868 , x_flex_value_set_id => l_adr_flex_value_set_id
23869 , x_value_type_code => l_adr_value_type_code
23870 , x_value_combination_id => l_adr_value_combination_id
23871 , x_value_segment_code => l_adr_value_segment_code
23872 , p_side => 'NA'
23873 , p_override_seg_flag => 'Y'
23874 );
23875
23876 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
23877
23878 xla_ae_lines_pkg.set_segment(
23879 p_to_segment_code => 'GL_ACCOUNT'
23880 , p_segment_value => l_segment
23881 , p_from_segment_code => l_adr_value_segment_code
23882 , p_from_combination_id => l_adr_value_combination_id
23883 , p_value_type_code => l_adr_value_type_code
23884 , p_transaction_coa_id => l_adr_transaction_coa_id
23885 , p_accounting_coa_id => l_adr_accounting_coa_id
23886 , p_flexfield_segment_code => l_adr_flexfield_segment_code
23887 , p_flex_value_set_id => l_adr_flex_value_set_id
23888 , p_adr_code => 'FV_46X002'
23889 , p_adr_type_code => 'S'
23890 , p_component_type => l_component_type
23891 , p_component_code => l_component_code
23892 , p_component_type_code => l_component_type_code
23893 , p_component_appl_id => l_component_appl_id
23894 , p_amb_context_code => l_amb_context_code
23895 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
23896 , p_event_class_code => 'PURCHASE_ORDER'
23897 , p_side => 'NA'
23898 );
23899
23900 END IF;
23901
23902 --
23903 --
23904 END IF;
23905
23906 --
23907 -- Update the line information that should be overwritten
23908 --
23909 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
23910 p_header_num => 1);
23911 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
23912
23913 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
23914
23915 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
23916 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
23917 END IF;
23918
23919 --
23920 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
23921 --
23922 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
23923 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
23924 ELSE
23925 ---------------------------------------------------------------------------------------------------
23926 -- 4262811a Switch Sign
23927 ---------------------------------------------------------------------------------------------------
23928 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
23929 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23930 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23931 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23932 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23933 -- 5132302
23934 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
23935 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23936
23937 END IF;
23938
23939 -- 4955764
23940 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23941 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
23942
23943
23944 XLA_AE_LINES_PKG.ValidateCurrentLine;
23945 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23946
23947 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23948 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
23949 ,p_balance_type_code => l_balance_type_code);
23950
23951 END IF;
23952
23953 -----------------------------------------------------------------------------------------
23954 -- 4262811 Multiperiod Accounting
23955 -----------------------------------------------------------------------------------------
23956 -- No MPA option is assigned.
23957
23958
23959 END IF;
23960 END IF;
23961 --
23962
23963 --
23964 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23965 trace
23966 (p_msg => 'END of AcctLineType_44'
23967 ,p_level => C_LEVEL_PROCEDURE
23968 ,p_module => l_log_module);
23969 END IF;
23970 --
23971 EXCEPTION
23972 WHEN xla_exceptions_pkg.application_exception THEN
23973 RAISE;
23974 WHEN OTHERS THEN
23975 xla_exceptions_pkg.raise_message
23976 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_44');
23977 END AcctLineType_44;
23978 --
23979
23980 ---------------------------------------
23981 --
23982 -- PRIVATE FUNCTION
23983 -- AcctLineType_45
23984 --
23985 ---------------------------------------
23986 PROCEDURE AcctLineType_45 (
23987 p_application_id IN NUMBER
23988 ,p_event_id IN NUMBER
23989 ,p_calculate_acctd_flag IN VARCHAR2
23990 ,p_calculate_g_l_flag IN VARCHAR2
23991 ,p_actual_flag IN OUT VARCHAR2
23992 ,p_balance_type_code OUT VARCHAR2
23993 ,p_gain_or_loss_ref OUT VARCHAR2
23994
23995 --PO Budget Account
23996 , p_source_3 IN NUMBER
23997 --Receiving Accounting Line Type
23998 , p_source_6 IN VARCHAR2
23999 --Applied to Application ID
24000 , p_source_7 IN NUMBER
24001 --Applied to Distribution Link Type
24002 , p_source_8 IN VARCHAR2
24003 --Applied to Entity Code
24004 , p_source_9 IN VARCHAR2
24005 --PO_DISTRIBUTION_ID
24006 , p_source_10 IN NUMBER
24007 --Applied To Purchase Document Identifier
24008 , p_source_11 IN NUMBER
24009 --DISTRIBUTION_IDENTIFIER
24010 , p_source_12 IN NUMBER
24011 --Distribution Type
24012 , p_source_13 IN VARCHAR2
24013 , p_source_13_meaning IN VARCHAR2
24014 --Encumbrance Reversal Amount Entered
24015 , p_source_14 IN NUMBER
24016 --Entered Currency Code
24017 , p_source_15 IN VARCHAR2
24018 --Transaction Encumbrance Reversal Amount
24019 , p_source_16 IN NUMBER
24020 --Costing Encumbrance Upgrade Option
24021 , p_source_17 IN VARCHAR2
24022 --Currency Conversion Date
24023 , p_source_19 IN DATE
24024 --Currency Conversion Rate
24025 , p_source_20 IN NUMBER
24026 --Currency Conversion Type
24027 , p_source_21 IN VARCHAR2
24028 --Purchasing Encumbrance Type Identifier
24029 , p_source_22 IN NUMBER
24030 --Federal Paid Unexpended Obligation Amount
24031 , p_source_28 IN NUMBER
24032 )
24033 IS
24034
24035 l_component_type VARCHAR2(80);
24036 l_component_code VARCHAR2(30);
24037 l_component_type_code VARCHAR2(1);
24038 l_component_appl_id INTEGER;
24039 l_amb_context_code VARCHAR2(30);
24040 l_entity_code VARCHAR2(30);
24041 l_event_class_code VARCHAR2(30);
24042 l_ae_header_id NUMBER;
24043 l_event_type_code VARCHAR2(30);
24044 l_line_definition_code VARCHAR2(30);
24045 l_line_definition_owner_code VARCHAR2(1);
24046 --
24047 -- adr variables
24048 l_segment VARCHAR2(30);
24049 l_ccid NUMBER;
24050 l_adr_transaction_coa_id NUMBER;
24051 l_adr_accounting_coa_id NUMBER;
24052 l_adr_flexfield_segment_code VARCHAR2(30);
24053 l_adr_flex_value_set_id NUMBER;
24054 l_adr_value_type_code VARCHAR2(30);
24055 l_adr_value_combination_id NUMBER;
24056 l_adr_value_segment_code VARCHAR2(30);
24057
24058 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
24059 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
24060 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
24061 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
24062
24063 -- 4262811 Variables ------------------------------------------------------------------------------------------
24064 l_entered_amt_idx NUMBER;
24065 l_accted_amt_idx NUMBER;
24066 l_acc_rev_flag VARCHAR2(1);
24067 l_accrual_line_num NUMBER;
24068 l_tmp_amt NUMBER;
24069 l_acc_rev_natural_side_code VARCHAR2(1);
24070
24071 l_num_entries NUMBER;
24072 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
24073 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
24074 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
24075 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
24076 l_recog_line_1 NUMBER;
24077 l_recog_line_2 NUMBER;
24078
24079 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
24080 l_bflow_applied_to_amt NUMBER; -- 5132302
24081 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
24082
24083 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
24084
24085 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
24086 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
24087
24088 ---------------------------------------------------------------------------------------------------------------
24089
24090
24091 --
24092 -- bulk performance
24093 --
24094 l_balance_type_code VARCHAR2(1);
24095 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
24096 l_log_module VARCHAR2(240);
24097
24098 --
24099 -- Upgrade strategy
24100 --
24101 l_actual_upg_option VARCHAR2(1);
24102 l_enc_upg_option VARCHAR2(1);
24103
24104 --
24105 BEGIN
24106 --
24107 IF g_log_enabled THEN
24108 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_45';
24109 END IF;
24110 --
24111 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24112
24113 trace
24114 (p_msg => 'BEGIN of AcctLineType_45'
24115 ,p_level => C_LEVEL_PROCEDURE
24116 ,p_module => l_log_module);
24117
24118 END IF;
24119 --
24120 l_component_type := 'AMB_JLT';
24121 l_component_code := 'FV_REV_PO_PAID_DR';
24122 l_component_type_code := 'S';
24123 l_component_appl_id := 707;
24124 l_amb_context_code := 'DEFAULT';
24125 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
24126 l_event_class_code := 'DELIVER_EXPENSE';
24127 l_event_type_code := 'DELIVER_EXPENSE_ALL';
24128 l_line_definition_owner_code := 'S';
24129 l_line_definition_code := 'FV_DELIVER_EXPENSE';
24130 --
24131 l_balance_type_code := 'A';
24132 l_segment := NULL;
24133 l_ccid := NULL;
24134 l_adr_transaction_coa_id := NULL;
24135 l_adr_accounting_coa_id := NULL;
24136 l_adr_flexfield_segment_code := NULL;
24137 l_adr_flex_value_set_id := NULL;
24138 l_adr_value_type_code := NULL;
24139 l_adr_value_combination_id := NULL;
24140 l_adr_value_segment_code := NULL;
24141
24142 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
24143 l_bflow_class_code := ''; -- 4219869 Business Flow
24144 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
24145 l_budgetary_control_flag := 'Y';
24146
24147 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24148 l_bflow_applied_to_amt := NULL; -- 5132302
24149 l_entered_amt_idx := NULL; -- 4262811
24150 l_accted_amt_idx := NULL; -- 4262811
24151 l_acc_rev_flag := NULL; -- 4262811
24152 l_accrual_line_num := NULL; -- 4262811
24153 l_tmp_amt := NULL; -- 4262811
24154 --
24155
24156 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
24157 l_balance_type_code <> 'B' THEN
24158 IF p_source_28 > 0 AND
24159 NVL(
24160 xla_ae_sources_pkg.GetSystemSourceChar(
24161 p_source_code => 'XLA_EVENT_TYPE_CODE'
24162 , p_source_type_code => 'Y'
24163 , p_source_application_id => 602
24164 ),'
24165 ') = 'DELIVER_EXPENSE' AND
24166 NVL(p_source_6,'
24167 ') = 'Charge'
24168 THEN
24169
24170 --
24171 XLA_AE_LINES_PKG.SetNewLine;
24172
24173 p_balance_type_code := l_balance_type_code;
24174 -- set the flag so later we will know whether the gain loss line needs to be created
24175
24176 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
24177 p_actual_flag :='A';
24178 END IF;
24179
24180 --
24181 -- bulk performance
24182 --
24183 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
24184 p_header_num => 0); -- 4262811
24185 --
24186 -- set accounting line options
24187 --
24188 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
24189 p_natural_side_code => 'D'
24190 , p_gain_or_loss_flag => 'N'
24191 , p_gl_transfer_mode_code => 'S'
24192 , p_acct_entry_type_code => 'A'
24193 , p_switch_side_flag => 'N'
24194 , p_merge_duplicate_code => 'N'
24195 );
24196 --
24197 l_acc_rev_natural_side_code := 'C'; -- 4262811
24198 --
24199 --
24200 -- set accounting line type info
24201 --
24202 xla_ae_lines_pkg.SetAcctLineType
24203 (p_component_type => l_component_type
24204 ,p_event_type_code => l_event_type_code
24205 ,p_line_definition_owner_code => l_line_definition_owner_code
24206 ,p_line_definition_code => l_line_definition_code
24207 ,p_accounting_line_code => l_component_code
24208 ,p_accounting_line_type_code => l_component_type_code
24209 ,p_accounting_line_appl_id => l_component_appl_id
24210 ,p_amb_context_code => l_amb_context_code
24211 ,p_entity_code => l_entity_code
24212 ,p_event_class_code => l_event_class_code);
24213 --
24214 -- set accounting class
24215 --
24216 xla_ae_lines_pkg.SetAcctClass(
24217 p_accounting_class_code => 'FEDERAL_EXP'
24218 , p_ae_header_id => l_ae_header_id
24219 );
24220
24221 --
24222 -- set rounding class
24223 --
24224 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
24225 'FEDERAL_EXP';
24226
24227 --
24228 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
24229 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
24230 --
24231 -- bulk performance
24232 --
24233 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
24234
24235 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
24236 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
24237
24238 -- 4955764
24239 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24240 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
24241
24242 -- 4458381 Public Sector Enh
24243
24244 --
24245 -- set accounting attributes for the line type
24246 --
24247 l_entered_amt_idx := 17;
24248 l_accted_amt_idx := 22;
24249 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24250 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
24251 l_rec_acct_attrs.array_num_value(1) := p_source_7;
24252 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
24253 l_rec_acct_attrs.array_char_value(2) := p_source_8;
24254 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
24255 l_rec_acct_attrs.array_char_value(3) := p_source_9;
24256 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
24257 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
24258 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
24259 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
24260 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
24261 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
24262 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
24263 l_rec_acct_attrs.array_char_value(7) := p_source_13;
24264 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
24265 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
24266 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
24267 l_rec_acct_attrs.array_num_value(9) := p_source_14;
24268 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
24269 l_rec_acct_attrs.array_char_value(10) := p_source_15;
24270 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
24271 l_rec_acct_attrs.array_num_value(11) := p_source_16;
24272 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
24273 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
24274 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
24275 l_rec_acct_attrs.array_num_value(13) := p_source_14;
24276 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
24277 l_rec_acct_attrs.array_char_value(14) := p_source_15;
24278 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
24279 l_rec_acct_attrs.array_num_value(15) := p_source_16;
24280 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
24281 l_rec_acct_attrs.array_char_value(16) := p_source_17;
24282 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
24283 l_rec_acct_attrs.array_num_value(17) := p_source_28;
24284 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
24285 l_rec_acct_attrs.array_char_value(18) := p_source_15;
24286 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
24287 l_rec_acct_attrs.array_date_value(19) := p_source_19;
24288 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
24289 l_rec_acct_attrs.array_num_value(20) := p_source_20;
24290 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
24291 l_rec_acct_attrs.array_char_value(21) := p_source_21;
24292 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
24293 l_rec_acct_attrs.array_num_value(22) := p_source_28;
24294 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
24295 l_rec_acct_attrs.array_num_value(23) := p_source_22;
24296 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
24297 l_rec_acct_attrs.array_num_value(24) := p_source_22;
24298
24299 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
24300 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
24301
24302 ---------------------------------------------------------------------------------------------------------------
24303 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
24304 ---------------------------------------------------------------------------------------------------------------
24305 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
24306
24307 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24308 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24309
24310 IF xla_accounting_cache_pkg.GetValueChar
24311 (p_source_code => 'LEDGER_CATEGORY_CODE'
24312 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
24313 AND l_bflow_method_code = 'PRIOR_ENTRY'
24314 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
24315 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
24316 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
24317 )
24318 THEN
24319 xla_ae_lines_pkg.BflowUpgEntry
24320 (p_business_method_code => l_bflow_method_code
24321 ,p_business_class_code => l_bflow_class_code
24322 ,p_balance_type => l_balance_type_code);
24323 ELSE
24324 NULL;
24325 -- No business flow processing for business flow method of NONE.
24326 END IF;
24327
24328 --
24329 -- call analytical criteria
24330 --
24331
24332 --
24333 -- call description
24334 --
24335 -- No description or it is inherited.
24336 --
24337 -- call ADRs
24338 -- Bug 4922099
24339 --
24340 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24341 (NVL(l_actual_upg_option, 'N') = 'O') OR
24342 (NVL(l_enc_upg_option, 'N') = 'O')
24343 )
24344 THEN
24345 NULL;
24346 --
24347 --
24348
24349 l_ccid := AcctDerRule_11(
24350 p_application_id => p_application_id
24351 , p_ae_header_id => l_ae_header_id
24352 , p_source_3 => p_source_3
24353 , x_transaction_coa_id => l_adr_transaction_coa_id
24354 , x_accounting_coa_id => l_adr_accounting_coa_id
24355 , x_value_type_code => l_adr_value_type_code
24356 , p_side => 'NA'
24357 );
24358
24359 xla_ae_lines_pkg.set_ccid(
24360 p_code_combination_id => l_ccid
24361 , p_value_type_code => l_adr_value_type_code
24362 , p_transaction_coa_id => l_adr_transaction_coa_id
24363 , p_accounting_coa_id => l_adr_accounting_coa_id
24364 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
24365 , p_adr_type_code => 'S'
24366 , p_component_type => l_component_type
24367 , p_component_code => l_component_code
24368 , p_component_type_code => l_component_type_code
24369 , p_component_appl_id => l_component_appl_id
24370 , p_amb_context_code => l_amb_context_code
24371 , p_side => 'NA'
24372 );
24373
24374
24375 l_segment := AcctDerRule_6(
24376 p_application_id => p_application_id
24377 , p_ae_header_id => l_ae_header_id
24378 , x_transaction_coa_id => l_adr_transaction_coa_id
24379 , x_accounting_coa_id => l_adr_accounting_coa_id
24380 , x_flexfield_segment_code => l_adr_flexfield_segment_code
24381 , x_flex_value_set_id => l_adr_flex_value_set_id
24382 , x_value_type_code => l_adr_value_type_code
24383 , x_value_combination_id => l_adr_value_combination_id
24384 , x_value_segment_code => l_adr_value_segment_code
24385 , p_side => 'NA'
24386 , p_override_seg_flag => 'Y'
24387 );
24388
24389 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
24390
24391 xla_ae_lines_pkg.set_segment(
24392 p_to_segment_code => 'GL_ACCOUNT'
24393 , p_segment_value => l_segment
24394 , p_from_segment_code => l_adr_value_segment_code
24395 , p_from_combination_id => l_adr_value_combination_id
24396 , p_value_type_code => l_adr_value_type_code
24397 , p_transaction_coa_id => l_adr_transaction_coa_id
24398 , p_accounting_coa_id => l_adr_accounting_coa_id
24399 , p_flexfield_segment_code => l_adr_flexfield_segment_code
24400 , p_flex_value_set_id => l_adr_flex_value_set_id
24401 , p_adr_code => 'FV_480201'
24402 , p_adr_type_code => 'S'
24403 , p_component_type => l_component_type
24404 , p_component_code => l_component_code
24405 , p_component_type_code => l_component_type_code
24406 , p_component_appl_id => l_component_appl_id
24407 , p_amb_context_code => l_amb_context_code
24408 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
24409 , p_event_class_code => 'DELIVER_EXPENSE'
24410 , p_side => 'NA'
24411 );
24412
24413 END IF;
24414
24415 --
24416 --
24417 END IF;
24418 --
24419 -- Bug 4922099
24420 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
24421 (NVL(l_enc_upg_option, 'N') = 'O')
24422 ) AND
24423 (l_bflow_method_code = 'PRIOR_ENTRY')
24424 )
24425 THEN
24426 IF
24427 --
24428 1 = 2
24429 --
24430 THEN
24431 xla_accounting_err_pkg.build_message
24432 (p_appli_s_name => 'XLA'
24433 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24434 ,p_token_1 => 'LINE_NUMBER'
24435 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
24436 ,p_token_2 => 'LINE_TYPE_NAME'
24437 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
24438 l_component_type
24439 ,l_component_code
24440 ,l_component_type_code
24441 ,l_component_appl_id
24442 ,l_amb_context_code
24443 ,l_entity_code
24444 ,l_event_class_code
24445 )
24446 ,p_token_3 => 'OWNER'
24447 ,p_value_3 => xla_lookups_pkg.get_meaning(
24448 p_lookup_type => 'XLA_OWNER_TYPE'
24449 ,p_lookup_code => l_component_type_code
24450 )
24451 ,p_token_4 => 'PRODUCT_NAME'
24452 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
24453 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
24454 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
24455 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
24456 ,p_ae_header_id => NULL
24457 );
24458
24459 IF (C_LEVEL_ERROR>= g_log_level) THEN
24460 trace
24461 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24462 ,p_level => C_LEVEL_ERROR
24463 ,p_module => l_log_module);
24464 END IF;
24465 END IF;
24466 END IF;
24467 --
24468 --
24469 ------------------------------------------------------------------------------------------------
24470 -- 4219869 Business Flow
24471 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
24472 -- Prior Entry. Currently, the following code is always generated.
24473 ------------------------------------------------------------------------------------------------
24474 XLA_AE_LINES_PKG.ValidateCurrentLine;
24475
24476 ------------------------------------------------------------------------------------
24477 -- 4219869 Business Flow
24478 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
24479 ------------------------------------------------------------------------------------
24480 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24481
24482 ----------------------------------------------------------------------------------
24483 -- 4219869 Business Flow
24484 -- Update journal entry status -- Need to generate this within IF <condition>
24485 ----------------------------------------------------------------------------------
24486 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24487 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
24488 ,p_balance_type_code => l_balance_type_code
24489 );
24490
24491 -------------------------------------------------------------------------------------------
24492 -- 4262811 - Generate the Accrual Reversal lines
24493 -------------------------------------------------------------------------------------------
24494 BEGIN
24495 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
24496 (g_array_event(p_event_id).array_value_num('header_index'));
24497 IF l_acc_rev_flag IS NULL THEN
24498 l_acc_rev_flag := 'N';
24499 END IF;
24500 EXCEPTION
24501 WHEN OTHERS THEN
24502 l_acc_rev_flag := 'N';
24503 END;
24504 --
24505 IF (l_acc_rev_flag = 'Y') THEN
24506
24507 -- 4645092 ------------------------------------------------------------------------------
24508 -- To allow MPA report to determine if it should generate report process
24509 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
24510 ------------------------------------------------------------------------------------------
24511
24512 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
24513 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
24514 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
24515 -- call ADRs
24516 -- Bug 4922099
24517 --
24518 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24519 (NVL(l_actual_upg_option, 'N') = 'O') OR
24520 (NVL(l_enc_upg_option, 'N') = 'O')
24521 )
24522 THEN
24523 NULL;
24524 --
24525 --
24526
24527 l_ccid := AcctDerRule_11(
24528 p_application_id => p_application_id
24529 , p_ae_header_id => l_ae_header_id
24530 , p_source_3 => p_source_3
24531 , x_transaction_coa_id => l_adr_transaction_coa_id
24532 , x_accounting_coa_id => l_adr_accounting_coa_id
24533 , x_value_type_code => l_adr_value_type_code
24534 , p_side => 'NA'
24535 );
24536
24537 xla_ae_lines_pkg.set_ccid(
24538 p_code_combination_id => l_ccid
24539 , p_value_type_code => l_adr_value_type_code
24540 , p_transaction_coa_id => l_adr_transaction_coa_id
24541 , p_accounting_coa_id => l_adr_accounting_coa_id
24542 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
24543 , p_adr_type_code => 'S'
24544 , p_component_type => l_component_type
24545 , p_component_code => l_component_code
24546 , p_component_type_code => l_component_type_code
24547 , p_component_appl_id => l_component_appl_id
24548 , p_amb_context_code => l_amb_context_code
24549 , p_side => 'NA'
24550 );
24551
24552
24553 l_segment := AcctDerRule_6(
24554 p_application_id => p_application_id
24555 , p_ae_header_id => l_ae_header_id
24556 , x_transaction_coa_id => l_adr_transaction_coa_id
24557 , x_accounting_coa_id => l_adr_accounting_coa_id
24558 , x_flexfield_segment_code => l_adr_flexfield_segment_code
24559 , x_flex_value_set_id => l_adr_flex_value_set_id
24560 , x_value_type_code => l_adr_value_type_code
24561 , x_value_combination_id => l_adr_value_combination_id
24562 , x_value_segment_code => l_adr_value_segment_code
24563 , p_side => 'NA'
24564 , p_override_seg_flag => 'Y'
24565 );
24566
24567 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
24568
24569 xla_ae_lines_pkg.set_segment(
24570 p_to_segment_code => 'GL_ACCOUNT'
24571 , p_segment_value => l_segment
24572 , p_from_segment_code => l_adr_value_segment_code
24573 , p_from_combination_id => l_adr_value_combination_id
24574 , p_value_type_code => l_adr_value_type_code
24575 , p_transaction_coa_id => l_adr_transaction_coa_id
24576 , p_accounting_coa_id => l_adr_accounting_coa_id
24577 , p_flexfield_segment_code => l_adr_flexfield_segment_code
24578 , p_flex_value_set_id => l_adr_flex_value_set_id
24579 , p_adr_code => 'FV_480201'
24580 , p_adr_type_code => 'S'
24581 , p_component_type => l_component_type
24582 , p_component_code => l_component_code
24583 , p_component_type_code => l_component_type_code
24584 , p_component_appl_id => l_component_appl_id
24585 , p_amb_context_code => l_amb_context_code
24586 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
24587 , p_event_class_code => 'DELIVER_EXPENSE'
24588 , p_side => 'NA'
24589 );
24590
24591 END IF;
24592
24593 --
24594 --
24595 END IF;
24596
24597 --
24598 -- Update the line information that should be overwritten
24599 --
24600 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
24601 p_header_num => 1);
24602 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
24603
24604 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
24605
24606 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
24607 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
24608 END IF;
24609
24610 --
24611 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
24612 --
24613 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
24614 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
24615 ELSE
24616 ---------------------------------------------------------------------------------------------------
24617 -- 4262811a Switch Sign
24618 ---------------------------------------------------------------------------------------------------
24619 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
24620 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24621 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24622 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24623 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24624 -- 5132302
24625 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
24626 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24627
24628 END IF;
24629
24630 -- 4955764
24631 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24632 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
24633
24634
24635 XLA_AE_LINES_PKG.ValidateCurrentLine;
24636 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24637
24638 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24639 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
24640 ,p_balance_type_code => l_balance_type_code);
24641
24642 END IF;
24643
24644 -----------------------------------------------------------------------------------------
24645 -- 4262811 Multiperiod Accounting
24646 -----------------------------------------------------------------------------------------
24647 -- No MPA option is assigned.
24648
24649
24650 END IF;
24651 END IF;
24652 --
24653
24654 --
24655 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24656 trace
24657 (p_msg => 'END of AcctLineType_45'
24658 ,p_level => C_LEVEL_PROCEDURE
24659 ,p_module => l_log_module);
24660 END IF;
24661 --
24662 EXCEPTION
24663 WHEN xla_exceptions_pkg.application_exception THEN
24664 RAISE;
24665 WHEN OTHERS THEN
24666 xla_exceptions_pkg.raise_message
24667 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_45');
24668 END AcctLineType_45;
24669 --
24670
24671 ---------------------------------------
24672 --
24673 -- PRIVATE FUNCTION
24674 -- AcctLineType_46
24675 --
24676 ---------------------------------------
24677 PROCEDURE AcctLineType_46 (
24678 p_application_id IN NUMBER
24679 ,p_event_id IN NUMBER
24680 ,p_calculate_acctd_flag IN VARCHAR2
24681 ,p_calculate_g_l_flag IN VARCHAR2
24682 ,p_actual_flag IN OUT VARCHAR2
24683 ,p_balance_type_code OUT VARCHAR2
24684 ,p_gain_or_loss_ref OUT VARCHAR2
24685
24686 --PO Budget Account
24687 , p_source_3 IN NUMBER
24688 --Applied to Application ID
24689 , p_source_7 IN NUMBER
24690 --Applied to Distribution Link Type
24691 , p_source_8 IN VARCHAR2
24692 --Applied to Entity Code
24693 , p_source_9 IN VARCHAR2
24694 --Applied To Purchase Document Identifier
24695 , p_source_11 IN NUMBER
24696 --DISTRIBUTION_IDENTIFIER
24697 , p_source_12 IN NUMBER
24698 --Distribution Type
24699 , p_source_13 IN VARCHAR2
24700 , p_source_13_meaning IN VARCHAR2
24701 --Encumbrance Reversal Amount Entered
24702 , p_source_14 IN NUMBER
24703 --Entered Currency Code
24704 , p_source_15 IN VARCHAR2
24705 --Transaction Encumbrance Reversal Amount
24706 , p_source_16 IN NUMBER
24707 --Costing Encumbrance Upgrade Option
24708 , p_source_17 IN VARCHAR2
24709 --Currency Conversion Date
24710 , p_source_19 IN DATE
24711 --Currency Conversion Rate
24712 , p_source_20 IN NUMBER
24713 --Currency Conversion Type
24714 , p_source_21 IN VARCHAR2
24715 --Purchasing Encumbrance Type Identifier
24716 , p_source_22 IN NUMBER
24717 --TXN_PO_DISTRIBUTION_ID
24718 , p_source_23 IN NUMBER
24719 --Federal Paid Unexpended Obligation Amount
24720 , p_source_28 IN NUMBER
24721 )
24722 IS
24723
24724 l_component_type VARCHAR2(80);
24725 l_component_code VARCHAR2(30);
24726 l_component_type_code VARCHAR2(1);
24727 l_component_appl_id INTEGER;
24728 l_amb_context_code VARCHAR2(30);
24729 l_entity_code VARCHAR2(30);
24730 l_event_class_code VARCHAR2(30);
24731 l_ae_header_id NUMBER;
24732 l_event_type_code VARCHAR2(30);
24733 l_line_definition_code VARCHAR2(30);
24734 l_line_definition_owner_code VARCHAR2(1);
24735 --
24736 -- adr variables
24737 l_segment VARCHAR2(30);
24738 l_ccid NUMBER;
24739 l_adr_transaction_coa_id NUMBER;
24740 l_adr_accounting_coa_id NUMBER;
24741 l_adr_flexfield_segment_code VARCHAR2(30);
24742 l_adr_flex_value_set_id NUMBER;
24743 l_adr_value_type_code VARCHAR2(30);
24744 l_adr_value_combination_id NUMBER;
24745 l_adr_value_segment_code VARCHAR2(30);
24746
24747 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
24748 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
24749 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
24750 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
24751
24752 -- 4262811 Variables ------------------------------------------------------------------------------------------
24753 l_entered_amt_idx NUMBER;
24754 l_accted_amt_idx NUMBER;
24755 l_acc_rev_flag VARCHAR2(1);
24756 l_accrual_line_num NUMBER;
24757 l_tmp_amt NUMBER;
24758 l_acc_rev_natural_side_code VARCHAR2(1);
24759
24760 l_num_entries NUMBER;
24761 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
24762 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
24763 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
24764 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
24765 l_recog_line_1 NUMBER;
24766 l_recog_line_2 NUMBER;
24767
24768 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
24769 l_bflow_applied_to_amt NUMBER; -- 5132302
24770 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
24771
24772 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
24773
24774 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
24775 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
24776
24777 ---------------------------------------------------------------------------------------------------------------
24778
24779
24780 --
24781 -- bulk performance
24782 --
24783 l_balance_type_code VARCHAR2(1);
24784 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
24785 l_log_module VARCHAR2(240);
24786
24787 --
24788 -- Upgrade strategy
24789 --
24790 l_actual_upg_option VARCHAR2(1);
24791 l_enc_upg_option VARCHAR2(1);
24792
24793 --
24794 BEGIN
24795 --
24796 IF g_log_enabled THEN
24797 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_46';
24798 END IF;
24799 --
24800 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24801
24802 trace
24803 (p_msg => 'BEGIN of AcctLineType_46'
24804 ,p_level => C_LEVEL_PROCEDURE
24805 ,p_module => l_log_module);
24806
24807 END IF;
24808 --
24809 l_component_type := 'AMB_JLT';
24810 l_component_code := 'FV_REV_PO_PAID_DR_DTI';
24811 l_component_type_code := 'S';
24812 l_component_appl_id := 707;
24813 l_amb_context_code := 'DEFAULT';
24814 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
24815 l_event_class_code := 'PURCHASE_ORDER';
24816 l_event_type_code := 'PURCHASE_ORDER_ALL';
24817 l_line_definition_owner_code := 'S';
24818 l_line_definition_code := 'FV_PO_DEL_INV';
24819 --
24820 l_balance_type_code := 'A';
24821 l_segment := NULL;
24822 l_ccid := NULL;
24823 l_adr_transaction_coa_id := NULL;
24824 l_adr_accounting_coa_id := NULL;
24825 l_adr_flexfield_segment_code := NULL;
24826 l_adr_flex_value_set_id := NULL;
24827 l_adr_value_type_code := NULL;
24828 l_adr_value_combination_id := NULL;
24829 l_adr_value_segment_code := NULL;
24830
24831 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
24832 l_bflow_class_code := ''; -- 4219869 Business Flow
24833 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
24834 l_budgetary_control_flag := 'Y';
24835
24836 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24837 l_bflow_applied_to_amt := NULL; -- 5132302
24838 l_entered_amt_idx := NULL; -- 4262811
24839 l_accted_amt_idx := NULL; -- 4262811
24840 l_acc_rev_flag := NULL; -- 4262811
24841 l_accrual_line_num := NULL; -- 4262811
24842 l_tmp_amt := NULL; -- 4262811
24843 --
24844
24845 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
24846 l_balance_type_code <> 'B' THEN
24847 IF p_source_28 > 0 AND
24848 NVL(
24849 xla_ae_sources_pkg.GetSystemSourceChar(
24850 p_source_code => 'XLA_EVENT_TYPE_CODE'
24851 , p_source_type_code => 'Y'
24852 , p_source_application_id => 602
24853 ),'
24854 ') = 'PO_DEL_INV'
24855 THEN
24856
24857 --
24858 XLA_AE_LINES_PKG.SetNewLine;
24859
24860 p_balance_type_code := l_balance_type_code;
24861 -- set the flag so later we will know whether the gain loss line needs to be created
24862
24863 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
24864 p_actual_flag :='A';
24865 END IF;
24866
24867 --
24868 -- bulk performance
24869 --
24870 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
24871 p_header_num => 0); -- 4262811
24872 --
24873 -- set accounting line options
24874 --
24875 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
24876 p_natural_side_code => 'D'
24877 , p_gain_or_loss_flag => 'N'
24878 , p_gl_transfer_mode_code => 'S'
24879 , p_acct_entry_type_code => 'A'
24880 , p_switch_side_flag => 'N'
24881 , p_merge_duplicate_code => 'N'
24882 );
24883 --
24884 l_acc_rev_natural_side_code := 'C'; -- 4262811
24885 --
24886 --
24887 -- set accounting line type info
24888 --
24889 xla_ae_lines_pkg.SetAcctLineType
24890 (p_component_type => l_component_type
24891 ,p_event_type_code => l_event_type_code
24892 ,p_line_definition_owner_code => l_line_definition_owner_code
24893 ,p_line_definition_code => l_line_definition_code
24894 ,p_accounting_line_code => l_component_code
24895 ,p_accounting_line_type_code => l_component_type_code
24896 ,p_accounting_line_appl_id => l_component_appl_id
24897 ,p_amb_context_code => l_amb_context_code
24898 ,p_entity_code => l_entity_code
24899 ,p_event_class_code => l_event_class_code);
24900 --
24901 -- set accounting class
24902 --
24903 xla_ae_lines_pkg.SetAcctClass(
24904 p_accounting_class_code => 'FEDERAL_INV'
24905 , p_ae_header_id => l_ae_header_id
24906 );
24907
24908 --
24909 -- set rounding class
24910 --
24911 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
24912 'FEDERAL_INV';
24913
24914 --
24915 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
24916 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
24917 --
24918 -- bulk performance
24919 --
24920 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
24921
24922 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
24923 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
24924
24925 -- 4955764
24926 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24927 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
24928
24929 -- 4458381 Public Sector Enh
24930
24931 --
24932 -- set accounting attributes for the line type
24933 --
24934 l_entered_amt_idx := 17;
24935 l_accted_amt_idx := 22;
24936 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24937 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
24938 l_rec_acct_attrs.array_num_value(1) := p_source_7;
24939 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
24940 l_rec_acct_attrs.array_char_value(2) := p_source_8;
24941 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
24942 l_rec_acct_attrs.array_char_value(3) := p_source_9;
24943 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
24944 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
24945 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
24946 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
24947 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
24948 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
24949 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
24950 l_rec_acct_attrs.array_char_value(7) := p_source_13;
24951 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
24952 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
24953 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
24954 l_rec_acct_attrs.array_num_value(9) := p_source_14;
24955 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
24956 l_rec_acct_attrs.array_char_value(10) := p_source_15;
24957 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
24958 l_rec_acct_attrs.array_num_value(11) := p_source_16;
24959 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
24960 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
24961 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
24962 l_rec_acct_attrs.array_num_value(13) := p_source_14;
24963 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
24964 l_rec_acct_attrs.array_char_value(14) := p_source_15;
24965 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
24966 l_rec_acct_attrs.array_num_value(15) := p_source_16;
24967 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
24968 l_rec_acct_attrs.array_char_value(16) := p_source_17;
24969 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
24970 l_rec_acct_attrs.array_num_value(17) := p_source_28;
24971 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
24972 l_rec_acct_attrs.array_char_value(18) := p_source_15;
24973 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
24974 l_rec_acct_attrs.array_date_value(19) := p_source_19;
24975 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
24976 l_rec_acct_attrs.array_num_value(20) := p_source_20;
24977 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
24978 l_rec_acct_attrs.array_char_value(21) := p_source_21;
24979 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
24980 l_rec_acct_attrs.array_num_value(22) := p_source_28;
24981 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
24982 l_rec_acct_attrs.array_num_value(23) := p_source_22;
24983 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
24984 l_rec_acct_attrs.array_num_value(24) := p_source_22;
24985
24986 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
24987 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
24988
24989 ---------------------------------------------------------------------------------------------------------------
24990 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
24991 ---------------------------------------------------------------------------------------------------------------
24992 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
24993
24994 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24995 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24996
24997 IF xla_accounting_cache_pkg.GetValueChar
24998 (p_source_code => 'LEDGER_CATEGORY_CODE'
24999 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
25000 AND l_bflow_method_code = 'PRIOR_ENTRY'
25001 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
25002 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
25003 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
25004 )
25005 THEN
25006 xla_ae_lines_pkg.BflowUpgEntry
25007 (p_business_method_code => l_bflow_method_code
25008 ,p_business_class_code => l_bflow_class_code
25009 ,p_balance_type => l_balance_type_code);
25010 ELSE
25011 NULL;
25012 -- No business flow processing for business flow method of NONE.
25013 END IF;
25014
25015 --
25016 -- call analytical criteria
25017 --
25018
25019 --
25020 -- call description
25021 --
25022 -- No description or it is inherited.
25023 --
25024 -- call ADRs
25025 -- Bug 4922099
25026 --
25027 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25028 (NVL(l_actual_upg_option, 'N') = 'O') OR
25029 (NVL(l_enc_upg_option, 'N') = 'O')
25030 )
25031 THEN
25032 NULL;
25033 --
25034 --
25035
25036 l_ccid := AcctDerRule_11(
25037 p_application_id => p_application_id
25038 , p_ae_header_id => l_ae_header_id
25039 , p_source_3 => p_source_3
25040 , x_transaction_coa_id => l_adr_transaction_coa_id
25041 , x_accounting_coa_id => l_adr_accounting_coa_id
25042 , x_value_type_code => l_adr_value_type_code
25043 , p_side => 'NA'
25044 );
25045
25046 xla_ae_lines_pkg.set_ccid(
25047 p_code_combination_id => l_ccid
25048 , p_value_type_code => l_adr_value_type_code
25049 , p_transaction_coa_id => l_adr_transaction_coa_id
25050 , p_accounting_coa_id => l_adr_accounting_coa_id
25051 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
25052 , p_adr_type_code => 'S'
25053 , p_component_type => l_component_type
25054 , p_component_code => l_component_code
25055 , p_component_type_code => l_component_type_code
25056 , p_component_appl_id => l_component_appl_id
25057 , p_amb_context_code => l_amb_context_code
25058 , p_side => 'NA'
25059 );
25060
25061
25062 l_segment := AcctDerRule_6(
25063 p_application_id => p_application_id
25064 , p_ae_header_id => l_ae_header_id
25065 , x_transaction_coa_id => l_adr_transaction_coa_id
25066 , x_accounting_coa_id => l_adr_accounting_coa_id
25067 , x_flexfield_segment_code => l_adr_flexfield_segment_code
25068 , x_flex_value_set_id => l_adr_flex_value_set_id
25069 , x_value_type_code => l_adr_value_type_code
25070 , x_value_combination_id => l_adr_value_combination_id
25071 , x_value_segment_code => l_adr_value_segment_code
25072 , p_side => 'NA'
25073 , p_override_seg_flag => 'Y'
25074 );
25075
25076 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
25077
25078 xla_ae_lines_pkg.set_segment(
25079 p_to_segment_code => 'GL_ACCOUNT'
25080 , p_segment_value => l_segment
25081 , p_from_segment_code => l_adr_value_segment_code
25082 , p_from_combination_id => l_adr_value_combination_id
25083 , p_value_type_code => l_adr_value_type_code
25084 , p_transaction_coa_id => l_adr_transaction_coa_id
25085 , p_accounting_coa_id => l_adr_accounting_coa_id
25086 , p_flexfield_segment_code => l_adr_flexfield_segment_code
25087 , p_flex_value_set_id => l_adr_flex_value_set_id
25088 , p_adr_code => 'FV_480201'
25089 , p_adr_type_code => 'S'
25090 , p_component_type => l_component_type
25091 , p_component_code => l_component_code
25092 , p_component_type_code => l_component_type_code
25093 , p_component_appl_id => l_component_appl_id
25094 , p_amb_context_code => l_amb_context_code
25095 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
25096 , p_event_class_code => 'PURCHASE_ORDER'
25097 , p_side => 'NA'
25098 );
25099
25100 END IF;
25101
25102 --
25103 --
25104 END IF;
25105 --
25106 -- Bug 4922099
25107 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
25108 (NVL(l_enc_upg_option, 'N') = 'O')
25109 ) AND
25110 (l_bflow_method_code = 'PRIOR_ENTRY')
25111 )
25112 THEN
25113 IF
25114 --
25115 1 = 2
25116 --
25117 THEN
25118 xla_accounting_err_pkg.build_message
25119 (p_appli_s_name => 'XLA'
25120 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25121 ,p_token_1 => 'LINE_NUMBER'
25122 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
25123 ,p_token_2 => 'LINE_TYPE_NAME'
25124 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
25125 l_component_type
25126 ,l_component_code
25127 ,l_component_type_code
25128 ,l_component_appl_id
25129 ,l_amb_context_code
25130 ,l_entity_code
25131 ,l_event_class_code
25132 )
25133 ,p_token_3 => 'OWNER'
25134 ,p_value_3 => xla_lookups_pkg.get_meaning(
25135 p_lookup_type => 'XLA_OWNER_TYPE'
25136 ,p_lookup_code => l_component_type_code
25137 )
25138 ,p_token_4 => 'PRODUCT_NAME'
25139 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
25140 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
25141 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
25142 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
25143 ,p_ae_header_id => NULL
25144 );
25145
25146 IF (C_LEVEL_ERROR>= g_log_level) THEN
25147 trace
25148 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25149 ,p_level => C_LEVEL_ERROR
25150 ,p_module => l_log_module);
25151 END IF;
25152 END IF;
25153 END IF;
25154 --
25155 --
25156 ------------------------------------------------------------------------------------------------
25157 -- 4219869 Business Flow
25158 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
25159 -- Prior Entry. Currently, the following code is always generated.
25160 ------------------------------------------------------------------------------------------------
25161 XLA_AE_LINES_PKG.ValidateCurrentLine;
25162
25163 ------------------------------------------------------------------------------------
25164 -- 4219869 Business Flow
25165 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
25166 ------------------------------------------------------------------------------------
25167 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25168
25169 ----------------------------------------------------------------------------------
25170 -- 4219869 Business Flow
25171 -- Update journal entry status -- Need to generate this within IF <condition>
25172 ----------------------------------------------------------------------------------
25173 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25174 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
25175 ,p_balance_type_code => l_balance_type_code
25176 );
25177
25178 -------------------------------------------------------------------------------------------
25179 -- 4262811 - Generate the Accrual Reversal lines
25180 -------------------------------------------------------------------------------------------
25181 BEGIN
25182 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
25183 (g_array_event(p_event_id).array_value_num('header_index'));
25184 IF l_acc_rev_flag IS NULL THEN
25185 l_acc_rev_flag := 'N';
25186 END IF;
25187 EXCEPTION
25188 WHEN OTHERS THEN
25189 l_acc_rev_flag := 'N';
25190 END;
25191 --
25192 IF (l_acc_rev_flag = 'Y') THEN
25193
25194 -- 4645092 ------------------------------------------------------------------------------
25195 -- To allow MPA report to determine if it should generate report process
25196 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
25197 ------------------------------------------------------------------------------------------
25198
25199 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
25200 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
25201 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
25202 -- call ADRs
25203 -- Bug 4922099
25204 --
25205 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25206 (NVL(l_actual_upg_option, 'N') = 'O') OR
25207 (NVL(l_enc_upg_option, 'N') = 'O')
25208 )
25209 THEN
25210 NULL;
25211 --
25212 --
25213
25214 l_ccid := AcctDerRule_11(
25215 p_application_id => p_application_id
25216 , p_ae_header_id => l_ae_header_id
25217 , p_source_3 => p_source_3
25218 , x_transaction_coa_id => l_adr_transaction_coa_id
25219 , x_accounting_coa_id => l_adr_accounting_coa_id
25220 , x_value_type_code => l_adr_value_type_code
25221 , p_side => 'NA'
25222 );
25223
25224 xla_ae_lines_pkg.set_ccid(
25225 p_code_combination_id => l_ccid
25226 , p_value_type_code => l_adr_value_type_code
25227 , p_transaction_coa_id => l_adr_transaction_coa_id
25228 , p_accounting_coa_id => l_adr_accounting_coa_id
25229 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
25230 , p_adr_type_code => 'S'
25231 , p_component_type => l_component_type
25232 , p_component_code => l_component_code
25233 , p_component_type_code => l_component_type_code
25234 , p_component_appl_id => l_component_appl_id
25235 , p_amb_context_code => l_amb_context_code
25236 , p_side => 'NA'
25237 );
25238
25239
25240 l_segment := AcctDerRule_6(
25241 p_application_id => p_application_id
25242 , p_ae_header_id => l_ae_header_id
25243 , x_transaction_coa_id => l_adr_transaction_coa_id
25244 , x_accounting_coa_id => l_adr_accounting_coa_id
25245 , x_flexfield_segment_code => l_adr_flexfield_segment_code
25246 , x_flex_value_set_id => l_adr_flex_value_set_id
25247 , x_value_type_code => l_adr_value_type_code
25248 , x_value_combination_id => l_adr_value_combination_id
25249 , x_value_segment_code => l_adr_value_segment_code
25250 , p_side => 'NA'
25251 , p_override_seg_flag => 'Y'
25252 );
25253
25254 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
25255
25256 xla_ae_lines_pkg.set_segment(
25257 p_to_segment_code => 'GL_ACCOUNT'
25258 , p_segment_value => l_segment
25259 , p_from_segment_code => l_adr_value_segment_code
25260 , p_from_combination_id => l_adr_value_combination_id
25261 , p_value_type_code => l_adr_value_type_code
25262 , p_transaction_coa_id => l_adr_transaction_coa_id
25263 , p_accounting_coa_id => l_adr_accounting_coa_id
25264 , p_flexfield_segment_code => l_adr_flexfield_segment_code
25265 , p_flex_value_set_id => l_adr_flex_value_set_id
25266 , p_adr_code => 'FV_480201'
25267 , p_adr_type_code => 'S'
25268 , p_component_type => l_component_type
25269 , p_component_code => l_component_code
25270 , p_component_type_code => l_component_type_code
25271 , p_component_appl_id => l_component_appl_id
25272 , p_amb_context_code => l_amb_context_code
25273 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
25274 , p_event_class_code => 'PURCHASE_ORDER'
25275 , p_side => 'NA'
25276 );
25277
25278 END IF;
25279
25280 --
25281 --
25282 END IF;
25283
25284 --
25285 -- Update the line information that should be overwritten
25286 --
25287 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
25288 p_header_num => 1);
25289 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
25290
25291 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
25292
25293 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
25294 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
25295 END IF;
25296
25297 --
25298 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
25299 --
25300 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
25301 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
25302 ELSE
25303 ---------------------------------------------------------------------------------------------------
25304 -- 4262811a Switch Sign
25305 ---------------------------------------------------------------------------------------------------
25306 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
25307 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25308 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25309 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25310 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25311 -- 5132302
25312 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
25313 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25314
25315 END IF;
25316
25317 -- 4955764
25318 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25319 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
25320
25321
25322 XLA_AE_LINES_PKG.ValidateCurrentLine;
25323 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25324
25325 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25326 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
25327 ,p_balance_type_code => l_balance_type_code);
25328
25329 END IF;
25330
25331 -----------------------------------------------------------------------------------------
25332 -- 4262811 Multiperiod Accounting
25333 -----------------------------------------------------------------------------------------
25334 -- No MPA option is assigned.
25335
25336
25337 END IF;
25338 END IF;
25339 --
25340
25341 --
25342 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25343 trace
25344 (p_msg => 'END of AcctLineType_46'
25345 ,p_level => C_LEVEL_PROCEDURE
25346 ,p_module => l_log_module);
25347 END IF;
25348 --
25349 EXCEPTION
25350 WHEN xla_exceptions_pkg.application_exception THEN
25351 RAISE;
25352 WHEN OTHERS THEN
25353 xla_exceptions_pkg.raise_message
25354 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_46');
25355 END AcctLineType_46;
25356 --
25357
25358 ---------------------------------------
25359 --
25360 -- PRIVATE FUNCTION
25361 -- AcctLineType_47
25362 --
25363 ---------------------------------------
25364 PROCEDURE AcctLineType_47 (
25365 p_application_id IN NUMBER
25366 ,p_event_id IN NUMBER
25367 ,p_calculate_acctd_flag IN VARCHAR2
25368 ,p_calculate_g_l_flag IN VARCHAR2
25369 ,p_actual_flag IN OUT VARCHAR2
25370 ,p_balance_type_code OUT VARCHAR2
25371 ,p_gain_or_loss_ref OUT VARCHAR2
25372
25373 --PO Budget Account
25374 , p_source_3 IN NUMBER
25375 --Receiving Accounting Line Type
25376 , p_source_6 IN VARCHAR2
25377 --Applied to Application ID
25378 , p_source_7 IN NUMBER
25379 --Applied to Distribution Link Type
25380 , p_source_8 IN VARCHAR2
25381 --Applied to Entity Code
25382 , p_source_9 IN VARCHAR2
25383 --PO_DISTRIBUTION_ID
25384 , p_source_10 IN NUMBER
25385 --Applied To Purchase Document Identifier
25386 , p_source_11 IN NUMBER
25387 --DISTRIBUTION_IDENTIFIER
25388 , p_source_12 IN NUMBER
25389 --Distribution Type
25390 , p_source_13 IN VARCHAR2
25391 , p_source_13_meaning IN VARCHAR2
25392 --Encumbrance Reversal Amount Entered
25393 , p_source_14 IN NUMBER
25394 --Entered Currency Code
25395 , p_source_15 IN VARCHAR2
25396 --Transaction Encumbrance Reversal Amount
25397 , p_source_16 IN NUMBER
25398 --Costing Encumbrance Upgrade Option
25399 , p_source_17 IN VARCHAR2
25400 --Currency Conversion Date
25401 , p_source_19 IN DATE
25402 --Currency Conversion Rate
25403 , p_source_20 IN NUMBER
25404 --Currency Conversion Type
25405 , p_source_21 IN VARCHAR2
25406 --Purchasing Encumbrance Type Identifier
25407 , p_source_22 IN NUMBER
25408 --Federal Unpaid Unexpended Obligation Amount
25409 , p_source_29 IN NUMBER
25410 --Federal Unexpended Obligation Amount
25411 , p_source_34 IN NUMBER
25412 )
25413 IS
25414
25415 l_component_type VARCHAR2(80);
25416 l_component_code VARCHAR2(30);
25417 l_component_type_code VARCHAR2(1);
25418 l_component_appl_id INTEGER;
25419 l_amb_context_code VARCHAR2(30);
25420 l_entity_code VARCHAR2(30);
25421 l_event_class_code VARCHAR2(30);
25422 l_ae_header_id NUMBER;
25423 l_event_type_code VARCHAR2(30);
25424 l_line_definition_code VARCHAR2(30);
25425 l_line_definition_owner_code VARCHAR2(1);
25426 --
25427 -- adr variables
25428 l_segment VARCHAR2(30);
25429 l_ccid NUMBER;
25430 l_adr_transaction_coa_id NUMBER;
25431 l_adr_accounting_coa_id NUMBER;
25432 l_adr_flexfield_segment_code VARCHAR2(30);
25433 l_adr_flex_value_set_id NUMBER;
25434 l_adr_value_type_code VARCHAR2(30);
25435 l_adr_value_combination_id NUMBER;
25436 l_adr_value_segment_code VARCHAR2(30);
25437
25438 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
25439 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
25440 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
25441 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
25442
25443 -- 4262811 Variables ------------------------------------------------------------------------------------------
25444 l_entered_amt_idx NUMBER;
25445 l_accted_amt_idx NUMBER;
25446 l_acc_rev_flag VARCHAR2(1);
25447 l_accrual_line_num NUMBER;
25448 l_tmp_amt NUMBER;
25449 l_acc_rev_natural_side_code VARCHAR2(1);
25450
25451 l_num_entries NUMBER;
25452 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
25453 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
25454 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
25455 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
25456 l_recog_line_1 NUMBER;
25457 l_recog_line_2 NUMBER;
25458
25459 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
25460 l_bflow_applied_to_amt NUMBER; -- 5132302
25461 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
25462
25463 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
25464
25465 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
25466 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
25467
25468 ---------------------------------------------------------------------------------------------------------------
25469
25470
25471 --
25472 -- bulk performance
25473 --
25474 l_balance_type_code VARCHAR2(1);
25475 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
25476 l_log_module VARCHAR2(240);
25477
25478 --
25479 -- Upgrade strategy
25480 --
25481 l_actual_upg_option VARCHAR2(1);
25482 l_enc_upg_option VARCHAR2(1);
25483
25484 --
25485 BEGIN
25486 --
25487 IF g_log_enabled THEN
25488 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_47';
25489 END IF;
25490 --
25491 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25492
25493 trace
25494 (p_msg => 'BEGIN of AcctLineType_47'
25495 ,p_level => C_LEVEL_PROCEDURE
25496 ,p_module => l_log_module);
25497
25498 END IF;
25499 --
25500 l_component_type := 'AMB_JLT';
25501 l_component_code := 'FV_REV_PO_UNPAID_DR';
25502 l_component_type_code := 'S';
25503 l_component_appl_id := 707;
25504 l_amb_context_code := 'DEFAULT';
25505 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
25506 l_event_class_code := 'DELIVER_EXPENSE';
25507 l_event_type_code := 'DELIVER_EXPENSE_ALL';
25508 l_line_definition_owner_code := 'S';
25509 l_line_definition_code := 'FV_DELIVER_EXPENSE';
25510 --
25511 l_balance_type_code := 'A';
25512 l_segment := NULL;
25513 l_ccid := NULL;
25514 l_adr_transaction_coa_id := NULL;
25515 l_adr_accounting_coa_id := NULL;
25516 l_adr_flexfield_segment_code := NULL;
25517 l_adr_flex_value_set_id := NULL;
25518 l_adr_value_type_code := NULL;
25519 l_adr_value_combination_id := NULL;
25520 l_adr_value_segment_code := NULL;
25521
25522 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
25523 l_bflow_class_code := ''; -- 4219869 Business Flow
25524 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
25525 l_budgetary_control_flag := 'Y';
25526
25527 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25528 l_bflow_applied_to_amt := NULL; -- 5132302
25529 l_entered_amt_idx := NULL; -- 4262811
25530 l_accted_amt_idx := NULL; -- 4262811
25531 l_acc_rev_flag := NULL; -- 4262811
25532 l_accrual_line_num := NULL; -- 4262811
25533 l_tmp_amt := NULL; -- 4262811
25534 --
25535
25536 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
25537 l_balance_type_code <> 'B' THEN
25538 IF p_source_29 > 0 AND
25539 NVL(
25540 xla_ae_sources_pkg.GetSystemSourceChar(
25541 p_source_code => 'XLA_EVENT_TYPE_CODE'
25542 , p_source_type_code => 'Y'
25543 , p_source_application_id => 602
25544 ),'
25545 ') = 'DELIVER_EXPENSE' AND
25546 NVL(p_source_6,'
25547 ') = 'Charge'
25548 THEN
25549
25550 --
25551 XLA_AE_LINES_PKG.SetNewLine;
25552
25553 p_balance_type_code := l_balance_type_code;
25554 -- set the flag so later we will know whether the gain loss line needs to be created
25555
25556 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
25557 p_actual_flag :='A';
25558 END IF;
25559
25560 --
25561 -- bulk performance
25562 --
25563 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
25564 p_header_num => 0); -- 4262811
25565 --
25566 -- set accounting line options
25567 --
25568 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
25569 p_natural_side_code => 'D'
25570 , p_gain_or_loss_flag => 'N'
25571 , p_gl_transfer_mode_code => 'S'
25572 , p_acct_entry_type_code => 'A'
25573 , p_switch_side_flag => 'N'
25574 , p_merge_duplicate_code => 'N'
25575 );
25576 --
25577 l_acc_rev_natural_side_code := 'C'; -- 4262811
25578 --
25579 --
25580 -- set accounting line type info
25581 --
25582 xla_ae_lines_pkg.SetAcctLineType
25583 (p_component_type => l_component_type
25584 ,p_event_type_code => l_event_type_code
25585 ,p_line_definition_owner_code => l_line_definition_owner_code
25586 ,p_line_definition_code => l_line_definition_code
25587 ,p_accounting_line_code => l_component_code
25588 ,p_accounting_line_type_code => l_component_type_code
25589 ,p_accounting_line_appl_id => l_component_appl_id
25590 ,p_amb_context_code => l_amb_context_code
25591 ,p_entity_code => l_entity_code
25592 ,p_event_class_code => l_event_class_code);
25593 --
25594 -- set accounting class
25595 --
25596 xla_ae_lines_pkg.SetAcctClass(
25597 p_accounting_class_code => 'FEDERAL_EXP'
25598 , p_ae_header_id => l_ae_header_id
25599 );
25600
25601 --
25602 -- set rounding class
25603 --
25604 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
25605 'FEDERAL_EXP';
25606
25607 --
25608 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
25609 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
25610 --
25611 -- bulk performance
25612 --
25613 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
25614
25615 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
25616 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
25617
25618 -- 4955764
25619 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25620 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
25621
25622 -- 4458381 Public Sector Enh
25623
25624 --
25625 -- set accounting attributes for the line type
25626 --
25627 l_entered_amt_idx := 17;
25628 l_accted_amt_idx := 22;
25629 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25630 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
25631 l_rec_acct_attrs.array_num_value(1) := p_source_7;
25632 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
25633 l_rec_acct_attrs.array_char_value(2) := p_source_8;
25634 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
25635 l_rec_acct_attrs.array_char_value(3) := p_source_9;
25636 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
25637 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_10);
25638 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
25639 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
25640 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
25641 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
25642 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
25643 l_rec_acct_attrs.array_char_value(7) := p_source_13;
25644 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
25645 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
25646 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
25647 l_rec_acct_attrs.array_num_value(9) := p_source_14;
25648 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
25649 l_rec_acct_attrs.array_char_value(10) := p_source_15;
25650 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
25651 l_rec_acct_attrs.array_num_value(11) := p_source_16;
25652 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
25653 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
25654 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
25655 l_rec_acct_attrs.array_num_value(13) := p_source_14;
25656 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
25657 l_rec_acct_attrs.array_char_value(14) := p_source_15;
25658 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
25659 l_rec_acct_attrs.array_num_value(15) := p_source_16;
25660 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
25661 l_rec_acct_attrs.array_char_value(16) := p_source_17;
25662 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
25663 l_rec_acct_attrs.array_num_value(17) := p_source_34;
25664 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
25665 l_rec_acct_attrs.array_char_value(18) := p_source_15;
25666 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
25667 l_rec_acct_attrs.array_date_value(19) := p_source_19;
25668 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
25669 l_rec_acct_attrs.array_num_value(20) := p_source_20;
25670 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
25671 l_rec_acct_attrs.array_char_value(21) := p_source_21;
25672 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
25673 l_rec_acct_attrs.array_num_value(22) := p_source_29;
25674 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
25675 l_rec_acct_attrs.array_num_value(23) := p_source_22;
25676 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
25677 l_rec_acct_attrs.array_num_value(24) := p_source_22;
25678
25679 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
25680 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
25681
25682 ---------------------------------------------------------------------------------------------------------------
25683 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
25684 ---------------------------------------------------------------------------------------------------------------
25685 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
25686
25687 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25688 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25689
25690 IF xla_accounting_cache_pkg.GetValueChar
25691 (p_source_code => 'LEDGER_CATEGORY_CODE'
25692 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
25693 AND l_bflow_method_code = 'PRIOR_ENTRY'
25694 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
25695 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
25696 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
25697 )
25698 THEN
25699 xla_ae_lines_pkg.BflowUpgEntry
25700 (p_business_method_code => l_bflow_method_code
25701 ,p_business_class_code => l_bflow_class_code
25702 ,p_balance_type => l_balance_type_code);
25703 ELSE
25704 NULL;
25705 -- No business flow processing for business flow method of NONE.
25706 END IF;
25707
25708 --
25709 -- call analytical criteria
25710 --
25711
25712 --
25713 -- call description
25714 --
25715 -- No description or it is inherited.
25716 --
25717 -- call ADRs
25718 -- Bug 4922099
25719 --
25720 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25721 (NVL(l_actual_upg_option, 'N') = 'O') OR
25722 (NVL(l_enc_upg_option, 'N') = 'O')
25723 )
25724 THEN
25725 NULL;
25726 --
25727 --
25728
25729 l_ccid := AcctDerRule_11(
25730 p_application_id => p_application_id
25731 , p_ae_header_id => l_ae_header_id
25732 , p_source_3 => p_source_3
25733 , x_transaction_coa_id => l_adr_transaction_coa_id
25734 , x_accounting_coa_id => l_adr_accounting_coa_id
25735 , x_value_type_code => l_adr_value_type_code
25736 , p_side => 'NA'
25737 );
25738
25739 xla_ae_lines_pkg.set_ccid(
25740 p_code_combination_id => l_ccid
25741 , p_value_type_code => l_adr_value_type_code
25742 , p_transaction_coa_id => l_adr_transaction_coa_id
25743 , p_accounting_coa_id => l_adr_accounting_coa_id
25744 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
25745 , p_adr_type_code => 'S'
25746 , p_component_type => l_component_type
25747 , p_component_code => l_component_code
25748 , p_component_type_code => l_component_type_code
25749 , p_component_appl_id => l_component_appl_id
25750 , p_amb_context_code => l_amb_context_code
25751 , p_side => 'NA'
25752 );
25753
25754
25755 l_segment := AcctDerRule_5(
25756 p_application_id => p_application_id
25757 , p_ae_header_id => l_ae_header_id
25758 , x_transaction_coa_id => l_adr_transaction_coa_id
25759 , x_accounting_coa_id => l_adr_accounting_coa_id
25760 , x_flexfield_segment_code => l_adr_flexfield_segment_code
25761 , x_flex_value_set_id => l_adr_flex_value_set_id
25762 , x_value_type_code => l_adr_value_type_code
25763 , x_value_combination_id => l_adr_value_combination_id
25764 , x_value_segment_code => l_adr_value_segment_code
25765 , p_side => 'NA'
25766 , p_override_seg_flag => 'Y'
25767 );
25768
25769 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
25770
25771 xla_ae_lines_pkg.set_segment(
25772 p_to_segment_code => 'GL_ACCOUNT'
25773 , p_segment_value => l_segment
25774 , p_from_segment_code => l_adr_value_segment_code
25775 , p_from_combination_id => l_adr_value_combination_id
25776 , p_value_type_code => l_adr_value_type_code
25777 , p_transaction_coa_id => l_adr_transaction_coa_id
25778 , p_accounting_coa_id => l_adr_accounting_coa_id
25779 , p_flexfield_segment_code => l_adr_flexfield_segment_code
25780 , p_flex_value_set_id => l_adr_flex_value_set_id
25781 , p_adr_code => 'FV_480101'
25782 , p_adr_type_code => 'S'
25783 , p_component_type => l_component_type
25784 , p_component_code => l_component_code
25785 , p_component_type_code => l_component_type_code
25786 , p_component_appl_id => l_component_appl_id
25787 , p_amb_context_code => l_amb_context_code
25788 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
25789 , p_event_class_code => 'DELIVER_EXPENSE'
25790 , p_side => 'NA'
25791 );
25792
25793 END IF;
25794
25795 --
25796 --
25797 END IF;
25798 --
25799 -- Bug 4922099
25800 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
25801 (NVL(l_enc_upg_option, 'N') = 'O')
25802 ) AND
25803 (l_bflow_method_code = 'PRIOR_ENTRY')
25804 )
25805 THEN
25806 IF
25807 --
25808 1 = 2
25809 --
25810 THEN
25811 xla_accounting_err_pkg.build_message
25812 (p_appli_s_name => 'XLA'
25813 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25814 ,p_token_1 => 'LINE_NUMBER'
25815 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
25816 ,p_token_2 => 'LINE_TYPE_NAME'
25817 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
25818 l_component_type
25819 ,l_component_code
25820 ,l_component_type_code
25821 ,l_component_appl_id
25822 ,l_amb_context_code
25823 ,l_entity_code
25824 ,l_event_class_code
25825 )
25826 ,p_token_3 => 'OWNER'
25827 ,p_value_3 => xla_lookups_pkg.get_meaning(
25828 p_lookup_type => 'XLA_OWNER_TYPE'
25829 ,p_lookup_code => l_component_type_code
25830 )
25831 ,p_token_4 => 'PRODUCT_NAME'
25832 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
25833 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
25834 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
25835 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
25836 ,p_ae_header_id => NULL
25837 );
25838
25839 IF (C_LEVEL_ERROR>= g_log_level) THEN
25840 trace
25841 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25842 ,p_level => C_LEVEL_ERROR
25843 ,p_module => l_log_module);
25844 END IF;
25845 END IF;
25846 END IF;
25847 --
25848 --
25849 ------------------------------------------------------------------------------------------------
25850 -- 4219869 Business Flow
25851 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
25852 -- Prior Entry. Currently, the following code is always generated.
25853 ------------------------------------------------------------------------------------------------
25854 XLA_AE_LINES_PKG.ValidateCurrentLine;
25855
25856 ------------------------------------------------------------------------------------
25857 -- 4219869 Business Flow
25858 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
25859 ------------------------------------------------------------------------------------
25860 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25861
25862 ----------------------------------------------------------------------------------
25863 -- 4219869 Business Flow
25864 -- Update journal entry status -- Need to generate this within IF <condition>
25865 ----------------------------------------------------------------------------------
25866 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25867 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
25868 ,p_balance_type_code => l_balance_type_code
25869 );
25870
25871 -------------------------------------------------------------------------------------------
25872 -- 4262811 - Generate the Accrual Reversal lines
25873 -------------------------------------------------------------------------------------------
25874 BEGIN
25875 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
25876 (g_array_event(p_event_id).array_value_num('header_index'));
25877 IF l_acc_rev_flag IS NULL THEN
25878 l_acc_rev_flag := 'N';
25879 END IF;
25880 EXCEPTION
25881 WHEN OTHERS THEN
25882 l_acc_rev_flag := 'N';
25883 END;
25884 --
25885 IF (l_acc_rev_flag = 'Y') THEN
25886
25887 -- 4645092 ------------------------------------------------------------------------------
25888 -- To allow MPA report to determine if it should generate report process
25889 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
25890 ------------------------------------------------------------------------------------------
25891
25892 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
25893 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
25894 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
25895 -- call ADRs
25896 -- Bug 4922099
25897 --
25898 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25899 (NVL(l_actual_upg_option, 'N') = 'O') OR
25900 (NVL(l_enc_upg_option, 'N') = 'O')
25901 )
25902 THEN
25903 NULL;
25904 --
25905 --
25906
25907 l_ccid := AcctDerRule_11(
25908 p_application_id => p_application_id
25909 , p_ae_header_id => l_ae_header_id
25910 , p_source_3 => p_source_3
25911 , x_transaction_coa_id => l_adr_transaction_coa_id
25912 , x_accounting_coa_id => l_adr_accounting_coa_id
25913 , x_value_type_code => l_adr_value_type_code
25914 , p_side => 'NA'
25915 );
25916
25917 xla_ae_lines_pkg.set_ccid(
25918 p_code_combination_id => l_ccid
25919 , p_value_type_code => l_adr_value_type_code
25920 , p_transaction_coa_id => l_adr_transaction_coa_id
25921 , p_accounting_coa_id => l_adr_accounting_coa_id
25922 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
25923 , p_adr_type_code => 'S'
25924 , p_component_type => l_component_type
25925 , p_component_code => l_component_code
25926 , p_component_type_code => l_component_type_code
25927 , p_component_appl_id => l_component_appl_id
25928 , p_amb_context_code => l_amb_context_code
25929 , p_side => 'NA'
25930 );
25931
25932
25933 l_segment := AcctDerRule_5(
25934 p_application_id => p_application_id
25935 , p_ae_header_id => l_ae_header_id
25936 , x_transaction_coa_id => l_adr_transaction_coa_id
25937 , x_accounting_coa_id => l_adr_accounting_coa_id
25938 , x_flexfield_segment_code => l_adr_flexfield_segment_code
25939 , x_flex_value_set_id => l_adr_flex_value_set_id
25940 , x_value_type_code => l_adr_value_type_code
25941 , x_value_combination_id => l_adr_value_combination_id
25942 , x_value_segment_code => l_adr_value_segment_code
25943 , p_side => 'NA'
25944 , p_override_seg_flag => 'Y'
25945 );
25946
25947 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
25948
25949 xla_ae_lines_pkg.set_segment(
25950 p_to_segment_code => 'GL_ACCOUNT'
25951 , p_segment_value => l_segment
25952 , p_from_segment_code => l_adr_value_segment_code
25953 , p_from_combination_id => l_adr_value_combination_id
25954 , p_value_type_code => l_adr_value_type_code
25955 , p_transaction_coa_id => l_adr_transaction_coa_id
25956 , p_accounting_coa_id => l_adr_accounting_coa_id
25957 , p_flexfield_segment_code => l_adr_flexfield_segment_code
25958 , p_flex_value_set_id => l_adr_flex_value_set_id
25959 , p_adr_code => 'FV_480101'
25960 , p_adr_type_code => 'S'
25961 , p_component_type => l_component_type
25962 , p_component_code => l_component_code
25963 , p_component_type_code => l_component_type_code
25964 , p_component_appl_id => l_component_appl_id
25965 , p_amb_context_code => l_amb_context_code
25966 , p_entity_code => 'RCV_ACCOUNTING_EVENTS'
25967 , p_event_class_code => 'DELIVER_EXPENSE'
25968 , p_side => 'NA'
25969 );
25970
25971 END IF;
25972
25973 --
25974 --
25975 END IF;
25976
25977 --
25978 -- Update the line information that should be overwritten
25979 --
25980 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
25981 p_header_num => 1);
25982 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
25983
25984 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
25985
25986 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
25987 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
25988 END IF;
25989
25990 --
25991 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
25992 --
25993 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
25994 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
25995 ELSE
25996 ---------------------------------------------------------------------------------------------------
25997 -- 4262811a Switch Sign
25998 ---------------------------------------------------------------------------------------------------
25999 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
26000 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26001 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26002 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26003 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26004 -- 5132302
26005 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
26006 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26007
26008 END IF;
26009
26010 -- 4955764
26011 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26012 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
26013
26014
26015 XLA_AE_LINES_PKG.ValidateCurrentLine;
26016 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26017
26018 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26019 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
26020 ,p_balance_type_code => l_balance_type_code);
26021
26022 END IF;
26023
26024 -----------------------------------------------------------------------------------------
26025 -- 4262811 Multiperiod Accounting
26026 -----------------------------------------------------------------------------------------
26027 -- No MPA option is assigned.
26028
26029
26030 END IF;
26031 END IF;
26032 --
26033
26034 --
26035 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26036 trace
26037 (p_msg => 'END of AcctLineType_47'
26038 ,p_level => C_LEVEL_PROCEDURE
26039 ,p_module => l_log_module);
26040 END IF;
26041 --
26042 EXCEPTION
26043 WHEN xla_exceptions_pkg.application_exception THEN
26044 RAISE;
26045 WHEN OTHERS THEN
26046 xla_exceptions_pkg.raise_message
26047 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_47');
26048 END AcctLineType_47;
26049 --
26050
26051 ---------------------------------------
26052 --
26053 -- PRIVATE FUNCTION
26054 -- AcctLineType_48
26055 --
26056 ---------------------------------------
26057 PROCEDURE AcctLineType_48 (
26058 p_application_id IN NUMBER
26059 ,p_event_id IN NUMBER
26060 ,p_calculate_acctd_flag IN VARCHAR2
26061 ,p_calculate_g_l_flag IN VARCHAR2
26062 ,p_actual_flag IN OUT VARCHAR2
26063 ,p_balance_type_code OUT VARCHAR2
26064 ,p_gain_or_loss_ref OUT VARCHAR2
26065
26066 --PO Budget Account
26067 , p_source_3 IN NUMBER
26068 --Applied to Application ID
26069 , p_source_7 IN NUMBER
26070 --Applied to Distribution Link Type
26071 , p_source_8 IN VARCHAR2
26072 --Applied to Entity Code
26073 , p_source_9 IN VARCHAR2
26074 --Applied To Purchase Document Identifier
26075 , p_source_11 IN NUMBER
26076 --DISTRIBUTION_IDENTIFIER
26077 , p_source_12 IN NUMBER
26078 --Distribution Type
26079 , p_source_13 IN VARCHAR2
26080 , p_source_13_meaning IN VARCHAR2
26081 --Encumbrance Reversal Amount Entered
26082 , p_source_14 IN NUMBER
26083 --Entered Currency Code
26084 , p_source_15 IN VARCHAR2
26085 --Transaction Encumbrance Reversal Amount
26086 , p_source_16 IN NUMBER
26087 --Costing Encumbrance Upgrade Option
26088 , p_source_17 IN VARCHAR2
26089 --Currency Conversion Date
26090 , p_source_19 IN DATE
26091 --Currency Conversion Rate
26092 , p_source_20 IN NUMBER
26093 --Currency Conversion Type
26094 , p_source_21 IN VARCHAR2
26095 --Purchasing Encumbrance Type Identifier
26096 , p_source_22 IN NUMBER
26097 --TXN_PO_DISTRIBUTION_ID
26098 , p_source_23 IN NUMBER
26099 --Federal Unpaid Unexpended Obligation Amount
26100 , p_source_29 IN NUMBER
26101 )
26102 IS
26103
26104 l_component_type VARCHAR2(80);
26105 l_component_code VARCHAR2(30);
26106 l_component_type_code VARCHAR2(1);
26107 l_component_appl_id INTEGER;
26108 l_amb_context_code VARCHAR2(30);
26109 l_entity_code VARCHAR2(30);
26110 l_event_class_code VARCHAR2(30);
26111 l_ae_header_id NUMBER;
26112 l_event_type_code VARCHAR2(30);
26113 l_line_definition_code VARCHAR2(30);
26114 l_line_definition_owner_code VARCHAR2(1);
26115 --
26116 -- adr variables
26117 l_segment VARCHAR2(30);
26118 l_ccid NUMBER;
26119 l_adr_transaction_coa_id NUMBER;
26120 l_adr_accounting_coa_id NUMBER;
26121 l_adr_flexfield_segment_code VARCHAR2(30);
26122 l_adr_flex_value_set_id NUMBER;
26123 l_adr_value_type_code VARCHAR2(30);
26124 l_adr_value_combination_id NUMBER;
26125 l_adr_value_segment_code VARCHAR2(30);
26126
26127 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
26128 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
26129 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
26130 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
26131
26132 -- 4262811 Variables ------------------------------------------------------------------------------------------
26133 l_entered_amt_idx NUMBER;
26134 l_accted_amt_idx NUMBER;
26135 l_acc_rev_flag VARCHAR2(1);
26136 l_accrual_line_num NUMBER;
26137 l_tmp_amt NUMBER;
26138 l_acc_rev_natural_side_code VARCHAR2(1);
26139
26140 l_num_entries NUMBER;
26141 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
26142 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
26143 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
26144 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
26145 l_recog_line_1 NUMBER;
26146 l_recog_line_2 NUMBER;
26147
26148 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
26149 l_bflow_applied_to_amt NUMBER; -- 5132302
26150 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
26151
26152 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
26153
26154 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
26155 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
26156
26157 ---------------------------------------------------------------------------------------------------------------
26158
26159
26160 --
26161 -- bulk performance
26162 --
26163 l_balance_type_code VARCHAR2(1);
26164 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
26165 l_log_module VARCHAR2(240);
26166
26167 --
26168 -- Upgrade strategy
26169 --
26170 l_actual_upg_option VARCHAR2(1);
26171 l_enc_upg_option VARCHAR2(1);
26172
26173 --
26174 BEGIN
26175 --
26176 IF g_log_enabled THEN
26177 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_48';
26178 END IF;
26179 --
26180 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26181
26182 trace
26183 (p_msg => 'BEGIN of AcctLineType_48'
26184 ,p_level => C_LEVEL_PROCEDURE
26185 ,p_module => l_log_module);
26186
26187 END IF;
26188 --
26189 l_component_type := 'AMB_JLT';
26190 l_component_code := 'FV_REV_PO_UNPAID_DR_DTI';
26191 l_component_type_code := 'S';
26192 l_component_appl_id := 707;
26193 l_amb_context_code := 'DEFAULT';
26194 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
26195 l_event_class_code := 'PURCHASE_ORDER';
26196 l_event_type_code := 'PURCHASE_ORDER_ALL';
26197 l_line_definition_owner_code := 'S';
26198 l_line_definition_code := 'FV_PO_DEL_INV';
26199 --
26200 l_balance_type_code := 'A';
26201 l_segment := NULL;
26202 l_ccid := NULL;
26203 l_adr_transaction_coa_id := NULL;
26204 l_adr_accounting_coa_id := NULL;
26205 l_adr_flexfield_segment_code := NULL;
26206 l_adr_flex_value_set_id := NULL;
26207 l_adr_value_type_code := NULL;
26208 l_adr_value_combination_id := NULL;
26209 l_adr_value_segment_code := NULL;
26210
26211 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
26212 l_bflow_class_code := ''; -- 4219869 Business Flow
26213 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
26214 l_budgetary_control_flag := 'Y';
26215
26216 l_bflow_applied_to_amt_idx := NULL; -- 5132302
26217 l_bflow_applied_to_amt := NULL; -- 5132302
26218 l_entered_amt_idx := NULL; -- 4262811
26219 l_accted_amt_idx := NULL; -- 4262811
26220 l_acc_rev_flag := NULL; -- 4262811
26221 l_accrual_line_num := NULL; -- 4262811
26222 l_tmp_amt := NULL; -- 4262811
26223 --
26224
26225 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
26226 l_balance_type_code <> 'B' THEN
26227 IF NVL(
26228 xla_ae_sources_pkg.GetSystemSourceChar(
26229 p_source_code => 'XLA_EVENT_TYPE_CODE'
26230 , p_source_type_code => 'Y'
26231 , p_source_application_id => 602
26232 ),'
26233 ') = 'PO_DEL_INV' AND
26234 p_source_29 > 0
26235 THEN
26236
26237 --
26238 XLA_AE_LINES_PKG.SetNewLine;
26239
26240 p_balance_type_code := l_balance_type_code;
26241 -- set the flag so later we will know whether the gain loss line needs to be created
26242
26243 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
26244 p_actual_flag :='A';
26245 END IF;
26246
26247 --
26248 -- bulk performance
26249 --
26250 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
26251 p_header_num => 0); -- 4262811
26252 --
26253 -- set accounting line options
26254 --
26255 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
26256 p_natural_side_code => 'D'
26257 , p_gain_or_loss_flag => 'N'
26258 , p_gl_transfer_mode_code => 'S'
26259 , p_acct_entry_type_code => 'A'
26260 , p_switch_side_flag => 'N'
26261 , p_merge_duplicate_code => 'N'
26262 );
26263 --
26264 l_acc_rev_natural_side_code := 'C'; -- 4262811
26265 --
26266 --
26267 -- set accounting line type info
26268 --
26269 xla_ae_lines_pkg.SetAcctLineType
26270 (p_component_type => l_component_type
26271 ,p_event_type_code => l_event_type_code
26272 ,p_line_definition_owner_code => l_line_definition_owner_code
26273 ,p_line_definition_code => l_line_definition_code
26274 ,p_accounting_line_code => l_component_code
26275 ,p_accounting_line_type_code => l_component_type_code
26276 ,p_accounting_line_appl_id => l_component_appl_id
26277 ,p_amb_context_code => l_amb_context_code
26278 ,p_entity_code => l_entity_code
26279 ,p_event_class_code => l_event_class_code);
26280 --
26281 -- set accounting class
26282 --
26283 xla_ae_lines_pkg.SetAcctClass(
26284 p_accounting_class_code => 'FEDERAL_INV'
26285 , p_ae_header_id => l_ae_header_id
26286 );
26287
26288 --
26289 -- set rounding class
26290 --
26291 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
26292 'FEDERAL_INV';
26293
26294 --
26295 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
26296 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
26297 --
26298 -- bulk performance
26299 --
26300 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
26301
26302 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
26303 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
26304
26305 -- 4955764
26306 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26307 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
26308
26309 -- 4458381 Public Sector Enh
26310
26311 --
26312 -- set accounting attributes for the line type
26313 --
26314 l_entered_amt_idx := 17;
26315 l_accted_amt_idx := 22;
26316 l_bflow_applied_to_amt_idx := NULL; -- 5132302
26317 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
26318 l_rec_acct_attrs.array_num_value(1) := p_source_7;
26319 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
26320 l_rec_acct_attrs.array_char_value(2) := p_source_8;
26321 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
26322 l_rec_acct_attrs.array_char_value(3) := p_source_9;
26323 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
26324 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
26325 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
26326 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
26327 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
26328 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
26329 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
26330 l_rec_acct_attrs.array_char_value(7) := p_source_13;
26331 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
26332 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
26333 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
26334 l_rec_acct_attrs.array_num_value(9) := p_source_14;
26335 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
26336 l_rec_acct_attrs.array_char_value(10) := p_source_15;
26337 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
26338 l_rec_acct_attrs.array_num_value(11) := p_source_16;
26339 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
26340 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
26341 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
26342 l_rec_acct_attrs.array_num_value(13) := p_source_14;
26343 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
26344 l_rec_acct_attrs.array_char_value(14) := p_source_15;
26345 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
26346 l_rec_acct_attrs.array_num_value(15) := p_source_16;
26347 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
26348 l_rec_acct_attrs.array_char_value(16) := p_source_17;
26349 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
26350 l_rec_acct_attrs.array_num_value(17) := p_source_29;
26351 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
26352 l_rec_acct_attrs.array_char_value(18) := p_source_15;
26353 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
26354 l_rec_acct_attrs.array_date_value(19) := p_source_19;
26355 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
26356 l_rec_acct_attrs.array_num_value(20) := p_source_20;
26357 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
26358 l_rec_acct_attrs.array_char_value(21) := p_source_21;
26359 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
26360 l_rec_acct_attrs.array_num_value(22) := p_source_29;
26361 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
26362 l_rec_acct_attrs.array_num_value(23) := p_source_22;
26363 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
26364 l_rec_acct_attrs.array_num_value(24) := p_source_22;
26365
26366 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
26367 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
26368
26369 ---------------------------------------------------------------------------------------------------------------
26370 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
26371 ---------------------------------------------------------------------------------------------------------------
26372 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
26373
26374 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26375 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26376
26377 IF xla_accounting_cache_pkg.GetValueChar
26378 (p_source_code => 'LEDGER_CATEGORY_CODE'
26379 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
26380 AND l_bflow_method_code = 'PRIOR_ENTRY'
26381 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
26382 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
26383 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
26384 )
26385 THEN
26386 xla_ae_lines_pkg.BflowUpgEntry
26387 (p_business_method_code => l_bflow_method_code
26388 ,p_business_class_code => l_bflow_class_code
26389 ,p_balance_type => l_balance_type_code);
26390 ELSE
26391 NULL;
26392 -- No business flow processing for business flow method of NONE.
26393 END IF;
26394
26395 --
26396 -- call analytical criteria
26397 --
26398
26399 --
26400 -- call description
26401 --
26402 -- No description or it is inherited.
26403 --
26404 -- call ADRs
26405 -- Bug 4922099
26406 --
26407 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26408 (NVL(l_actual_upg_option, 'N') = 'O') OR
26409 (NVL(l_enc_upg_option, 'N') = 'O')
26410 )
26411 THEN
26412 NULL;
26413 --
26414 --
26415
26416 l_ccid := AcctDerRule_11(
26417 p_application_id => p_application_id
26418 , p_ae_header_id => l_ae_header_id
26419 , p_source_3 => p_source_3
26420 , x_transaction_coa_id => l_adr_transaction_coa_id
26421 , x_accounting_coa_id => l_adr_accounting_coa_id
26422 , x_value_type_code => l_adr_value_type_code
26423 , p_side => 'NA'
26424 );
26425
26426 xla_ae_lines_pkg.set_ccid(
26427 p_code_combination_id => l_ccid
26428 , p_value_type_code => l_adr_value_type_code
26429 , p_transaction_coa_id => l_adr_transaction_coa_id
26430 , p_accounting_coa_id => l_adr_accounting_coa_id
26431 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
26432 , p_adr_type_code => 'S'
26433 , p_component_type => l_component_type
26434 , p_component_code => l_component_code
26435 , p_component_type_code => l_component_type_code
26436 , p_component_appl_id => l_component_appl_id
26437 , p_amb_context_code => l_amb_context_code
26438 , p_side => 'NA'
26439 );
26440
26441
26442 l_segment := AcctDerRule_5(
26443 p_application_id => p_application_id
26444 , p_ae_header_id => l_ae_header_id
26445 , x_transaction_coa_id => l_adr_transaction_coa_id
26446 , x_accounting_coa_id => l_adr_accounting_coa_id
26447 , x_flexfield_segment_code => l_adr_flexfield_segment_code
26448 , x_flex_value_set_id => l_adr_flex_value_set_id
26449 , x_value_type_code => l_adr_value_type_code
26450 , x_value_combination_id => l_adr_value_combination_id
26451 , x_value_segment_code => l_adr_value_segment_code
26452 , p_side => 'NA'
26453 , p_override_seg_flag => 'Y'
26454 );
26455
26456 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
26457
26458 xla_ae_lines_pkg.set_segment(
26459 p_to_segment_code => 'GL_ACCOUNT'
26460 , p_segment_value => l_segment
26461 , p_from_segment_code => l_adr_value_segment_code
26462 , p_from_combination_id => l_adr_value_combination_id
26463 , p_value_type_code => l_adr_value_type_code
26464 , p_transaction_coa_id => l_adr_transaction_coa_id
26465 , p_accounting_coa_id => l_adr_accounting_coa_id
26466 , p_flexfield_segment_code => l_adr_flexfield_segment_code
26467 , p_flex_value_set_id => l_adr_flex_value_set_id
26468 , p_adr_code => 'FV_480101'
26469 , p_adr_type_code => 'S'
26470 , p_component_type => l_component_type
26471 , p_component_code => l_component_code
26472 , p_component_type_code => l_component_type_code
26473 , p_component_appl_id => l_component_appl_id
26474 , p_amb_context_code => l_amb_context_code
26475 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
26476 , p_event_class_code => 'PURCHASE_ORDER'
26477 , p_side => 'NA'
26478 );
26479
26480 END IF;
26481
26482 --
26483 --
26484 END IF;
26485 --
26486 -- Bug 4922099
26487 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
26488 (NVL(l_enc_upg_option, 'N') = 'O')
26489 ) AND
26490 (l_bflow_method_code = 'PRIOR_ENTRY')
26491 )
26492 THEN
26493 IF
26494 --
26495 1 = 2
26496 --
26497 THEN
26498 xla_accounting_err_pkg.build_message
26499 (p_appli_s_name => 'XLA'
26500 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26501 ,p_token_1 => 'LINE_NUMBER'
26502 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
26503 ,p_token_2 => 'LINE_TYPE_NAME'
26504 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
26505 l_component_type
26506 ,l_component_code
26507 ,l_component_type_code
26508 ,l_component_appl_id
26509 ,l_amb_context_code
26510 ,l_entity_code
26511 ,l_event_class_code
26512 )
26513 ,p_token_3 => 'OWNER'
26514 ,p_value_3 => xla_lookups_pkg.get_meaning(
26515 p_lookup_type => 'XLA_OWNER_TYPE'
26516 ,p_lookup_code => l_component_type_code
26517 )
26518 ,p_token_4 => 'PRODUCT_NAME'
26519 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
26520 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
26521 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
26522 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
26523 ,p_ae_header_id => NULL
26524 );
26525
26526 IF (C_LEVEL_ERROR>= g_log_level) THEN
26527 trace
26528 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26529 ,p_level => C_LEVEL_ERROR
26530 ,p_module => l_log_module);
26531 END IF;
26532 END IF;
26533 END IF;
26534 --
26535 --
26536 ------------------------------------------------------------------------------------------------
26537 -- 4219869 Business Flow
26538 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
26539 -- Prior Entry. Currently, the following code is always generated.
26540 ------------------------------------------------------------------------------------------------
26541 XLA_AE_LINES_PKG.ValidateCurrentLine;
26542
26543 ------------------------------------------------------------------------------------
26544 -- 4219869 Business Flow
26545 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
26546 ------------------------------------------------------------------------------------
26547 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26548
26549 ----------------------------------------------------------------------------------
26550 -- 4219869 Business Flow
26551 -- Update journal entry status -- Need to generate this within IF <condition>
26552 ----------------------------------------------------------------------------------
26553 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26554 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
26555 ,p_balance_type_code => l_balance_type_code
26556 );
26557
26558 -------------------------------------------------------------------------------------------
26559 -- 4262811 - Generate the Accrual Reversal lines
26560 -------------------------------------------------------------------------------------------
26561 BEGIN
26562 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
26563 (g_array_event(p_event_id).array_value_num('header_index'));
26564 IF l_acc_rev_flag IS NULL THEN
26565 l_acc_rev_flag := 'N';
26566 END IF;
26567 EXCEPTION
26568 WHEN OTHERS THEN
26569 l_acc_rev_flag := 'N';
26570 END;
26571 --
26572 IF (l_acc_rev_flag = 'Y') THEN
26573
26574 -- 4645092 ------------------------------------------------------------------------------
26575 -- To allow MPA report to determine if it should generate report process
26576 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
26577 ------------------------------------------------------------------------------------------
26578
26579 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
26580 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
26581 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
26582 -- call ADRs
26583 -- Bug 4922099
26584 --
26585 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26586 (NVL(l_actual_upg_option, 'N') = 'O') OR
26587 (NVL(l_enc_upg_option, 'N') = 'O')
26588 )
26589 THEN
26590 NULL;
26591 --
26592 --
26593
26594 l_ccid := AcctDerRule_11(
26595 p_application_id => p_application_id
26596 , p_ae_header_id => l_ae_header_id
26597 , p_source_3 => p_source_3
26598 , x_transaction_coa_id => l_adr_transaction_coa_id
26599 , x_accounting_coa_id => l_adr_accounting_coa_id
26600 , x_value_type_code => l_adr_value_type_code
26601 , p_side => 'NA'
26602 );
26603
26604 xla_ae_lines_pkg.set_ccid(
26605 p_code_combination_id => l_ccid
26606 , p_value_type_code => l_adr_value_type_code
26607 , p_transaction_coa_id => l_adr_transaction_coa_id
26608 , p_accounting_coa_id => l_adr_accounting_coa_id
26609 , p_adr_code => 'FV_PO_BUDGET_ACCOUNT'
26610 , p_adr_type_code => 'S'
26611 , p_component_type => l_component_type
26612 , p_component_code => l_component_code
26613 , p_component_type_code => l_component_type_code
26614 , p_component_appl_id => l_component_appl_id
26615 , p_amb_context_code => l_amb_context_code
26616 , p_side => 'NA'
26617 );
26618
26619
26620 l_segment := AcctDerRule_5(
26621 p_application_id => p_application_id
26622 , p_ae_header_id => l_ae_header_id
26623 , x_transaction_coa_id => l_adr_transaction_coa_id
26624 , x_accounting_coa_id => l_adr_accounting_coa_id
26625 , x_flexfield_segment_code => l_adr_flexfield_segment_code
26626 , x_flex_value_set_id => l_adr_flex_value_set_id
26627 , x_value_type_code => l_adr_value_type_code
26628 , x_value_combination_id => l_adr_value_combination_id
26629 , x_value_segment_code => l_adr_value_segment_code
26630 , p_side => 'NA'
26631 , p_override_seg_flag => 'Y'
26632 );
26633
26634 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
26635
26636 xla_ae_lines_pkg.set_segment(
26637 p_to_segment_code => 'GL_ACCOUNT'
26638 , p_segment_value => l_segment
26639 , p_from_segment_code => l_adr_value_segment_code
26640 , p_from_combination_id => l_adr_value_combination_id
26641 , p_value_type_code => l_adr_value_type_code
26642 , p_transaction_coa_id => l_adr_transaction_coa_id
26643 , p_accounting_coa_id => l_adr_accounting_coa_id
26644 , p_flexfield_segment_code => l_adr_flexfield_segment_code
26645 , p_flex_value_set_id => l_adr_flex_value_set_id
26646 , p_adr_code => 'FV_480101'
26647 , p_adr_type_code => 'S'
26648 , p_component_type => l_component_type
26649 , p_component_code => l_component_code
26650 , p_component_type_code => l_component_type_code
26651 , p_component_appl_id => l_component_appl_id
26652 , p_amb_context_code => l_amb_context_code
26653 , p_entity_code => 'MTL_ACCOUNTING_EVENTS'
26654 , p_event_class_code => 'PURCHASE_ORDER'
26655 , p_side => 'NA'
26656 );
26657
26658 END IF;
26659
26660 --
26661 --
26662 END IF;
26663
26664 --
26665 -- Update the line information that should be overwritten
26666 --
26667 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
26668 p_header_num => 1);
26669 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
26670
26671 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
26672
26673 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
26674 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
26675 END IF;
26676
26677 --
26678 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
26679 --
26680 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
26681 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
26682 ELSE
26683 ---------------------------------------------------------------------------------------------------
26684 -- 4262811a Switch Sign
26685 ---------------------------------------------------------------------------------------------------
26686 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
26687 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26688 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26689 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26690 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26691 -- 5132302
26692 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
26693 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26694
26695 END IF;
26696
26697 -- 4955764
26698 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26699 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
26700
26701
26702 XLA_AE_LINES_PKG.ValidateCurrentLine;
26703 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26704
26705 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26706 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
26707 ,p_balance_type_code => l_balance_type_code);
26708
26709 END IF;
26710
26711 -----------------------------------------------------------------------------------------
26712 -- 4262811 Multiperiod Accounting
26713 -----------------------------------------------------------------------------------------
26714 -- No MPA option is assigned.
26715
26716
26717 END IF;
26718 END IF;
26719 --
26720
26721 --
26722 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26723 trace
26724 (p_msg => 'END of AcctLineType_48'
26725 ,p_level => C_LEVEL_PROCEDURE
26726 ,p_module => l_log_module);
26727 END IF;
26728 --
26729 EXCEPTION
26730 WHEN xla_exceptions_pkg.application_exception THEN
26731 RAISE;
26732 WHEN OTHERS THEN
26733 xla_exceptions_pkg.raise_message
26734 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_48');
26735 END AcctLineType_48;
26736 --
26737
26738 ---------------------------------------
26739 --
26740 -- PRIVATE FUNCTION
26741 -- AcctLineType_49
26742 --
26743 ---------------------------------------
26744 PROCEDURE AcctLineType_49 (
26745 p_application_id IN NUMBER
26746 ,p_event_id IN NUMBER
26747 ,p_calculate_acctd_flag IN VARCHAR2
26748 ,p_calculate_g_l_flag IN VARCHAR2
26749 ,p_actual_flag IN OUT VARCHAR2
26750 ,p_balance_type_code OUT VARCHAR2
26751 ,p_gain_or_loss_ref OUT VARCHAR2
26752
26753 --Federal Fund Category
26754 , p_source_2 IN VARCHAR2
26755 --PO Budget Account
26756 , p_source_3 IN NUMBER
26757 --Receiving Accounting Line Type
26758 , p_source_6 IN VARCHAR2
26759 --DISTRIBUTION_IDENTIFIER
26760 , p_source_12 IN NUMBER
26761 --Distribution Type
26762 , p_source_13 IN VARCHAR2
26763 , p_source_13_meaning IN VARCHAR2
26764 --Encumbrance Reversal Amount Entered
26765 , p_source_14 IN NUMBER
26766 --Entered Currency Code
26767 , p_source_15 IN VARCHAR2
26768 --Transaction Encumbrance Reversal Amount
26769 , p_source_16 IN NUMBER
26770 --Costing Encumbrance Upgrade Option
26771 , p_source_17 IN VARCHAR2
26772 --Purchasing Encumbrance Type Identifier
26773 , p_source_22 IN NUMBER
26774 --Entered Amount
26775 , p_source_25 IN NUMBER
26776 --Accounted Amount
26777 , p_source_26 IN NUMBER
26778 --FEDERAL_RCV_SUB_LEDGER_ID
26779 , p_source_32 IN NUMBER
26780 --PARENT_TRANSACTION_ID
26781 , p_source_33 IN NUMBER
26782 )
26783 IS
26784
26785 l_component_type VARCHAR2(80);
26786 l_component_code VARCHAR2(30);
26787 l_component_type_code VARCHAR2(1);
26788 l_component_appl_id INTEGER;
26789 l_amb_context_code VARCHAR2(30);
26790 l_entity_code VARCHAR2(30);
26791 l_event_class_code VARCHAR2(30);
26792 l_ae_header_id NUMBER;
26793 l_event_type_code VARCHAR2(30);
26794 l_line_definition_code VARCHAR2(30);
26795 l_line_definition_owner_code VARCHAR2(1);
26796 --
26797 -- adr variables
26798 l_segment VARCHAR2(30);
26799 l_ccid NUMBER;
26800 l_adr_transaction_coa_id NUMBER;
26801 l_adr_accounting_coa_id NUMBER;
26802 l_adr_flexfield_segment_code VARCHAR2(30);
26803 l_adr_flex_value_set_id NUMBER;
26804 l_adr_value_type_code VARCHAR2(30);
26805 l_adr_value_combination_id NUMBER;
26806 l_adr_value_segment_code VARCHAR2(30);
26807
26808 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
26809 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
26810 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
26811 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
26812
26813 -- 4262811 Variables ------------------------------------------------------------------------------------------
26814 l_entered_amt_idx NUMBER;
26815 l_accted_amt_idx NUMBER;
26816 l_acc_rev_flag VARCHAR2(1);
26817 l_accrual_line_num NUMBER;
26818 l_tmp_amt NUMBER;
26819 l_acc_rev_natural_side_code VARCHAR2(1);
26820
26821 l_num_entries NUMBER;
26822 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
26823 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
26824 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
26825 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
26826 l_recog_line_1 NUMBER;
26827 l_recog_line_2 NUMBER;
26828
26829 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
26830 l_bflow_applied_to_amt NUMBER; -- 5132302
26831 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
26832
26833 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
26834
26835 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
26836 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
26837
26838 ---------------------------------------------------------------------------------------------------------------
26839
26840
26841 --
26842 -- bulk performance
26843 --
26844 l_balance_type_code VARCHAR2(1);
26845 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
26846 l_log_module VARCHAR2(240);
26847
26848 --
26849 -- Upgrade strategy
26850 --
26851 l_actual_upg_option VARCHAR2(1);
26852 l_enc_upg_option VARCHAR2(1);
26853
26854 --
26855 BEGIN
26856 --
26857 IF g_log_enabled THEN
26858 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_49';
26859 END IF;
26860 --
26861 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26862
26863 trace
26864 (p_msg => 'BEGIN of AcctLineType_49'
26865 ,p_level => C_LEVEL_PROCEDURE
26866 ,p_module => l_log_module);
26867
26868 END IF;
26869 --
26870 l_component_type := 'AMB_JLT';
26871 l_component_code := 'FV_REV_RECLASSIFY_APPR_CR';
26872 l_component_type_code := 'S';
26873 l_component_appl_id := 707;
26874 l_amb_context_code := 'DEFAULT';
26875 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
26876 l_event_class_code := 'DELIVER_EXPENSE';
26877 l_event_type_code := 'DELIVER_EXPENSE_ALL';
26878 l_line_definition_owner_code := 'S';
26879 l_line_definition_code := 'FV_RETURN_TO_RECEIVING';
26880 --
26881 l_balance_type_code := 'A';
26882 l_segment := NULL;
26883 l_ccid := NULL;
26884 l_adr_transaction_coa_id := NULL;
26885 l_adr_accounting_coa_id := NULL;
26886 l_adr_flexfield_segment_code := NULL;
26887 l_adr_flex_value_set_id := NULL;
26888 l_adr_value_type_code := NULL;
26889 l_adr_value_combination_id := NULL;
26890 l_adr_value_segment_code := NULL;
26891
26892 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
26893 l_bflow_class_code := 'FV_UNEXP_APPR'; -- 4219869 Business Flow
26894 l_inherit_desc_flag := 'Y'; -- 4219869 Business Flow
26895 l_budgetary_control_flag := 'Y';
26896
26897 l_bflow_applied_to_amt_idx := NULL; -- 5132302
26898 l_bflow_applied_to_amt := NULL; -- 5132302
26899 l_entered_amt_idx := NULL; -- 4262811
26900 l_accted_amt_idx := NULL; -- 4262811
26901 l_acc_rev_flag := NULL; -- 4262811
26902 l_accrual_line_num := NULL; -- 4262811
26903 l_tmp_amt := NULL; -- 4262811
26904 --
26905
26906 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
26907 l_balance_type_code <> 'B' THEN
26908 IF NVL(p_source_2,'
26909 ') = 'B' AND
26910 NVL(
26911 xla_ae_sources_pkg.GetSystemSourceChar(
26912 p_source_code => 'XLA_EVENT_TYPE_CODE'
26913 , p_source_type_code => 'Y'
26914 , p_source_application_id => 602
26915 ),'
26916 ') = 'RETURN_TO_RECEIVING' AND
26917 (NVL(p_source_2,'
26918 ') = 'A' OR
26919 NVL(p_source_2,'
26920 ') = 'C') AND
26921 NVL(p_source_6,'
26922 ') = 'Charge'
26923 THEN
26924
26925 --
26926 XLA_AE_LINES_PKG.SetNewLine;
26927
26928 p_balance_type_code := l_balance_type_code;
26929 -- set the flag so later we will know whether the gain loss line needs to be created
26930
26931 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
26932 p_actual_flag :='A';
26933 END IF;
26934
26935 --
26936 -- bulk performance
26937 --
26938 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
26939 p_header_num => 0); -- 4262811
26940 --
26941 -- set accounting line options
26942 --
26943 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
26944 p_natural_side_code => 'C'
26945 , p_gain_or_loss_flag => 'N'
26946 , p_gl_transfer_mode_code => 'S'
26947 , p_acct_entry_type_code => 'A'
26948 , p_switch_side_flag => 'N'
26949 , p_merge_duplicate_code => 'N'
26950 );
26951 --
26952 l_acc_rev_natural_side_code := 'D'; -- 4262811
26953 --
26954 --
26955 -- set accounting line type info
26956 --
26957 xla_ae_lines_pkg.SetAcctLineType
26958 (p_component_type => l_component_type
26959 ,p_event_type_code => l_event_type_code
26960 ,p_line_definition_owner_code => l_line_definition_owner_code
26961 ,p_line_definition_code => l_line_definition_code
26962 ,p_accounting_line_code => l_component_code
26963 ,p_accounting_line_type_code => l_component_type_code
26964 ,p_accounting_line_appl_id => l_component_appl_id
26965 ,p_amb_context_code => l_amb_context_code
26966 ,p_entity_code => l_entity_code
26967 ,p_event_class_code => l_event_class_code);
26968 --
26969 -- set accounting class
26970 --
26971 xla_ae_lines_pkg.SetAcctClass(
26972 p_accounting_class_code => 'FEDERAL_EXP'
26973 , p_ae_header_id => l_ae_header_id
26974 );
26975
26976 --
26977 -- set rounding class
26978 --
26979 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
26980 'FEDERAL_EXP';
26981
26982 --
26983 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
26984 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
26985 --
26986 -- bulk performance
26987 --
26988 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
26989
26990 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
26991 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
26992
26993 -- 4955764
26994 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26995 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
26996
26997 -- 4458381 Public Sector Enh
26998
26999 --
27000 -- set accounting attributes for the line type
27001 --
27002 l_entered_amt_idx := 17;
27003 l_accted_amt_idx := 19;
27004 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27005 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
27006 l_rec_acct_attrs.array_num_value(1) :=
27007 xla_ae_sources_pkg.GetSystemSourceNum(
27008 p_source_code => 'XLA_EVENT_APPL_ID'
27009 , p_source_type_code => 'Y'
27010 , p_source_application_id => 602
27011 );
27012 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
27013 l_rec_acct_attrs.array_char_value(2) := p_source_13;
27014 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
27015 l_rec_acct_attrs.array_char_value(3) :=
27016 xla_ae_sources_pkg.GetSystemSourceChar(
27017 p_source_code => 'XLA_ENTITY_CODE'
27018 , p_source_type_code => 'Y'
27019 , p_source_application_id => 602
27020 );
27021 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
27022 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_32);
27023 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
27024 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_33);
27025 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
27026 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
27027 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
27028 l_rec_acct_attrs.array_char_value(7) := p_source_13;
27029 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
27030 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
27031 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
27032 l_rec_acct_attrs.array_num_value(9) := p_source_14;
27033 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
27034 l_rec_acct_attrs.array_char_value(10) := p_source_15;
27035 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
27036 l_rec_acct_attrs.array_num_value(11) := p_source_16;
27037 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
27038 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
27039 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
27040 l_rec_acct_attrs.array_num_value(13) := p_source_14;
27041 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
27042 l_rec_acct_attrs.array_char_value(14) := p_source_15;
27043 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
27044 l_rec_acct_attrs.array_num_value(15) := p_source_16;
27045 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
27046 l_rec_acct_attrs.array_char_value(16) := p_source_17;
27047 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
27048 l_rec_acct_attrs.array_num_value(17) := p_source_25;
27049 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
27050 l_rec_acct_attrs.array_char_value(18) := p_source_15;
27051 l_rec_acct_attrs.array_acct_attr_code(19) := 'LEDGER_AMOUNT';
27052 l_rec_acct_attrs.array_num_value(19) := p_source_26;
27053 l_rec_acct_attrs.array_acct_attr_code(20) := 'UPG_CR_ENC_TYPE_ID';
27054 l_rec_acct_attrs.array_num_value(20) := p_source_22;
27055 l_rec_acct_attrs.array_acct_attr_code(21) := 'UPG_DR_ENC_TYPE_ID';
27056 l_rec_acct_attrs.array_num_value(21) := p_source_22;
27057
27058 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
27059 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
27060
27061 ---------------------------------------------------------------------------------------------------------------
27062 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
27063 ---------------------------------------------------------------------------------------------------------------
27064 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
27065
27066 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27067 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27068
27069 IF xla_accounting_cache_pkg.GetValueChar
27070 (p_source_code => 'LEDGER_CATEGORY_CODE'
27071 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
27072 AND l_bflow_method_code = 'PRIOR_ENTRY'
27073 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
27074 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
27075 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
27076 )
27077 THEN
27078 xla_ae_lines_pkg.BflowUpgEntry
27079 (p_business_method_code => l_bflow_method_code
27080 ,p_business_class_code => l_bflow_class_code
27081 ,p_balance_type => l_balance_type_code);
27082 ELSE
27083 NULL;
27084 XLA_AE_LINES_PKG.business_flow_validation(
27085 p_business_method_code => l_bflow_method_code
27086 ,p_business_class_code => l_bflow_class_code
27087 ,p_inherit_description_flag => l_inherit_desc_flag);
27088 END IF;
27089
27090 --
27091 -- call analytical criteria
27092 --
27093 -- Inherited Analytical Criteria for business flow method of Prior Entry.
27094 --
27095 -- call description
27096 --
27097 -- No description or it is inherited.
27098 --
27099 -- call ADRs
27100 -- Bug 4922099
27101 --
27102 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27103 (NVL(l_actual_upg_option, 'N') = 'O') OR
27104 (NVL(l_enc_upg_option, 'N') = 'O')
27105 )
27106 THEN
27107 NULL;
27108 --
27109 --
27110
27111 --
27112 --
27113 END IF;
27114 --
27115 -- Bug 4922099
27116 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
27117 (NVL(l_enc_upg_option, 'N') = 'O')
27118 ) AND
27119 (l_bflow_method_code = 'PRIOR_ENTRY')
27120 )
27121 THEN
27122 IF
27123 --
27124 1 = 1
27125 --
27126 THEN
27127 xla_accounting_err_pkg.build_message
27128 (p_appli_s_name => 'XLA'
27129 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27130 ,p_token_1 => 'LINE_NUMBER'
27131 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
27132 ,p_token_2 => 'LINE_TYPE_NAME'
27133 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
27134 l_component_type
27135 ,l_component_code
27136 ,l_component_type_code
27137 ,l_component_appl_id
27138 ,l_amb_context_code
27139 ,l_entity_code
27140 ,l_event_class_code
27141 )
27142 ,p_token_3 => 'OWNER'
27143 ,p_value_3 => xla_lookups_pkg.get_meaning(
27144 p_lookup_type => 'XLA_OWNER_TYPE'
27145 ,p_lookup_code => l_component_type_code
27146 )
27147 ,p_token_4 => 'PRODUCT_NAME'
27148 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
27149 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
27150 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
27151 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
27152 ,p_ae_header_id => NULL
27153 );
27154
27155 IF (C_LEVEL_ERROR>= g_log_level) THEN
27156 trace
27157 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27158 ,p_level => C_LEVEL_ERROR
27159 ,p_module => l_log_module);
27160 END IF;
27161 END IF;
27162 END IF;
27163 --
27164 --
27165 ------------------------------------------------------------------------------------------------
27166 -- 4219869 Business Flow
27167 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
27168 -- Prior Entry. Currently, the following code is always generated.
27169 ------------------------------------------------------------------------------------------------
27170 -- No ValidateCurrentLine for business flow method of Prior Entry
27171
27172 ------------------------------------------------------------------------------------
27173 -- 4219869 Business Flow
27174 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
27175 ------------------------------------------------------------------------------------
27176 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27177
27178 ----------------------------------------------------------------------------------
27179 -- 4219869 Business Flow
27180 -- Update journal entry status -- Need to generate this within IF <condition>
27181 ----------------------------------------------------------------------------------
27182 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27183 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
27184 ,p_balance_type_code => l_balance_type_code
27185 );
27186
27187 -------------------------------------------------------------------------------------------
27188 -- 4262811 - Generate the Accrual Reversal lines
27189 -------------------------------------------------------------------------------------------
27190 BEGIN
27191 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
27192 (g_array_event(p_event_id).array_value_num('header_index'));
27193 IF l_acc_rev_flag IS NULL THEN
27194 l_acc_rev_flag := 'N';
27195 END IF;
27196 EXCEPTION
27197 WHEN OTHERS THEN
27198 l_acc_rev_flag := 'N';
27199 END;
27200 --
27201 IF (l_acc_rev_flag = 'Y') THEN
27202
27203 -- 4645092 ------------------------------------------------------------------------------
27204 -- To allow MPA report to determine if it should generate report process
27205 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
27206 ------------------------------------------------------------------------------------------
27207
27208 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
27209 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
27210 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
27211 -- call ADRs
27212 -- Bug 4922099
27213 --
27214 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27215 (NVL(l_actual_upg_option, 'N') = 'O') OR
27216 (NVL(l_enc_upg_option, 'N') = 'O')
27217 )
27218 THEN
27219 NULL;
27220 --
27221 --
27222
27223 --
27224 --
27225 END IF;
27226
27227 --
27228 -- Update the line information that should be overwritten
27229 --
27230 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
27231 p_header_num => 1);
27232 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
27233
27234 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
27235
27236 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
27237 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
27238 END IF;
27239
27240 --
27241 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
27242 --
27243 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
27244 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
27245 ELSE
27246 ---------------------------------------------------------------------------------------------------
27247 -- 4262811a Switch Sign
27248 ---------------------------------------------------------------------------------------------------
27249 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
27250 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27251 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27252 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27253 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27254 -- 5132302
27255 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
27256 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27257
27258 END IF;
27259
27260 -- 4955764
27261 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27262 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
27263
27264
27265 XLA_AE_LINES_PKG.ValidateCurrentLine;
27266 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27267
27268 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27269 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
27270 ,p_balance_type_code => l_balance_type_code);
27271
27272 END IF;
27273
27274 -----------------------------------------------------------------------------------------
27275 -- 4262811 Multiperiod Accounting
27276 -----------------------------------------------------------------------------------------
27277 -- No MPA option is assigned.
27278
27279
27280 END IF;
27281 END IF;
27282 --
27283
27284 --
27285 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27286 trace
27287 (p_msg => 'END of AcctLineType_49'
27288 ,p_level => C_LEVEL_PROCEDURE
27289 ,p_module => l_log_module);
27290 END IF;
27291 --
27292 EXCEPTION
27293 WHEN xla_exceptions_pkg.application_exception THEN
27294 RAISE;
27295 WHEN OTHERS THEN
27296 xla_exceptions_pkg.raise_message
27297 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_49');
27298 END AcctLineType_49;
27299 --
27300
27301 ---------------------------------------
27302 --
27303 -- PRIVATE FUNCTION
27304 -- AcctLineType_50
27305 --
27306 ---------------------------------------
27307 PROCEDURE AcctLineType_50 (
27308 p_application_id IN NUMBER
27309 ,p_event_id IN NUMBER
27310 ,p_calculate_acctd_flag IN VARCHAR2
27311 ,p_calculate_g_l_flag IN VARCHAR2
27312 ,p_actual_flag IN OUT VARCHAR2
27313 ,p_balance_type_code OUT VARCHAR2
27314 ,p_gain_or_loss_ref OUT VARCHAR2
27315
27316 --Federal Fund Category
27317 , p_source_2 IN VARCHAR2
27318 --PO Budget Account
27319 , p_source_3 IN NUMBER
27320 --Applied to Application ID
27321 , p_source_7 IN NUMBER
27322 --Applied to Distribution Link Type
27323 , p_source_8 IN VARCHAR2
27324 --Applied to Entity Code
27325 , p_source_9 IN VARCHAR2
27326 --Applied To Purchase Document Identifier
27327 , p_source_11 IN NUMBER
27328 --DISTRIBUTION_IDENTIFIER
27329 , p_source_12 IN NUMBER
27330 --Distribution Type
27331 , p_source_13 IN VARCHAR2
27332 , p_source_13_meaning IN VARCHAR2
27333 --Encumbrance Reversal Amount Entered
27334 , p_source_14 IN NUMBER
27335 --Entered Currency Code
27336 , p_source_15 IN VARCHAR2
27337 --Transaction Encumbrance Reversal Amount
27338 , p_source_16 IN NUMBER
27339 --Costing Encumbrance Upgrade Option
27340 , p_source_17 IN VARCHAR2
27341 --Purchasing Encumbrance Type Identifier
27342 , p_source_22 IN NUMBER
27343 --TXN_PO_DISTRIBUTION_ID
27344 , p_source_23 IN NUMBER
27345 --Entered Amount
27346 , p_source_25 IN NUMBER
27347 --Accounted Amount
27348 , p_source_26 IN NUMBER
27349 )
27350 IS
27351
27352 l_component_type VARCHAR2(80);
27353 l_component_code VARCHAR2(30);
27354 l_component_type_code VARCHAR2(1);
27355 l_component_appl_id INTEGER;
27356 l_amb_context_code VARCHAR2(30);
27357 l_entity_code VARCHAR2(30);
27358 l_event_class_code VARCHAR2(30);
27359 l_ae_header_id NUMBER;
27360 l_event_type_code VARCHAR2(30);
27361 l_line_definition_code VARCHAR2(30);
27362 l_line_definition_owner_code VARCHAR2(1);
27363 --
27364 -- adr variables
27365 l_segment VARCHAR2(30);
27366 l_ccid NUMBER;
27367 l_adr_transaction_coa_id NUMBER;
27368 l_adr_accounting_coa_id NUMBER;
27369 l_adr_flexfield_segment_code VARCHAR2(30);
27370 l_adr_flex_value_set_id NUMBER;
27371 l_adr_value_type_code VARCHAR2(30);
27372 l_adr_value_combination_id NUMBER;
27373 l_adr_value_segment_code VARCHAR2(30);
27374
27375 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
27376 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
27377 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
27378 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
27379
27380 -- 4262811 Variables ------------------------------------------------------------------------------------------
27381 l_entered_amt_idx NUMBER;
27382 l_accted_amt_idx NUMBER;
27383 l_acc_rev_flag VARCHAR2(1);
27384 l_accrual_line_num NUMBER;
27385 l_tmp_amt NUMBER;
27386 l_acc_rev_natural_side_code VARCHAR2(1);
27387
27388 l_num_entries NUMBER;
27389 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
27390 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
27391 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
27392 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
27393 l_recog_line_1 NUMBER;
27394 l_recog_line_2 NUMBER;
27395
27396 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
27397 l_bflow_applied_to_amt NUMBER; -- 5132302
27398 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
27399
27400 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
27401
27402 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
27403 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
27404
27405 ---------------------------------------------------------------------------------------------------------------
27406
27407
27408 --
27409 -- bulk performance
27410 --
27411 l_balance_type_code VARCHAR2(1);
27412 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
27413 l_log_module VARCHAR2(240);
27414
27415 --
27416 -- Upgrade strategy
27417 --
27418 l_actual_upg_option VARCHAR2(1);
27419 l_enc_upg_option VARCHAR2(1);
27420
27421 --
27422 BEGIN
27423 --
27424 IF g_log_enabled THEN
27425 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_50';
27426 END IF;
27427 --
27428 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27429
27430 trace
27431 (p_msg => 'BEGIN of AcctLineType_50'
27432 ,p_level => C_LEVEL_PROCEDURE
27433 ,p_module => l_log_module);
27434
27435 END IF;
27436 --
27437 l_component_type := 'AMB_JLT';
27438 l_component_code := 'FV_REV_RECLASSIFY_APPR_CR_RTI';
27439 l_component_type_code := 'S';
27440 l_component_appl_id := 707;
27441 l_amb_context_code := 'DEFAULT';
27442 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
27443 l_event_class_code := 'PURCHASE_ORDER';
27444 l_event_type_code := 'PURCHASE_ORDER_ALL';
27445 l_line_definition_owner_code := 'S';
27446 l_line_definition_code := 'FV_RET_RI_INV';
27447 --
27448 l_balance_type_code := 'A';
27449 l_segment := NULL;
27450 l_ccid := NULL;
27451 l_adr_transaction_coa_id := NULL;
27452 l_adr_accounting_coa_id := NULL;
27453 l_adr_flexfield_segment_code := NULL;
27454 l_adr_flex_value_set_id := NULL;
27455 l_adr_value_type_code := NULL;
27456 l_adr_value_combination_id := NULL;
27457 l_adr_value_segment_code := NULL;
27458
27459 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
27460 l_bflow_class_code := 'FV_UNEXP_APPR'; -- 4219869 Business Flow
27461 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
27462 l_budgetary_control_flag := 'Y';
27463
27464 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27465 l_bflow_applied_to_amt := NULL; -- 5132302
27466 l_entered_amt_idx := NULL; -- 4262811
27467 l_accted_amt_idx := NULL; -- 4262811
27468 l_acc_rev_flag := NULL; -- 4262811
27469 l_accrual_line_num := NULL; -- 4262811
27470 l_tmp_amt := NULL; -- 4262811
27471 --
27472
27473 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
27474 l_balance_type_code <> 'B' THEN
27475 IF (NVL(p_source_2,'
27476 ') = 'A' OR
27477 NVL(p_source_2,'
27478 ') = 'B' OR
27479 NVL(p_source_2,'
27480 ') = 'C') AND
27481 NVL(
27482 xla_ae_sources_pkg.GetSystemSourceChar(
27483 p_source_code => 'XLA_EVENT_TYPE_CODE'
27484 , p_source_type_code => 'Y'
27485 , p_source_application_id => 602
27486 ),'
27487 ') = 'RET_RI_INV'
27488 THEN
27489
27490 --
27491 XLA_AE_LINES_PKG.SetNewLine;
27492
27493 p_balance_type_code := l_balance_type_code;
27494 -- set the flag so later we will know whether the gain loss line needs to be created
27495
27496 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
27497 p_actual_flag :='A';
27498 END IF;
27499
27500 --
27501 -- bulk performance
27502 --
27503 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
27504 p_header_num => 0); -- 4262811
27505 --
27506 -- set accounting line options
27507 --
27508 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
27509 p_natural_side_code => 'C'
27510 , p_gain_or_loss_flag => 'N'
27511 , p_gl_transfer_mode_code => 'S'
27512 , p_acct_entry_type_code => 'A'
27513 , p_switch_side_flag => 'N'
27514 , p_merge_duplicate_code => 'N'
27515 );
27516 --
27517 l_acc_rev_natural_side_code := 'D'; -- 4262811
27518 --
27519 --
27520 -- set accounting line type info
27521 --
27522 xla_ae_lines_pkg.SetAcctLineType
27523 (p_component_type => l_component_type
27524 ,p_event_type_code => l_event_type_code
27525 ,p_line_definition_owner_code => l_line_definition_owner_code
27526 ,p_line_definition_code => l_line_definition_code
27527 ,p_accounting_line_code => l_component_code
27528 ,p_accounting_line_type_code => l_component_type_code
27529 ,p_accounting_line_appl_id => l_component_appl_id
27530 ,p_amb_context_code => l_amb_context_code
27531 ,p_entity_code => l_entity_code
27532 ,p_event_class_code => l_event_class_code);
27533 --
27534 -- set accounting class
27535 --
27536 xla_ae_lines_pkg.SetAcctClass(
27537 p_accounting_class_code => 'FEDERAL_INV'
27538 , p_ae_header_id => l_ae_header_id
27539 );
27540
27541 --
27542 -- set rounding class
27543 --
27544 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
27545 'FEDERAL_INV';
27546
27547 --
27548 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
27549 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
27550 --
27551 -- bulk performance
27552 --
27553 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
27554
27555 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
27556 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
27557
27558 -- 4955764
27559 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27560 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
27561
27562 -- 4458381 Public Sector Enh
27563
27564 --
27565 -- set accounting attributes for the line type
27566 --
27567 l_entered_amt_idx := 17;
27568 l_accted_amt_idx := 19;
27569 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27570 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
27571 l_rec_acct_attrs.array_num_value(1) := p_source_7;
27572 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
27573 l_rec_acct_attrs.array_char_value(2) := p_source_8;
27574 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
27575 l_rec_acct_attrs.array_char_value(3) := p_source_9;
27576 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
27577 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
27578 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
27579 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
27580 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
27581 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
27582 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
27583 l_rec_acct_attrs.array_char_value(7) := p_source_13;
27584 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
27585 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
27586 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
27587 l_rec_acct_attrs.array_num_value(9) := p_source_14;
27588 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
27589 l_rec_acct_attrs.array_char_value(10) := p_source_15;
27590 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
27591 l_rec_acct_attrs.array_num_value(11) := p_source_16;
27592 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
27593 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
27594 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
27595 l_rec_acct_attrs.array_num_value(13) := p_source_14;
27596 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
27597 l_rec_acct_attrs.array_char_value(14) := p_source_15;
27598 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
27599 l_rec_acct_attrs.array_num_value(15) := p_source_16;
27600 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
27601 l_rec_acct_attrs.array_char_value(16) := p_source_17;
27602 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
27603 l_rec_acct_attrs.array_num_value(17) := p_source_25;
27604 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
27605 l_rec_acct_attrs.array_char_value(18) := p_source_15;
27606 l_rec_acct_attrs.array_acct_attr_code(19) := 'LEDGER_AMOUNT';
27607 l_rec_acct_attrs.array_num_value(19) := p_source_26;
27608 l_rec_acct_attrs.array_acct_attr_code(20) := 'UPG_CR_ENC_TYPE_ID';
27609 l_rec_acct_attrs.array_num_value(20) := p_source_22;
27610 l_rec_acct_attrs.array_acct_attr_code(21) := 'UPG_DR_ENC_TYPE_ID';
27611 l_rec_acct_attrs.array_num_value(21) := p_source_22;
27612
27613 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
27614 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
27615
27616 ---------------------------------------------------------------------------------------------------------------
27617 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
27618 ---------------------------------------------------------------------------------------------------------------
27619 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
27620
27621 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27622 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27623
27624 IF xla_accounting_cache_pkg.GetValueChar
27625 (p_source_code => 'LEDGER_CATEGORY_CODE'
27626 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
27627 AND l_bflow_method_code = 'PRIOR_ENTRY'
27628 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
27629 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
27630 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
27631 )
27632 THEN
27633 xla_ae_lines_pkg.BflowUpgEntry
27634 (p_business_method_code => l_bflow_method_code
27635 ,p_business_class_code => l_bflow_class_code
27636 ,p_balance_type => l_balance_type_code);
27637 ELSE
27638 NULL;
27639 XLA_AE_LINES_PKG.business_flow_validation(
27640 p_business_method_code => l_bflow_method_code
27641 ,p_business_class_code => l_bflow_class_code
27642 ,p_inherit_description_flag => l_inherit_desc_flag);
27643 END IF;
27644
27645 --
27646 -- call analytical criteria
27647 --
27648 -- Inherited Analytical Criteria for business flow method of Prior Entry.
27649 --
27650 -- call description
27651 --
27652 -- No description or it is inherited.
27653 --
27654 -- call ADRs
27655 -- Bug 4922099
27656 --
27657 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27658 (NVL(l_actual_upg_option, 'N') = 'O') OR
27659 (NVL(l_enc_upg_option, 'N') = 'O')
27660 )
27661 THEN
27662 NULL;
27663 --
27664 --
27665
27666 --
27667 --
27668 END IF;
27669 --
27670 -- Bug 4922099
27671 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
27672 (NVL(l_enc_upg_option, 'N') = 'O')
27673 ) AND
27674 (l_bflow_method_code = 'PRIOR_ENTRY')
27675 )
27676 THEN
27677 IF
27678 --
27679 1 = 1
27680 --
27681 THEN
27682 xla_accounting_err_pkg.build_message
27683 (p_appli_s_name => 'XLA'
27684 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27685 ,p_token_1 => 'LINE_NUMBER'
27686 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
27687 ,p_token_2 => 'LINE_TYPE_NAME'
27688 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
27689 l_component_type
27690 ,l_component_code
27691 ,l_component_type_code
27692 ,l_component_appl_id
27693 ,l_amb_context_code
27694 ,l_entity_code
27695 ,l_event_class_code
27696 )
27697 ,p_token_3 => 'OWNER'
27698 ,p_value_3 => xla_lookups_pkg.get_meaning(
27699 p_lookup_type => 'XLA_OWNER_TYPE'
27700 ,p_lookup_code => l_component_type_code
27701 )
27702 ,p_token_4 => 'PRODUCT_NAME'
27703 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
27704 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
27705 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
27706 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
27707 ,p_ae_header_id => NULL
27708 );
27709
27710 IF (C_LEVEL_ERROR>= g_log_level) THEN
27711 trace
27712 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27713 ,p_level => C_LEVEL_ERROR
27714 ,p_module => l_log_module);
27715 END IF;
27716 END IF;
27717 END IF;
27718 --
27719 --
27720 ------------------------------------------------------------------------------------------------
27721 -- 4219869 Business Flow
27722 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
27723 -- Prior Entry. Currently, the following code is always generated.
27724 ------------------------------------------------------------------------------------------------
27725 -- No ValidateCurrentLine for business flow method of Prior Entry
27726
27727 ------------------------------------------------------------------------------------
27728 -- 4219869 Business Flow
27729 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
27730 ------------------------------------------------------------------------------------
27731 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27732
27733 ----------------------------------------------------------------------------------
27734 -- 4219869 Business Flow
27735 -- Update journal entry status -- Need to generate this within IF <condition>
27736 ----------------------------------------------------------------------------------
27737 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27738 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
27739 ,p_balance_type_code => l_balance_type_code
27740 );
27741
27742 -------------------------------------------------------------------------------------------
27743 -- 4262811 - Generate the Accrual Reversal lines
27744 -------------------------------------------------------------------------------------------
27745 BEGIN
27746 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
27747 (g_array_event(p_event_id).array_value_num('header_index'));
27748 IF l_acc_rev_flag IS NULL THEN
27749 l_acc_rev_flag := 'N';
27750 END IF;
27751 EXCEPTION
27752 WHEN OTHERS THEN
27753 l_acc_rev_flag := 'N';
27754 END;
27755 --
27756 IF (l_acc_rev_flag = 'Y') THEN
27757
27758 -- 4645092 ------------------------------------------------------------------------------
27759 -- To allow MPA report to determine if it should generate report process
27760 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
27761 ------------------------------------------------------------------------------------------
27762
27763 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
27764 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
27765 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
27766 -- call ADRs
27767 -- Bug 4922099
27768 --
27769 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27770 (NVL(l_actual_upg_option, 'N') = 'O') OR
27771 (NVL(l_enc_upg_option, 'N') = 'O')
27772 )
27773 THEN
27774 NULL;
27775 --
27776 --
27777
27778 --
27779 --
27780 END IF;
27781
27782 --
27783 -- Update the line information that should be overwritten
27784 --
27785 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
27786 p_header_num => 1);
27787 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
27788
27789 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
27790
27791 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
27792 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
27793 END IF;
27794
27795 --
27796 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
27797 --
27798 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
27799 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
27800 ELSE
27801 ---------------------------------------------------------------------------------------------------
27802 -- 4262811a Switch Sign
27803 ---------------------------------------------------------------------------------------------------
27804 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
27805 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27806 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27807 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27808 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27809 -- 5132302
27810 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
27811 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27812
27813 END IF;
27814
27815 -- 4955764
27816 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27817 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
27818
27819
27820 XLA_AE_LINES_PKG.ValidateCurrentLine;
27821 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27822
27823 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27824 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
27825 ,p_balance_type_code => l_balance_type_code);
27826
27827 END IF;
27828
27829 -----------------------------------------------------------------------------------------
27830 -- 4262811 Multiperiod Accounting
27831 -----------------------------------------------------------------------------------------
27832 -- No MPA option is assigned.
27833
27834
27835 END IF;
27836 END IF;
27837 --
27838
27839 --
27840 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27841 trace
27842 (p_msg => 'END of AcctLineType_50'
27843 ,p_level => C_LEVEL_PROCEDURE
27844 ,p_module => l_log_module);
27845 END IF;
27846 --
27847 EXCEPTION
27848 WHEN xla_exceptions_pkg.application_exception THEN
27849 RAISE;
27850 WHEN OTHERS THEN
27851 xla_exceptions_pkg.raise_message
27852 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_50');
27853 END AcctLineType_50;
27854 --
27855
27856 ---------------------------------------
27857 --
27858 -- PRIVATE FUNCTION
27859 -- AcctLineType_51
27860 --
27861 ---------------------------------------
27862 PROCEDURE AcctLineType_51 (
27863 p_application_id IN NUMBER
27864 ,p_event_id IN NUMBER
27865 ,p_calculate_acctd_flag IN VARCHAR2
27866 ,p_calculate_g_l_flag IN VARCHAR2
27867 ,p_actual_flag IN OUT VARCHAR2
27868 ,p_balance_type_code OUT VARCHAR2
27869 ,p_gain_or_loss_ref OUT VARCHAR2
27870
27871 --Federal Fund Category
27872 , p_source_2 IN VARCHAR2
27873 --PO Budget Account
27874 , p_source_3 IN NUMBER
27875 --Receiving Accounting Line Type
27876 , p_source_6 IN VARCHAR2
27877 --DISTRIBUTION_IDENTIFIER
27878 , p_source_12 IN NUMBER
27879 --Distribution Type
27880 , p_source_13 IN VARCHAR2
27881 , p_source_13_meaning IN VARCHAR2
27882 --Encumbrance Reversal Amount Entered
27883 , p_source_14 IN NUMBER
27884 --Entered Currency Code
27885 , p_source_15 IN VARCHAR2
27886 --Transaction Encumbrance Reversal Amount
27887 , p_source_16 IN NUMBER
27888 --Costing Encumbrance Upgrade Option
27889 , p_source_17 IN VARCHAR2
27890 --Purchasing Encumbrance Type Identifier
27891 , p_source_22 IN NUMBER
27892 --Entered Amount
27893 , p_source_25 IN NUMBER
27894 --Accounted Amount
27895 , p_source_26 IN NUMBER
27896 --FEDERAL_RCV_SUB_LEDGER_ID
27897 , p_source_32 IN NUMBER
27898 --PARENT_TRANSACTION_ID
27899 , p_source_33 IN NUMBER
27900 )
27901 IS
27902
27903 l_component_type VARCHAR2(80);
27904 l_component_code VARCHAR2(30);
27905 l_component_type_code VARCHAR2(1);
27906 l_component_appl_id INTEGER;
27907 l_amb_context_code VARCHAR2(30);
27908 l_entity_code VARCHAR2(30);
27909 l_event_class_code VARCHAR2(30);
27910 l_ae_header_id NUMBER;
27911 l_event_type_code VARCHAR2(30);
27912 l_line_definition_code VARCHAR2(30);
27913 l_line_definition_owner_code VARCHAR2(1);
27914 --
27915 -- adr variables
27916 l_segment VARCHAR2(30);
27917 l_ccid NUMBER;
27918 l_adr_transaction_coa_id NUMBER;
27919 l_adr_accounting_coa_id NUMBER;
27920 l_adr_flexfield_segment_code VARCHAR2(30);
27921 l_adr_flex_value_set_id NUMBER;
27922 l_adr_value_type_code VARCHAR2(30);
27923 l_adr_value_combination_id NUMBER;
27924 l_adr_value_segment_code VARCHAR2(30);
27925
27926 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
27927 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
27928 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
27929 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
27930
27931 -- 4262811 Variables ------------------------------------------------------------------------------------------
27932 l_entered_amt_idx NUMBER;
27933 l_accted_amt_idx NUMBER;
27934 l_acc_rev_flag VARCHAR2(1);
27935 l_accrual_line_num NUMBER;
27936 l_tmp_amt NUMBER;
27937 l_acc_rev_natural_side_code VARCHAR2(1);
27938
27939 l_num_entries NUMBER;
27940 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
27941 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
27942 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
27943 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
27944 l_recog_line_1 NUMBER;
27945 l_recog_line_2 NUMBER;
27946
27947 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
27948 l_bflow_applied_to_amt NUMBER; -- 5132302
27949 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
27950
27951 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
27952
27953 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
27954 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
27955
27956 ---------------------------------------------------------------------------------------------------------------
27957
27958
27959 --
27960 -- bulk performance
27961 --
27962 l_balance_type_code VARCHAR2(1);
27963 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
27964 l_log_module VARCHAR2(240);
27965
27966 --
27967 -- Upgrade strategy
27968 --
27969 l_actual_upg_option VARCHAR2(1);
27970 l_enc_upg_option VARCHAR2(1);
27971
27972 --
27973 BEGIN
27974 --
27975 IF g_log_enabled THEN
27976 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_51';
27977 END IF;
27978 --
27979 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27980
27981 trace
27982 (p_msg => 'BEGIN of AcctLineType_51'
27983 ,p_level => C_LEVEL_PROCEDURE
27984 ,p_module => l_log_module);
27985
27986 END IF;
27987 --
27988 l_component_type := 'AMB_JLT';
27989 l_component_code := 'FV_REV_RECLASSIFY_APPR_DR';
27990 l_component_type_code := 'S';
27991 l_component_appl_id := 707;
27992 l_amb_context_code := 'DEFAULT';
27993 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
27994 l_event_class_code := 'DELIVER_EXPENSE';
27995 l_event_type_code := 'DELIVER_EXPENSE_ALL';
27996 l_line_definition_owner_code := 'S';
27997 l_line_definition_code := 'FV_RETURN_TO_RECEIVING';
27998 --
27999 l_balance_type_code := 'A';
28000 l_segment := NULL;
28001 l_ccid := NULL;
28002 l_adr_transaction_coa_id := NULL;
28003 l_adr_accounting_coa_id := NULL;
28004 l_adr_flexfield_segment_code := NULL;
28005 l_adr_flex_value_set_id := NULL;
28006 l_adr_value_type_code := NULL;
28007 l_adr_value_combination_id := NULL;
28008 l_adr_value_segment_code := NULL;
28009
28010 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
28011 l_bflow_class_code := 'FV_EXP_APPR'; -- 4219869 Business Flow
28012 l_inherit_desc_flag := 'Y'; -- 4219869 Business Flow
28013 l_budgetary_control_flag := 'Y';
28014
28015 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28016 l_bflow_applied_to_amt := NULL; -- 5132302
28017 l_entered_amt_idx := NULL; -- 4262811
28018 l_accted_amt_idx := NULL; -- 4262811
28019 l_acc_rev_flag := NULL; -- 4262811
28020 l_accrual_line_num := NULL; -- 4262811
28021 l_tmp_amt := NULL; -- 4262811
28022 --
28023
28024 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
28025 l_balance_type_code <> 'B' THEN
28026 IF NVL(
28027 xla_ae_sources_pkg.GetSystemSourceChar(
28028 p_source_code => 'XLA_EVENT_TYPE_CODE'
28029 , p_source_type_code => 'Y'
28030 , p_source_application_id => 602
28031 ),'
28032 ') = 'RETURN_TO_RECEIVING' AND
28033 (NVL(p_source_2,'
28034 ') = 'A' OR
28035 NVL(p_source_2,'
28036 ') = 'B' OR
28037 NVL(p_source_2,'
28038 ') = 'C') AND
28039 NVL(p_source_6,'
28040 ') = 'Charge'
28041 THEN
28042
28043 --
28044 XLA_AE_LINES_PKG.SetNewLine;
28045
28046 p_balance_type_code := l_balance_type_code;
28047 -- set the flag so later we will know whether the gain loss line needs to be created
28048
28049 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
28050 p_actual_flag :='A';
28051 END IF;
28052
28053 --
28054 -- bulk performance
28055 --
28056 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
28057 p_header_num => 0); -- 4262811
28058 --
28059 -- set accounting line options
28060 --
28061 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
28062 p_natural_side_code => 'D'
28063 , p_gain_or_loss_flag => 'N'
28064 , p_gl_transfer_mode_code => 'S'
28065 , p_acct_entry_type_code => 'A'
28066 , p_switch_side_flag => 'N'
28067 , p_merge_duplicate_code => 'N'
28068 );
28069 --
28070 l_acc_rev_natural_side_code := 'C'; -- 4262811
28071 --
28072 --
28073 -- set accounting line type info
28074 --
28075 xla_ae_lines_pkg.SetAcctLineType
28076 (p_component_type => l_component_type
28077 ,p_event_type_code => l_event_type_code
28078 ,p_line_definition_owner_code => l_line_definition_owner_code
28079 ,p_line_definition_code => l_line_definition_code
28080 ,p_accounting_line_code => l_component_code
28081 ,p_accounting_line_type_code => l_component_type_code
28082 ,p_accounting_line_appl_id => l_component_appl_id
28083 ,p_amb_context_code => l_amb_context_code
28084 ,p_entity_code => l_entity_code
28085 ,p_event_class_code => l_event_class_code);
28086 --
28087 -- set accounting class
28088 --
28089 xla_ae_lines_pkg.SetAcctClass(
28090 p_accounting_class_code => 'FEDERAL_EXP'
28091 , p_ae_header_id => l_ae_header_id
28092 );
28093
28094 --
28095 -- set rounding class
28096 --
28097 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
28098 'FEDERAL_EXP';
28099
28100 --
28101 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
28102 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
28103 --
28104 -- bulk performance
28105 --
28106 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
28107
28108 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
28109 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
28110
28111 -- 4955764
28112 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28113 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
28114
28115 -- 4458381 Public Sector Enh
28116
28117 --
28118 -- set accounting attributes for the line type
28119 --
28120 l_entered_amt_idx := 17;
28121 l_accted_amt_idx := 19;
28122 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28123 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
28124 l_rec_acct_attrs.array_num_value(1) :=
28125 xla_ae_sources_pkg.GetSystemSourceNum(
28126 p_source_code => 'XLA_EVENT_APPL_ID'
28127 , p_source_type_code => 'Y'
28128 , p_source_application_id => 602
28129 );
28130 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
28131 l_rec_acct_attrs.array_char_value(2) := p_source_13;
28132 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
28133 l_rec_acct_attrs.array_char_value(3) :=
28134 xla_ae_sources_pkg.GetSystemSourceChar(
28135 p_source_code => 'XLA_ENTITY_CODE'
28136 , p_source_type_code => 'Y'
28137 , p_source_application_id => 602
28138 );
28139 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
28140 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_32);
28141 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
28142 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_33);
28143 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
28144 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
28145 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
28146 l_rec_acct_attrs.array_char_value(7) := p_source_13;
28147 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
28148 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
28149 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
28150 l_rec_acct_attrs.array_num_value(9) := p_source_14;
28151 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
28152 l_rec_acct_attrs.array_char_value(10) := p_source_15;
28153 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
28154 l_rec_acct_attrs.array_num_value(11) := p_source_16;
28155 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
28156 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
28157 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
28158 l_rec_acct_attrs.array_num_value(13) := p_source_14;
28159 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
28160 l_rec_acct_attrs.array_char_value(14) := p_source_15;
28161 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
28162 l_rec_acct_attrs.array_num_value(15) := p_source_16;
28163 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
28164 l_rec_acct_attrs.array_char_value(16) := p_source_17;
28165 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
28166 l_rec_acct_attrs.array_num_value(17) := p_source_25;
28167 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
28168 l_rec_acct_attrs.array_char_value(18) := p_source_15;
28169 l_rec_acct_attrs.array_acct_attr_code(19) := 'LEDGER_AMOUNT';
28170 l_rec_acct_attrs.array_num_value(19) := p_source_26;
28171 l_rec_acct_attrs.array_acct_attr_code(20) := 'UPG_CR_ENC_TYPE_ID';
28172 l_rec_acct_attrs.array_num_value(20) := p_source_22;
28173 l_rec_acct_attrs.array_acct_attr_code(21) := 'UPG_DR_ENC_TYPE_ID';
28174 l_rec_acct_attrs.array_num_value(21) := p_source_22;
28175
28176 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
28177 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
28178
28179 ---------------------------------------------------------------------------------------------------------------
28180 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
28181 ---------------------------------------------------------------------------------------------------------------
28182 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
28183
28184 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28185 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28186
28187 IF xla_accounting_cache_pkg.GetValueChar
28188 (p_source_code => 'LEDGER_CATEGORY_CODE'
28189 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
28190 AND l_bflow_method_code = 'PRIOR_ENTRY'
28191 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
28192 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
28193 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
28194 )
28195 THEN
28196 xla_ae_lines_pkg.BflowUpgEntry
28197 (p_business_method_code => l_bflow_method_code
28198 ,p_business_class_code => l_bflow_class_code
28199 ,p_balance_type => l_balance_type_code);
28200 ELSE
28201 NULL;
28202 XLA_AE_LINES_PKG.business_flow_validation(
28203 p_business_method_code => l_bflow_method_code
28204 ,p_business_class_code => l_bflow_class_code
28205 ,p_inherit_description_flag => l_inherit_desc_flag);
28206 END IF;
28207
28208 --
28209 -- call analytical criteria
28210 --
28211 -- Inherited Analytical Criteria for business flow method of Prior Entry.
28212 --
28213 -- call description
28214 --
28215 -- No description or it is inherited.
28216 --
28217 -- call ADRs
28218 -- Bug 4922099
28219 --
28220 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28221 (NVL(l_actual_upg_option, 'N') = 'O') OR
28222 (NVL(l_enc_upg_option, 'N') = 'O')
28223 )
28224 THEN
28225 NULL;
28226 --
28227 --
28228
28229 --
28230 --
28231 END IF;
28232 --
28233 -- Bug 4922099
28234 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
28235 (NVL(l_enc_upg_option, 'N') = 'O')
28236 ) AND
28237 (l_bflow_method_code = 'PRIOR_ENTRY')
28238 )
28239 THEN
28240 IF
28241 --
28242 1 = 1
28243 --
28244 THEN
28245 xla_accounting_err_pkg.build_message
28246 (p_appli_s_name => 'XLA'
28247 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28248 ,p_token_1 => 'LINE_NUMBER'
28249 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
28250 ,p_token_2 => 'LINE_TYPE_NAME'
28251 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
28252 l_component_type
28253 ,l_component_code
28254 ,l_component_type_code
28255 ,l_component_appl_id
28256 ,l_amb_context_code
28257 ,l_entity_code
28258 ,l_event_class_code
28259 )
28260 ,p_token_3 => 'OWNER'
28261 ,p_value_3 => xla_lookups_pkg.get_meaning(
28262 p_lookup_type => 'XLA_OWNER_TYPE'
28263 ,p_lookup_code => l_component_type_code
28264 )
28265 ,p_token_4 => 'PRODUCT_NAME'
28266 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
28267 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
28268 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
28269 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
28270 ,p_ae_header_id => NULL
28271 );
28272
28273 IF (C_LEVEL_ERROR>= g_log_level) THEN
28274 trace
28275 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28276 ,p_level => C_LEVEL_ERROR
28277 ,p_module => l_log_module);
28278 END IF;
28279 END IF;
28280 END IF;
28281 --
28282 --
28283 ------------------------------------------------------------------------------------------------
28284 -- 4219869 Business Flow
28285 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
28286 -- Prior Entry. Currently, the following code is always generated.
28287 ------------------------------------------------------------------------------------------------
28288 -- No ValidateCurrentLine for business flow method of Prior Entry
28289
28290 ------------------------------------------------------------------------------------
28291 -- 4219869 Business Flow
28292 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
28293 ------------------------------------------------------------------------------------
28294 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28295
28296 ----------------------------------------------------------------------------------
28297 -- 4219869 Business Flow
28298 -- Update journal entry status -- Need to generate this within IF <condition>
28299 ----------------------------------------------------------------------------------
28300 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28301 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
28302 ,p_balance_type_code => l_balance_type_code
28303 );
28304
28305 -------------------------------------------------------------------------------------------
28306 -- 4262811 - Generate the Accrual Reversal lines
28307 -------------------------------------------------------------------------------------------
28308 BEGIN
28309 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
28310 (g_array_event(p_event_id).array_value_num('header_index'));
28311 IF l_acc_rev_flag IS NULL THEN
28312 l_acc_rev_flag := 'N';
28313 END IF;
28314 EXCEPTION
28315 WHEN OTHERS THEN
28316 l_acc_rev_flag := 'N';
28317 END;
28318 --
28319 IF (l_acc_rev_flag = 'Y') THEN
28320
28321 -- 4645092 ------------------------------------------------------------------------------
28322 -- To allow MPA report to determine if it should generate report process
28323 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
28324 ------------------------------------------------------------------------------------------
28325
28326 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
28327 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
28328 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
28329 -- call ADRs
28330 -- Bug 4922099
28331 --
28332 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28333 (NVL(l_actual_upg_option, 'N') = 'O') OR
28334 (NVL(l_enc_upg_option, 'N') = 'O')
28335 )
28336 THEN
28337 NULL;
28338 --
28339 --
28340
28341 --
28342 --
28343 END IF;
28344
28345 --
28346 -- Update the line information that should be overwritten
28347 --
28348 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
28349 p_header_num => 1);
28350 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
28351
28352 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
28353
28354 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
28355 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
28356 END IF;
28357
28358 --
28359 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
28360 --
28361 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
28362 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
28363 ELSE
28364 ---------------------------------------------------------------------------------------------------
28365 -- 4262811a Switch Sign
28366 ---------------------------------------------------------------------------------------------------
28367 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
28368 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28369 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28370 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28371 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28372 -- 5132302
28373 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
28374 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28375
28376 END IF;
28377
28378 -- 4955764
28379 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28380 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
28381
28382
28383 XLA_AE_LINES_PKG.ValidateCurrentLine;
28384 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28385
28386 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28387 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
28388 ,p_balance_type_code => l_balance_type_code);
28389
28390 END IF;
28391
28392 -----------------------------------------------------------------------------------------
28393 -- 4262811 Multiperiod Accounting
28394 -----------------------------------------------------------------------------------------
28395 -- No MPA option is assigned.
28396
28397
28398 END IF;
28399 END IF;
28400 --
28401
28402 --
28403 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28404 trace
28405 (p_msg => 'END of AcctLineType_51'
28406 ,p_level => C_LEVEL_PROCEDURE
28407 ,p_module => l_log_module);
28408 END IF;
28409 --
28410 EXCEPTION
28411 WHEN xla_exceptions_pkg.application_exception THEN
28412 RAISE;
28413 WHEN OTHERS THEN
28414 xla_exceptions_pkg.raise_message
28415 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_51');
28416 END AcctLineType_51;
28417 --
28418
28419 ---------------------------------------
28420 --
28421 -- PRIVATE FUNCTION
28422 -- AcctLineType_52
28423 --
28424 ---------------------------------------
28425 PROCEDURE AcctLineType_52 (
28426 p_application_id IN NUMBER
28427 ,p_event_id IN NUMBER
28428 ,p_calculate_acctd_flag IN VARCHAR2
28429 ,p_calculate_g_l_flag IN VARCHAR2
28430 ,p_actual_flag IN OUT VARCHAR2
28431 ,p_balance_type_code OUT VARCHAR2
28432 ,p_gain_or_loss_ref OUT VARCHAR2
28433
28434 --Federal Fund Category
28435 , p_source_2 IN VARCHAR2
28436 --PO Budget Account
28437 , p_source_3 IN NUMBER
28438 --Applied to Application ID
28439 , p_source_7 IN NUMBER
28440 --Applied to Distribution Link Type
28441 , p_source_8 IN VARCHAR2
28442 --Applied to Entity Code
28443 , p_source_9 IN VARCHAR2
28444 --Applied To Purchase Document Identifier
28445 , p_source_11 IN NUMBER
28446 --DISTRIBUTION_IDENTIFIER
28447 , p_source_12 IN NUMBER
28448 --Distribution Type
28449 , p_source_13 IN VARCHAR2
28450 , p_source_13_meaning IN VARCHAR2
28451 --Encumbrance Reversal Amount Entered
28452 , p_source_14 IN NUMBER
28453 --Entered Currency Code
28454 , p_source_15 IN VARCHAR2
28455 --Transaction Encumbrance Reversal Amount
28456 , p_source_16 IN NUMBER
28457 --Costing Encumbrance Upgrade Option
28458 , p_source_17 IN VARCHAR2
28459 --Purchasing Encumbrance Type Identifier
28460 , p_source_22 IN NUMBER
28461 --TXN_PO_DISTRIBUTION_ID
28462 , p_source_23 IN NUMBER
28463 --Entered Amount
28464 , p_source_25 IN NUMBER
28465 --Accounted Amount
28466 , p_source_26 IN NUMBER
28467 )
28468 IS
28469
28470 l_component_type VARCHAR2(80);
28471 l_component_code VARCHAR2(30);
28472 l_component_type_code VARCHAR2(1);
28473 l_component_appl_id INTEGER;
28474 l_amb_context_code VARCHAR2(30);
28475 l_entity_code VARCHAR2(30);
28476 l_event_class_code VARCHAR2(30);
28477 l_ae_header_id NUMBER;
28478 l_event_type_code VARCHAR2(30);
28479 l_line_definition_code VARCHAR2(30);
28480 l_line_definition_owner_code VARCHAR2(1);
28481 --
28482 -- adr variables
28483 l_segment VARCHAR2(30);
28484 l_ccid NUMBER;
28485 l_adr_transaction_coa_id NUMBER;
28486 l_adr_accounting_coa_id NUMBER;
28487 l_adr_flexfield_segment_code VARCHAR2(30);
28488 l_adr_flex_value_set_id NUMBER;
28489 l_adr_value_type_code VARCHAR2(30);
28490 l_adr_value_combination_id NUMBER;
28491 l_adr_value_segment_code VARCHAR2(30);
28492
28493 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
28494 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
28495 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
28496 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
28497
28498 -- 4262811 Variables ------------------------------------------------------------------------------------------
28499 l_entered_amt_idx NUMBER;
28500 l_accted_amt_idx NUMBER;
28501 l_acc_rev_flag VARCHAR2(1);
28502 l_accrual_line_num NUMBER;
28503 l_tmp_amt NUMBER;
28504 l_acc_rev_natural_side_code VARCHAR2(1);
28505
28506 l_num_entries NUMBER;
28507 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
28508 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
28509 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
28510 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
28511 l_recog_line_1 NUMBER;
28512 l_recog_line_2 NUMBER;
28513
28514 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
28515 l_bflow_applied_to_amt NUMBER; -- 5132302
28516 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
28517
28518 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
28519
28520 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
28521 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
28522
28523 ---------------------------------------------------------------------------------------------------------------
28524
28525
28526 --
28527 -- bulk performance
28528 --
28529 l_balance_type_code VARCHAR2(1);
28530 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
28531 l_log_module VARCHAR2(240);
28532
28533 --
28534 -- Upgrade strategy
28535 --
28536 l_actual_upg_option VARCHAR2(1);
28537 l_enc_upg_option VARCHAR2(1);
28538
28539 --
28540 BEGIN
28541 --
28542 IF g_log_enabled THEN
28543 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_52';
28544 END IF;
28545 --
28546 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28547
28548 trace
28549 (p_msg => 'BEGIN of AcctLineType_52'
28550 ,p_level => C_LEVEL_PROCEDURE
28551 ,p_module => l_log_module);
28552
28553 END IF;
28554 --
28555 l_component_type := 'AMB_JLT';
28556 l_component_code := 'FV_REV_RECLASSIFY_APPR_DR_RTI';
28557 l_component_type_code := 'S';
28558 l_component_appl_id := 707;
28559 l_amb_context_code := 'DEFAULT';
28560 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
28561 l_event_class_code := 'PURCHASE_ORDER';
28562 l_event_type_code := 'PURCHASE_ORDER_ALL';
28563 l_line_definition_owner_code := 'S';
28564 l_line_definition_code := 'FV_RET_RI_INV';
28565 --
28566 l_balance_type_code := 'A';
28567 l_segment := NULL;
28568 l_ccid := NULL;
28569 l_adr_transaction_coa_id := NULL;
28570 l_adr_accounting_coa_id := NULL;
28571 l_adr_flexfield_segment_code := NULL;
28572 l_adr_flex_value_set_id := NULL;
28573 l_adr_value_type_code := NULL;
28574 l_adr_value_combination_id := NULL;
28575 l_adr_value_segment_code := NULL;
28576
28577 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
28578 l_bflow_class_code := 'FV_EXP_APPR'; -- 4219869 Business Flow
28579 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
28580 l_budgetary_control_flag := 'Y';
28581
28582 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28583 l_bflow_applied_to_amt := NULL; -- 5132302
28584 l_entered_amt_idx := NULL; -- 4262811
28585 l_accted_amt_idx := NULL; -- 4262811
28586 l_acc_rev_flag := NULL; -- 4262811
28587 l_accrual_line_num := NULL; -- 4262811
28588 l_tmp_amt := NULL; -- 4262811
28589 --
28590
28591 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
28592 l_balance_type_code <> 'B' THEN
28593 IF (NVL(p_source_2,'
28594 ') = 'A' OR
28595 NVL(p_source_2,'
28596 ') = 'B' OR
28597 NVL(p_source_2,'
28598 ') = 'C') AND
28599 NVL(
28600 xla_ae_sources_pkg.GetSystemSourceChar(
28601 p_source_code => 'XLA_EVENT_TYPE_CODE'
28602 , p_source_type_code => 'Y'
28603 , p_source_application_id => 602
28604 ),'
28605 ') = 'RET_RI_INV'
28606 THEN
28607
28608 --
28609 XLA_AE_LINES_PKG.SetNewLine;
28610
28611 p_balance_type_code := l_balance_type_code;
28612 -- set the flag so later we will know whether the gain loss line needs to be created
28613
28614 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
28615 p_actual_flag :='A';
28616 END IF;
28617
28618 --
28619 -- bulk performance
28620 --
28621 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
28622 p_header_num => 0); -- 4262811
28623 --
28624 -- set accounting line options
28625 --
28626 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
28627 p_natural_side_code => 'D'
28628 , p_gain_or_loss_flag => 'N'
28629 , p_gl_transfer_mode_code => 'S'
28630 , p_acct_entry_type_code => 'A'
28631 , p_switch_side_flag => 'N'
28632 , p_merge_duplicate_code => 'N'
28633 );
28634 --
28635 l_acc_rev_natural_side_code := 'C'; -- 4262811
28636 --
28637 --
28638 -- set accounting line type info
28639 --
28640 xla_ae_lines_pkg.SetAcctLineType
28641 (p_component_type => l_component_type
28642 ,p_event_type_code => l_event_type_code
28643 ,p_line_definition_owner_code => l_line_definition_owner_code
28644 ,p_line_definition_code => l_line_definition_code
28645 ,p_accounting_line_code => l_component_code
28646 ,p_accounting_line_type_code => l_component_type_code
28647 ,p_accounting_line_appl_id => l_component_appl_id
28648 ,p_amb_context_code => l_amb_context_code
28649 ,p_entity_code => l_entity_code
28650 ,p_event_class_code => l_event_class_code);
28651 --
28652 -- set accounting class
28653 --
28654 xla_ae_lines_pkg.SetAcctClass(
28655 p_accounting_class_code => 'FEDERAL_INV'
28656 , p_ae_header_id => l_ae_header_id
28657 );
28658
28659 --
28660 -- set rounding class
28661 --
28662 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
28663 'FEDERAL_INV';
28664
28665 --
28666 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
28667 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
28668 --
28669 -- bulk performance
28670 --
28671 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
28672
28673 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
28674 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
28675
28676 -- 4955764
28677 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28678 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
28679
28680 -- 4458381 Public Sector Enh
28681
28682 --
28683 -- set accounting attributes for the line type
28684 --
28685 l_entered_amt_idx := 17;
28686 l_accted_amt_idx := 19;
28687 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28688 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
28689 l_rec_acct_attrs.array_num_value(1) := p_source_7;
28690 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
28691 l_rec_acct_attrs.array_char_value(2) := p_source_8;
28692 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
28693 l_rec_acct_attrs.array_char_value(3) := p_source_9;
28694 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
28695 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_23);
28696 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
28697 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_11);
28698 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
28699 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_12);
28700 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
28701 l_rec_acct_attrs.array_char_value(7) := p_source_13;
28702 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
28703 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_3);
28704 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
28705 l_rec_acct_attrs.array_num_value(9) := p_source_14;
28706 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
28707 l_rec_acct_attrs.array_char_value(10) := p_source_15;
28708 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
28709 l_rec_acct_attrs.array_num_value(11) := p_source_16;
28710 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
28711 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_3);
28712 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
28713 l_rec_acct_attrs.array_num_value(13) := p_source_14;
28714 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
28715 l_rec_acct_attrs.array_char_value(14) := p_source_15;
28716 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
28717 l_rec_acct_attrs.array_num_value(15) := p_source_16;
28718 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
28719 l_rec_acct_attrs.array_char_value(16) := p_source_17;
28720 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
28721 l_rec_acct_attrs.array_num_value(17) := p_source_25;
28722 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
28723 l_rec_acct_attrs.array_char_value(18) := p_source_15;
28724 l_rec_acct_attrs.array_acct_attr_code(19) := 'LEDGER_AMOUNT';
28725 l_rec_acct_attrs.array_num_value(19) := p_source_26;
28726 l_rec_acct_attrs.array_acct_attr_code(20) := 'UPG_CR_ENC_TYPE_ID';
28727 l_rec_acct_attrs.array_num_value(20) := p_source_22;
28728 l_rec_acct_attrs.array_acct_attr_code(21) := 'UPG_DR_ENC_TYPE_ID';
28729 l_rec_acct_attrs.array_num_value(21) := p_source_22;
28730
28731 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
28732 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
28733
28734 ---------------------------------------------------------------------------------------------------------------
28735 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
28736 ---------------------------------------------------------------------------------------------------------------
28737 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
28738
28739 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28740 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28741
28742 IF xla_accounting_cache_pkg.GetValueChar
28743 (p_source_code => 'LEDGER_CATEGORY_CODE'
28744 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
28745 AND l_bflow_method_code = 'PRIOR_ENTRY'
28746 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
28747 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
28748 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
28749 )
28750 THEN
28751 xla_ae_lines_pkg.BflowUpgEntry
28752 (p_business_method_code => l_bflow_method_code
28753 ,p_business_class_code => l_bflow_class_code
28754 ,p_balance_type => l_balance_type_code);
28755 ELSE
28756 NULL;
28757 XLA_AE_LINES_PKG.business_flow_validation(
28758 p_business_method_code => l_bflow_method_code
28759 ,p_business_class_code => l_bflow_class_code
28760 ,p_inherit_description_flag => l_inherit_desc_flag);
28761 END IF;
28762
28763 --
28764 -- call analytical criteria
28765 --
28766 -- Inherited Analytical Criteria for business flow method of Prior Entry.
28767 --
28768 -- call description
28769 --
28770 -- No description or it is inherited.
28771 --
28772 -- call ADRs
28773 -- Bug 4922099
28774 --
28775 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28776 (NVL(l_actual_upg_option, 'N') = 'O') OR
28777 (NVL(l_enc_upg_option, 'N') = 'O')
28778 )
28779 THEN
28780 NULL;
28781 --
28782 --
28783
28784 --
28785 --
28786 END IF;
28787 --
28788 -- Bug 4922099
28789 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
28790 (NVL(l_enc_upg_option, 'N') = 'O')
28791 ) AND
28792 (l_bflow_method_code = 'PRIOR_ENTRY')
28793 )
28794 THEN
28795 IF
28796 --
28797 1 = 1
28798 --
28799 THEN
28800 xla_accounting_err_pkg.build_message
28801 (p_appli_s_name => 'XLA'
28802 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28803 ,p_token_1 => 'LINE_NUMBER'
28804 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
28805 ,p_token_2 => 'LINE_TYPE_NAME'
28806 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
28807 l_component_type
28808 ,l_component_code
28809 ,l_component_type_code
28810 ,l_component_appl_id
28811 ,l_amb_context_code
28812 ,l_entity_code
28813 ,l_event_class_code
28814 )
28815 ,p_token_3 => 'OWNER'
28816 ,p_value_3 => xla_lookups_pkg.get_meaning(
28817 p_lookup_type => 'XLA_OWNER_TYPE'
28818 ,p_lookup_code => l_component_type_code
28819 )
28820 ,p_token_4 => 'PRODUCT_NAME'
28821 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
28822 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
28823 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
28824 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
28825 ,p_ae_header_id => NULL
28826 );
28827
28828 IF (C_LEVEL_ERROR>= g_log_level) THEN
28829 trace
28830 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28831 ,p_level => C_LEVEL_ERROR
28832 ,p_module => l_log_module);
28833 END IF;
28834 END IF;
28835 END IF;
28836 --
28837 --
28838 ------------------------------------------------------------------------------------------------
28839 -- 4219869 Business Flow
28840 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
28841 -- Prior Entry. Currently, the following code is always generated.
28842 ------------------------------------------------------------------------------------------------
28843 -- No ValidateCurrentLine for business flow method of Prior Entry
28844
28845 ------------------------------------------------------------------------------------
28846 -- 4219869 Business Flow
28847 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
28848 ------------------------------------------------------------------------------------
28849 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28850
28851 ----------------------------------------------------------------------------------
28852 -- 4219869 Business Flow
28853 -- Update journal entry status -- Need to generate this within IF <condition>
28854 ----------------------------------------------------------------------------------
28855 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28856 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
28857 ,p_balance_type_code => l_balance_type_code
28858 );
28859
28860 -------------------------------------------------------------------------------------------
28861 -- 4262811 - Generate the Accrual Reversal lines
28862 -------------------------------------------------------------------------------------------
28863 BEGIN
28864 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
28865 (g_array_event(p_event_id).array_value_num('header_index'));
28866 IF l_acc_rev_flag IS NULL THEN
28867 l_acc_rev_flag := 'N';
28868 END IF;
28869 EXCEPTION
28870 WHEN OTHERS THEN
28871 l_acc_rev_flag := 'N';
28872 END;
28873 --
28874 IF (l_acc_rev_flag = 'Y') THEN
28875
28876 -- 4645092 ------------------------------------------------------------------------------
28877 -- To allow MPA report to determine if it should generate report process
28878 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
28879 ------------------------------------------------------------------------------------------
28880
28881 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
28882 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
28883 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
28884 -- call ADRs
28885 -- Bug 4922099
28886 --
28887 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28888 (NVL(l_actual_upg_option, 'N') = 'O') OR
28889 (NVL(l_enc_upg_option, 'N') = 'O')
28890 )
28891 THEN
28892 NULL;
28893 --
28894 --
28895
28896 --
28897 --
28898 END IF;
28899
28900 --
28901 -- Update the line information that should be overwritten
28902 --
28903 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
28904 p_header_num => 1);
28905 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
28906
28907 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
28908
28909 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
28910 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
28911 END IF;
28912
28913 --
28914 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
28915 --
28916 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
28917 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
28918 ELSE
28919 ---------------------------------------------------------------------------------------------------
28920 -- 4262811a Switch Sign
28921 ---------------------------------------------------------------------------------------------------
28922 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
28923 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28924 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28925 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28926 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28927 -- 5132302
28928 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
28929 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28930
28931 END IF;
28932
28933 -- 4955764
28934 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28935 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
28936
28937
28938 XLA_AE_LINES_PKG.ValidateCurrentLine;
28939 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28940
28941 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28942 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
28943 ,p_balance_type_code => l_balance_type_code);
28944
28945 END IF;
28946
28947 -----------------------------------------------------------------------------------------
28948 -- 4262811 Multiperiod Accounting
28949 -----------------------------------------------------------------------------------------
28950 -- No MPA option is assigned.
28951
28952
28953 END IF;
28954 END IF;
28955 --
28956
28957 --
28958 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28959 trace
28960 (p_msg => 'END of AcctLineType_52'
28961 ,p_level => C_LEVEL_PROCEDURE
28962 ,p_module => l_log_module);
28963 END IF;
28964 --
28965 EXCEPTION
28966 WHEN xla_exceptions_pkg.application_exception THEN
28967 RAISE;
28968 WHEN OTHERS THEN
28969 xla_exceptions_pkg.raise_message
28970 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.AcctLineType_52');
28971 END AcctLineType_52;
28972 --
28973
28974 ---------------------------------------
28975 --
28976 -- PRIVATE PROCEDURE
28977 -- insert_sources_53
28978 --
28979 ----------------------------------------
28980 --
28981 PROCEDURE insert_sources_53(
28982 p_target_ledger_id IN NUMBER
28983 , p_language IN VARCHAR2
28984 , p_sla_ledger_id IN NUMBER
28985 , p_pad_start_date IN DATE
28986 , p_pad_end_date IN DATE
28987 )
28988 IS
28989
28990 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DELIVER_EXPENSE_ALL';
28991 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DELIVER_EXPENSE';
28992 p_apps_owner VARCHAR2(30);
28993 l_log_module VARCHAR2(240);
28994 BEGIN
28995 IF g_log_enabled THEN
28996 l_log_module := C_DEFAULT_MODULE||'.insert_sources_53';
28997 END IF;
28998 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28999
29000 trace
29001 (p_msg => 'BEGIN of insert_sources_53'
29002 ,p_level => C_LEVEL_PROCEDURE
29003 ,p_module => l_log_module);
29004
29005 END IF;
29006
29007 -- select APPS owner
29008 SELECT oracle_username
29009 INTO p_apps_owner
29010 FROM fnd_oracle_userid
29011 WHERE read_only_flag = 'U'
29012 ;
29013
29014 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
29015 trace
29016 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
29017 ' - p_language = '||p_language||
29018 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
29019 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
29020 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
29021 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
29022 ,p_level => C_LEVEL_STATEMENT
29023 ,p_module => l_log_module);
29024 END IF;
29025
29026
29027 --
29028 INSERT INTO xla_diag_sources --hdr2
29029 (
29030 event_id
29031 , ledger_id
29032 , sla_ledger_id
29033 , description_language
29034 , object_name
29035 , object_type_code
29036 , line_number
29037 , source_application_id
29038 , source_type_code
29039 , source_code
29040 , source_value
29041 , source_meaning
29042 , created_by
29043 , creation_date
29044 , last_update_date
29045 , last_updated_by
29046 , last_update_login
29047 , program_update_date
29048 , program_application_id
29049 , program_id
29050 , request_id
29051 )
29052 SELECT
29053 event_id
29054 , p_target_ledger_id
29055 , p_sla_ledger_id
29056 , p_language
29057 , object_name
29058 , object_type_code
29059 , line_number
29060 , source_application_id
29061 , source_type_code
29062 , source_code
29063 , SUBSTR(source_value ,1,1996)
29064 , SUBSTR(source_meaning ,1,200)
29065 , xla_environment_pkg.g_Usr_Id
29066 , TRUNC(SYSDATE)
29067 , TRUNC(SYSDATE)
29068 , xla_environment_pkg.g_Usr_Id
29069 , xla_environment_pkg.g_Login_Id
29070 , TRUNC(SYSDATE)
29071 , xla_environment_pkg.g_Prog_Appl_Id
29072 , xla_environment_pkg.g_Prog_Id
29073 , xla_environment_pkg.g_Req_Id
29074 FROM (
29075 SELECT xet.event_id event_id
29076 , 0 line_number
29077 , CASE r
29078 WHEN 1 THEN 'PO_DISTS_REF_V'
29079 WHEN 2 THEN 'CST_XLA_RCV_REF_V'
29080 WHEN 3 THEN 'CST_XLA_RCV_REF_V'
29081 WHEN 4 THEN 'CST_XLA_RCV_REF_V'
29082 WHEN 5 THEN 'CST_XLA_RCV_REF_V'
29083 WHEN 6 THEN 'CST_XLA_RCV_REF_V'
29084 WHEN 7 THEN 'CST_XLA_RCV_HEADERS_V'
29085 WHEN 8 THEN 'CST_XLA_RCV_REF_V'
29086 WHEN 9 THEN 'CST_XLA_RCV_HEADERS_V'
29087 WHEN 10 THEN 'CST_XLA_RCV_REF_V'
29088 WHEN 11 THEN 'PSA_CST_XLA_UPG_V'
29089 WHEN 12 THEN 'CST_XLA_RCV_HEADERS_V'
29090 WHEN 13 THEN 'CST_XLA_RCV_HEADERS_V'
29091 WHEN 14 THEN 'CST_XLA_RCV_HEADERS_V'
29092 WHEN 15 THEN 'PO_HEADERS_REF_V'
29093 WHEN 16 THEN 'CST_XLA_RCV_REF_V'
29094 WHEN 17 THEN 'CST_XLA_RCV_HEADERS_V'
29095
29096 ELSE null
29097 END object_name
29098 , CASE r
29099 WHEN 1 THEN 'HEADER'
29100 WHEN 2 THEN 'HEADER'
29101 WHEN 3 THEN 'HEADER'
29102 WHEN 4 THEN 'HEADER'
29103 WHEN 5 THEN 'HEADER'
29104 WHEN 6 THEN 'HEADER'
29105 WHEN 7 THEN 'HEADER'
29106 WHEN 8 THEN 'HEADER'
29107 WHEN 9 THEN 'HEADER'
29108 WHEN 10 THEN 'HEADER'
29109 WHEN 11 THEN 'HEADER'
29110 WHEN 12 THEN 'HEADER'
29111 WHEN 13 THEN 'HEADER'
29112 WHEN 14 THEN 'HEADER'
29113 WHEN 15 THEN 'HEADER'
29114 WHEN 16 THEN 'HEADER'
29115 WHEN 17 THEN 'HEADER'
29116
29117 ELSE null
29118 END object_type_code
29119 , CASE r
29120 WHEN 1 THEN '201'
29121 WHEN 2 THEN '707'
29122 WHEN 3 THEN '707'
29123 WHEN 4 THEN '707'
29124 WHEN 5 THEN '707'
29125 WHEN 6 THEN '707'
29126 WHEN 7 THEN '707'
29127 WHEN 8 THEN '707'
29128 WHEN 9 THEN '707'
29129 WHEN 10 THEN '707'
29130 WHEN 11 THEN '707'
29131 WHEN 12 THEN '707'
29132 WHEN 13 THEN '707'
29133 WHEN 14 THEN '707'
29134 WHEN 15 THEN '201'
29135 WHEN 16 THEN '707'
29136 WHEN 17 THEN '707'
29137
29138 ELSE null
29139 END source_application_id
29140 , 'S' source_type_code
29141 , CASE r
29142 WHEN 1 THEN 'PO_BUDGET_ACCOUNT'
29143 WHEN 2 THEN 'APPLIED_TO_APPL_ID'
29144 WHEN 3 THEN 'APPLIED_TO_DIST_LINK_TYPE'
29145 WHEN 4 THEN 'APPLIED_TO_ENTITY_CODE'
29146 WHEN 5 THEN 'PO_DISTRIBUTION_ID'
29147 WHEN 6 THEN 'APPLIED_TO_PO_DOC_ID'
29148 WHEN 7 THEN 'DISTRIBUTION_TYPE'
29149 WHEN 8 THEN 'ENCUM_REVERSAL_AMOUNT_ENTERED'
29150 WHEN 9 THEN 'CURRENCY_CODE'
29151 WHEN 10 THEN 'ENCUMBRANCE_REVERSAL_AMOUNT'
29152 WHEN 11 THEN 'CST_ENCUM_UPG_OPTION'
29153 WHEN 12 THEN 'CURRENCY_CONVERSION_DATE'
29154 WHEN 13 THEN 'CURRENCY_CONVERSION_RATE'
29155 WHEN 14 THEN 'CURRENCY_CONVERSION_TYPE'
29156 WHEN 15 THEN 'PURCH_ENCUMBRANCE_TYPE_ID'
29157 WHEN 16 THEN 'PARENT_TRANSACTION_ID'
29158 WHEN 17 THEN 'TRANSFER_TO_GL_INDICATOR'
29159
29160 ELSE null
29161 END source_code
29162 , CASE r
29163 WHEN 1 THEN TO_CHAR(h5.PO_BUDGET_ACCOUNT)
29164 WHEN 2 THEN TO_CHAR(h3.APPLIED_TO_APPL_ID)
29165 WHEN 3 THEN TO_CHAR(h3.APPLIED_TO_DIST_LINK_TYPE)
29166 WHEN 4 THEN TO_CHAR(h3.APPLIED_TO_ENTITY_CODE)
29167 WHEN 5 THEN TO_CHAR(h3.PO_DISTRIBUTION_ID)
29168 WHEN 6 THEN TO_CHAR(h3.APPLIED_TO_PO_DOC_ID)
29169 WHEN 7 THEN TO_CHAR(h1.DISTRIBUTION_TYPE)
29170 WHEN 8 THEN TO_CHAR(h3.ENCUM_REVERSAL_AMOUNT_ENTERED)
29171 WHEN 9 THEN TO_CHAR(h1.CURRENCY_CODE)
29172 WHEN 10 THEN TO_CHAR(h3.ENCUMBRANCE_REVERSAL_AMOUNT)
29173 WHEN 11 THEN TO_CHAR(h7.CST_ENCUM_UPG_OPTION)
29174 WHEN 12 THEN TO_CHAR(h1.CURRENCY_CONVERSION_DATE)
29175 WHEN 13 THEN TO_CHAR(h1.CURRENCY_CONVERSION_RATE)
29176 WHEN 14 THEN TO_CHAR(h1.CURRENCY_CONVERSION_TYPE)
29177 WHEN 15 THEN TO_CHAR(h6.PURCH_ENCUMBRANCE_TYPE_ID)
29178 WHEN 16 THEN TO_CHAR(h3.PARENT_TRANSACTION_ID)
29179 WHEN 17 THEN TO_CHAR(h1.TRANSFER_TO_GL_INDICATOR)
29180
29181 ELSE null
29182 END source_value
29183 , CASE r
29184 WHEN 7 THEN fvl13.meaning
29185 WHEN 17 THEN fvl36.meaning
29186
29187 ELSE null
29188 END source_meaning
29189 FROM xla_events_gt xet
29190 , CST_XLA_RCV_HEADERS_V h1
29191 , CST_XLA_RCV_REF_V h3
29192 , PO_DISTS_REF_V h5
29193 , PO_HEADERS_REF_V h6
29194 , PSA_CST_XLA_UPG_V h7
29195 , fnd_lookup_values fvl13
29196 , fnd_lookup_values fvl36
29197 ,(select rownum r from all_objects where rownum <= 17 and owner = p_apps_owner)
29198 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
29199 AND xet.event_class_code = C_EVENT_CLASS_CODE
29200 AND h1.event_id = xet.event_id
29201 AND h3.ref_rcv_accounting_event_id = h1.rcv_accounting_event_id AND h3.po_header_id = h5.po_header_id (+) and h3.po_distribution_id = h5.po_distribution_id (+) AND h3.po_header_id = h6.po_header_id (+) AND h3.rcv_transaction_id = h7.transaction_id (+) AND fvl13.lookup_type(+) = 'CST_DISTRIBUTION_TYPE'
29202 AND fvl13.lookup_code(+) = h1.DISTRIBUTION_TYPE
29203 AND fvl13.view_application_id(+) = 700
29204 AND fvl13.language(+) = USERENV('LANG')
29205 AND fvl36.lookup_type(+) = 'YES_NO'
29206 AND fvl36.lookup_code(+) = h1.TRANSFER_TO_GL_INDICATOR
29207 AND fvl36.view_application_id(+) = 0
29208 AND fvl36.language(+) = USERENV('LANG')
29209
29210 )
29211 ;
29212 --
29213 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
29214
29215 trace
29216 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
29217 ,p_level => C_LEVEL_STATEMENT
29218 ,p_module => l_log_module);
29219
29220 END IF;
29221 --
29222
29223
29224
29225 --
29226 INSERT INTO xla_diag_sources --line2
29227 (
29228 event_id
29229 , ledger_id
29230 , sla_ledger_id
29231 , description_language
29232 , object_name
29233 , object_type_code
29234 , line_number
29235 , source_application_id
29236 , source_type_code
29237 , source_code
29238 , source_value
29239 , source_meaning
29240 , created_by
29241 , creation_date
29242 , last_update_date
29243 , last_updated_by
29244 , last_update_login
29245 , program_update_date
29246 , program_application_id
29247 , program_id
29248 , request_id
29249 )
29250 SELECT event_id
29251 , p_target_ledger_id
29252 , p_sla_ledger_id
29253 , p_language
29254 , object_name
29255 , object_type_code
29256 , line_number
29257 , source_application_id
29258 , source_type_code
29259 , source_code
29260 , SUBSTR(source_value,1,1996)
29261 , SUBSTR(source_meaning ,1,200)
29262 , xla_environment_pkg.g_Usr_Id
29263 , TRUNC(SYSDATE)
29264 , TRUNC(SYSDATE)
29265 , xla_environment_pkg.g_Usr_Id
29266 , xla_environment_pkg.g_Login_Id
29267 , TRUNC(SYSDATE)
29268 , xla_environment_pkg.g_Prog_Appl_Id
29269 , xla_environment_pkg.g_Prog_Id
29270 , xla_environment_pkg.g_Req_Id
29271 FROM (
29272 SELECT xet.event_id event_id
29273 , l2.line_number line_number
29274 , CASE r
29275 WHEN 1 THEN 'FV_XLA_CST_REF_V'
29276 WHEN 2 THEN 'FV_XLA_CST_REF_V'
29277 WHEN 3 THEN 'FV_XLA_CST_REF_V'
29278 WHEN 4 THEN 'CST_XLA_RCV_LINES_V'
29279 WHEN 5 THEN 'CST_XLA_RCV_LINES_V'
29280 WHEN 6 THEN 'FV_XLA_CST_REF_V'
29281 WHEN 7 THEN 'FV_XLA_CST_REF_V'
29282 WHEN 8 THEN 'CST_XLA_RCV_LINES_V'
29283 WHEN 9 THEN 'CST_XLA_RCV_LINES_V'
29284 WHEN 10 THEN 'FV_XLA_CST_REF_V'
29285 WHEN 11 THEN 'FV_XLA_CST_REF_V'
29286 WHEN 12 THEN 'FV_XLA_CST_REF_V'
29287 WHEN 13 THEN 'FV_XLA_CST_REF_V'
29288 WHEN 14 THEN 'FV_XLA_CST_REF_V'
29289
29290 ELSE null
29291 END object_name
29292 , CASE r
29293 WHEN 1 THEN 'LINE'
29294 WHEN 2 THEN 'LINE'
29295 WHEN 3 THEN 'LINE'
29296 WHEN 4 THEN 'LINE'
29297 WHEN 5 THEN 'LINE'
29298 WHEN 6 THEN 'LINE'
29299 WHEN 7 THEN 'LINE'
29300 WHEN 8 THEN 'LINE'
29301 WHEN 9 THEN 'LINE'
29302 WHEN 10 THEN 'LINE'
29303 WHEN 11 THEN 'LINE'
29304 WHEN 12 THEN 'LINE'
29305 WHEN 13 THEN 'LINE'
29306 WHEN 14 THEN 'LINE'
29307
29308 ELSE null
29309 END object_type_code
29310 , CASE r
29311 WHEN 1 THEN '8901'
29312 WHEN 2 THEN '8901'
29313 WHEN 3 THEN '8901'
29314 WHEN 4 THEN '707'
29315 WHEN 5 THEN '707'
29316 WHEN 6 THEN '8901'
29317 WHEN 7 THEN '8901'
29318 WHEN 8 THEN '707'
29319 WHEN 9 THEN '707'
29320 WHEN 10 THEN '8901'
29321 WHEN 11 THEN '8901'
29322 WHEN 12 THEN '8901'
29323 WHEN 13 THEN '8901'
29324 WHEN 14 THEN '8901'
29325
29326 ELSE null
29327 END source_application_id
29328 , 'S' source_type_code
29329 , CASE r
29330 WHEN 1 THEN 'FEDERAL_FUND_EXPIRED_STATUS'
29331 WHEN 2 THEN 'FEDERAL_FUND_CATEGORY'
29332 WHEN 3 THEN 'FEDERAL_PRIOR_YEAR_FLAG'
29333 WHEN 4 THEN 'RCV_ACCOUNTING_LINE_TYPE'
29334 WHEN 5 THEN 'DISTRIBUTION_IDENTIFIER'
29335 WHEN 6 THEN 'FEDERAL_ANTICIPATED_AMT'
29336 WHEN 7 THEN 'FEDERAL_UNANTICIPATED_AMT'
29337 WHEN 8 THEN 'ENTERED_AMOUNT'
29338 WHEN 9 THEN 'ACCOUNTED_AMOUNT'
29339 WHEN 10 THEN 'FEDERAL_NET_PYA_ADJ_AMT'
29340 WHEN 11 THEN 'FEDERAL_PAID_UNEXP_OBG_AMT'
29341 WHEN 12 THEN 'FEDERAL_UNPAID_UNEXP_OBG_AMT'
29342 WHEN 13 THEN 'FEDERAL_RCV_SUB_LEDGER_ID'
29343 WHEN 14 THEN 'FEDERAL_UNEXP_OBG_AMT'
29344
29345 ELSE null
29346 END source_code
29347 , CASE r
29348 WHEN 1 THEN TO_CHAR(l4.FEDERAL_FUND_EXPIRED_STATUS)
29349 WHEN 2 THEN TO_CHAR(l4.FEDERAL_FUND_CATEGORY)
29350 WHEN 3 THEN TO_CHAR(l4.FEDERAL_PRIOR_YEAR_FLAG)
29351 WHEN 4 THEN TO_CHAR(l2.RCV_ACCOUNTING_LINE_TYPE)
29352 WHEN 5 THEN TO_CHAR(l2.DISTRIBUTION_IDENTIFIER)
29353 WHEN 6 THEN TO_CHAR(l4.FEDERAL_ANTICIPATED_AMT)
29354 WHEN 7 THEN TO_CHAR(l4.FEDERAL_UNANTICIPATED_AMT)
29355 WHEN 8 THEN TO_CHAR(l2.ENTERED_AMOUNT)
29356 WHEN 9 THEN TO_CHAR(l2.ACCOUNTED_AMOUNT)
29357 WHEN 10 THEN TO_CHAR(l4.FEDERAL_NET_PYA_ADJ_AMT)
29358 WHEN 11 THEN TO_CHAR(l4.FEDERAL_PAID_UNEXP_OBG_AMT)
29359 WHEN 12 THEN TO_CHAR(l4.FEDERAL_UNPAID_UNEXP_OBG_AMT)
29360 WHEN 13 THEN TO_CHAR(l4.FEDERAL_RCV_SUB_LEDGER_ID)
29361 WHEN 14 THEN TO_CHAR(l4.FEDERAL_UNEXP_OBG_AMT)
29362
29363 ELSE null
29364 END source_value
29365 , null source_meaning
29366 FROM xla_events_gt xet
29367 , CST_XLA_RCV_LINES_V l2
29368 , FV_XLA_CST_REF_V l4
29369 , (select rownum r from all_objects where rownum <= 14 and owner = p_apps_owner)
29370 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
29371 AND xet.event_class_code = C_EVENT_CLASS_CODE
29372 AND l2.event_id = xet.event_id
29373 AND l4.federal_event_id = l2.event_id and l4.federal_line_number=l2.line_number
29374 )
29375 ;
29376 --
29377 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
29378
29379 trace
29380 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
29381 ,p_level => C_LEVEL_STATEMENT
29382 ,p_module => l_log_module);
29383
29384 END IF;
29385
29386
29387 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29388 trace
29389 (p_msg => 'END of insert_sources_53'
29390 ,p_level => C_LEVEL_PROCEDURE
29391 ,p_module => l_log_module);
29392 END IF;
29393 EXCEPTION
29394 WHEN xla_exceptions_pkg.application_exception THEN
29395 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
29396 trace
29397 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
29398 ,p_level => C_LEVEL_EXCEPTION
29399 ,p_module => l_log_module);
29400 END IF;
29401 RAISE;
29402 WHEN OTHERS THEN
29403 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
29404 trace
29405 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
29406 ,p_level => C_LEVEL_EXCEPTION
29407 ,p_module => l_log_module);
29408 END IF;
29409 xla_exceptions_pkg.raise_message
29410 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.insert_sources_53');
29411 END insert_sources_53;
29412 --
29413
29414 ---------------------------------------
29415 --
29416 -- PRIVATE FUNCTION
29417 -- EventClass_53
29418 --
29419 ----------------------------------------
29420 --
29421 FUNCTION EventClass_53
29422 (p_application_id IN NUMBER
29423 ,p_base_ledger_id IN NUMBER
29424 ,p_target_ledger_id IN NUMBER
29425 ,p_language IN VARCHAR2
29426 ,p_currency_code IN VARCHAR2
29427 ,p_sla_ledger_id IN NUMBER
29428 ,p_pad_start_date IN DATE
29429 ,p_pad_end_date IN DATE
29430 ,p_primary_ledger_id IN NUMBER)
29431 RETURN BOOLEAN IS
29432 --
29433 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DELIVER_EXPENSE_ALL';
29434 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DELIVER_EXPENSE';
29435
29436 l_calculate_acctd_flag VARCHAR2(1) :='N';
29437 l_calculate_g_l_flag VARCHAR2(1) :='N';
29438 --
29439 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
29440 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
29441 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
29442 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
29443 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
29444 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
29445 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
29446 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
29447 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
29448 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
29449 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
29450 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
29451 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
29452 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
29453 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
29454 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
29455 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
29456 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
29457 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
29458 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
29459 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
29460 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
29461 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
29462 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
29463 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
29464 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
29465
29466 l_event_id NUMBER;
29467 l_previous_event_id NUMBER;
29468 l_first_event_id NUMBER;
29469 l_last_event_id NUMBER;
29470
29471 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
29472 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
29473 --
29474 --
29475 l_result BOOLEAN := TRUE;
29476 l_rows NUMBER := 1000;
29477 l_event_type_name VARCHAR2(80) := 'All';
29478 l_event_class_name VARCHAR2(80) := 'Delivery to Expense Destination';
29479 l_description VARCHAR2(4000);
29480 l_transaction_reversal NUMBER;
29481 l_ae_header_id NUMBER;
29482 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
29483 l_log_module VARCHAR2(240);
29484 --
29485 l_acct_reversal_source VARCHAR2(30);
29486 l_trx_reversal_source VARCHAR2(30);
29487
29488 l_continue_with_lines BOOLEAN := TRUE;
29489 --
29490 l_acc_rev_gl_date_source DATE; -- 4262811
29491 --
29492 type t_array_event_id is table of number index by binary_integer;
29493
29494 l_rec_array_event t_rec_array_event;
29495 l_null_rec_array_event t_rec_array_event;
29496 l_array_ae_header_id xla_number_array_type;
29497 l_actual_flag VARCHAR2(1) := NULL;
29498 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
29499 l_balance_type_code VARCHAR2(1) :=NULL;
29500 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
29501
29502 --
29503 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
29504 --
29505
29506 TYPE t_array_source_3 IS TABLE OF PO_DISTS_REF_V.PO_BUDGET_ACCOUNT%TYPE INDEX BY BINARY_INTEGER;
29507 TYPE t_array_source_7 IS TABLE OF CST_XLA_RCV_REF_V.APPLIED_TO_APPL_ID%TYPE INDEX BY BINARY_INTEGER;
29508 TYPE t_array_source_8 IS TABLE OF CST_XLA_RCV_REF_V.APPLIED_TO_DIST_LINK_TYPE%TYPE INDEX BY BINARY_INTEGER;
29509 TYPE t_array_source_9 IS TABLE OF CST_XLA_RCV_REF_V.APPLIED_TO_ENTITY_CODE%TYPE INDEX BY BINARY_INTEGER;
29510 TYPE t_array_source_10 IS TABLE OF CST_XLA_RCV_REF_V.PO_DISTRIBUTION_ID%TYPE INDEX BY BINARY_INTEGER;
29511 TYPE t_array_source_11 IS TABLE OF CST_XLA_RCV_REF_V.APPLIED_TO_PO_DOC_ID%TYPE INDEX BY BINARY_INTEGER;
29512 TYPE t_array_source_13 IS TABLE OF CST_XLA_RCV_HEADERS_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
29513 TYPE t_array_source_14 IS TABLE OF CST_XLA_RCV_REF_V.ENCUM_REVERSAL_AMOUNT_ENTERED%TYPE INDEX BY BINARY_INTEGER;
29514 TYPE t_array_source_15 IS TABLE OF CST_XLA_RCV_HEADERS_V.CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
29515 TYPE t_array_source_16 IS TABLE OF CST_XLA_RCV_REF_V.ENCUMBRANCE_REVERSAL_AMOUNT%TYPE INDEX BY BINARY_INTEGER;
29516 TYPE t_array_source_17 IS TABLE OF PSA_CST_XLA_UPG_V.CST_ENCUM_UPG_OPTION%TYPE INDEX BY BINARY_INTEGER;
29517 TYPE t_array_source_19 IS TABLE OF CST_XLA_RCV_HEADERS_V.CURRENCY_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
29518 TYPE t_array_source_20 IS TABLE OF CST_XLA_RCV_HEADERS_V.CURRENCY_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
29519 TYPE t_array_source_21 IS TABLE OF CST_XLA_RCV_HEADERS_V.CURRENCY_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
29520 TYPE t_array_source_22 IS TABLE OF PO_HEADERS_REF_V.PURCH_ENCUMBRANCE_TYPE_ID%TYPE INDEX BY BINARY_INTEGER;
29521 TYPE t_array_source_33 IS TABLE OF CST_XLA_RCV_REF_V.PARENT_TRANSACTION_ID%TYPE INDEX BY BINARY_INTEGER;
29522 TYPE t_array_source_36 IS TABLE OF CST_XLA_RCV_HEADERS_V.TRANSFER_TO_GL_INDICATOR%TYPE INDEX BY BINARY_INTEGER;
29523
29524 TYPE t_array_source_1 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_FUND_EXPIRED_STATUS%TYPE INDEX BY BINARY_INTEGER;
29525 TYPE t_array_source_2 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_FUND_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
29526 TYPE t_array_source_5 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_PRIOR_YEAR_FLAG%TYPE INDEX BY BINARY_INTEGER;
29527 TYPE t_array_source_6 IS TABLE OF CST_XLA_RCV_LINES_V.RCV_ACCOUNTING_LINE_TYPE%TYPE INDEX BY BINARY_INTEGER;
29528 TYPE t_array_source_12 IS TABLE OF CST_XLA_RCV_LINES_V.DISTRIBUTION_IDENTIFIER%TYPE INDEX BY BINARY_INTEGER;
29529 TYPE t_array_source_18 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_ANTICIPATED_AMT%TYPE INDEX BY BINARY_INTEGER;
29530 TYPE t_array_source_24 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_UNANTICIPATED_AMT%TYPE INDEX BY BINARY_INTEGER;
29531 TYPE t_array_source_25 IS TABLE OF CST_XLA_RCV_LINES_V.ENTERED_AMOUNT%TYPE INDEX BY BINARY_INTEGER;
29532 TYPE t_array_source_26 IS TABLE OF CST_XLA_RCV_LINES_V.ACCOUNTED_AMOUNT%TYPE INDEX BY BINARY_INTEGER;
29533 TYPE t_array_source_27 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_NET_PYA_ADJ_AMT%TYPE INDEX BY BINARY_INTEGER;
29534 TYPE t_array_source_28 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_PAID_UNEXP_OBG_AMT%TYPE INDEX BY BINARY_INTEGER;
29535 TYPE t_array_source_29 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_UNPAID_UNEXP_OBG_AMT%TYPE INDEX BY BINARY_INTEGER;
29536 TYPE t_array_source_32 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_RCV_SUB_LEDGER_ID%TYPE INDEX BY BINARY_INTEGER;
29537 TYPE t_array_source_34 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_UNEXP_OBG_AMT%TYPE INDEX BY BINARY_INTEGER;
29538
29539 l_array_source_3 t_array_source_3;
29540 l_array_source_7 t_array_source_7;
29541 l_array_source_8 t_array_source_8;
29542 l_array_source_9 t_array_source_9;
29543 l_array_source_10 t_array_source_10;
29544 l_array_source_11 t_array_source_11;
29545 l_array_source_13 t_array_source_13;
29546 l_array_source_13_meaning t_array_lookup_meaning;
29547 l_array_source_14 t_array_source_14;
29548 l_array_source_15 t_array_source_15;
29549 l_array_source_16 t_array_source_16;
29550 l_array_source_17 t_array_source_17;
29551 l_array_source_19 t_array_source_19;
29552 l_array_source_20 t_array_source_20;
29553 l_array_source_21 t_array_source_21;
29554 l_array_source_22 t_array_source_22;
29555 l_array_source_33 t_array_source_33;
29556 l_array_source_36 t_array_source_36;
29557 l_array_source_36_meaning t_array_lookup_meaning;
29558
29559 l_array_source_1 t_array_source_1;
29560 l_array_source_2 t_array_source_2;
29561 l_array_source_5 t_array_source_5;
29562 l_array_source_6 t_array_source_6;
29563 l_array_source_12 t_array_source_12;
29564 l_array_source_18 t_array_source_18;
29565 l_array_source_24 t_array_source_24;
29566 l_array_source_25 t_array_source_25;
29567 l_array_source_26 t_array_source_26;
29568 l_array_source_27 t_array_source_27;
29569 l_array_source_28 t_array_source_28;
29570 l_array_source_29 t_array_source_29;
29571 l_array_source_32 t_array_source_32;
29572 l_array_source_34 t_array_source_34;
29573
29574 --
29575 CURSOR header_cur
29576 IS
29577 SELECT /*+ leading(xet) cardinality(xet,1) */
29578 -- Event Class Code: DELIVER_EXPENSE
29579 xet.entity_id
29580 ,xet.legal_entity_id
29581 ,xet.entity_code
29582 ,xet.transaction_number
29583 ,xet.event_id
29584 ,xet.event_class_code
29585 ,xet.event_type_code
29586 ,xet.event_number
29587 ,xet.event_date
29588 ,xet.transaction_date
29589 ,xet.reference_num_1
29590 ,xet.reference_num_2
29591 ,xet.reference_num_3
29592 ,xet.reference_num_4
29593 ,xet.reference_char_1
29594 ,xet.reference_char_2
29595 ,xet.reference_char_3
29596 ,xet.reference_char_4
29597 ,xet.reference_date_1
29598 ,xet.reference_date_2
29599 ,xet.reference_date_3
29600 ,xet.reference_date_4
29601 ,xet.event_created_by
29602 ,xet.budgetary_control_flag
29603 , h5.PO_BUDGET_ACCOUNT source_3
29604 , h3.APPLIED_TO_APPL_ID source_7
29605 , h3.APPLIED_TO_DIST_LINK_TYPE source_8
29606 , h3.APPLIED_TO_ENTITY_CODE source_9
29607 , h3.PO_DISTRIBUTION_ID source_10
29608 , h3.APPLIED_TO_PO_DOC_ID source_11
29609 , h1.DISTRIBUTION_TYPE source_13
29610 , fvl13.meaning source_13_meaning
29611 , h3.ENCUM_REVERSAL_AMOUNT_ENTERED source_14
29612 , h1.CURRENCY_CODE source_15
29613 , h3.ENCUMBRANCE_REVERSAL_AMOUNT source_16
29614 , h7.CST_ENCUM_UPG_OPTION source_17
29615 , h1.CURRENCY_CONVERSION_DATE source_19
29616 , h1.CURRENCY_CONVERSION_RATE source_20
29617 , h1.CURRENCY_CONVERSION_TYPE source_21
29618 , h6.PURCH_ENCUMBRANCE_TYPE_ID source_22
29619 , h3.PARENT_TRANSACTION_ID source_33
29620 , h1.TRANSFER_TO_GL_INDICATOR source_36
29621 , fvl36.meaning source_36_meaning
29622 FROM xla_events_gt xet
29623 , CST_XLA_RCV_HEADERS_V h1
29624 , CST_XLA_RCV_REF_V h3
29625 , PO_DISTS_REF_V h5
29626 , PO_HEADERS_REF_V h6
29627 , PSA_CST_XLA_UPG_V h7
29628 , fnd_lookup_values fvl13
29629 , fnd_lookup_values fvl36
29630 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
29631 and xet.event_class_code = C_EVENT_CLASS_CODE
29632 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
29633 AND h3.REF_RCV_ACCOUNTING_EVENT_ID = h1.RCV_ACCOUNTING_EVENT_ID AND h3.po_header_id = h5.po_header_id (+) AND h3.po_distribution_id = h5.po_distribution_id (+) AND h3.po_header_id = h6.po_header_id (+) AND h3.rcv_transaction_id = h7.transaction_id (+) AND fvl13.lookup_type(+) = 'CST_DISTRIBUTION_TYPE'
29634 AND fvl13.lookup_code(+) = h1.DISTRIBUTION_TYPE
29635 AND fvl13.view_application_id(+) = 700
29636 AND fvl13.language(+) = USERENV('LANG')
29637 AND fvl36.lookup_type(+) = 'YES_NO'
29638 AND fvl36.lookup_code(+) = h1.TRANSFER_TO_GL_INDICATOR
29639 AND fvl36.view_application_id(+) = 0
29640 AND fvl36.language(+) = USERENV('LANG')
29641
29642 ORDER BY event_id
29643 ;
29644
29645
29646 --
29647 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
29648 IS
29649 SELECT /*+ leading(xet) cardinality(xet,1) */
29650 -- Event Class Code: DELIVER_EXPENSE
29651 xet.entity_id
29652 ,xet.legal_entity_id
29653 ,xet.entity_code
29654 ,xet.transaction_number
29655 ,xet.event_id
29656 ,xet.event_class_code
29657 ,xet.event_type_code
29658 ,xet.event_number
29659 ,xet.event_date
29660 ,xet.transaction_date
29661 ,xet.reference_num_1
29662 ,xet.reference_num_2
29663 ,xet.reference_num_3
29664 ,xet.reference_num_4
29665 ,xet.reference_char_1
29666 ,xet.reference_char_2
29667 ,xet.reference_char_3
29668 ,xet.reference_char_4
29669 ,xet.reference_date_1
29670 ,xet.reference_date_2
29671 ,xet.reference_date_3
29672 ,xet.reference_date_4
29673 ,xet.event_created_by
29674 ,xet.budgetary_control_flag
29675 , l2.LINE_NUMBER
29676 , l4.FEDERAL_FUND_EXPIRED_STATUS source_1
29677 , l4.FEDERAL_FUND_CATEGORY source_2
29678 , l4.FEDERAL_PRIOR_YEAR_FLAG source_5
29679 , l2.RCV_ACCOUNTING_LINE_TYPE source_6
29680 , l2.DISTRIBUTION_IDENTIFIER source_12
29681 , l4.FEDERAL_ANTICIPATED_AMT source_18
29682 , l4.FEDERAL_UNANTICIPATED_AMT source_24
29683 , l2.ENTERED_AMOUNT source_25
29684 , l2.ACCOUNTED_AMOUNT source_26
29685 , l4.FEDERAL_NET_PYA_ADJ_AMT source_27
29686 , l4.FEDERAL_PAID_UNEXP_OBG_AMT source_28
29687 , l4.FEDERAL_UNPAID_UNEXP_OBG_AMT source_29
29688 , l4.FEDERAL_RCV_SUB_LEDGER_ID source_32
29689 , l4.FEDERAL_UNEXP_OBG_AMT source_34
29690 FROM xla_events_gt xet
29691 , CST_XLA_RCV_LINES_V l2
29692 , FV_XLA_CST_REF_V l4
29693 WHERE xet.event_id between x_first_event_id and x_last_event_id
29694 and xet.event_date between p_pad_start_date and p_pad_end_date
29695 and xet.event_class_code = C_EVENT_CLASS_CODE
29696 and xet.event_status_code <> 'N' AND l2.event_id = xet.event_id
29697 AND l4.federal_event_id = l2.event_id AND l4.federal_line_number=l2.line_number;
29698
29699 --
29700 BEGIN
29701 IF g_log_enabled THEN
29702 l_log_module := C_DEFAULT_MODULE||'.EventClass_53';
29703 END IF;
29704 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29705 trace
29706 (p_msg => 'BEGIN of EventClass_53'
29707 ,p_level => C_LEVEL_PROCEDURE
29708 ,p_module => l_log_module);
29709 END IF;
29710
29711 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
29712 trace
29713 (p_msg => 'p_application_id = '||p_application_id||
29714 ' - p_base_ledger_id = '||p_base_ledger_id||
29715 ' - p_target_ledger_id = '||p_target_ledger_id||
29716 ' - p_language = '||p_language||
29717 ' - p_currency_code = '||p_currency_code||
29718 ' - p_sla_ledger_id = '||p_sla_ledger_id
29719 ,p_level => C_LEVEL_STATEMENT
29720 ,p_module => l_log_module);
29721 END IF;
29722 --
29723 -- initialze arrays
29724 --
29725 g_array_event.DELETE;
29726 l_rec_array_event := l_null_rec_array_event;
29727 --
29728 --------------------------------------
29729 -- 4262811 Initialze MPA Line Number
29730 --------------------------------------
29731 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
29732
29733 --
29734
29735 --
29736 OPEN header_cur;
29737 --
29738 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
29739 trace
29740 (p_msg => 'SQL - FETCH header_cur'
29741 ,p_level => C_LEVEL_STATEMENT
29742 ,p_module => l_log_module);
29743 END IF;
29744 --
29745 LOOP
29746 FETCH header_cur BULK COLLECT INTO
29747 l_array_entity_id
29748 , l_array_legal_entity_id
29749 , l_array_entity_code
29750 , l_array_transaction_num
29751 , l_array_event_id
29752 , l_array_class_code
29753 , l_array_event_type
29754 , l_array_event_number
29755 , l_array_event_date
29756 , l_array_transaction_date
29757 , l_array_reference_num_1
29758 , l_array_reference_num_2
29759 , l_array_reference_num_3
29760 , l_array_reference_num_4
29761 , l_array_reference_char_1
29762 , l_array_reference_char_2
29763 , l_array_reference_char_3
29764 , l_array_reference_char_4
29765 , l_array_reference_date_1
29766 , l_array_reference_date_2
29767 , l_array_reference_date_3
29768 , l_array_reference_date_4
29769 , l_array_event_created_by
29770 , l_array_budgetary_control_flag
29771 , l_array_source_3
29772 , l_array_source_7
29773 , l_array_source_8
29774 , l_array_source_9
29775 , l_array_source_10
29776 , l_array_source_11
29777 , l_array_source_13
29778 , l_array_source_13_meaning
29779 , l_array_source_14
29780 , l_array_source_15
29781 , l_array_source_16
29782 , l_array_source_17
29783 , l_array_source_19
29784 , l_array_source_20
29785 , l_array_source_21
29786 , l_array_source_22
29787 , l_array_source_33
29788 , l_array_source_36
29789 , l_array_source_36_meaning
29790 LIMIT l_rows;
29791 --
29792 IF (C_LEVEL_EVENT >= g_log_level) THEN
29793 trace
29794 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
29795 ,p_level => C_LEVEL_EVENT
29796 ,p_module => l_log_module);
29797 END IF;
29798 --
29799 EXIT WHEN l_array_entity_id.COUNT = 0;
29800
29801 -- initialize arrays
29802 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
29803 XLA_AE_LINES_PKG.g_rec_lines := NULL;
29804
29805 --
29806 -- Bug 4458708
29807 --
29808 XLA_AE_LINES_PKG.g_LineNumber := 0;
29809
29810
29811 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
29812 g_last_hdr_idx := l_array_event_id.LAST;
29813 --
29814 -- loop for the headers. Each iteration is for each header extract row
29815 -- fetched in header cursor
29816 --
29817 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
29818
29819 --
29820 -- set event info as cache for other routines to refer event attributes
29821 --
29822 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
29823 (p_application_id => p_application_id
29824 ,p_primary_ledger_id => p_primary_ledger_id
29825 ,p_base_ledger_id => p_base_ledger_id
29826 ,p_target_ledger_id => p_target_ledger_id
29827 ,p_entity_id => l_array_entity_id(hdr_idx)
29828 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
29829 ,p_entity_code => l_array_entity_code(hdr_idx)
29830 ,p_transaction_num => l_array_transaction_num(hdr_idx)
29831 ,p_event_id => l_array_event_id(hdr_idx)
29832 ,p_event_class_code => l_array_class_code(hdr_idx)
29833 ,p_event_type_code => l_array_event_type(hdr_idx)
29834 ,p_event_number => l_array_event_number(hdr_idx)
29835 ,p_event_date => l_array_event_date(hdr_idx)
29836 ,p_transaction_date => l_array_transaction_date(hdr_idx)
29837 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
29838 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
29839 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
29840 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
29841 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
29842 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
29843 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
29844 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
29845 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
29846 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
29847 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
29848 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
29849 ,p_event_created_by => l_array_event_created_by(hdr_idx)
29850 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
29851
29852 --
29853 -- set the status of entry to C_VALID (0)
29854 --
29855 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
29856
29857 --
29858 -- initialize a row for ae header
29859 --
29860 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
29861
29862 l_event_id := l_array_event_id(hdr_idx);
29863
29864 --
29865 -- storing the hdr_idx for event. May be used by line cursor.
29866 --
29867 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
29868
29869 --
29870 -- store sources from header extract. This can be improved to
29871 -- store only those sources from header extract that may be used in lines
29872 --
29873
29874 g_array_event(l_event_id).array_value_num('source_3') := l_array_source_3(hdr_idx);
29875 g_array_event(l_event_id).array_value_num('source_7') := l_array_source_7(hdr_idx);
29876 g_array_event(l_event_id).array_value_char('source_8') := l_array_source_8(hdr_idx);
29877 g_array_event(l_event_id).array_value_char('source_9') := l_array_source_9(hdr_idx);
29878 g_array_event(l_event_id).array_value_num('source_10') := l_array_source_10(hdr_idx);
29879 g_array_event(l_event_id).array_value_num('source_11') := l_array_source_11(hdr_idx);
29880 g_array_event(l_event_id).array_value_char('source_13') := l_array_source_13(hdr_idx);
29881 g_array_event(l_event_id).array_value_char('source_13_meaning') := l_array_source_13_meaning(hdr_idx);
29882 g_array_event(l_event_id).array_value_num('source_14') := l_array_source_14(hdr_idx);
29883 g_array_event(l_event_id).array_value_char('source_15') := l_array_source_15(hdr_idx);
29884 g_array_event(l_event_id).array_value_num('source_16') := l_array_source_16(hdr_idx);
29885 g_array_event(l_event_id).array_value_char('source_17') := l_array_source_17(hdr_idx);
29886 g_array_event(l_event_id).array_value_date('source_19') := l_array_source_19(hdr_idx);
29887 g_array_event(l_event_id).array_value_num('source_20') := l_array_source_20(hdr_idx);
29888 g_array_event(l_event_id).array_value_char('source_21') := l_array_source_21(hdr_idx);
29889 g_array_event(l_event_id).array_value_num('source_22') := l_array_source_22(hdr_idx);
29890 g_array_event(l_event_id).array_value_num('source_33') := l_array_source_33(hdr_idx);
29891 g_array_event(l_event_id).array_value_char('source_36') := l_array_source_36(hdr_idx);
29892 g_array_event(l_event_id).array_value_char('source_36_meaning') := l_array_source_36_meaning(hdr_idx);
29893
29894 --
29895 -- initilaize the status of ae headers for diffrent balance types
29896 -- the status is initialised to C_NOT_CREATED (2)
29897 --
29898 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
29899 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
29900 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
29901
29902 --
29903 -- call api to validate and store accounting attributes for header
29904 --
29905
29906 ------------------------------------------------------------
29907 -- Accrual Reversal : to get date for Standard Source (NONE)
29908 ------------------------------------------------------------
29909 l_acc_rev_gl_date_source := NULL;
29910
29911 l_rec_acct_attrs.array_acct_attr_code(1) := 'ENCUMBRANCE_TYPE_ID';
29912 l_rec_acct_attrs.array_num_value(1) := g_array_event(l_event_id).array_value_num('source_22');
29913 l_rec_acct_attrs.array_acct_attr_code(2) := 'GL_DATE';
29914 l_rec_acct_attrs.array_date_value(2) :=
29915 xla_ae_sources_pkg.GetSystemSourceDate(
29916 p_source_code => 'XLA_REFERENCE_DATE_1'
29917 , p_source_type_code => 'Y'
29918 , p_source_application_id => 602
29919 );
29920 l_rec_acct_attrs.array_acct_attr_code(3) := 'GL_TRANSFER_FLAG';
29921 l_rec_acct_attrs.array_char_value(3) := g_array_event(l_event_id).array_value_char('source_36');
29922
29923
29924 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
29925
29926 XLA_AE_HEADER_PKG.SetJeCategoryName;
29927
29928 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
29929 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
29930 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
29931 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
29932 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
29933
29934
29935 -- No header level analytical criteria
29936
29937 --
29938 --accounting attribute enhancement, bug 3612931
29939 --
29940 l_trx_reversal_source := SUBSTR(NULL, 1,30);
29941
29942 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
29943 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
29944
29945 xla_accounting_err_pkg.build_message
29946 (p_appli_s_name => 'XLA'
29947 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
29948 ,p_token_1 => 'ACCT_ATTR_NAME'
29949 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
29950 ,p_token_2 => 'PRODUCT_NAME'
29951 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
29952 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
29953 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
29954 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
29955
29956 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
29957 --
29958 -- following sets the accounting attributes needed to reverse
29959 -- accounting for a distributeion
29960 --
29961 xla_ae_lines_pkg.SetTrxReversalAttrs
29962 (p_event_id => l_event_id
29963 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
29964 ,p_trx_reversal_source => l_trx_reversal_source);
29965
29966 END IF;
29967
29968
29969 ----------------------------------------------------------------
29970 -- 4262811 - update the header statuses to invalid in need be
29971 ----------------------------------------------------------------
29972 --
29973 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
29974
29975
29976 -----------------------------------------------
29977 -- No accrual reversal for the event class/type
29978 -----------------------------------------------
29979 ----------------------------------------------------------------
29980
29981 --
29982 -- this ends the header loop iteration for one bulk fetch
29983 --
29984 END LOOP;
29985
29986 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
29987 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
29988
29989 --
29990 -- insert dummy rows into lines gt table that were created due to
29991 -- transaction reversals
29992 --
29993 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
29994 l_result := XLA_AE_LINES_PKG.InsertLines;
29995 END IF;
29996
29997 --
29998 -- reset the temp_line_num for each set of events fetched from header
29999 -- cursor rather than doing it for each new event in line cursor
30000 -- Bug 3939231
30001 --
30002 xla_ae_lines_pkg.g_temp_line_num := 0;
30003
30004
30005
30006 --
30007 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
30008 --
30009 --
30010 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
30011
30012 trace
30013 (p_msg => 'SQL - FETCH line_cur'
30014 ,p_level => C_LEVEL_STATEMENT
30015 ,p_module => l_log_module);
30016
30017 END IF;
30018 --
30019 --
30020 LOOP
30021 --
30022 FETCH line_cur BULK COLLECT INTO
30023 l_array_entity_id
30024 , l_array_legal_entity_id
30025 , l_array_entity_code
30026 , l_array_transaction_num
30027 , l_array_event_id
30028 , l_array_class_code
30029 , l_array_event_type
30030 , l_array_event_number
30031 , l_array_event_date
30032 , l_array_transaction_date
30033 , l_array_reference_num_1
30034 , l_array_reference_num_2
30035 , l_array_reference_num_3
30036 , l_array_reference_num_4
30037 , l_array_reference_char_1
30038 , l_array_reference_char_2
30039 , l_array_reference_char_3
30040 , l_array_reference_char_4
30041 , l_array_reference_date_1
30042 , l_array_reference_date_2
30043 , l_array_reference_date_3
30044 , l_array_reference_date_4
30045 , l_array_event_created_by
30046 , l_array_budgetary_control_flag
30047 , l_array_extract_line_num
30048 , l_array_source_1
30049 , l_array_source_2
30050 , l_array_source_5
30051 , l_array_source_6
30052 , l_array_source_12
30053 , l_array_source_18
30054 , l_array_source_24
30055 , l_array_source_25
30056 , l_array_source_26
30057 , l_array_source_27
30058 , l_array_source_28
30059 , l_array_source_29
30060 , l_array_source_32
30061 , l_array_source_34
30062 LIMIT l_rows;
30063
30064 --
30065 IF (C_LEVEL_EVENT >= g_log_level) THEN
30066 trace
30067 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
30068 ,p_level => C_LEVEL_EVENT
30069 ,p_module => l_log_module);
30070 END IF;
30071 --
30072 EXIT WHEN l_array_entity_id.count = 0;
30073
30074 XLA_AE_LINES_PKG.g_rec_lines := null;
30075
30076 --
30077 -- Bug 4458708
30078 --
30079 XLA_AE_LINES_PKG.g_LineNumber := 0;
30080 --
30081 --
30082
30083 FOR Idx IN 1..l_array_event_id.count LOOP
30084 --
30085 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
30086 --
30087 l_event_id := l_array_event_id(idx); -- 5648433
30088
30089 --
30090 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
30091 --
30092
30093 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
30094 (g_array_event(l_event_id).array_value_num('header_index'))
30095 ,'N'
30096 ) <> 'Y'
30097 THEN
30098 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
30099 trace
30100 (p_msg => 'Trancaction revesal option is not Y '
30101 ,p_level => C_LEVEL_STATEMENT
30102 ,p_module => l_log_module);
30103 END IF;
30104
30105 --
30106 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
30107 --
30108 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
30109 --
30110 -- set event info as cache for other routines to refer event attributes
30111 --
30112
30113 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
30114 l_previous_event_id := l_event_id;
30115
30116 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
30117 (p_application_id => p_application_id
30118 ,p_primary_ledger_id => p_primary_ledger_id
30119 ,p_base_ledger_id => p_base_ledger_id
30120 ,p_target_ledger_id => p_target_ledger_id
30121 ,p_entity_id => l_array_entity_id(Idx)
30122 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
30123 ,p_entity_code => l_array_entity_code(Idx)
30124 ,p_transaction_num => l_array_transaction_num(Idx)
30125 ,p_event_id => l_array_event_id(Idx)
30126 ,p_event_class_code => l_array_class_code(Idx)
30127 ,p_event_type_code => l_array_event_type(Idx)
30128 ,p_event_number => l_array_event_number(Idx)
30129 ,p_event_date => l_array_event_date(Idx)
30130 ,p_transaction_date => l_array_transaction_date(Idx)
30131 ,p_reference_num_1 => l_array_reference_num_1(Idx)
30132 ,p_reference_num_2 => l_array_reference_num_2(Idx)
30133 ,p_reference_num_3 => l_array_reference_num_3(Idx)
30134 ,p_reference_num_4 => l_array_reference_num_4(Idx)
30135 ,p_reference_char_1 => l_array_reference_char_1(Idx)
30136 ,p_reference_char_2 => l_array_reference_char_2(Idx)
30137 ,p_reference_char_3 => l_array_reference_char_3(Idx)
30138 ,p_reference_char_4 => l_array_reference_char_4(Idx)
30139 ,p_reference_date_1 => l_array_reference_date_1(Idx)
30140 ,p_reference_date_2 => l_array_reference_date_2(Idx)
30141 ,p_reference_date_3 => l_array_reference_date_3(Idx)
30142 ,p_reference_date_4 => l_array_reference_date_4(Idx)
30143 ,p_event_created_by => l_array_event_created_by(Idx)
30144 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
30145 --
30146 END IF;
30147
30148
30149
30150 --
30151 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
30152
30153 l_acct_reversal_source := SUBSTR(NULL, 1,30);
30154
30155 IF l_continue_with_lines THEN
30156 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
30157 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
30158
30159 xla_accounting_err_pkg.build_message
30160 (p_appli_s_name => 'XLA'
30161 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
30162 ,p_token_1 => 'LINE_NUMBER'
30163 ,p_value_1 => l_array_extract_line_num(Idx)
30164 ,p_token_2 => 'PRODUCT_NAME'
30165 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
30166 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
30167 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
30168 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
30169
30170 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
30171 --
30172 -- following sets the accounting attributes needed to reverse
30173 -- accounting for a distributeion
30174 --
30175
30176 --
30177 -- 5217187
30178 --
30179 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
30180 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
30181 g_array_event(l_event_id).array_value_num('header_index'));
30182 --
30183 --
30184
30185 -- No reversal code generated
30186
30187 xla_ae_lines_pkg.SetAcctReversalAttrs
30188 (p_event_id => l_event_id
30189 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
30190 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30191 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
30192 END IF;
30193
30194 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
30195 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
30196
30197 --
30198 AcctLineType_12 (
30199 p_application_id => p_application_id
30200 ,p_event_id => l_event_id
30201 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30202 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30203 ,p_actual_flag => l_actual_flag
30204 ,p_balance_type_code => l_balance_type_code
30205 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30206
30207 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30208 , p_source_5 => l_array_source_5(Idx)
30209 , p_source_6 => l_array_source_6(Idx)
30210 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30211 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30212 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30213 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30214 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30215 , p_source_12 => l_array_source_12(Idx)
30216 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30217 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30218 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30219 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30220 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30221 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30222 , p_source_18 => l_array_source_18(Idx)
30223 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30224 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30225 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30226 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30227 );
30228 If(l_balance_type_code = 'A') THEN
30229 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30230 END IF;
30231
30232 --
30233
30234
30235 --
30236 AcctLineType_14 (
30237 p_application_id => p_application_id
30238 ,p_event_id => l_event_id
30239 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30240 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30241 ,p_actual_flag => l_actual_flag
30242 ,p_balance_type_code => l_balance_type_code
30243 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30244
30245 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30246 , p_source_5 => l_array_source_5(Idx)
30247 , p_source_6 => l_array_source_6(Idx)
30248 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30249 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30250 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30251 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30252 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30253 , p_source_12 => l_array_source_12(Idx)
30254 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30255 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30256 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30257 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30258 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30259 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30260 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30261 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30262 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30263 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30264 , p_source_24 => l_array_source_24(Idx)
30265 );
30266 If(l_balance_type_code = 'A') THEN
30267 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30268 END IF;
30269
30270 --
30271
30272
30273 --
30274 AcctLineType_16 (
30275 p_application_id => p_application_id
30276 ,p_event_id => l_event_id
30277 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30278 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30279 ,p_actual_flag => l_actual_flag
30280 ,p_balance_type_code => l_balance_type_code
30281 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30282
30283 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30284 , p_source_6 => l_array_source_6(Idx)
30285 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30286 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30287 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30288 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30289 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30290 , p_source_12 => l_array_source_12(Idx)
30291 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30292 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30293 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30294 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30295 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30296 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30297 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30298 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30299 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30300 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30301 , p_source_25 => l_array_source_25(Idx)
30302 , p_source_26 => l_array_source_26(Idx)
30303 );
30304 If(l_balance_type_code = 'A') THEN
30305 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30306 END IF;
30307
30308 --
30309
30310
30311 --
30312 AcctLineType_18 (
30313 p_application_id => p_application_id
30314 ,p_event_id => l_event_id
30315 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30316 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30317 ,p_actual_flag => l_actual_flag
30318 ,p_balance_type_code => l_balance_type_code
30319 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30320
30321 , p_source_2 => l_array_source_2(Idx)
30322 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30323 , p_source_6 => l_array_source_6(Idx)
30324 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30325 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30326 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30327 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30328 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30329 , p_source_12 => l_array_source_12(Idx)
30330 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30331 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30332 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30333 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30334 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30335 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30336 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30337 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30338 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30339 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30340 , p_source_25 => l_array_source_25(Idx)
30341 , p_source_26 => l_array_source_26(Idx)
30342 );
30343 If(l_balance_type_code = 'A') THEN
30344 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30345 END IF;
30346
30347 --
30348
30349
30350 --
30351 AcctLineType_20 (
30352 p_application_id => p_application_id
30353 ,p_event_id => l_event_id
30354 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30355 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30356 ,p_actual_flag => l_actual_flag
30357 ,p_balance_type_code => l_balance_type_code
30358 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30359
30360 , p_source_2 => l_array_source_2(Idx)
30361 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30362 , p_source_6 => l_array_source_6(Idx)
30363 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30364 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30365 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30366 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30367 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30368 , p_source_12 => l_array_source_12(Idx)
30369 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30370 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30371 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30372 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30373 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30374 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30375 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30376 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30377 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30378 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30379 , p_source_25 => l_array_source_25(Idx)
30380 , p_source_26 => l_array_source_26(Idx)
30381 );
30382 If(l_balance_type_code = 'A') THEN
30383 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30384 END IF;
30385
30386 --
30387
30388
30389 --
30390 AcctLineType_22 (
30391 p_application_id => p_application_id
30392 ,p_event_id => l_event_id
30393 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30394 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30395 ,p_actual_flag => l_actual_flag
30396 ,p_balance_type_code => l_balance_type_code
30397 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30398
30399 , p_source_1 => l_array_source_1(Idx)
30400 , p_source_2 => l_array_source_2(Idx)
30401 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30402 , p_source_6 => l_array_source_6(Idx)
30403 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30404 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30405 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30406 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30407 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30408 , p_source_12 => l_array_source_12(Idx)
30409 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30410 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30411 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30412 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30413 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30414 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30415 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30416 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30417 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30418 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30419 , p_source_25 => l_array_source_25(Idx)
30420 , p_source_26 => l_array_source_26(Idx)
30421 );
30422 If(l_balance_type_code = 'A') THEN
30423 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30424 END IF;
30425
30426 --
30427
30428
30429 --
30430 AcctLineType_24 (
30431 p_application_id => p_application_id
30432 ,p_event_id => l_event_id
30433 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30434 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30435 ,p_actual_flag => l_actual_flag
30436 ,p_balance_type_code => l_balance_type_code
30437 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30438
30439 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30440 , p_source_5 => l_array_source_5(Idx)
30441 , p_source_6 => l_array_source_6(Idx)
30442 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30443 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30444 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30445 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30446 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30447 , p_source_12 => l_array_source_12(Idx)
30448 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30449 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30450 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30451 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30452 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30453 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30454 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30455 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30456 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30457 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30458 , p_source_27 => l_array_source_27(Idx)
30459 );
30460 If(l_balance_type_code = 'A') THEN
30461 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30462 END IF;
30463
30464 --
30465
30466
30467 --
30468 AcctLineType_26 (
30469 p_application_id => p_application_id
30470 ,p_event_id => l_event_id
30471 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30472 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30473 ,p_actual_flag => l_actual_flag
30474 ,p_balance_type_code => l_balance_type_code
30475 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30476
30477 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30478 , p_source_5 => l_array_source_5(Idx)
30479 , p_source_6 => l_array_source_6(Idx)
30480 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30481 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30482 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30483 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30484 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30485 , p_source_12 => l_array_source_12(Idx)
30486 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30487 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30488 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30489 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30490 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30491 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30492 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30493 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30494 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30495 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30496 , p_source_27 => l_array_source_27(Idx)
30497 );
30498 If(l_balance_type_code = 'A') THEN
30499 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30500 END IF;
30501
30502 --
30503
30504
30505 --
30506 AcctLineType_28 (
30507 p_application_id => p_application_id
30508 ,p_event_id => l_event_id
30509 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30510 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30511 ,p_actual_flag => l_actual_flag
30512 ,p_balance_type_code => l_balance_type_code
30513 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30514
30515 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30516 , p_source_5 => l_array_source_5(Idx)
30517 , p_source_6 => l_array_source_6(Idx)
30518 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30519 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30520 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30521 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30522 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30523 , p_source_12 => l_array_source_12(Idx)
30524 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30525 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30526 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30527 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30528 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30529 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30530 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30531 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30532 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30533 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30534 , p_source_27 => l_array_source_27(Idx)
30535 );
30536 If(l_balance_type_code = 'A') THEN
30537 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30538 END IF;
30539
30540 --
30541
30542
30543 --
30544 AcctLineType_30 (
30545 p_application_id => p_application_id
30546 ,p_event_id => l_event_id
30547 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30548 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30549 ,p_actual_flag => l_actual_flag
30550 ,p_balance_type_code => l_balance_type_code
30551 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30552
30553 , p_source_1 => l_array_source_1(Idx)
30554 , p_source_2 => l_array_source_2(Idx)
30555 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30556 , p_source_6 => l_array_source_6(Idx)
30557 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30558 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30559 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30560 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30561 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30562 , p_source_12 => l_array_source_12(Idx)
30563 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30564 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30565 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30566 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30567 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30568 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30569 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30570 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30571 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30572 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30573 , p_source_25 => l_array_source_25(Idx)
30574 , p_source_26 => l_array_source_26(Idx)
30575 );
30576 If(l_balance_type_code = 'A') THEN
30577 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30578 END IF;
30579
30580 --
30581
30582
30583 --
30584 AcctLineType_32 (
30585 p_application_id => p_application_id
30586 ,p_event_id => l_event_id
30587 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30588 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30589 ,p_actual_flag => l_actual_flag
30590 ,p_balance_type_code => l_balance_type_code
30591 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30592
30593 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30594 , p_source_6 => l_array_source_6(Idx)
30595 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30596 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30597 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30598 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30599 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30600 , p_source_12 => l_array_source_12(Idx)
30601 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30602 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30603 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30604 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30605 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30606 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30607 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30608 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30609 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30610 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30611 , p_source_28 => l_array_source_28(Idx)
30612 );
30613 If(l_balance_type_code = 'A') THEN
30614 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30615 END IF;
30616
30617 --
30618
30619
30620 --
30621 AcctLineType_34 (
30622 p_application_id => p_application_id
30623 ,p_event_id => l_event_id
30624 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30625 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30626 ,p_actual_flag => l_actual_flag
30627 ,p_balance_type_code => l_balance_type_code
30628 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30629
30630 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30631 , p_source_6 => l_array_source_6(Idx)
30632 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30633 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30634 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30635 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30636 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30637 , p_source_12 => l_array_source_12(Idx)
30638 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30639 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30640 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30641 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30642 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30643 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30644 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30645 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30646 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30647 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30648 , p_source_29 => l_array_source_29(Idx)
30649 );
30650 If(l_balance_type_code = 'A') THEN
30651 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30652 END IF;
30653
30654 --
30655
30656
30657 --
30658 AcctLineType_36 (
30659 p_application_id => p_application_id
30660 ,p_event_id => l_event_id
30661 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30662 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30663 ,p_actual_flag => l_actual_flag
30664 ,p_balance_type_code => l_balance_type_code
30665 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30666
30667 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30668 , p_source_6 => l_array_source_6(Idx)
30669 , p_source_12 => l_array_source_12(Idx)
30670 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30671 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30672 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30673 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30674 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30675 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30676 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30677 , p_source_25 => l_array_source_25(Idx)
30678 , p_source_26 => l_array_source_26(Idx)
30679 , p_source_32 => l_array_source_32(Idx)
30680 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
30681 );
30682 If(l_balance_type_code = 'A') THEN
30683 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30684 END IF;
30685
30686 --
30687
30688
30689 --
30690 AcctLineType_38 (
30691 p_application_id => p_application_id
30692 ,p_event_id => l_event_id
30693 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30694 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30695 ,p_actual_flag => l_actual_flag
30696 ,p_balance_type_code => l_balance_type_code
30697 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30698
30699 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30700 , p_source_6 => l_array_source_6(Idx)
30701 , p_source_12 => l_array_source_12(Idx)
30702 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30703 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30704 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30705 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30706 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30707 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30708 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30709 , p_source_25 => l_array_source_25(Idx)
30710 , p_source_26 => l_array_source_26(Idx)
30711 , p_source_32 => l_array_source_32(Idx)
30712 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
30713 );
30714 If(l_balance_type_code = 'A') THEN
30715 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30716 END IF;
30717
30718 --
30719
30720
30721 --
30722 AcctLineType_40 (
30723 p_application_id => p_application_id
30724 ,p_event_id => l_event_id
30725 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30726 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30727 ,p_actual_flag => l_actual_flag
30728 ,p_balance_type_code => l_balance_type_code
30729 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30730
30731 , p_source_1 => l_array_source_1(Idx)
30732 , p_source_2 => l_array_source_2(Idx)
30733 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30734 , p_source_5 => l_array_source_5(Idx)
30735 , p_source_6 => l_array_source_6(Idx)
30736 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30737 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30738 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30739 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30740 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30741 , p_source_12 => l_array_source_12(Idx)
30742 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30743 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30744 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30745 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30746 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30747 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30748 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30749 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30750 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30751 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30752 , p_source_26 => l_array_source_26(Idx)
30753 , p_source_28 => l_array_source_28(Idx)
30754 , p_source_34 => l_array_source_34(Idx)
30755 );
30756 If(l_balance_type_code = 'A') THEN
30757 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30758 END IF;
30759
30760 --
30761
30762
30763 --
30764 AcctLineType_41 (
30765 p_application_id => p_application_id
30766 ,p_event_id => l_event_id
30767 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30768 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30769 ,p_actual_flag => l_actual_flag
30770 ,p_balance_type_code => l_balance_type_code
30771 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30772
30773 , p_source_1 => l_array_source_1(Idx)
30774 , p_source_2 => l_array_source_2(Idx)
30775 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30776 , p_source_5 => l_array_source_5(Idx)
30777 , p_source_6 => l_array_source_6(Idx)
30778 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30779 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30780 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30781 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30782 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30783 , p_source_12 => l_array_source_12(Idx)
30784 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30785 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30786 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30787 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30788 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30789 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30790 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30791 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30792 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30793 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30794 , p_source_26 => l_array_source_26(Idx)
30795 , p_source_29 => l_array_source_29(Idx)
30796 , p_source_34 => l_array_source_34(Idx)
30797 );
30798 If(l_balance_type_code = 'A') THEN
30799 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30800 END IF;
30801
30802 --
30803
30804
30805 --
30806 AcctLineType_43 (
30807 p_application_id => p_application_id
30808 ,p_event_id => l_event_id
30809 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30810 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30811 ,p_actual_flag => l_actual_flag
30812 ,p_balance_type_code => l_balance_type_code
30813 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30814
30815 , p_source_1 => l_array_source_1(Idx)
30816 , p_source_2 => l_array_source_2(Idx)
30817 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30818 , p_source_5 => l_array_source_5(Idx)
30819 , p_source_6 => l_array_source_6(Idx)
30820 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30821 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30822 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30823 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30824 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30825 , p_source_12 => l_array_source_12(Idx)
30826 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30827 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30828 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30829 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30830 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30831 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30832 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30833 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30834 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30835 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30836 , p_source_26 => l_array_source_26(Idx)
30837 , p_source_34 => l_array_source_34(Idx)
30838 );
30839 If(l_balance_type_code = 'A') THEN
30840 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30841 END IF;
30842
30843 --
30844
30845
30846 --
30847 AcctLineType_45 (
30848 p_application_id => p_application_id
30849 ,p_event_id => l_event_id
30850 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30851 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30852 ,p_actual_flag => l_actual_flag
30853 ,p_balance_type_code => l_balance_type_code
30854 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30855
30856 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30857 , p_source_6 => l_array_source_6(Idx)
30858 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30859 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30860 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30861 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30862 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30863 , p_source_12 => l_array_source_12(Idx)
30864 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30865 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30866 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30867 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30868 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30869 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30870 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30871 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30872 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30873 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30874 , p_source_28 => l_array_source_28(Idx)
30875 );
30876 If(l_balance_type_code = 'A') THEN
30877 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30878 END IF;
30879
30880 --
30881
30882
30883 --
30884 AcctLineType_47 (
30885 p_application_id => p_application_id
30886 ,p_event_id => l_event_id
30887 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30888 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30889 ,p_actual_flag => l_actual_flag
30890 ,p_balance_type_code => l_balance_type_code
30891 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30892
30893 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30894 , p_source_6 => l_array_source_6(Idx)
30895 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
30896 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
30897 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
30898 , p_source_10 => g_array_event(l_event_id).array_value_num('source_10')
30899 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
30900 , p_source_12 => l_array_source_12(Idx)
30901 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30902 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30903 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30904 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30905 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30906 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30907 , p_source_19 => g_array_event(l_event_id).array_value_date('source_19')
30908 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
30909 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
30910 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30911 , p_source_29 => l_array_source_29(Idx)
30912 , p_source_34 => l_array_source_34(Idx)
30913 );
30914 If(l_balance_type_code = 'A') THEN
30915 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30916 END IF;
30917
30918 --
30919
30920
30921 --
30922 AcctLineType_49 (
30923 p_application_id => p_application_id
30924 ,p_event_id => l_event_id
30925 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30926 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30927 ,p_actual_flag => l_actual_flag
30928 ,p_balance_type_code => l_balance_type_code
30929 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30930
30931 , p_source_2 => l_array_source_2(Idx)
30932 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30933 , p_source_6 => l_array_source_6(Idx)
30934 , p_source_12 => l_array_source_12(Idx)
30935 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30936 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30937 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30938 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30939 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30940 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30941 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30942 , p_source_25 => l_array_source_25(Idx)
30943 , p_source_26 => l_array_source_26(Idx)
30944 , p_source_32 => l_array_source_32(Idx)
30945 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
30946 );
30947 If(l_balance_type_code = 'A') THEN
30948 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30949 END IF;
30950
30951 --
30952
30953
30954 --
30955 AcctLineType_51 (
30956 p_application_id => p_application_id
30957 ,p_event_id => l_event_id
30958 ,p_calculate_acctd_flag => l_calculate_acctd_flag
30959 ,p_calculate_g_l_flag => l_calculate_g_l_flag
30960 ,p_actual_flag => l_actual_flag
30961 ,p_balance_type_code => l_balance_type_code
30962 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
30963
30964 , p_source_2 => l_array_source_2(Idx)
30965 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
30966 , p_source_6 => l_array_source_6(Idx)
30967 , p_source_12 => l_array_source_12(Idx)
30968 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
30969 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
30970 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
30971 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
30972 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
30973 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
30974 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
30975 , p_source_25 => l_array_source_25(Idx)
30976 , p_source_26 => l_array_source_26(Idx)
30977 , p_source_32 => l_array_source_32(Idx)
30978 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
30979 );
30980 If(l_balance_type_code = 'A') THEN
30981 l_actual_gain_loss_ref := l_gain_or_loss_ref;
30982 END IF;
30983
30984 --
30985
30986 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
30987 -- or secondary ledger that has different currency with primary
30988 -- or alc that is calculated by sla
30989 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
30990 (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code in ('ALC', 'SECONDARY') AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.calculate_amts_flag='Y'))
30991
30992 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
30993 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
30994 AND (l_actual_flag = 'A')) THEN
30995 XLA_AE_LINES_PKG.CreateGainOrLossLines(
30996 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
30997 ,p_application_id => p_application_id
30998 ,p_amb_context_code => 'DEFAULT'
30999 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
31000 ,p_event_class_code => C_EVENT_CLASS_CODE
31001 ,p_event_type_code => C_EVENT_TYPE_CODE
31002
31003 ,p_gain_ccid => -1
31004 ,p_loss_ccid => -1
31005
31006 ,p_actual_flag => l_actual_flag
31007 ,p_enc_flag => null
31008 ,p_actual_g_l_ref => l_actual_gain_loss_ref
31009 ,p_enc_g_l_ref => null
31010 );
31011 END IF;
31012 END IF;
31013 END IF;
31014
31015 ELSE
31016 --
31017 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
31018 --
31019 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
31020 trace
31021 (p_msg => 'Trancaction revesal option is Y'
31022 ,p_level => C_LEVEL_STATEMENT
31023 ,p_module => l_log_module);
31024 END IF;
31025 END IF;
31026
31027 END LOOP;
31028 l_result := XLA_AE_LINES_PKG.InsertLines ;
31029 end loop;
31030 close line_cur;
31031
31032
31033 --
31034 -- insert headers into xla_ae_headers_gt table
31035 --
31036 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
31037
31038 -- insert into errors table here.
31039
31040 END LOOP;
31041
31042 --
31043 -- 4865292
31044 --
31045 -- Compare g_hdr_extract_count with event count in
31046 -- CreateHeadersAndLines.
31047 --
31048 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
31049
31050 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
31051 trace (p_msg => '# rows extracted from header extract objects '
31052 || ' (running total): '
31053 || g_hdr_extract_count
31054 ,p_level => C_LEVEL_STATEMENT
31055 ,p_module => l_log_module);
31056 END IF;
31057
31058 CLOSE header_cur;
31059 --
31060
31061 --
31062 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31063 trace
31064 (p_msg => 'END of EventClass_53'
31065 ,p_level => C_LEVEL_PROCEDURE
31066 ,p_module => l_log_module);
31067 END IF;
31068 --
31069 RETURN l_result;
31070 EXCEPTION
31071 WHEN xla_exceptions_pkg.application_exception THEN
31072
31073 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
31074
31075
31076 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
31077
31078 RAISE;
31079
31080 WHEN NO_DATA_FOUND THEN
31081
31082 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
31083 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
31084
31085 FOR header_record IN header_cur
31086 LOOP
31087 l_array_header_events(header_record.event_id) := header_record.event_id;
31088 END LOOP;
31089
31090 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
31091 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
31092
31093 fnd_file.put_line(fnd_file.LOG, ' ');
31094 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
31095 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
31096 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
31097
31098 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
31099 LOOP
31100 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
31101 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
31102 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
31103 END IF;
31104 END LOOP;
31105
31106 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
31107 fnd_file.put_line(fnd_file.LOG, ' ');
31108
31109
31110 xla_exceptions_pkg.raise_message
31111 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.EventClass_53');
31112
31113
31114 WHEN OTHERS THEN
31115 xla_exceptions_pkg.raise_message
31116 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.EventClass_53');
31117 END EventClass_53;
31118 --
31119
31120 ---------------------------------------
31121 --
31122 -- PRIVATE PROCEDURE
31123 -- insert_sources_54
31124 --
31125 ----------------------------------------
31126 --
31127 PROCEDURE insert_sources_54(
31128 p_target_ledger_id IN NUMBER
31129 , p_language IN VARCHAR2
31130 , p_sla_ledger_id IN NUMBER
31131 , p_pad_start_date IN DATE
31132 , p_pad_end_date IN DATE
31133 )
31134 IS
31135
31136 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'PURCHASE_ORDER_ALL';
31137 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'PURCHASE_ORDER';
31138 p_apps_owner VARCHAR2(30);
31139 l_log_module VARCHAR2(240);
31140 BEGIN
31141 IF g_log_enabled THEN
31142 l_log_module := C_DEFAULT_MODULE||'.insert_sources_54';
31143 END IF;
31144 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31145
31146 trace
31147 (p_msg => 'BEGIN of insert_sources_54'
31148 ,p_level => C_LEVEL_PROCEDURE
31149 ,p_module => l_log_module);
31150
31151 END IF;
31152
31153 -- select APPS owner
31154 SELECT oracle_username
31155 INTO p_apps_owner
31156 FROM fnd_oracle_userid
31157 WHERE read_only_flag = 'U'
31158 ;
31159
31160 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
31161 trace
31162 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
31163 ' - p_language = '||p_language||
31164 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
31165 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
31166 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
31167 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
31168 ,p_level => C_LEVEL_STATEMENT
31169 ,p_module => l_log_module);
31170 END IF;
31171
31172
31173 --
31174 INSERT INTO xla_diag_sources --hdr2
31175 (
31176 event_id
31177 , ledger_id
31178 , sla_ledger_id
31179 , description_language
31180 , object_name
31181 , object_type_code
31182 , line_number
31183 , source_application_id
31184 , source_type_code
31185 , source_code
31186 , source_value
31187 , source_meaning
31188 , created_by
31189 , creation_date
31190 , last_update_date
31191 , last_updated_by
31192 , last_update_login
31193 , program_update_date
31194 , program_application_id
31195 , program_id
31196 , request_id
31197 )
31198 SELECT
31199 event_id
31200 , p_target_ledger_id
31201 , p_sla_ledger_id
31202 , p_language
31203 , object_name
31204 , object_type_code
31205 , line_number
31206 , source_application_id
31207 , source_type_code
31208 , source_code
31209 , SUBSTR(source_value ,1,1996)
31210 , SUBSTR(source_meaning ,1,200)
31211 , xla_environment_pkg.g_Usr_Id
31212 , TRUNC(SYSDATE)
31213 , TRUNC(SYSDATE)
31214 , xla_environment_pkg.g_Usr_Id
31215 , xla_environment_pkg.g_Login_Id
31216 , TRUNC(SYSDATE)
31217 , xla_environment_pkg.g_Prog_Appl_Id
31218 , xla_environment_pkg.g_Prog_Id
31219 , xla_environment_pkg.g_Req_Id
31220 FROM (
31221 SELECT xet.event_id event_id
31222 , 0 line_number
31223 , CASE r
31224 WHEN 1 THEN 'PO_DISTS_REF_V'
31225 WHEN 2 THEN 'CST_XLA_INV_REF_V'
31226 WHEN 3 THEN 'CST_XLA_INV_REF_V'
31227 WHEN 4 THEN 'CST_XLA_INV_REF_V'
31228 WHEN 5 THEN 'CST_XLA_INV_REF_V'
31229 WHEN 6 THEN 'CST_XLA_INV_HEADERS_V'
31230 WHEN 7 THEN 'CST_XLA_INV_REF_V'
31231 WHEN 8 THEN 'CST_XLA_INV_REF_V'
31232 WHEN 9 THEN 'PSA_CST_XLA_UPG_V'
31233 WHEN 10 THEN 'PO_HEADERS_REF_V'
31234 WHEN 11 THEN 'CST_XLA_INV_REF_V'
31235 WHEN 12 THEN 'CST_XLA_INV_REF_V'
31236 WHEN 13 THEN 'CST_XLA_INV_HEADERS_V'
31237
31238 ELSE null
31239 END object_name
31240 , CASE r
31241 WHEN 1 THEN 'HEADER'
31242 WHEN 2 THEN 'HEADER'
31243 WHEN 3 THEN 'HEADER'
31244 WHEN 4 THEN 'HEADER'
31245 WHEN 5 THEN 'HEADER'
31246 WHEN 6 THEN 'HEADER'
31247 WHEN 7 THEN 'HEADER'
31248 WHEN 8 THEN 'HEADER'
31249 WHEN 9 THEN 'HEADER'
31250 WHEN 10 THEN 'HEADER'
31251 WHEN 11 THEN 'HEADER'
31252 WHEN 12 THEN 'HEADER'
31253 WHEN 13 THEN 'HEADER'
31254
31255 ELSE null
31256 END object_type_code
31257 , CASE r
31258 WHEN 1 THEN '201'
31259 WHEN 2 THEN '707'
31260 WHEN 3 THEN '707'
31261 WHEN 4 THEN '707'
31262 WHEN 5 THEN '707'
31263 WHEN 6 THEN '707'
31264 WHEN 7 THEN '707'
31265 WHEN 8 THEN '707'
31266 WHEN 9 THEN '707'
31267 WHEN 10 THEN '201'
31268 WHEN 11 THEN '707'
31269 WHEN 12 THEN '707'
31270 WHEN 13 THEN '707'
31271
31272 ELSE null
31273 END source_application_id
31274 , 'S' source_type_code
31275 , CASE r
31276 WHEN 1 THEN 'PO_BUDGET_ACCOUNT'
31277 WHEN 2 THEN 'APPLIED_TO_APPL_ID'
31278 WHEN 3 THEN 'APPLIED_TO_DIST_LINK_TYPE'
31279 WHEN 4 THEN 'APPLIED_TO_ENTITY_CODE'
31280 WHEN 5 THEN 'APPLIED_TO_PO_DOC_ID'
31281 WHEN 6 THEN 'DISTRIBUTION_TYPE'
31282 WHEN 7 THEN 'ENCUM_REVERSAL_AMOUNT_ENTERED'
31283 WHEN 8 THEN 'ENCUMBRANCE_REVERSAL_AMOUNT'
31284 WHEN 9 THEN 'CST_ENCUM_UPG_OPTION'
31285 WHEN 10 THEN 'PURCH_ENCUMBRANCE_TYPE_ID'
31286 WHEN 11 THEN 'TXN_PO_DISTRIBUTION_ID'
31287 WHEN 12 THEN 'PARENT_TRANSACTION_ID'
31288 WHEN 13 THEN 'TRANSFER_TO_GL_INDICATOR'
31289
31290 ELSE null
31291 END source_code
31292 , CASE r
31293 WHEN 1 THEN TO_CHAR(h5.PO_BUDGET_ACCOUNT)
31294 WHEN 2 THEN TO_CHAR(h3.APPLIED_TO_APPL_ID)
31295 WHEN 3 THEN TO_CHAR(h3.APPLIED_TO_DIST_LINK_TYPE)
31296 WHEN 4 THEN TO_CHAR(h3.APPLIED_TO_ENTITY_CODE)
31297 WHEN 5 THEN TO_CHAR(h3.APPLIED_TO_PO_DOC_ID)
31298 WHEN 6 THEN TO_CHAR(h1.DISTRIBUTION_TYPE)
31299 WHEN 7 THEN TO_CHAR(h3.ENCUM_REVERSAL_AMOUNT_ENTERED)
31300 WHEN 8 THEN TO_CHAR(h3.ENCUMBRANCE_REVERSAL_AMOUNT)
31301 WHEN 9 THEN TO_CHAR(h7.CST_ENCUM_UPG_OPTION)
31302 WHEN 10 THEN TO_CHAR(h6.PURCH_ENCUMBRANCE_TYPE_ID)
31303 WHEN 11 THEN TO_CHAR(h3.TXN_PO_DISTRIBUTION_ID)
31304 WHEN 12 THEN TO_CHAR(h3.PARENT_TRANSACTION_ID)
31305 WHEN 13 THEN TO_CHAR(h1.TRANSFER_TO_GL_INDICATOR)
31306
31307 ELSE null
31308 END source_value
31309 , CASE r
31310 WHEN 6 THEN fvl13.meaning
31311 WHEN 13 THEN fvl36.meaning
31312
31313 ELSE null
31314 END source_meaning
31315 FROM xla_events_gt xet
31316 , CST_XLA_INV_HEADERS_V h1
31317 , CST_XLA_INV_REF_V h3
31318 , PO_DISTS_REF_V h5
31319 , PO_HEADERS_REF_V h6
31320 , PSA_CST_XLA_UPG_V h7
31321 , fnd_lookup_values fvl13
31322 , fnd_lookup_values fvl36
31323 ,(select rownum r from all_objects where rownum <= 13 and owner = p_apps_owner)
31324 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
31325 AND xet.event_class_code = C_EVENT_CLASS_CODE
31326 AND h1.event_id = xet.event_id
31327 AND h3.ref_transaction_id = h1.transaction_id AND h3.txn_po_header_id = h5.po_header_id (+) and h3.txn_po_distribution_id = h5.po_distribution_id (+) AND h3.txn_po_header_id = h6.po_header_id (+) AND h3.rcv_transaction_id = h7.transaction_id (+) AND fvl13.lookup_type(+) = 'CST_DISTRIBUTION_TYPE'
31328 AND fvl13.lookup_code(+) = h1.DISTRIBUTION_TYPE
31329 AND fvl13.view_application_id(+) = 700
31330 AND fvl13.language(+) = USERENV('LANG')
31331 AND fvl36.lookup_type(+) = 'YES_NO'
31332 AND fvl36.lookup_code(+) = h1.TRANSFER_TO_GL_INDICATOR
31333 AND fvl36.view_application_id(+) = 0
31334 AND fvl36.language(+) = USERENV('LANG')
31335
31336 )
31337 ;
31338 --
31339 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
31340
31341 trace
31342 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
31343 ,p_level => C_LEVEL_STATEMENT
31344 ,p_module => l_log_module);
31345
31346 END IF;
31347 --
31348
31349
31350
31351 --
31352 INSERT INTO xla_diag_sources --line2
31353 (
31354 event_id
31355 , ledger_id
31356 , sla_ledger_id
31357 , description_language
31358 , object_name
31359 , object_type_code
31360 , line_number
31361 , source_application_id
31362 , source_type_code
31363 , source_code
31364 , source_value
31365 , source_meaning
31366 , created_by
31367 , creation_date
31368 , last_update_date
31369 , last_updated_by
31370 , last_update_login
31371 , program_update_date
31372 , program_application_id
31373 , program_id
31374 , request_id
31375 )
31376 SELECT event_id
31377 , p_target_ledger_id
31378 , p_sla_ledger_id
31379 , p_language
31380 , object_name
31381 , object_type_code
31382 , line_number
31383 , source_application_id
31384 , source_type_code
31385 , source_code
31386 , SUBSTR(source_value,1,1996)
31387 , SUBSTR(source_meaning ,1,200)
31388 , xla_environment_pkg.g_Usr_Id
31389 , TRUNC(SYSDATE)
31390 , TRUNC(SYSDATE)
31391 , xla_environment_pkg.g_Usr_Id
31392 , xla_environment_pkg.g_Login_Id
31393 , TRUNC(SYSDATE)
31394 , xla_environment_pkg.g_Prog_Appl_Id
31395 , xla_environment_pkg.g_Prog_Id
31396 , xla_environment_pkg.g_Req_Id
31397 FROM (
31398 SELECT xet.event_id event_id
31399 , l2.line_number line_number
31400 , CASE r
31401 WHEN 1 THEN 'FV_XLA_CST_REF_V'
31402 WHEN 2 THEN 'FV_XLA_CST_REF_V'
31403 WHEN 3 THEN 'FV_XLA_CST_REF_V'
31404 WHEN 4 THEN 'CST_XLA_INV_LINES_V'
31405 WHEN 5 THEN 'CST_XLA_INV_LINES_V'
31406 WHEN 6 THEN 'FV_XLA_CST_REF_V'
31407 WHEN 7 THEN 'CST_XLA_INV_LINES_V'
31408 WHEN 8 THEN 'CST_XLA_INV_LINES_V'
31409 WHEN 9 THEN 'CST_XLA_INV_LINES_V'
31410 WHEN 10 THEN 'FV_XLA_CST_REF_V'
31411 WHEN 11 THEN 'CST_XLA_INV_LINES_V'
31412 WHEN 12 THEN 'CST_XLA_INV_LINES_V'
31413 WHEN 13 THEN 'FV_XLA_CST_REF_V'
31414 WHEN 14 THEN 'FV_XLA_CST_REF_V'
31415 WHEN 15 THEN 'FV_XLA_CST_REF_V'
31416 WHEN 16 THEN 'FV_XLA_CST_REF_V'
31417 WHEN 17 THEN 'FV_XLA_CST_REF_V'
31418
31419 ELSE null
31420 END object_name
31421 , CASE r
31422 WHEN 1 THEN 'LINE'
31423 WHEN 2 THEN 'LINE'
31424 WHEN 3 THEN 'LINE'
31425 WHEN 4 THEN 'LINE'
31426 WHEN 5 THEN 'LINE'
31427 WHEN 6 THEN 'LINE'
31428 WHEN 7 THEN 'LINE'
31429 WHEN 8 THEN 'LINE'
31430 WHEN 9 THEN 'LINE'
31431 WHEN 10 THEN 'LINE'
31432 WHEN 11 THEN 'LINE'
31433 WHEN 12 THEN 'LINE'
31434 WHEN 13 THEN 'LINE'
31435 WHEN 14 THEN 'LINE'
31436 WHEN 15 THEN 'LINE'
31437 WHEN 16 THEN 'LINE'
31438 WHEN 17 THEN 'LINE'
31439
31440 ELSE null
31441 END object_type_code
31442 , CASE r
31443 WHEN 1 THEN '8901'
31444 WHEN 2 THEN '8901'
31445 WHEN 3 THEN '8901'
31446 WHEN 4 THEN '707'
31447 WHEN 5 THEN '707'
31448 WHEN 6 THEN '8901'
31449 WHEN 7 THEN '707'
31450 WHEN 8 THEN '707'
31451 WHEN 9 THEN '707'
31452 WHEN 10 THEN '8901'
31453 WHEN 11 THEN '707'
31454 WHEN 12 THEN '707'
31455 WHEN 13 THEN '8901'
31456 WHEN 14 THEN '8901'
31457 WHEN 15 THEN '8901'
31458 WHEN 16 THEN '8901'
31459 WHEN 17 THEN '8901'
31460
31461 ELSE null
31462 END source_application_id
31463 , 'S' source_type_code
31464 , CASE r
31465 WHEN 1 THEN 'FEDERAL_FUND_EXPIRED_STATUS'
31466 WHEN 2 THEN 'FEDERAL_FUND_CATEGORY'
31467 WHEN 3 THEN 'FEDERAL_PRIOR_YEAR_FLAG'
31468 WHEN 4 THEN 'DISTRIBUTION_IDENTIFIER'
31469 WHEN 5 THEN 'CURRENCY_CODE'
31470 WHEN 6 THEN 'FEDERAL_ANTICIPATED_AMT'
31471 WHEN 7 THEN 'CURRENCY_CONVERSION_DATE'
31472 WHEN 8 THEN 'CURRENCY_CONVERSION_RATE'
31473 WHEN 9 THEN 'CURRENCY_CONVERSION_TYPE'
31474 WHEN 10 THEN 'FEDERAL_UNANTICIPATED_AMT'
31475 WHEN 11 THEN 'ENTERED_AMOUNT'
31476 WHEN 12 THEN 'ACCOUNTED_AMOUNT'
31477 WHEN 13 THEN 'FEDERAL_NET_PYA_ADJ_AMT'
31478 WHEN 14 THEN 'FEDERAL_PAID_UNEXP_OBG_AMT'
31479 WHEN 15 THEN 'FEDERAL_UNPAID_UNEXP_OBG_AMT'
31480 WHEN 16 THEN 'FEDERAL_RCV_SUB_LEDGER_ID'
31481 WHEN 17 THEN 'FEDERAL_UNEXP_OBG_AMT'
31482
31483 ELSE null
31484 END source_code
31485 , CASE r
31486 WHEN 1 THEN TO_CHAR(l4.FEDERAL_FUND_EXPIRED_STATUS)
31487 WHEN 2 THEN TO_CHAR(l4.FEDERAL_FUND_CATEGORY)
31488 WHEN 3 THEN TO_CHAR(l4.FEDERAL_PRIOR_YEAR_FLAG)
31489 WHEN 4 THEN TO_CHAR(l2.DISTRIBUTION_IDENTIFIER)
31490 WHEN 5 THEN TO_CHAR(l2.CURRENCY_CODE)
31491 WHEN 6 THEN TO_CHAR(l4.FEDERAL_ANTICIPATED_AMT)
31492 WHEN 7 THEN TO_CHAR(l2.CURRENCY_CONVERSION_DATE)
31493 WHEN 8 THEN TO_CHAR(l2.CURRENCY_CONVERSION_RATE)
31494 WHEN 9 THEN TO_CHAR(l2.CURRENCY_CONVERSION_TYPE)
31495 WHEN 10 THEN TO_CHAR(l4.FEDERAL_UNANTICIPATED_AMT)
31496 WHEN 11 THEN TO_CHAR(l2.ENTERED_AMOUNT)
31497 WHEN 12 THEN TO_CHAR(l2.ACCOUNTED_AMOUNT)
31498 WHEN 13 THEN TO_CHAR(l4.FEDERAL_NET_PYA_ADJ_AMT)
31499 WHEN 14 THEN TO_CHAR(l4.FEDERAL_PAID_UNEXP_OBG_AMT)
31500 WHEN 15 THEN TO_CHAR(l4.FEDERAL_UNPAID_UNEXP_OBG_AMT)
31501 WHEN 16 THEN TO_CHAR(l4.FEDERAL_RCV_SUB_LEDGER_ID)
31502 WHEN 17 THEN TO_CHAR(l4.FEDERAL_UNEXP_OBG_AMT)
31503
31504 ELSE null
31505 END source_value
31506 , null source_meaning
31507 FROM xla_events_gt xet
31508 , CST_XLA_INV_LINES_V l2
31509 , FV_XLA_CST_REF_V l4
31510 , (select rownum r from all_objects where rownum <= 17 and owner = p_apps_owner)
31511 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
31512 AND xet.event_class_code = C_EVENT_CLASS_CODE
31513 AND l2.event_id = xet.event_id
31514 AND l4.federal_event_id (+) = l2.event_id and l4.federal_line_number (+) =l2.line_number
31515 )
31516 ;
31517 --
31518 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
31519
31520 trace
31521 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
31522 ,p_level => C_LEVEL_STATEMENT
31523 ,p_module => l_log_module);
31524
31525 END IF;
31526
31527
31528 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31529 trace
31530 (p_msg => 'END of insert_sources_54'
31531 ,p_level => C_LEVEL_PROCEDURE
31532 ,p_module => l_log_module);
31533 END IF;
31534 EXCEPTION
31535 WHEN xla_exceptions_pkg.application_exception THEN
31536 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
31537 trace
31538 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
31539 ,p_level => C_LEVEL_EXCEPTION
31540 ,p_module => l_log_module);
31541 END IF;
31542 RAISE;
31543 WHEN OTHERS THEN
31544 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
31545 trace
31546 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
31547 ,p_level => C_LEVEL_EXCEPTION
31548 ,p_module => l_log_module);
31549 END IF;
31550 xla_exceptions_pkg.raise_message
31551 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.insert_sources_54');
31552 END insert_sources_54;
31553 --
31554
31555 ---------------------------------------
31556 --
31557 -- PRIVATE FUNCTION
31558 -- EventClass_54
31559 --
31560 ----------------------------------------
31561 --
31562 FUNCTION EventClass_54
31563 (p_application_id IN NUMBER
31564 ,p_base_ledger_id IN NUMBER
31565 ,p_target_ledger_id IN NUMBER
31566 ,p_language IN VARCHAR2
31567 ,p_currency_code IN VARCHAR2
31568 ,p_sla_ledger_id IN NUMBER
31569 ,p_pad_start_date IN DATE
31570 ,p_pad_end_date IN DATE
31571 ,p_primary_ledger_id IN NUMBER)
31572 RETURN BOOLEAN IS
31573 --
31574 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'PURCHASE_ORDER_ALL';
31575 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'PURCHASE_ORDER';
31576
31577 l_calculate_acctd_flag VARCHAR2(1) :='N';
31578 l_calculate_g_l_flag VARCHAR2(1) :='N';
31579 --
31580 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
31581 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
31582 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
31583 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
31584 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
31585 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
31586 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
31587 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
31588 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
31589 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
31590 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
31591 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
31592 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
31593 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
31594 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
31595 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
31596 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
31597 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
31598 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
31599 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
31600 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
31601 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
31602 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
31603 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
31604 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
31605 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
31606
31607 l_event_id NUMBER;
31608 l_previous_event_id NUMBER;
31609 l_first_event_id NUMBER;
31610 l_last_event_id NUMBER;
31611
31612 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
31613 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
31614 --
31615 --
31616 l_result BOOLEAN := TRUE;
31617 l_rows NUMBER := 1000;
31618 l_event_type_name VARCHAR2(80) := 'All';
31619 l_event_class_name VARCHAR2(80) := 'PO Delivery into Inventory';
31620 l_description VARCHAR2(4000);
31621 l_transaction_reversal NUMBER;
31622 l_ae_header_id NUMBER;
31623 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
31624 l_log_module VARCHAR2(240);
31625 --
31626 l_acct_reversal_source VARCHAR2(30);
31627 l_trx_reversal_source VARCHAR2(30);
31628
31629 l_continue_with_lines BOOLEAN := TRUE;
31630 --
31631 l_acc_rev_gl_date_source DATE; -- 4262811
31632 --
31633 type t_array_event_id is table of number index by binary_integer;
31634
31635 l_rec_array_event t_rec_array_event;
31636 l_null_rec_array_event t_rec_array_event;
31637 l_array_ae_header_id xla_number_array_type;
31638 l_actual_flag VARCHAR2(1) := NULL;
31639 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
31640 l_balance_type_code VARCHAR2(1) :=NULL;
31641 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
31642
31643 --
31644 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
31645 --
31646
31647 TYPE t_array_source_3 IS TABLE OF PO_DISTS_REF_V.PO_BUDGET_ACCOUNT%TYPE INDEX BY BINARY_INTEGER;
31648 TYPE t_array_source_7 IS TABLE OF CST_XLA_INV_REF_V.APPLIED_TO_APPL_ID%TYPE INDEX BY BINARY_INTEGER;
31649 TYPE t_array_source_8 IS TABLE OF CST_XLA_INV_REF_V.APPLIED_TO_DIST_LINK_TYPE%TYPE INDEX BY BINARY_INTEGER;
31650 TYPE t_array_source_9 IS TABLE OF CST_XLA_INV_REF_V.APPLIED_TO_ENTITY_CODE%TYPE INDEX BY BINARY_INTEGER;
31651 TYPE t_array_source_11 IS TABLE OF CST_XLA_INV_REF_V.APPLIED_TO_PO_DOC_ID%TYPE INDEX BY BINARY_INTEGER;
31652 TYPE t_array_source_13 IS TABLE OF CST_XLA_INV_HEADERS_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
31653 TYPE t_array_source_14 IS TABLE OF CST_XLA_INV_REF_V.ENCUM_REVERSAL_AMOUNT_ENTERED%TYPE INDEX BY BINARY_INTEGER;
31654 TYPE t_array_source_16 IS TABLE OF CST_XLA_INV_REF_V.ENCUMBRANCE_REVERSAL_AMOUNT%TYPE INDEX BY BINARY_INTEGER;
31655 TYPE t_array_source_17 IS TABLE OF PSA_CST_XLA_UPG_V.CST_ENCUM_UPG_OPTION%TYPE INDEX BY BINARY_INTEGER;
31656 TYPE t_array_source_22 IS TABLE OF PO_HEADERS_REF_V.PURCH_ENCUMBRANCE_TYPE_ID%TYPE INDEX BY BINARY_INTEGER;
31657 TYPE t_array_source_23 IS TABLE OF CST_XLA_INV_REF_V.TXN_PO_DISTRIBUTION_ID%TYPE INDEX BY BINARY_INTEGER;
31658 TYPE t_array_source_33 IS TABLE OF CST_XLA_INV_REF_V.PARENT_TRANSACTION_ID%TYPE INDEX BY BINARY_INTEGER;
31659 TYPE t_array_source_36 IS TABLE OF CST_XLA_INV_HEADERS_V.TRANSFER_TO_GL_INDICATOR%TYPE INDEX BY BINARY_INTEGER;
31660
31661 TYPE t_array_source_1 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_FUND_EXPIRED_STATUS%TYPE INDEX BY BINARY_INTEGER;
31662 TYPE t_array_source_2 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_FUND_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
31663 TYPE t_array_source_5 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_PRIOR_YEAR_FLAG%TYPE INDEX BY BINARY_INTEGER;
31664 TYPE t_array_source_12 IS TABLE OF CST_XLA_INV_LINES_V.DISTRIBUTION_IDENTIFIER%TYPE INDEX BY BINARY_INTEGER;
31665 TYPE t_array_source_15 IS TABLE OF CST_XLA_INV_LINES_V.CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
31666 TYPE t_array_source_18 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_ANTICIPATED_AMT%TYPE INDEX BY BINARY_INTEGER;
31667 TYPE t_array_source_19 IS TABLE OF CST_XLA_INV_LINES_V.CURRENCY_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
31668 TYPE t_array_source_20 IS TABLE OF CST_XLA_INV_LINES_V.CURRENCY_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
31669 TYPE t_array_source_21 IS TABLE OF CST_XLA_INV_LINES_V.CURRENCY_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
31670 TYPE t_array_source_24 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_UNANTICIPATED_AMT%TYPE INDEX BY BINARY_INTEGER;
31671 TYPE t_array_source_25 IS TABLE OF CST_XLA_INV_LINES_V.ENTERED_AMOUNT%TYPE INDEX BY BINARY_INTEGER;
31672 TYPE t_array_source_26 IS TABLE OF CST_XLA_INV_LINES_V.ACCOUNTED_AMOUNT%TYPE INDEX BY BINARY_INTEGER;
31673 TYPE t_array_source_27 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_NET_PYA_ADJ_AMT%TYPE INDEX BY BINARY_INTEGER;
31674 TYPE t_array_source_28 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_PAID_UNEXP_OBG_AMT%TYPE INDEX BY BINARY_INTEGER;
31675 TYPE t_array_source_29 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_UNPAID_UNEXP_OBG_AMT%TYPE INDEX BY BINARY_INTEGER;
31676 TYPE t_array_source_32 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_RCV_SUB_LEDGER_ID%TYPE INDEX BY BINARY_INTEGER;
31677 TYPE t_array_source_34 IS TABLE OF FV_XLA_CST_REF_V.FEDERAL_UNEXP_OBG_AMT%TYPE INDEX BY BINARY_INTEGER;
31678
31679 l_array_source_3 t_array_source_3;
31680 l_array_source_7 t_array_source_7;
31681 l_array_source_8 t_array_source_8;
31682 l_array_source_9 t_array_source_9;
31683 l_array_source_11 t_array_source_11;
31684 l_array_source_13 t_array_source_13;
31685 l_array_source_13_meaning t_array_lookup_meaning;
31686 l_array_source_14 t_array_source_14;
31687 l_array_source_16 t_array_source_16;
31688 l_array_source_17 t_array_source_17;
31689 l_array_source_22 t_array_source_22;
31690 l_array_source_23 t_array_source_23;
31691 l_array_source_33 t_array_source_33;
31692 l_array_source_36 t_array_source_36;
31693 l_array_source_36_meaning t_array_lookup_meaning;
31694
31695 l_array_source_1 t_array_source_1;
31696 l_array_source_2 t_array_source_2;
31697 l_array_source_5 t_array_source_5;
31698 l_array_source_12 t_array_source_12;
31699 l_array_source_15 t_array_source_15;
31700 l_array_source_18 t_array_source_18;
31701 l_array_source_19 t_array_source_19;
31702 l_array_source_20 t_array_source_20;
31703 l_array_source_21 t_array_source_21;
31704 l_array_source_24 t_array_source_24;
31705 l_array_source_25 t_array_source_25;
31706 l_array_source_26 t_array_source_26;
31707 l_array_source_27 t_array_source_27;
31708 l_array_source_28 t_array_source_28;
31709 l_array_source_29 t_array_source_29;
31710 l_array_source_32 t_array_source_32;
31711 l_array_source_34 t_array_source_34;
31712
31713 --
31714 CURSOR header_cur
31715 IS
31716 SELECT /*+ leading(xet) cardinality(xet,1) */
31717 -- Event Class Code: PURCHASE_ORDER
31718 xet.entity_id
31719 ,xet.legal_entity_id
31720 ,xet.entity_code
31721 ,xet.transaction_number
31722 ,xet.event_id
31723 ,xet.event_class_code
31724 ,xet.event_type_code
31725 ,xet.event_number
31726 ,xet.event_date
31727 ,xet.transaction_date
31728 ,xet.reference_num_1
31729 ,xet.reference_num_2
31730 ,xet.reference_num_3
31731 ,xet.reference_num_4
31732 ,xet.reference_char_1
31733 ,xet.reference_char_2
31734 ,xet.reference_char_3
31735 ,xet.reference_char_4
31736 ,xet.reference_date_1
31737 ,xet.reference_date_2
31738 ,xet.reference_date_3
31739 ,xet.reference_date_4
31740 ,xet.event_created_by
31741 ,xet.budgetary_control_flag
31742 , h5.PO_BUDGET_ACCOUNT source_3
31743 , h3.APPLIED_TO_APPL_ID source_7
31744 , h3.APPLIED_TO_DIST_LINK_TYPE source_8
31745 , h3.APPLIED_TO_ENTITY_CODE source_9
31746 , h3.APPLIED_TO_PO_DOC_ID source_11
31747 , h1.DISTRIBUTION_TYPE source_13
31748 , fvl13.meaning source_13_meaning
31749 , h3.ENCUM_REVERSAL_AMOUNT_ENTERED source_14
31750 , h3.ENCUMBRANCE_REVERSAL_AMOUNT source_16
31751 , h7.CST_ENCUM_UPG_OPTION source_17
31752 , h6.PURCH_ENCUMBRANCE_TYPE_ID source_22
31753 , h3.TXN_PO_DISTRIBUTION_ID source_23
31754 , h3.PARENT_TRANSACTION_ID source_33
31755 , h1.TRANSFER_TO_GL_INDICATOR source_36
31756 , fvl36.meaning source_36_meaning
31757 FROM xla_events_gt xet
31758 , CST_XLA_INV_HEADERS_V h1
31759 , CST_XLA_INV_REF_V h3
31760 , PO_DISTS_REF_V h5
31761 , PO_HEADERS_REF_V h6
31762 , PSA_CST_XLA_UPG_V h7
31763 , fnd_lookup_values fvl13
31764 , fnd_lookup_values fvl36
31765 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
31766 and xet.event_class_code = C_EVENT_CLASS_CODE
31767 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
31768 AND h3.ref_transaction_id = h1.transaction_id AND h3.txn_po_header_id = h5.po_header_id (+) AND h3.txn_po_distribution_id = h5.po_distribution_id (+) AND h3.txn_po_header_id = h6.po_header_id (+) AND h3.rcv_transaction_id = h7.transaction_id (+) AND fvl13.lookup_type(+) = 'CST_DISTRIBUTION_TYPE'
31769 AND fvl13.lookup_code(+) = h1.DISTRIBUTION_TYPE
31770 AND fvl13.view_application_id(+) = 700
31771 AND fvl13.language(+) = USERENV('LANG')
31772 AND fvl36.lookup_type(+) = 'YES_NO'
31773 AND fvl36.lookup_code(+) = h1.TRANSFER_TO_GL_INDICATOR
31774 AND fvl36.view_application_id(+) = 0
31775 AND fvl36.language(+) = USERENV('LANG')
31776
31777 ORDER BY event_id
31778 ;
31779
31780
31781 --
31782 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
31783 IS
31784 SELECT /*+ leading(xet) cardinality(xet,1) */
31785 -- Event Class Code: PURCHASE_ORDER
31786 xet.entity_id
31787 ,xet.legal_entity_id
31788 ,xet.entity_code
31789 ,xet.transaction_number
31790 ,xet.event_id
31791 ,xet.event_class_code
31792 ,xet.event_type_code
31793 ,xet.event_number
31794 ,xet.event_date
31795 ,xet.transaction_date
31796 ,xet.reference_num_1
31797 ,xet.reference_num_2
31798 ,xet.reference_num_3
31799 ,xet.reference_num_4
31800 ,xet.reference_char_1
31801 ,xet.reference_char_2
31802 ,xet.reference_char_3
31803 ,xet.reference_char_4
31804 ,xet.reference_date_1
31805 ,xet.reference_date_2
31806 ,xet.reference_date_3
31807 ,xet.reference_date_4
31808 ,xet.event_created_by
31809 ,xet.budgetary_control_flag
31810 , l2.LINE_NUMBER
31811 , l4.FEDERAL_FUND_EXPIRED_STATUS source_1
31812 , l4.FEDERAL_FUND_CATEGORY source_2
31813 , l4.FEDERAL_PRIOR_YEAR_FLAG source_5
31814 , l2.DISTRIBUTION_IDENTIFIER source_12
31815 , l2.CURRENCY_CODE source_15
31816 , l4.FEDERAL_ANTICIPATED_AMT source_18
31817 , l2.CURRENCY_CONVERSION_DATE source_19
31818 , l2.CURRENCY_CONVERSION_RATE source_20
31819 , l2.CURRENCY_CONVERSION_TYPE source_21
31820 , l4.FEDERAL_UNANTICIPATED_AMT source_24
31821 , l2.ENTERED_AMOUNT source_25
31822 , l2.ACCOUNTED_AMOUNT source_26
31823 , l4.FEDERAL_NET_PYA_ADJ_AMT source_27
31824 , l4.FEDERAL_PAID_UNEXP_OBG_AMT source_28
31825 , l4.FEDERAL_UNPAID_UNEXP_OBG_AMT source_29
31826 , l4.FEDERAL_RCV_SUB_LEDGER_ID source_32
31827 , l4.FEDERAL_UNEXP_OBG_AMT source_34
31828 FROM xla_events_gt xet
31829 , CST_XLA_INV_LINES_V l2
31830 , FV_XLA_CST_REF_V l4
31831 WHERE xet.event_id between x_first_event_id and x_last_event_id
31832 and xet.event_date between p_pad_start_date and p_pad_end_date
31833 and xet.event_class_code = C_EVENT_CLASS_CODE
31834 and xet.event_status_code <> 'N' AND l2.event_id = xet.event_id
31835 AND l4.federal_event_id (+) = l2.event_id AND l4.federal_line_number (+) =l2.line_number;
31836
31837 --
31838 BEGIN
31839 IF g_log_enabled THEN
31840 l_log_module := C_DEFAULT_MODULE||'.EventClass_54';
31841 END IF;
31842 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31843 trace
31844 (p_msg => 'BEGIN of EventClass_54'
31845 ,p_level => C_LEVEL_PROCEDURE
31846 ,p_module => l_log_module);
31847 END IF;
31848
31849 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
31850 trace
31851 (p_msg => 'p_application_id = '||p_application_id||
31852 ' - p_base_ledger_id = '||p_base_ledger_id||
31853 ' - p_target_ledger_id = '||p_target_ledger_id||
31854 ' - p_language = '||p_language||
31855 ' - p_currency_code = '||p_currency_code||
31856 ' - p_sla_ledger_id = '||p_sla_ledger_id
31857 ,p_level => C_LEVEL_STATEMENT
31858 ,p_module => l_log_module);
31859 END IF;
31860 --
31861 -- initialze arrays
31862 --
31863 g_array_event.DELETE;
31864 l_rec_array_event := l_null_rec_array_event;
31865 --
31866 --------------------------------------
31867 -- 4262811 Initialze MPA Line Number
31868 --------------------------------------
31869 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
31870
31871 --
31872
31873 --
31874 OPEN header_cur;
31875 --
31876 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
31877 trace
31878 (p_msg => 'SQL - FETCH header_cur'
31879 ,p_level => C_LEVEL_STATEMENT
31880 ,p_module => l_log_module);
31881 END IF;
31882 --
31883 LOOP
31884 FETCH header_cur BULK COLLECT INTO
31885 l_array_entity_id
31886 , l_array_legal_entity_id
31887 , l_array_entity_code
31888 , l_array_transaction_num
31889 , l_array_event_id
31890 , l_array_class_code
31891 , l_array_event_type
31892 , l_array_event_number
31893 , l_array_event_date
31894 , l_array_transaction_date
31895 , l_array_reference_num_1
31896 , l_array_reference_num_2
31897 , l_array_reference_num_3
31898 , l_array_reference_num_4
31899 , l_array_reference_char_1
31900 , l_array_reference_char_2
31901 , l_array_reference_char_3
31902 , l_array_reference_char_4
31903 , l_array_reference_date_1
31904 , l_array_reference_date_2
31905 , l_array_reference_date_3
31906 , l_array_reference_date_4
31907 , l_array_event_created_by
31908 , l_array_budgetary_control_flag
31909 , l_array_source_3
31910 , l_array_source_7
31911 , l_array_source_8
31912 , l_array_source_9
31913 , l_array_source_11
31914 , l_array_source_13
31915 , l_array_source_13_meaning
31916 , l_array_source_14
31917 , l_array_source_16
31918 , l_array_source_17
31919 , l_array_source_22
31920 , l_array_source_23
31921 , l_array_source_33
31922 , l_array_source_36
31923 , l_array_source_36_meaning
31924 LIMIT l_rows;
31925 --
31926 IF (C_LEVEL_EVENT >= g_log_level) THEN
31927 trace
31928 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
31929 ,p_level => C_LEVEL_EVENT
31930 ,p_module => l_log_module);
31931 END IF;
31932 --
31933 EXIT WHEN l_array_entity_id.COUNT = 0;
31934
31935 -- initialize arrays
31936 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
31937 XLA_AE_LINES_PKG.g_rec_lines := NULL;
31938
31939 --
31940 -- Bug 4458708
31941 --
31942 XLA_AE_LINES_PKG.g_LineNumber := 0;
31943
31944
31945 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
31946 g_last_hdr_idx := l_array_event_id.LAST;
31947 --
31948 -- loop for the headers. Each iteration is for each header extract row
31949 -- fetched in header cursor
31950 --
31951 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
31952
31953 --
31954 -- set event info as cache for other routines to refer event attributes
31955 --
31956 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
31957 (p_application_id => p_application_id
31958 ,p_primary_ledger_id => p_primary_ledger_id
31959 ,p_base_ledger_id => p_base_ledger_id
31960 ,p_target_ledger_id => p_target_ledger_id
31961 ,p_entity_id => l_array_entity_id(hdr_idx)
31962 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
31963 ,p_entity_code => l_array_entity_code(hdr_idx)
31964 ,p_transaction_num => l_array_transaction_num(hdr_idx)
31965 ,p_event_id => l_array_event_id(hdr_idx)
31966 ,p_event_class_code => l_array_class_code(hdr_idx)
31967 ,p_event_type_code => l_array_event_type(hdr_idx)
31968 ,p_event_number => l_array_event_number(hdr_idx)
31969 ,p_event_date => l_array_event_date(hdr_idx)
31970 ,p_transaction_date => l_array_transaction_date(hdr_idx)
31971 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
31972 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
31973 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
31974 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
31975 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
31976 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
31977 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
31978 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
31979 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
31980 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
31981 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
31982 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
31983 ,p_event_created_by => l_array_event_created_by(hdr_idx)
31984 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
31985
31986 --
31987 -- set the status of entry to C_VALID (0)
31988 --
31989 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
31990
31991 --
31992 -- initialize a row for ae header
31993 --
31994 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
31995
31996 l_event_id := l_array_event_id(hdr_idx);
31997
31998 --
31999 -- storing the hdr_idx for event. May be used by line cursor.
32000 --
32001 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
32002
32003 --
32004 -- store sources from header extract. This can be improved to
32005 -- store only those sources from header extract that may be used in lines
32006 --
32007
32008 g_array_event(l_event_id).array_value_num('source_3') := l_array_source_3(hdr_idx);
32009 g_array_event(l_event_id).array_value_num('source_7') := l_array_source_7(hdr_idx);
32010 g_array_event(l_event_id).array_value_char('source_8') := l_array_source_8(hdr_idx);
32011 g_array_event(l_event_id).array_value_char('source_9') := l_array_source_9(hdr_idx);
32012 g_array_event(l_event_id).array_value_num('source_11') := l_array_source_11(hdr_idx);
32013 g_array_event(l_event_id).array_value_char('source_13') := l_array_source_13(hdr_idx);
32014 g_array_event(l_event_id).array_value_char('source_13_meaning') := l_array_source_13_meaning(hdr_idx);
32015 g_array_event(l_event_id).array_value_num('source_14') := l_array_source_14(hdr_idx);
32016 g_array_event(l_event_id).array_value_num('source_16') := l_array_source_16(hdr_idx);
32017 g_array_event(l_event_id).array_value_char('source_17') := l_array_source_17(hdr_idx);
32018 g_array_event(l_event_id).array_value_num('source_22') := l_array_source_22(hdr_idx);
32019 g_array_event(l_event_id).array_value_num('source_23') := l_array_source_23(hdr_idx);
32020 g_array_event(l_event_id).array_value_num('source_33') := l_array_source_33(hdr_idx);
32021 g_array_event(l_event_id).array_value_char('source_36') := l_array_source_36(hdr_idx);
32022 g_array_event(l_event_id).array_value_char('source_36_meaning') := l_array_source_36_meaning(hdr_idx);
32023
32024 --
32025 -- initilaize the status of ae headers for diffrent balance types
32026 -- the status is initialised to C_NOT_CREATED (2)
32027 --
32028 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
32029 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
32030 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
32031
32032 --
32033 -- call api to validate and store accounting attributes for header
32034 --
32035
32036 ------------------------------------------------------------
32037 -- Accrual Reversal : to get date for Standard Source (NONE)
32038 ------------------------------------------------------------
32039 l_acc_rev_gl_date_source := NULL;
32040
32041 l_rec_acct_attrs.array_acct_attr_code(1) := 'ENCUMBRANCE_TYPE_ID';
32042 l_rec_acct_attrs.array_num_value(1) := g_array_event(l_event_id).array_value_num('source_22');
32043 l_rec_acct_attrs.array_acct_attr_code(2) := 'GL_DATE';
32044 l_rec_acct_attrs.array_date_value(2) :=
32045 xla_ae_sources_pkg.GetSystemSourceDate(
32046 p_source_code => 'XLA_REFERENCE_DATE_1'
32047 , p_source_type_code => 'Y'
32048 , p_source_application_id => 602
32049 );
32050 l_rec_acct_attrs.array_acct_attr_code(3) := 'GL_TRANSFER_FLAG';
32051 l_rec_acct_attrs.array_char_value(3) := g_array_event(l_event_id).array_value_char('source_36');
32052
32053
32054 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
32055
32056 XLA_AE_HEADER_PKG.SetJeCategoryName;
32057
32058 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
32059 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
32060 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
32061 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
32062 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
32063
32064
32065 -- No header level analytical criteria
32066
32067 --
32068 --accounting attribute enhancement, bug 3612931
32069 --
32070 l_trx_reversal_source := SUBSTR(NULL, 1,30);
32071
32072 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
32073 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
32074
32075 xla_accounting_err_pkg.build_message
32076 (p_appli_s_name => 'XLA'
32077 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
32078 ,p_token_1 => 'ACCT_ATTR_NAME'
32079 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
32080 ,p_token_2 => 'PRODUCT_NAME'
32081 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
32082 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
32083 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
32084 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
32085
32086 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
32087 --
32088 -- following sets the accounting attributes needed to reverse
32089 -- accounting for a distributeion
32090 --
32091 xla_ae_lines_pkg.SetTrxReversalAttrs
32092 (p_event_id => l_event_id
32093 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
32094 ,p_trx_reversal_source => l_trx_reversal_source);
32095
32096 END IF;
32097
32098
32099 ----------------------------------------------------------------
32100 -- 4262811 - update the header statuses to invalid in need be
32101 ----------------------------------------------------------------
32102 --
32103 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
32104
32105
32106 -----------------------------------------------
32107 -- No accrual reversal for the event class/type
32108 -----------------------------------------------
32109 ----------------------------------------------------------------
32110
32111 --
32112 -- this ends the header loop iteration for one bulk fetch
32113 --
32114 END LOOP;
32115
32116 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
32117 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
32118
32119 --
32120 -- insert dummy rows into lines gt table that were created due to
32121 -- transaction reversals
32122 --
32123 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
32124 l_result := XLA_AE_LINES_PKG.InsertLines;
32125 END IF;
32126
32127 --
32128 -- reset the temp_line_num for each set of events fetched from header
32129 -- cursor rather than doing it for each new event in line cursor
32130 -- Bug 3939231
32131 --
32132 xla_ae_lines_pkg.g_temp_line_num := 0;
32133
32134
32135
32136 --
32137 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
32138 --
32139 --
32140 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
32141
32142 trace
32143 (p_msg => 'SQL - FETCH line_cur'
32144 ,p_level => C_LEVEL_STATEMENT
32145 ,p_module => l_log_module);
32146
32147 END IF;
32148 --
32149 --
32150 LOOP
32151 --
32152 FETCH line_cur BULK COLLECT INTO
32153 l_array_entity_id
32154 , l_array_legal_entity_id
32155 , l_array_entity_code
32156 , l_array_transaction_num
32157 , l_array_event_id
32158 , l_array_class_code
32159 , l_array_event_type
32160 , l_array_event_number
32161 , l_array_event_date
32162 , l_array_transaction_date
32163 , l_array_reference_num_1
32164 , l_array_reference_num_2
32165 , l_array_reference_num_3
32166 , l_array_reference_num_4
32167 , l_array_reference_char_1
32168 , l_array_reference_char_2
32169 , l_array_reference_char_3
32170 , l_array_reference_char_4
32171 , l_array_reference_date_1
32172 , l_array_reference_date_2
32173 , l_array_reference_date_3
32174 , l_array_reference_date_4
32175 , l_array_event_created_by
32176 , l_array_budgetary_control_flag
32177 , l_array_extract_line_num
32178 , l_array_source_1
32179 , l_array_source_2
32180 , l_array_source_5
32181 , l_array_source_12
32182 , l_array_source_15
32183 , l_array_source_18
32184 , l_array_source_19
32185 , l_array_source_20
32186 , l_array_source_21
32187 , l_array_source_24
32188 , l_array_source_25
32189 , l_array_source_26
32190 , l_array_source_27
32191 , l_array_source_28
32192 , l_array_source_29
32193 , l_array_source_32
32194 , l_array_source_34
32195 LIMIT l_rows;
32196
32197 --
32198 IF (C_LEVEL_EVENT >= g_log_level) THEN
32199 trace
32200 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
32201 ,p_level => C_LEVEL_EVENT
32202 ,p_module => l_log_module);
32203 END IF;
32204 --
32205 EXIT WHEN l_array_entity_id.count = 0;
32206
32207 XLA_AE_LINES_PKG.g_rec_lines := null;
32208
32209 --
32210 -- Bug 4458708
32211 --
32212 XLA_AE_LINES_PKG.g_LineNumber := 0;
32213 --
32214 --
32215
32216 FOR Idx IN 1..l_array_event_id.count LOOP
32217 --
32218 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
32219 --
32220 l_event_id := l_array_event_id(idx); -- 5648433
32221
32222 --
32223 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
32224 --
32225
32226 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
32227 (g_array_event(l_event_id).array_value_num('header_index'))
32228 ,'N'
32229 ) <> 'Y'
32230 THEN
32231 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
32232 trace
32233 (p_msg => 'Trancaction revesal option is not Y '
32234 ,p_level => C_LEVEL_STATEMENT
32235 ,p_module => l_log_module);
32236 END IF;
32237
32238 --
32239 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
32240 --
32241 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
32242 --
32243 -- set event info as cache for other routines to refer event attributes
32244 --
32245
32246 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
32247 l_previous_event_id := l_event_id;
32248
32249 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
32250 (p_application_id => p_application_id
32251 ,p_primary_ledger_id => p_primary_ledger_id
32252 ,p_base_ledger_id => p_base_ledger_id
32253 ,p_target_ledger_id => p_target_ledger_id
32254 ,p_entity_id => l_array_entity_id(Idx)
32255 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
32256 ,p_entity_code => l_array_entity_code(Idx)
32257 ,p_transaction_num => l_array_transaction_num(Idx)
32258 ,p_event_id => l_array_event_id(Idx)
32259 ,p_event_class_code => l_array_class_code(Idx)
32260 ,p_event_type_code => l_array_event_type(Idx)
32261 ,p_event_number => l_array_event_number(Idx)
32262 ,p_event_date => l_array_event_date(Idx)
32263 ,p_transaction_date => l_array_transaction_date(Idx)
32264 ,p_reference_num_1 => l_array_reference_num_1(Idx)
32265 ,p_reference_num_2 => l_array_reference_num_2(Idx)
32266 ,p_reference_num_3 => l_array_reference_num_3(Idx)
32267 ,p_reference_num_4 => l_array_reference_num_4(Idx)
32268 ,p_reference_char_1 => l_array_reference_char_1(Idx)
32269 ,p_reference_char_2 => l_array_reference_char_2(Idx)
32270 ,p_reference_char_3 => l_array_reference_char_3(Idx)
32271 ,p_reference_char_4 => l_array_reference_char_4(Idx)
32272 ,p_reference_date_1 => l_array_reference_date_1(Idx)
32273 ,p_reference_date_2 => l_array_reference_date_2(Idx)
32274 ,p_reference_date_3 => l_array_reference_date_3(Idx)
32275 ,p_reference_date_4 => l_array_reference_date_4(Idx)
32276 ,p_event_created_by => l_array_event_created_by(Idx)
32277 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
32278 --
32279 END IF;
32280
32281
32282
32283 --
32284 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
32285
32286 l_acct_reversal_source := SUBSTR(NULL, 1,30);
32287
32288 IF l_continue_with_lines THEN
32289 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
32290 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
32291
32292 xla_accounting_err_pkg.build_message
32293 (p_appli_s_name => 'XLA'
32294 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
32295 ,p_token_1 => 'LINE_NUMBER'
32296 ,p_value_1 => l_array_extract_line_num(Idx)
32297 ,p_token_2 => 'PRODUCT_NAME'
32298 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
32299 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
32300 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
32301 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
32302
32303 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
32304 --
32305 -- following sets the accounting attributes needed to reverse
32306 -- accounting for a distributeion
32307 --
32308
32309 --
32310 -- 5217187
32311 --
32312 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
32313 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
32314 g_array_event(l_event_id).array_value_num('header_index'));
32315 --
32316 --
32317
32318 -- No reversal code generated
32319
32320 xla_ae_lines_pkg.SetAcctReversalAttrs
32321 (p_event_id => l_event_id
32322 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
32323 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32324 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
32325 END IF;
32326
32327 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
32328 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
32329
32330 --
32331 AcctLineType_13 (
32332 p_application_id => p_application_id
32333 ,p_event_id => l_event_id
32334 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32335 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32336 ,p_actual_flag => l_actual_flag
32337 ,p_balance_type_code => l_balance_type_code
32338 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32339
32340 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32341 , p_source_5 => l_array_source_5(Idx)
32342 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32343 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32344 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32345 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32346 , p_source_12 => l_array_source_12(Idx)
32347 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32348 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32349 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32350 , p_source_15 => l_array_source_15(Idx)
32351 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32352 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32353 , p_source_18 => l_array_source_18(Idx)
32354 , p_source_19 => l_array_source_19(Idx)
32355 , p_source_20 => l_array_source_20(Idx)
32356 , p_source_21 => l_array_source_21(Idx)
32357 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32358 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32359 );
32360 If(l_balance_type_code = 'A') THEN
32361 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32362 END IF;
32363
32364 --
32365
32366
32367 --
32368 AcctLineType_15 (
32369 p_application_id => p_application_id
32370 ,p_event_id => l_event_id
32371 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32372 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32373 ,p_actual_flag => l_actual_flag
32374 ,p_balance_type_code => l_balance_type_code
32375 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32376
32377 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32378 , p_source_5 => l_array_source_5(Idx)
32379 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32380 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32381 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32382 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32383 , p_source_12 => l_array_source_12(Idx)
32384 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32385 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32386 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32387 , p_source_15 => l_array_source_15(Idx)
32388 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32389 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32390 , p_source_19 => l_array_source_19(Idx)
32391 , p_source_20 => l_array_source_20(Idx)
32392 , p_source_21 => l_array_source_21(Idx)
32393 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32394 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32395 , p_source_24 => l_array_source_24(Idx)
32396 );
32397 If(l_balance_type_code = 'A') THEN
32398 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32399 END IF;
32400
32401 --
32402
32403
32404 --
32405 AcctLineType_17 (
32406 p_application_id => p_application_id
32407 ,p_event_id => l_event_id
32408 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32409 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32410 ,p_actual_flag => l_actual_flag
32411 ,p_balance_type_code => l_balance_type_code
32412 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32413
32414 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32415 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32416 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32417 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32418 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32419 , p_source_12 => l_array_source_12(Idx)
32420 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32421 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32422 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32423 , p_source_15 => l_array_source_15(Idx)
32424 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32425 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32426 , p_source_19 => l_array_source_19(Idx)
32427 , p_source_20 => l_array_source_20(Idx)
32428 , p_source_21 => l_array_source_21(Idx)
32429 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32430 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32431 , p_source_25 => l_array_source_25(Idx)
32432 , p_source_26 => l_array_source_26(Idx)
32433 );
32434 If(l_balance_type_code = 'A') THEN
32435 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32436 END IF;
32437
32438 --
32439
32440
32441 --
32442 AcctLineType_19 (
32443 p_application_id => p_application_id
32444 ,p_event_id => l_event_id
32445 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32446 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32447 ,p_actual_flag => l_actual_flag
32448 ,p_balance_type_code => l_balance_type_code
32449 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32450
32451 , p_source_2 => l_array_source_2(Idx)
32452 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32453 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32454 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32455 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32456 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32457 , p_source_12 => l_array_source_12(Idx)
32458 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32459 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32460 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32461 , p_source_15 => l_array_source_15(Idx)
32462 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32463 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32464 , p_source_19 => l_array_source_19(Idx)
32465 , p_source_20 => l_array_source_20(Idx)
32466 , p_source_21 => l_array_source_21(Idx)
32467 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32468 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32469 , p_source_25 => l_array_source_25(Idx)
32470 , p_source_26 => l_array_source_26(Idx)
32471 );
32472 If(l_balance_type_code = 'A') THEN
32473 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32474 END IF;
32475
32476 --
32477
32478
32479 --
32480 AcctLineType_21 (
32481 p_application_id => p_application_id
32482 ,p_event_id => l_event_id
32483 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32484 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32485 ,p_actual_flag => l_actual_flag
32486 ,p_balance_type_code => l_balance_type_code
32487 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32488
32489 , p_source_2 => l_array_source_2(Idx)
32490 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32491 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32492 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32493 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32494 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32495 , p_source_12 => l_array_source_12(Idx)
32496 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32497 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32498 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32499 , p_source_15 => l_array_source_15(Idx)
32500 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32501 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32502 , p_source_19 => l_array_source_19(Idx)
32503 , p_source_20 => l_array_source_20(Idx)
32504 , p_source_21 => l_array_source_21(Idx)
32505 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32506 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32507 , p_source_25 => l_array_source_25(Idx)
32508 , p_source_26 => l_array_source_26(Idx)
32509 );
32510 If(l_balance_type_code = 'A') THEN
32511 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32512 END IF;
32513
32514 --
32515
32516
32517 --
32518 AcctLineType_23 (
32519 p_application_id => p_application_id
32520 ,p_event_id => l_event_id
32521 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32522 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32523 ,p_actual_flag => l_actual_flag
32524 ,p_balance_type_code => l_balance_type_code
32525 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32526
32527 , p_source_1 => l_array_source_1(Idx)
32528 , p_source_2 => l_array_source_2(Idx)
32529 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32530 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32531 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32532 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32533 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32534 , p_source_12 => l_array_source_12(Idx)
32535 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32536 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32537 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32538 , p_source_15 => l_array_source_15(Idx)
32539 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32540 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32541 , p_source_19 => l_array_source_19(Idx)
32542 , p_source_20 => l_array_source_20(Idx)
32543 , p_source_21 => l_array_source_21(Idx)
32544 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32545 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32546 , p_source_25 => l_array_source_25(Idx)
32547 , p_source_26 => l_array_source_26(Idx)
32548 );
32549 If(l_balance_type_code = 'A') THEN
32550 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32551 END IF;
32552
32553 --
32554
32555
32556 --
32557 AcctLineType_25 (
32558 p_application_id => p_application_id
32559 ,p_event_id => l_event_id
32560 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32561 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32562 ,p_actual_flag => l_actual_flag
32563 ,p_balance_type_code => l_balance_type_code
32564 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32565
32566 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32567 , p_source_5 => l_array_source_5(Idx)
32568 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32569 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32570 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32571 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32572 , p_source_12 => l_array_source_12(Idx)
32573 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32574 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32575 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32576 , p_source_15 => l_array_source_15(Idx)
32577 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32578 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32579 , p_source_19 => l_array_source_19(Idx)
32580 , p_source_20 => l_array_source_20(Idx)
32581 , p_source_21 => l_array_source_21(Idx)
32582 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32583 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32584 , p_source_27 => l_array_source_27(Idx)
32585 );
32586 If(l_balance_type_code = 'A') THEN
32587 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32588 END IF;
32589
32590 --
32591
32592
32593 --
32594 AcctLineType_27 (
32595 p_application_id => p_application_id
32596 ,p_event_id => l_event_id
32597 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32598 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32599 ,p_actual_flag => l_actual_flag
32600 ,p_balance_type_code => l_balance_type_code
32601 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32602
32603 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32604 , p_source_5 => l_array_source_5(Idx)
32605 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32606 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32607 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32608 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32609 , p_source_12 => l_array_source_12(Idx)
32610 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32611 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32612 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32613 , p_source_15 => l_array_source_15(Idx)
32614 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32615 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32616 , p_source_19 => l_array_source_19(Idx)
32617 , p_source_20 => l_array_source_20(Idx)
32618 , p_source_21 => l_array_source_21(Idx)
32619 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32620 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32621 , p_source_27 => l_array_source_27(Idx)
32622 );
32623 If(l_balance_type_code = 'A') THEN
32624 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32625 END IF;
32626
32627 --
32628
32629
32630 --
32631 AcctLineType_29 (
32632 p_application_id => p_application_id
32633 ,p_event_id => l_event_id
32634 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32635 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32636 ,p_actual_flag => l_actual_flag
32637 ,p_balance_type_code => l_balance_type_code
32638 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32639
32640 , p_source_1 => l_array_source_1(Idx)
32641 , p_source_2 => l_array_source_2(Idx)
32642 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32643 , p_source_5 => l_array_source_5(Idx)
32644 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32645 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32646 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32647 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32648 , p_source_12 => l_array_source_12(Idx)
32649 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32650 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32651 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32652 , p_source_15 => l_array_source_15(Idx)
32653 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32654 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32655 , p_source_19 => l_array_source_19(Idx)
32656 , p_source_20 => l_array_source_20(Idx)
32657 , p_source_21 => l_array_source_21(Idx)
32658 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32659 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32660 , p_source_27 => l_array_source_27(Idx)
32661 );
32662 If(l_balance_type_code = 'A') THEN
32663 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32664 END IF;
32665
32666 --
32667
32668
32669 --
32670 AcctLineType_31 (
32671 p_application_id => p_application_id
32672 ,p_event_id => l_event_id
32673 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32674 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32675 ,p_actual_flag => l_actual_flag
32676 ,p_balance_type_code => l_balance_type_code
32677 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32678
32679 , p_source_1 => l_array_source_1(Idx)
32680 , p_source_2 => l_array_source_2(Idx)
32681 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32682 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32683 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32684 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32685 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32686 , p_source_12 => l_array_source_12(Idx)
32687 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32688 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32689 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32690 , p_source_15 => l_array_source_15(Idx)
32691 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32692 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32693 , p_source_19 => l_array_source_19(Idx)
32694 , p_source_20 => l_array_source_20(Idx)
32695 , p_source_21 => l_array_source_21(Idx)
32696 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32697 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32698 , p_source_25 => l_array_source_25(Idx)
32699 , p_source_26 => l_array_source_26(Idx)
32700 );
32701 If(l_balance_type_code = 'A') THEN
32702 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32703 END IF;
32704
32705 --
32706
32707
32708 --
32709 AcctLineType_33 (
32710 p_application_id => p_application_id
32711 ,p_event_id => l_event_id
32712 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32713 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32714 ,p_actual_flag => l_actual_flag
32715 ,p_balance_type_code => l_balance_type_code
32716 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32717
32718 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32719 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32720 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32721 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32722 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32723 , p_source_12 => l_array_source_12(Idx)
32724 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32725 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32726 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32727 , p_source_15 => l_array_source_15(Idx)
32728 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32729 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32730 , p_source_19 => l_array_source_19(Idx)
32731 , p_source_20 => l_array_source_20(Idx)
32732 , p_source_21 => l_array_source_21(Idx)
32733 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32734 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32735 , p_source_28 => l_array_source_28(Idx)
32736 );
32737 If(l_balance_type_code = 'A') THEN
32738 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32739 END IF;
32740
32741 --
32742
32743
32744 --
32745 AcctLineType_35 (
32746 p_application_id => p_application_id
32747 ,p_event_id => l_event_id
32748 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32749 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32750 ,p_actual_flag => l_actual_flag
32751 ,p_balance_type_code => l_balance_type_code
32752 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32753
32754 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32755 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32756 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32757 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32758 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32759 , p_source_12 => l_array_source_12(Idx)
32760 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32761 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32762 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32763 , p_source_15 => l_array_source_15(Idx)
32764 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32765 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32766 , p_source_19 => l_array_source_19(Idx)
32767 , p_source_20 => l_array_source_20(Idx)
32768 , p_source_21 => l_array_source_21(Idx)
32769 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32770 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32771 , p_source_29 => l_array_source_29(Idx)
32772 );
32773 If(l_balance_type_code = 'A') THEN
32774 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32775 END IF;
32776
32777 --
32778
32779
32780 --
32781 AcctLineType_37 (
32782 p_application_id => p_application_id
32783 ,p_event_id => l_event_id
32784 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32785 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32786 ,p_actual_flag => l_actual_flag
32787 ,p_balance_type_code => l_balance_type_code
32788 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32789
32790 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32791 , p_source_12 => l_array_source_12(Idx)
32792 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32793 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32794 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32795 , p_source_15 => l_array_source_15(Idx)
32796 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32797 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32798 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32799 , p_source_25 => l_array_source_25(Idx)
32800 , p_source_26 => l_array_source_26(Idx)
32801 , p_source_32 => l_array_source_32(Idx)
32802 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
32803 );
32804 If(l_balance_type_code = 'A') THEN
32805 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32806 END IF;
32807
32808 --
32809
32810
32811 --
32812 AcctLineType_39 (
32813 p_application_id => p_application_id
32814 ,p_event_id => l_event_id
32815 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32816 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32817 ,p_actual_flag => l_actual_flag
32818 ,p_balance_type_code => l_balance_type_code
32819 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32820
32821 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32822 , p_source_12 => l_array_source_12(Idx)
32823 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32824 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32825 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32826 , p_source_15 => l_array_source_15(Idx)
32827 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32828 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32829 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32830 , p_source_25 => l_array_source_25(Idx)
32831 , p_source_26 => l_array_source_26(Idx)
32832 , p_source_32 => l_array_source_32(Idx)
32833 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
32834 );
32835 If(l_balance_type_code = 'A') THEN
32836 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32837 END IF;
32838
32839 --
32840
32841
32842 --
32843 AcctLineType_42 (
32844 p_application_id => p_application_id
32845 ,p_event_id => l_event_id
32846 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32847 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32848 ,p_actual_flag => l_actual_flag
32849 ,p_balance_type_code => l_balance_type_code
32850 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32851
32852 , p_source_1 => l_array_source_1(Idx)
32853 , p_source_2 => l_array_source_2(Idx)
32854 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32855 , p_source_5 => l_array_source_5(Idx)
32856 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32857 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32858 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32859 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32860 , p_source_12 => l_array_source_12(Idx)
32861 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32862 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32863 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32864 , p_source_15 => l_array_source_15(Idx)
32865 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32866 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32867 , p_source_19 => l_array_source_19(Idx)
32868 , p_source_20 => l_array_source_20(Idx)
32869 , p_source_21 => l_array_source_21(Idx)
32870 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32871 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32872 , p_source_25 => l_array_source_25(Idx)
32873 , p_source_26 => l_array_source_26(Idx)
32874 , p_source_34 => l_array_source_34(Idx)
32875 );
32876 If(l_balance_type_code = 'A') THEN
32877 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32878 END IF;
32879
32880 --
32881
32882
32883 --
32884 AcctLineType_44 (
32885 p_application_id => p_application_id
32886 ,p_event_id => l_event_id
32887 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32888 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32889 ,p_actual_flag => l_actual_flag
32890 ,p_balance_type_code => l_balance_type_code
32891 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32892
32893 , p_source_1 => l_array_source_1(Idx)
32894 , p_source_2 => l_array_source_2(Idx)
32895 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32896 , p_source_5 => l_array_source_5(Idx)
32897 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32898 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32899 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32900 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32901 , p_source_12 => l_array_source_12(Idx)
32902 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32903 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32904 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32905 , p_source_15 => l_array_source_15(Idx)
32906 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32907 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32908 , p_source_19 => l_array_source_19(Idx)
32909 , p_source_20 => l_array_source_20(Idx)
32910 , p_source_21 => l_array_source_21(Idx)
32911 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32912 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32913 , p_source_26 => l_array_source_26(Idx)
32914 , p_source_34 => l_array_source_34(Idx)
32915 );
32916 If(l_balance_type_code = 'A') THEN
32917 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32918 END IF;
32919
32920 --
32921
32922
32923 --
32924 AcctLineType_46 (
32925 p_application_id => p_application_id
32926 ,p_event_id => l_event_id
32927 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32928 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32929 ,p_actual_flag => l_actual_flag
32930 ,p_balance_type_code => l_balance_type_code
32931 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32932
32933 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32934 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32935 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32936 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32937 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32938 , p_source_12 => l_array_source_12(Idx)
32939 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32940 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32941 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32942 , p_source_15 => l_array_source_15(Idx)
32943 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32944 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32945 , p_source_19 => l_array_source_19(Idx)
32946 , p_source_20 => l_array_source_20(Idx)
32947 , p_source_21 => l_array_source_21(Idx)
32948 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32949 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32950 , p_source_28 => l_array_source_28(Idx)
32951 );
32952 If(l_balance_type_code = 'A') THEN
32953 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32954 END IF;
32955
32956 --
32957
32958
32959 --
32960 AcctLineType_48 (
32961 p_application_id => p_application_id
32962 ,p_event_id => l_event_id
32963 ,p_calculate_acctd_flag => l_calculate_acctd_flag
32964 ,p_calculate_g_l_flag => l_calculate_g_l_flag
32965 ,p_actual_flag => l_actual_flag
32966 ,p_balance_type_code => l_balance_type_code
32967 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
32968
32969 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
32970 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
32971 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
32972 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
32973 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
32974 , p_source_12 => l_array_source_12(Idx)
32975 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
32976 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
32977 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
32978 , p_source_15 => l_array_source_15(Idx)
32979 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
32980 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
32981 , p_source_19 => l_array_source_19(Idx)
32982 , p_source_20 => l_array_source_20(Idx)
32983 , p_source_21 => l_array_source_21(Idx)
32984 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
32985 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
32986 , p_source_29 => l_array_source_29(Idx)
32987 );
32988 If(l_balance_type_code = 'A') THEN
32989 l_actual_gain_loss_ref := l_gain_or_loss_ref;
32990 END IF;
32991
32992 --
32993
32994
32995 --
32996 AcctLineType_50 (
32997 p_application_id => p_application_id
32998 ,p_event_id => l_event_id
32999 ,p_calculate_acctd_flag => l_calculate_acctd_flag
33000 ,p_calculate_g_l_flag => l_calculate_g_l_flag
33001 ,p_actual_flag => l_actual_flag
33002 ,p_balance_type_code => l_balance_type_code
33003 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
33004
33005 , p_source_2 => l_array_source_2(Idx)
33006 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
33007 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
33008 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
33009 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
33010 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
33011 , p_source_12 => l_array_source_12(Idx)
33012 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
33013 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
33014 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
33015 , p_source_15 => l_array_source_15(Idx)
33016 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
33017 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
33018 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
33019 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
33020 , p_source_25 => l_array_source_25(Idx)
33021 , p_source_26 => l_array_source_26(Idx)
33022 );
33023 If(l_balance_type_code = 'A') THEN
33024 l_actual_gain_loss_ref := l_gain_or_loss_ref;
33025 END IF;
33026
33027 --
33028
33029
33030 --
33031 AcctLineType_52 (
33032 p_application_id => p_application_id
33033 ,p_event_id => l_event_id
33034 ,p_calculate_acctd_flag => l_calculate_acctd_flag
33035 ,p_calculate_g_l_flag => l_calculate_g_l_flag
33036 ,p_actual_flag => l_actual_flag
33037 ,p_balance_type_code => l_balance_type_code
33038 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
33039
33040 , p_source_2 => l_array_source_2(Idx)
33041 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
33042 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
33043 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
33044 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
33045 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
33046 , p_source_12 => l_array_source_12(Idx)
33047 , p_source_13 => g_array_event(l_event_id).array_value_char('source_13')
33048 , p_source_13_meaning => g_array_event(l_event_id).array_value_char('source_13_meaning')
33049 , p_source_14 => g_array_event(l_event_id).array_value_num('source_14')
33050 , p_source_15 => l_array_source_15(Idx)
33051 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
33052 , p_source_17 => g_array_event(l_event_id).array_value_char('source_17')
33053 , p_source_22 => g_array_event(l_event_id).array_value_num('source_22')
33054 , p_source_23 => g_array_event(l_event_id).array_value_num('source_23')
33055 , p_source_25 => l_array_source_25(Idx)
33056 , p_source_26 => l_array_source_26(Idx)
33057 );
33058 If(l_balance_type_code = 'A') THEN
33059 l_actual_gain_loss_ref := l_gain_or_loss_ref;
33060 END IF;
33061
33062 --
33063
33064 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
33065 -- or secondary ledger that has different currency with primary
33066 -- or alc that is calculated by sla
33067 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
33068 (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code in ('ALC', 'SECONDARY') AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.calculate_amts_flag='Y'))
33069
33070 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
33071 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
33072 AND (l_actual_flag = 'A')) THEN
33073 XLA_AE_LINES_PKG.CreateGainOrLossLines(
33074 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
33075 ,p_application_id => p_application_id
33076 ,p_amb_context_code => 'DEFAULT'
33077 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
33078 ,p_event_class_code => C_EVENT_CLASS_CODE
33079 ,p_event_type_code => C_EVENT_TYPE_CODE
33080
33081 ,p_gain_ccid => -1
33082 ,p_loss_ccid => -1
33083
33084 ,p_actual_flag => l_actual_flag
33085 ,p_enc_flag => null
33086 ,p_actual_g_l_ref => l_actual_gain_loss_ref
33087 ,p_enc_g_l_ref => null
33088 );
33089 END IF;
33090 END IF;
33091 END IF;
33092
33093 ELSE
33094 --
33095 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
33096 --
33097 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
33098 trace
33099 (p_msg => 'Trancaction revesal option is Y'
33100 ,p_level => C_LEVEL_STATEMENT
33101 ,p_module => l_log_module);
33102 END IF;
33103 END IF;
33104
33105 END LOOP;
33106 l_result := XLA_AE_LINES_PKG.InsertLines ;
33107 end loop;
33108 close line_cur;
33109
33110
33111 --
33112 -- insert headers into xla_ae_headers_gt table
33113 --
33114 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
33115
33116 -- insert into errors table here.
33117
33118 END LOOP;
33119
33120 --
33121 -- 4865292
33122 --
33123 -- Compare g_hdr_extract_count with event count in
33124 -- CreateHeadersAndLines.
33125 --
33126 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
33127
33128 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
33129 trace (p_msg => '# rows extracted from header extract objects '
33130 || ' (running total): '
33131 || g_hdr_extract_count
33132 ,p_level => C_LEVEL_STATEMENT
33133 ,p_module => l_log_module);
33134 END IF;
33135
33136 CLOSE header_cur;
33137 --
33138
33139 --
33140 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33141 trace
33142 (p_msg => 'END of EventClass_54'
33143 ,p_level => C_LEVEL_PROCEDURE
33144 ,p_module => l_log_module);
33145 END IF;
33146 --
33147 RETURN l_result;
33148 EXCEPTION
33149 WHEN xla_exceptions_pkg.application_exception THEN
33150
33151 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
33152
33153
33154 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
33155
33156 RAISE;
33157
33158 WHEN NO_DATA_FOUND THEN
33159
33160 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
33161 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
33162
33163 FOR header_record IN header_cur
33164 LOOP
33165 l_array_header_events(header_record.event_id) := header_record.event_id;
33166 END LOOP;
33167
33168 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
33169 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
33170
33171 fnd_file.put_line(fnd_file.LOG, ' ');
33172 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
33173 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
33174 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
33175
33176 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
33177 LOOP
33178 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
33179 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
33180 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
33181 END IF;
33182 END LOOP;
33183
33184 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
33185 fnd_file.put_line(fnd_file.LOG, ' ');
33186
33187
33188 xla_exceptions_pkg.raise_message
33189 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.EventClass_54');
33190
33191
33192 WHEN OTHERS THEN
33193 xla_exceptions_pkg.raise_message
33194 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.EventClass_54');
33195 END EventClass_54;
33196 --
33197
33198 --
33199 --+============================================+
33200 --| |
33201 --| PRIVATE FUNCTION |
33202 --| |
33203 --+============================================+
33204 --
33205 FUNCTION CreateHeadersAndLines
33206 (p_application_id IN NUMBER
33207 ,p_base_ledger_id IN NUMBER
33208 ,p_target_ledger_id IN NUMBER
33209 ,p_pad_start_date IN DATE
33210 ,p_pad_end_date IN DATE
33211 ,p_primary_ledger_id IN NUMBER)
33212 RETURN BOOLEAN IS
33213 l_created BOOLEAN:=FALSE;
33214 l_event_id NUMBER;
33215 l_event_date DATE;
33216 l_language VARCHAR2(30);
33217 l_currency_code VARCHAR2(30);
33218 l_sla_ledger_id NUMBER;
33219 l_log_module VARCHAR2(240);
33220
33221 BEGIN
33222 --
33223 IF g_log_enabled THEN
33224 l_log_module := C_DEFAULT_MODULE||'.CreateHeadersAndLines';
33225 END IF;
33226 --
33227 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33228 trace
33229 (p_msg => 'BEGIN of CreateHeadersAndLines'
33230 ,p_level => C_LEVEL_PROCEDURE
33231 ,p_module => l_log_module);
33232 END IF;
33233
33234 l_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
33235 l_currency_code := xla_ae_journal_entry_pkg.g_cache_ledgers_info.currency_code;
33236 l_sla_ledger_id := xla_ae_journal_entry_pkg.g_cache_ledgers_info.sla_ledger_id;
33237
33238 --
33239 -- initialize array of lines with NULL
33240 --
33241 xla_ae_lines_pkg.SetNullLine;
33242
33243 --
33244 -- initialize header extract count -- Bug 4865292
33245 --
33246 g_hdr_extract_count:= 0;
33247
33248
33249 l_created := EventClass_53(
33250 p_application_id => p_application_id
33251 , p_base_ledger_id => p_base_ledger_id
33252 , p_target_ledger_id => p_target_ledger_id
33253 , p_language => l_language
33254 , p_currency_code => l_currency_code
33255 , p_sla_ledger_id => l_sla_ledger_id
33256 , p_pad_start_date => p_pad_start_date
33257 , p_pad_end_date => p_pad_end_date
33258 , p_primary_ledger_id => p_primary_ledger_id
33259 );
33260
33261
33262
33263 IF ( g_diagnostics_mode ='Y' ) THEN
33264
33265 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
33266 trace
33267 (p_msg => 'CALL Transaction Objects Diagnostics'
33268 ,p_level => C_LEVEL_STATEMENT
33269 ,p_module => l_log_module);
33270
33271 END IF;
33272
33273 insert_sources_53(
33274 p_target_ledger_id => p_target_ledger_id
33275 , p_language => l_language
33276 , p_sla_ledger_id => l_sla_ledger_id
33277 , p_pad_start_date => p_pad_start_date
33278 , p_pad_end_date => p_pad_end_date
33279 );
33280
33281 END IF;
33282
33283 l_created := EventClass_54(
33284 p_application_id => p_application_id
33285 , p_base_ledger_id => p_base_ledger_id
33286 , p_target_ledger_id => p_target_ledger_id
33287 , p_language => l_language
33288 , p_currency_code => l_currency_code
33289 , p_sla_ledger_id => l_sla_ledger_id
33290 , p_pad_start_date => p_pad_start_date
33291 , p_pad_end_date => p_pad_end_date
33292 , p_primary_ledger_id => p_primary_ledger_id
33293 );
33294
33295
33296
33297 IF ( g_diagnostics_mode ='Y' ) THEN
33298
33299 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
33300 trace
33301 (p_msg => 'CALL Transaction Objects Diagnostics'
33302 ,p_level => C_LEVEL_STATEMENT
33303 ,p_module => l_log_module);
33304
33305 END IF;
33306
33307 insert_sources_54(
33308 p_target_ledger_id => p_target_ledger_id
33309 , p_language => l_language
33310 , p_sla_ledger_id => l_sla_ledger_id
33311 , p_pad_start_date => p_pad_start_date
33312 , p_pad_end_date => p_pad_end_date
33313 );
33314
33315 END IF;
33316
33317
33318 --
33319 -- Bug 4865292
33320 -- When the number of events and that of header extract do not match,
33321 -- set the no header extract flag to indicate there are some issues
33322 -- in header extract.
33323 --
33324 -- Event count context is set in xla_accounting_pkg.unit_processor.
33325 -- Build_Message for this error is called in xla_accounting_pkg.post_accounting
33326 -- to report it as a general error.
33327 --
33328 IF xla_context_pkg.get_event_count_context <> g_hdr_extract_count
33329 AND xla_context_pkg.get_event_nohdr_context <> 'Y' THEN
33330
33331 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
33332 trace
33333 (p_msg => '# of extracted headers and events does not match'
33334 ,p_level => C_LEVEL_STATEMENT
33335 ,p_module => l_log_module);
33336
33337 trace
33338 (p_msg => '# of extracted headers: '
33339 ||g_hdr_extract_count
33340 ,p_level => C_LEVEL_STATEMENT
33341 ,p_module => l_log_module);
33342
33343 trace
33344 (p_msg => '# of events in xla_events_gt: '
33345 ||xla_context_pkg.get_event_count_context
33346 ,p_level => C_LEVEL_STATEMENT
33347 ,p_module => l_log_module);
33348
33349 trace
33350 (p_msg => 'Event No Header Extract Context: '
33351 ||xla_context_pkg.get_event_nohdr_context
33352 ,p_level => C_LEVEL_STATEMENT
33353 ,p_module => l_log_module);
33354
33355 END IF;
33356
33357
33358 xla_context_pkg.set_event_nohdr_context
33359 (p_nohdr_extract_flag => 'Y'
33360 ,p_client_id => sys_context('USERENV','CLIENT_IDENTIFIER'));
33361
33362 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
33363 trace
33364 (p_msg => 'No Header Extract Flag is set to Y'
33365 ,p_level => C_LEVEL_STATEMENT
33366 ,p_module => l_log_module);
33367 END IF;
33368
33369 END IF;
33370
33371 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33372 trace
33373 (p_msg => 'END of CreateHeadersAndLines'
33374 ,p_level => C_LEVEL_PROCEDURE
33375 ,p_module => l_log_module);
33376 END IF;
33377
33378 RETURN l_created;
33379 EXCEPTION
33380 WHEN xla_exceptions_pkg.application_exception THEN
33381 RAISE;
33382 WHEN OTHERS THEN
33383 xla_exceptions_pkg.raise_message
33384 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.CreateHeadersAndLines');
33385 END CreateHeadersAndLines;
33386 --
33387 --
33388
33389 --
33390 --+============================================+
33391 --| |
33392 --| PUBLIC FUNCTION |
33393 --| |
33394 --+============================================+
33395 --
33396 FUNCTION CreateJournalEntries
33397 (p_application_id IN NUMBER
33398 ,p_base_ledger_id IN NUMBER
33399 ,p_pad_start_date IN DATE
33400 ,p_pad_end_date IN DATE
33401 ,p_primary_ledger_id IN NUMBER)
33402 RETURN NUMBER IS
33403 l_log_module VARCHAR2(240);
33404 l_array_ledgers xla_accounting_cache_pkg.t_array_ledger_id;
33405 l_temp_result BOOLEAN;
33406 l_result NUMBER;
33407 BEGIN
33408 --
33409 IF g_log_enabled THEN
33410 l_log_module := C_DEFAULT_MODULE||'.CreateJournalEntries';
33411 END IF;
33412 --
33413 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33414 trace
33415 (p_msg => 'BEGIN of CreateJournalEntries'||
33416 ' - p_base_ledger_id = '||TO_CHAR(p_base_ledger_id)
33417 ,p_level => C_LEVEL_PROCEDURE
33418 ,p_module => l_log_module);
33419
33420 END IF;
33421
33422 --
33423 g_diagnostics_mode:= xla_accounting_engine_pkg.g_diagnostics_mode;
33424
33425 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
33426 trace
33427 (p_msg => 'g_diagnostics_mode = '||g_diagnostics_mode
33428 ,p_level => C_LEVEL_STATEMENT
33429 ,p_module => l_log_module);
33430 END IF;
33431 --
33432 xla_ae_journal_entry_pkg.SetProductAcctDefinition
33433 (p_product_rule_code => 'FV_CST_AAD'
33434 ,p_product_rule_type_code => 'S'
33435 ,p_product_rule_version => ''
33436 ,p_product_rule_name => 'Federal Costing Application Accounting Definition'
33437 ,p_amb_context_code => 'DEFAULT'
33438 );
33439
33440 l_array_ledgers :=
33441 xla_ae_journal_entry_pkg.GetAlternateCurrencyLedger
33442 (p_base_ledger_id => p_base_ledger_id);
33443
33444 FOR Idx IN 1 .. l_array_ledgers.COUNT LOOP
33445 l_temp_result :=
33446 XLA_AE_JOURNAL_ENTRY_PKG.GetLedgersInfo
33447 (p_application_id => p_application_id
33448 ,p_base_ledger_id => p_base_ledger_id
33449 ,p_target_ledger_id => l_array_ledgers(Idx)
33450 ,p_primary_ledger_id => p_primary_ledger_id
33451 ,p_pad_start_date => p_pad_start_date
33452 ,p_pad_end_date => p_pad_end_date);
33453
33454 l_temp_result :=
33455 l_temp_result AND
33456 CreateHeadersAndLines
33457 (p_application_id => p_application_id
33458 ,p_base_ledger_id => p_base_ledger_id
33459 ,p_target_ledger_id => l_array_ledgers(Idx)
33460 ,p_pad_start_date => p_pad_start_date
33461 ,p_pad_end_date => p_pad_end_date
33462 ,p_primary_ledger_id => p_primary_ledger_id
33463 );
33464 END LOOP;
33465
33466
33467 IF (g_diagnostics_mode = 'Y' AND
33468 C_LEVEL_UNEXPECTED >= g_log_level AND
33469 xla_environment_pkg.g_Req_Id IS NOT NULL ) THEN
33470
33471 xla_accounting_dump_pkg.acctg_event_extract_log(
33472 p_application_id => p_application_id
33473 ,p_request_id => xla_environment_pkg.g_Req_Id
33474 );
33475
33476 END IF;
33477
33478 CASE l_temp_result
33479 WHEN TRUE THEN l_result := 0;
33480 ELSE l_result := 2;
33481 END CASE;
33482
33483 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33484 trace
33485 (p_msg => 'return value. = '||TO_CHAR(l_result)
33486 ,p_level => C_LEVEL_PROCEDURE
33487 ,p_module => l_log_module);
33488 trace
33489 (p_msg => 'END of CreateJournalEntries '
33490 ,p_level => C_LEVEL_PROCEDURE
33491 ,p_module => l_log_module);
33492 END IF;
33493
33494 RETURN l_result;
33495 EXCEPTION
33496 WHEN xla_exceptions_pkg.application_exception THEN
33497 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33498 trace
33499 (p_msg => 'ERROR. = '||sqlerrm
33500 ,p_level => C_LEVEL_PROCEDURE
33501 ,p_module => l_log_module);
33502 END IF;
33503 RAISE;
33504 WHEN OTHERS THEN
33505 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33506 trace
33507 (p_msg => 'ERROR. = '||sqlerrm
33508 ,p_level => C_LEVEL_PROCEDURE
33509 ,p_module => l_log_module);
33510 END IF;
33511 xla_exceptions_pkg.raise_message
33512 (p_location => 'XLA_00707_AAD_S_000007_BC_PKG.CreateJournalEntries');
33513 END CreateJournalEntries;
33514 --
33515 --=============================================================================
33516 --
33517 --
33518 --
33519 --
33520 --
33521 --
33522 --
33523 --
33524 --
33525 --
33526 --
33527 --
33528 --
33529 --
33530 --
33531 --
33532 --
33533 --
33534 --
33535 --
33536 --
33537 --
33538 --=============================================================================
33539 --=============================================================================
33540 -- *********** Initialization routine **********
33541 --=============================================================================
33542
33543 BEGIN
33544 g_log_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
33545 g_log_enabled := fnd_log.test
33546 (log_level => g_log_level
33547 ,module => C_DEFAULT_MODULE);
33548
33549 IF NOT g_log_enabled THEN
33550 g_log_level := C_LEVEL_LOG_DISABLED;
33551 END IF;
33552 --
33553 END XLA_00707_AAD_S_000007_BC_PKG;
33554 --