[Home] [Help]
PACKAGE BODY: APPS.XLA_00222_AAD_S_000009_PKG
Source
1 PACKAGE BODY XLA_00222_AAD_S_000009_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_00222_AAD_S_000009_PKG |
10 | |
11 | DESCRIPTION |
12 | Package generated From Product Accounting Definition |
13 | Name : Multi-Fund Federal Receivables Accrual - Account Method|
14 | Code : MFAR_FED_AR_ACCRUAL_ACCOUNT |
15 | Owner : PRODUCT |
16 | Version : |
17 | AMB Context Code: DEFAULT |
18 | HISTORY |
19 | Generated at 30-03-2009 at 05:03:47 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_00222_AAD_S_000009_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_00222_AAD_S_000009_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_00222_AAD_S_000009_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_00222_AAD_S_000009_PKG.GetMeaning');
228 END GetMeaning;
229 --
230
231 ---------------------------------------
232 --
233 -- PRIVATE FUNCTION
234 -- Description_1
235 --
236 ---------------------------------------
237 FUNCTION Description_1 (
238 p_application_id IN NUMBER
239 , p_ae_header_id IN NUMBER DEFAULT NULL
240 )
241 RETURN VARCHAR2
242 IS
243 l_component_type VARCHAR2(80) ;
244 l_component_code VARCHAR2(30) ;
245 l_component_type_code VARCHAR2(1) ;
246 l_component_appl_id INTEGER ;
247 l_amb_context_code VARCHAR2(30) ;
248 l_ledger_language VARCHAR2(30) ;
249 l_source VARCHAR2(1996) ;
250 l_description VARCHAR2(2000) ;
251 l_log_module VARCHAR2(240) ;
252 BEGIN
253 IF g_log_enabled THEN
254 l_log_module := C_DEFAULT_MODULE||'.Description_1';
255 END IF;
256 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
257 trace
258 (p_msg => 'BEGIN of Description_1'
259 ,p_level => C_LEVEL_PROCEDURE
260 ,p_module => l_log_module);
261 END IF;
262
263 l_ledger_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
264 l_component_type := 'AMB_DESCRIPTION';
265 l_component_code := 'MFAR_JE_DESCRIPTION_ACCOUNT';
266 l_component_type_code := 'S';
267 l_component_appl_id := 222;
268 l_amb_context_code := 'DEFAULT';
269 l_source := NULL;
270 l_description := NULL;
271
272
273
274 IF
275 l_ledger_language = 'US' THEN
276 l_description := SUBSTR(CONCAT(l_description,'Multi-Fund Account'),1,2000);
277 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
278 END IF;
279 l_description := SUBSTR(l_description,1,1996);
280 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
281 trace
282 (p_msg => 'END of Description_1'
283 ,p_level => C_LEVEL_PROCEDURE
284 ,p_module => l_log_module);
285
286 END IF;
287 RETURN l_description;
288
289 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
290 trace
291 (p_msg => 'END of Description_1'
292 ,p_level => C_LEVEL_PROCEDURE
293 ,p_module => l_log_module);
294 END IF;
295 RETURN NULL;
296 EXCEPTION
297 WHEN VALUE_ERROR THEN
298 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
299 trace
300 (p_msg => 'ERROR: '||sqlerrm
301 ,p_level => C_LEVEL_EXCEPTION
302 ,p_module => l_log_module);
303 END IF;
304 RAISE;
305 WHEN xla_exceptions_pkg.application_exception THEN
306 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
307 trace
308 (p_msg => 'ERROR: '||sqlerrm
309 ,p_level => C_LEVEL_EXCEPTION
310 ,p_module => l_log_module);
311 END IF;
312 RAISE;
313 WHEN OTHERS THEN
314 xla_exceptions_pkg.raise_message
315 (p_location => 'XLA_00222_AAD_S_000009_PKG.Description_1');
316 END Description_1;
317
318 ---------------------------------------
319 --
320 -- PRIVATE FUNCTION
321 -- AcctDerRule_2
322 --
323 ---------------------------------------
324 FUNCTION AcctDerRule_2 (
325 p_application_id IN NUMBER
326 , p_ae_header_id IN NUMBER
327 , p_side IN VARCHAR2
328 , p_override_seg_flag IN VARCHAR2
329 --Remittance Bank Account Bank Charges Acount
330 , p_source_1 IN NUMBER
331 , x_transaction_coa_id OUT NOCOPY NUMBER
332 , x_accounting_coa_id OUT NOCOPY NUMBER
333 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
334 , x_flex_value_set_id OUT NOCOPY NUMBER
335 , x_value_type_code OUT NOCOPY VARCHAR2
336 , x_value_combination_id OUT NOCOPY NUMBER
337 , x_value_segment_code OUT NOCOPY VARCHAR2
338 )
339 RETURN VARCHAR2
340 IS
341 l_component_type VARCHAR2(80) ;
342 l_component_code VARCHAR2(30) ;
346 l_log_module VARCHAR2(240) ;
343 l_component_type_code VARCHAR2(1) ;
344 l_component_appl_id INTEGER ;
345 l_amb_context_code VARCHAR2(30) ;
347 l_output_value VARCHAR2(30) ;
348 BEGIN
349 IF g_log_enabled THEN
350 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_2';
351 END IF;
352 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
353
354 trace
355 (p_msg => 'BEGIN of AcctDerRule_2'
356 ,p_level => C_LEVEL_PROCEDURE
357 ,p_module => l_log_module);
358
359 END IF;
360
361 l_component_type := 'AMB_ADR';
362 l_component_code := 'MFAR_BNK_CHARGES_NATURAL_SEG';
363 l_component_type_code := 'S';
364 l_component_appl_id := 222;
365 l_amb_context_code := 'DEFAULT';
366 x_transaction_coa_id := null;
367 x_accounting_coa_id := null;
368 x_flexfield_segment_code := 'GL_ACCOUNT';
369 x_flex_value_set_id := null ;
370
371
372 --
373 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
374
375 trace
376 (p_msg => 'END of AcctDerRule_2'
377 ,p_level => C_LEVEL_PROCEDURE
378 ,p_module => l_log_module);
379
380 END IF;
381 x_value_combination_id := TO_NUMBER(p_source_1) ;
382 x_value_segment_code := 'GL_ACCOUNT' ;
383 x_value_type_code := 'S';
384 l_output_value := null;
385 RETURN l_output_value;
386
387
388 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
389
390 trace
391 (p_msg => 'END of AcctDerRule_2(invalid)'
392 ,p_level => C_LEVEL_PROCEDURE
393 ,p_module => l_log_module);
394
395 END IF;
396
397 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
398 x_value_combination_id := null;
399 x_value_segment_code := null;
400 x_value_type_code := null;
401 l_output_value := null;
402 xla_accounting_err_pkg.build_message
403 (p_appli_s_name => 'XLA'
404 ,p_msg_name => 'XLA_AP_INVALID_ADR'
405 ,p_token_1 => 'COMPONENT_NAME'
406 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
407 l_component_type
408 , l_component_code
409 , l_component_type_code
410 , l_component_appl_id
411 , l_amb_context_code
412 )
413 ,p_token_2 => 'OWNER'
414 ,p_value_2 => xla_lookups_pkg.get_meaning(
415 'XLA_OWNER_TYPE'
416 ,l_component_type_code
417 )
418 ,p_token_3 => 'PAD_NAME'
419 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
420 ,p_token_4 => 'PAD_OWNER'
421 ,p_value_4 => xla_lookups_pkg.get_meaning(
422 'XLA_OWNER_TYPE'
423 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
424 )
425 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
426 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
427 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
428 ,p_ae_header_id => NULL
429 );
430 RETURN l_output_value;
431 EXCEPTION
432 WHEN xla_exceptions_pkg.application_exception THEN
433 RAISE;
434 WHEN OTHERS THEN
435 xla_exceptions_pkg.raise_message
436 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_2');
437 END AcctDerRule_2;
438 --
439
440 ---------------------------------------
441 --
442 -- PRIVATE FUNCTION
443 -- AcctDerRule_3
444 --
445 ---------------------------------------
446 FUNCTION AcctDerRule_3 (
447 p_application_id IN NUMBER
448 , p_ae_header_id IN NUMBER
449 , p_side IN VARCHAR2
450 , p_override_seg_flag IN VARCHAR2
451 --Credit Memo Default Receivable Account
452 , p_source_2 IN NUMBER
453 , x_transaction_coa_id OUT NOCOPY NUMBER
454 , x_accounting_coa_id OUT NOCOPY NUMBER
455 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
456 , x_flex_value_set_id OUT NOCOPY NUMBER
457 , x_value_type_code OUT NOCOPY VARCHAR2
458 , x_value_combination_id OUT NOCOPY NUMBER
459 , x_value_segment_code OUT NOCOPY VARCHAR2
460 )
461 RETURN VARCHAR2
462 IS
463 l_component_type VARCHAR2(80) ;
464 l_component_code VARCHAR2(30) ;
465 l_component_type_code VARCHAR2(1) ;
466 l_component_appl_id INTEGER ;
470 BEGIN
467 l_amb_context_code VARCHAR2(30) ;
468 l_log_module VARCHAR2(240) ;
469 l_output_value VARCHAR2(30) ;
471 IF g_log_enabled THEN
472 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_3';
473 END IF;
474 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
475
476 trace
477 (p_msg => 'BEGIN of AcctDerRule_3'
478 ,p_level => C_LEVEL_PROCEDURE
479 ,p_module => l_log_module);
480
481 END IF;
482
483 l_component_type := 'AMB_ADR';
484 l_component_code := 'MFAR_CM_NATURAL_SEGMENT';
485 l_component_type_code := 'S';
486 l_component_appl_id := 222;
487 l_amb_context_code := 'DEFAULT';
488 x_transaction_coa_id := null;
489 x_accounting_coa_id := null;
490 x_flexfield_segment_code := 'GL_ACCOUNT';
491 x_flex_value_set_id := null ;
492
493
494 --
495 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
496
497 trace
498 (p_msg => 'END of AcctDerRule_3'
499 ,p_level => C_LEVEL_PROCEDURE
500 ,p_module => l_log_module);
501
502 END IF;
503 x_value_combination_id := TO_NUMBER(p_source_2) ;
504 x_value_segment_code := 'GL_ACCOUNT' ;
505 x_value_type_code := 'S';
506 l_output_value := null;
507 RETURN l_output_value;
508
509
510 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
511
512 trace
513 (p_msg => 'END of AcctDerRule_3(invalid)'
514 ,p_level => C_LEVEL_PROCEDURE
515 ,p_module => l_log_module);
516
517 END IF;
518
519 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
520 x_value_combination_id := null;
521 x_value_segment_code := null;
522 x_value_type_code := null;
523 l_output_value := null;
524 xla_accounting_err_pkg.build_message
525 (p_appli_s_name => 'XLA'
526 ,p_msg_name => 'XLA_AP_INVALID_ADR'
527 ,p_token_1 => 'COMPONENT_NAME'
528 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
529 l_component_type
530 , l_component_code
531 , l_component_type_code
532 , l_component_appl_id
533 , l_amb_context_code
534 )
535 ,p_token_2 => 'OWNER'
536 ,p_value_2 => xla_lookups_pkg.get_meaning(
537 'XLA_OWNER_TYPE'
538 ,l_component_type_code
539 )
540 ,p_token_3 => 'PAD_NAME'
541 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
542 ,p_token_4 => 'PAD_OWNER'
543 ,p_value_4 => xla_lookups_pkg.get_meaning(
544 'XLA_OWNER_TYPE'
545 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
546 )
547 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
548 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
549 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
550 ,p_ae_header_id => NULL
551 );
552 RETURN l_output_value;
553 EXCEPTION
554 WHEN xla_exceptions_pkg.application_exception THEN
555 RAISE;
556 WHEN OTHERS THEN
557 xla_exceptions_pkg.raise_message
558 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_3');
559 END AcctDerRule_3;
560 --
561
562 ---------------------------------------
563 --
564 -- PRIVATE FUNCTION
565 -- AcctDerRule_4
566 --
567 ---------------------------------------
568 FUNCTION AcctDerRule_4 (
569 p_application_id IN NUMBER
570 , p_ae_header_id IN NUMBER
571 , p_side IN VARCHAR2
572 , p_override_seg_flag IN VARCHAR2
573 --Remittance Bank Account Confirmation Account
574 , p_source_3 IN NUMBER
575 , x_transaction_coa_id OUT NOCOPY NUMBER
576 , x_accounting_coa_id OUT NOCOPY NUMBER
577 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
578 , x_flex_value_set_id OUT NOCOPY NUMBER
579 , x_value_type_code OUT NOCOPY VARCHAR2
580 , x_value_combination_id OUT NOCOPY NUMBER
581 , x_value_segment_code OUT NOCOPY VARCHAR2
582 )
583 RETURN VARCHAR2
584 IS
585 l_component_type VARCHAR2(80) ;
586 l_component_code VARCHAR2(30) ;
587 l_component_type_code VARCHAR2(1) ;
588 l_component_appl_id INTEGER ;
589 l_amb_context_code VARCHAR2(30) ;
593 IF g_log_enabled THEN
590 l_log_module VARCHAR2(240) ;
591 l_output_value VARCHAR2(30) ;
592 BEGIN
594 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_4';
595 END IF;
596 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
597
598 trace
599 (p_msg => 'BEGIN of AcctDerRule_4'
600 ,p_level => C_LEVEL_PROCEDURE
601 ,p_module => l_log_module);
602
603 END IF;
604
605 l_component_type := 'AMB_ADR';
606 l_component_code := 'MFAR_RCT_CONFIRMATION_NATSEG';
607 l_component_type_code := 'S';
608 l_component_appl_id := 222;
609 l_amb_context_code := 'DEFAULT';
610 x_transaction_coa_id := null;
611 x_accounting_coa_id := null;
612 x_flexfield_segment_code := 'GL_ACCOUNT';
613 x_flex_value_set_id := null ;
614
615
616 --
617 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
618
619 trace
620 (p_msg => 'END of AcctDerRule_4'
621 ,p_level => C_LEVEL_PROCEDURE
622 ,p_module => l_log_module);
623
624 END IF;
625 x_value_combination_id := TO_NUMBER(p_source_3) ;
626 x_value_segment_code := 'GL_ACCOUNT' ;
627 x_value_type_code := 'S';
628 l_output_value := null;
629 RETURN l_output_value;
630
631
632 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
633
634 trace
635 (p_msg => 'END of AcctDerRule_4(invalid)'
636 ,p_level => C_LEVEL_PROCEDURE
637 ,p_module => l_log_module);
638
639 END IF;
640
641 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
642 x_value_combination_id := null;
643 x_value_segment_code := null;
644 x_value_type_code := null;
645 l_output_value := null;
646 xla_accounting_err_pkg.build_message
647 (p_appli_s_name => 'XLA'
648 ,p_msg_name => 'XLA_AP_INVALID_ADR'
649 ,p_token_1 => 'COMPONENT_NAME'
650 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
651 l_component_type
652 , l_component_code
653 , l_component_type_code
654 , l_component_appl_id
655 , l_amb_context_code
656 )
657 ,p_token_2 => 'OWNER'
658 ,p_value_2 => xla_lookups_pkg.get_meaning(
659 'XLA_OWNER_TYPE'
660 ,l_component_type_code
661 )
662 ,p_token_3 => 'PAD_NAME'
663 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
664 ,p_token_4 => 'PAD_OWNER'
665 ,p_value_4 => xla_lookups_pkg.get_meaning(
666 'XLA_OWNER_TYPE'
667 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
668 )
669 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
670 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
671 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
672 ,p_ae_header_id => NULL
673 );
674 RETURN l_output_value;
675 EXCEPTION
676 WHEN xla_exceptions_pkg.application_exception THEN
677 RAISE;
678 WHEN OTHERS THEN
679 xla_exceptions_pkg.raise_message
680 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_4');
681 END AcctDerRule_4;
682 --
683
684 ---------------------------------------
685 --
686 -- PRIVATE FUNCTION
687 -- AcctDerRule_5
688 --
689 ---------------------------------------
690 FUNCTION AcctDerRule_5 (
691 p_application_id IN NUMBER
692 , p_ae_header_id IN NUMBER
693 , p_side IN VARCHAR2
694 , p_override_seg_flag IN VARCHAR2
695 --Remittance Bank Account Earned Account
696 , p_source_4 IN NUMBER
697 , x_transaction_coa_id OUT NOCOPY NUMBER
698 , x_accounting_coa_id OUT NOCOPY NUMBER
699 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
700 , x_flex_value_set_id OUT NOCOPY NUMBER
701 , x_value_type_code OUT NOCOPY VARCHAR2
702 , x_value_combination_id OUT NOCOPY NUMBER
703 , x_value_segment_code OUT NOCOPY VARCHAR2
704 )
705 RETURN VARCHAR2
706 IS
707 l_component_type VARCHAR2(80) ;
708 l_component_code VARCHAR2(30) ;
709 l_component_type_code VARCHAR2(1) ;
710 l_component_appl_id INTEGER ;
711 l_amb_context_code VARCHAR2(30) ;
712 l_log_module VARCHAR2(240) ;
713 l_output_value VARCHAR2(30) ;
714 BEGIN
718 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
715 IF g_log_enabled THEN
716 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_5';
717 END IF;
719
720 trace
721 (p_msg => 'BEGIN of AcctDerRule_5'
722 ,p_level => C_LEVEL_PROCEDURE
723 ,p_module => l_log_module);
724
725 END IF;
726
727 l_component_type := 'AMB_ADR';
728 l_component_code := 'MFAR_RCT_EARNED_NATURAL_SEG';
729 l_component_type_code := 'S';
730 l_component_appl_id := 222;
731 l_amb_context_code := 'DEFAULT';
732 x_transaction_coa_id := null;
733 x_accounting_coa_id := null;
734 x_flexfield_segment_code := 'GL_ACCOUNT';
735 x_flex_value_set_id := null ;
736
737
738 --
739 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
740
741 trace
742 (p_msg => 'END of AcctDerRule_5'
743 ,p_level => C_LEVEL_PROCEDURE
744 ,p_module => l_log_module);
745
746 END IF;
747 x_value_combination_id := TO_NUMBER(p_source_4) ;
748 x_value_segment_code := 'GL_ACCOUNT' ;
749 x_value_type_code := 'S';
750 l_output_value := null;
751 RETURN l_output_value;
752
753
754 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
755
756 trace
757 (p_msg => 'END of AcctDerRule_5(invalid)'
758 ,p_level => C_LEVEL_PROCEDURE
759 ,p_module => l_log_module);
760
761 END IF;
762
763 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
764 x_value_combination_id := null;
765 x_value_segment_code := null;
766 x_value_type_code := null;
767 l_output_value := null;
768 xla_accounting_err_pkg.build_message
769 (p_appli_s_name => 'XLA'
770 ,p_msg_name => 'XLA_AP_INVALID_ADR'
771 ,p_token_1 => 'COMPONENT_NAME'
772 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
773 l_component_type
774 , l_component_code
775 , l_component_type_code
776 , l_component_appl_id
777 , l_amb_context_code
778 )
779 ,p_token_2 => 'OWNER'
780 ,p_value_2 => xla_lookups_pkg.get_meaning(
781 'XLA_OWNER_TYPE'
782 ,l_component_type_code
783 )
784 ,p_token_3 => 'PAD_NAME'
785 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
786 ,p_token_4 => 'PAD_OWNER'
787 ,p_value_4 => xla_lookups_pkg.get_meaning(
788 'XLA_OWNER_TYPE'
789 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
790 )
791 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
792 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
793 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
794 ,p_ae_header_id => NULL
795 );
796 RETURN l_output_value;
797 EXCEPTION
798 WHEN xla_exceptions_pkg.application_exception THEN
799 RAISE;
800 WHEN OTHERS THEN
801 xla_exceptions_pkg.raise_message
802 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_5');
803 END AcctDerRule_5;
804 --
805
806 ---------------------------------------
807 --
808 -- PRIVATE FUNCTION
809 -- AcctDerRule_6
810 --
811 ---------------------------------------
812 FUNCTION AcctDerRule_6 (
813 p_application_id IN NUMBER
814 , p_ae_header_id IN NUMBER
815 , p_side IN VARCHAR2
816 , p_override_seg_flag IN VARCHAR2
817 --Remittance Bank Account Cash Account
818 , p_source_5 IN NUMBER
819 , x_transaction_coa_id OUT NOCOPY NUMBER
820 , x_accounting_coa_id OUT NOCOPY NUMBER
821 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
822 , x_flex_value_set_id OUT NOCOPY NUMBER
823 , x_value_type_code OUT NOCOPY VARCHAR2
824 , x_value_combination_id OUT NOCOPY NUMBER
825 , x_value_segment_code OUT NOCOPY VARCHAR2
826 )
827 RETURN VARCHAR2
828 IS
829 l_component_type VARCHAR2(80) ;
830 l_component_code VARCHAR2(30) ;
831 l_component_type_code VARCHAR2(1) ;
832 l_component_appl_id INTEGER ;
833 l_amb_context_code VARCHAR2(30) ;
834 l_log_module VARCHAR2(240) ;
835 l_output_value VARCHAR2(30) ;
836 BEGIN
837 IF g_log_enabled THEN
838 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_6';
839 END IF;
843 (p_msg => 'BEGIN of AcctDerRule_6'
840 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
841
842 trace
844 ,p_level => C_LEVEL_PROCEDURE
845 ,p_module => l_log_module);
846
847 END IF;
848
849 l_component_type := 'AMB_ADR';
850 l_component_code := 'MFAR_RCT_NATURAL_SEGMENT';
851 l_component_type_code := 'S';
852 l_component_appl_id := 222;
853 l_amb_context_code := 'DEFAULT';
854 x_transaction_coa_id := null;
855 x_accounting_coa_id := null;
856 x_flexfield_segment_code := 'GL_ACCOUNT';
857 x_flex_value_set_id := null ;
858
859
860 --
861 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
862
863 trace
864 (p_msg => 'END of AcctDerRule_6'
865 ,p_level => C_LEVEL_PROCEDURE
866 ,p_module => l_log_module);
867
868 END IF;
869 x_value_combination_id := TO_NUMBER(p_source_5) ;
870 x_value_segment_code := 'GL_ACCOUNT' ;
871 x_value_type_code := 'S';
872 l_output_value := null;
873 RETURN l_output_value;
874
875
876 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
877
878 trace
879 (p_msg => 'END of AcctDerRule_6(invalid)'
880 ,p_level => C_LEVEL_PROCEDURE
881 ,p_module => l_log_module);
882
883 END IF;
884
885 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
886 x_value_combination_id := null;
887 x_value_segment_code := null;
888 x_value_type_code := null;
889 l_output_value := null;
890 xla_accounting_err_pkg.build_message
891 (p_appli_s_name => 'XLA'
892 ,p_msg_name => 'XLA_AP_INVALID_ADR'
893 ,p_token_1 => 'COMPONENT_NAME'
894 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
895 l_component_type
896 , l_component_code
897 , l_component_type_code
898 , l_component_appl_id
899 , l_amb_context_code
900 )
901 ,p_token_2 => 'OWNER'
902 ,p_value_2 => xla_lookups_pkg.get_meaning(
903 'XLA_OWNER_TYPE'
904 ,l_component_type_code
905 )
906 ,p_token_3 => 'PAD_NAME'
907 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
908 ,p_token_4 => 'PAD_OWNER'
909 ,p_value_4 => xla_lookups_pkg.get_meaning(
910 'XLA_OWNER_TYPE'
911 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
912 )
913 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
914 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
915 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
916 ,p_ae_header_id => NULL
917 );
918 RETURN l_output_value;
919 EXCEPTION
920 WHEN xla_exceptions_pkg.application_exception THEN
921 RAISE;
922 WHEN OTHERS THEN
923 xla_exceptions_pkg.raise_message
924 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_6');
925 END AcctDerRule_6;
926 --
927
928 ---------------------------------------
929 --
930 -- PRIVATE FUNCTION
931 -- AcctDerRule_7
932 --
933 ---------------------------------------
934 FUNCTION AcctDerRule_7 (
935 p_application_id IN NUMBER
936 , p_ae_header_id IN NUMBER
937 , p_side IN VARCHAR2
938 , p_override_seg_flag IN VARCHAR2
939 --Remittance Bank Account Remittance Account
940 , p_source_6 IN NUMBER
941 , x_transaction_coa_id OUT NOCOPY NUMBER
942 , x_accounting_coa_id OUT NOCOPY NUMBER
943 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
944 , x_flex_value_set_id OUT NOCOPY NUMBER
945 , x_value_type_code OUT NOCOPY VARCHAR2
946 , x_value_combination_id OUT NOCOPY NUMBER
947 , x_value_segment_code OUT NOCOPY VARCHAR2
948 )
949 RETURN VARCHAR2
950 IS
951 l_component_type VARCHAR2(80) ;
952 l_component_code VARCHAR2(30) ;
953 l_component_type_code VARCHAR2(1) ;
954 l_component_appl_id INTEGER ;
955 l_amb_context_code VARCHAR2(30) ;
956 l_log_module VARCHAR2(240) ;
957 l_output_value VARCHAR2(30) ;
958 BEGIN
959 IF g_log_enabled THEN
960 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_7';
961 END IF;
962 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
963
964 trace
968
965 (p_msg => 'BEGIN of AcctDerRule_7'
966 ,p_level => C_LEVEL_PROCEDURE
967 ,p_module => l_log_module);
969 END IF;
970
971 l_component_type := 'AMB_ADR';
972 l_component_code := 'MFAR_RCT_REMITTANCE_NATSEG';
973 l_component_type_code := 'S';
974 l_component_appl_id := 222;
975 l_amb_context_code := 'DEFAULT';
976 x_transaction_coa_id := null;
977 x_accounting_coa_id := null;
978 x_flexfield_segment_code := 'GL_ACCOUNT';
979 x_flex_value_set_id := null ;
980
981
982 --
983 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
984
985 trace
986 (p_msg => 'END of AcctDerRule_7'
987 ,p_level => C_LEVEL_PROCEDURE
988 ,p_module => l_log_module);
989
990 END IF;
991 x_value_combination_id := TO_NUMBER(p_source_6) ;
992 x_value_segment_code := 'GL_ACCOUNT' ;
993 x_value_type_code := 'S';
994 l_output_value := null;
995 RETURN l_output_value;
996
997
998 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
999
1000 trace
1001 (p_msg => 'END of AcctDerRule_7(invalid)'
1002 ,p_level => C_LEVEL_PROCEDURE
1003 ,p_module => l_log_module);
1004
1005 END IF;
1006
1007 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1008 x_value_combination_id := null;
1009 x_value_segment_code := null;
1010 x_value_type_code := null;
1011 l_output_value := null;
1012 xla_accounting_err_pkg.build_message
1013 (p_appli_s_name => 'XLA'
1014 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1015 ,p_token_1 => 'COMPONENT_NAME'
1016 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1017 l_component_type
1018 , l_component_code
1019 , l_component_type_code
1020 , l_component_appl_id
1021 , l_amb_context_code
1022 )
1023 ,p_token_2 => 'OWNER'
1024 ,p_value_2 => xla_lookups_pkg.get_meaning(
1025 'XLA_OWNER_TYPE'
1026 ,l_component_type_code
1027 )
1028 ,p_token_3 => 'PAD_NAME'
1029 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1030 ,p_token_4 => 'PAD_OWNER'
1031 ,p_value_4 => xla_lookups_pkg.get_meaning(
1032 'XLA_OWNER_TYPE'
1033 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1034 )
1035 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1036 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1037 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1038 ,p_ae_header_id => NULL
1039 );
1040 RETURN l_output_value;
1041 EXCEPTION
1042 WHEN xla_exceptions_pkg.application_exception THEN
1043 RAISE;
1044 WHEN OTHERS THEN
1045 xla_exceptions_pkg.raise_message
1046 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_7');
1047 END AcctDerRule_7;
1048 --
1049
1050 ---------------------------------------
1051 --
1052 -- PRIVATE FUNCTION
1053 -- AcctDerRule_8
1054 --
1055 ---------------------------------------
1056 FUNCTION AcctDerRule_8 (
1057 p_application_id IN NUMBER
1058 , p_ae_header_id IN NUMBER
1059 , p_side IN VARCHAR2
1060 , p_override_seg_flag IN VARCHAR2
1061 --Remittance Bank Account Unearned Account
1062 , p_source_7 IN NUMBER
1063 , x_transaction_coa_id OUT NOCOPY NUMBER
1064 , x_accounting_coa_id OUT NOCOPY NUMBER
1065 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1066 , x_flex_value_set_id OUT NOCOPY NUMBER
1067 , x_value_type_code OUT NOCOPY VARCHAR2
1068 , x_value_combination_id OUT NOCOPY NUMBER
1069 , x_value_segment_code OUT NOCOPY VARCHAR2
1070 )
1071 RETURN VARCHAR2
1072 IS
1073 l_component_type VARCHAR2(80) ;
1074 l_component_code VARCHAR2(30) ;
1075 l_component_type_code VARCHAR2(1) ;
1076 l_component_appl_id INTEGER ;
1077 l_amb_context_code VARCHAR2(30) ;
1078 l_log_module VARCHAR2(240) ;
1079 l_output_value VARCHAR2(30) ;
1080 BEGIN
1081 IF g_log_enabled THEN
1082 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_8';
1083 END IF;
1084 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1085
1086 trace
1087 (p_msg => 'BEGIN of AcctDerRule_8'
1088 ,p_level => C_LEVEL_PROCEDURE
1092
1089 ,p_module => l_log_module);
1090
1091 END IF;
1093 l_component_type := 'AMB_ADR';
1094 l_component_code := 'MFAR_RCT_UNEARNED_NATURAL_SEG';
1095 l_component_type_code := 'S';
1096 l_component_appl_id := 222;
1097 l_amb_context_code := 'DEFAULT';
1098 x_transaction_coa_id := null;
1099 x_accounting_coa_id := null;
1100 x_flexfield_segment_code := 'GL_ACCOUNT';
1101 x_flex_value_set_id := null ;
1102
1103
1104 --
1105 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1106
1107 trace
1108 (p_msg => 'END of AcctDerRule_8'
1109 ,p_level => C_LEVEL_PROCEDURE
1110 ,p_module => l_log_module);
1111
1112 END IF;
1113 x_value_combination_id := TO_NUMBER(p_source_7) ;
1114 x_value_segment_code := 'GL_ACCOUNT' ;
1115 x_value_type_code := 'S';
1116 l_output_value := null;
1117 RETURN l_output_value;
1118
1119
1120 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1121
1122 trace
1123 (p_msg => 'END of AcctDerRule_8(invalid)'
1124 ,p_level => C_LEVEL_PROCEDURE
1125 ,p_module => l_log_module);
1126
1127 END IF;
1128
1129 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1130 x_value_combination_id := null;
1131 x_value_segment_code := null;
1132 x_value_type_code := null;
1133 l_output_value := null;
1134 xla_accounting_err_pkg.build_message
1135 (p_appli_s_name => 'XLA'
1136 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1137 ,p_token_1 => 'COMPONENT_NAME'
1138 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1139 l_component_type
1140 , l_component_code
1141 , l_component_type_code
1142 , l_component_appl_id
1143 , l_amb_context_code
1144 )
1145 ,p_token_2 => 'OWNER'
1146 ,p_value_2 => xla_lookups_pkg.get_meaning(
1147 'XLA_OWNER_TYPE'
1148 ,l_component_type_code
1149 )
1150 ,p_token_3 => 'PAD_NAME'
1151 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1152 ,p_token_4 => 'PAD_OWNER'
1153 ,p_value_4 => xla_lookups_pkg.get_meaning(
1154 'XLA_OWNER_TYPE'
1155 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1156 )
1157 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1158 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1159 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1160 ,p_ae_header_id => NULL
1161 );
1162 RETURN l_output_value;
1163 EXCEPTION
1164 WHEN xla_exceptions_pkg.application_exception THEN
1165 RAISE;
1166 WHEN OTHERS THEN
1167 xla_exceptions_pkg.raise_message
1168 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_8');
1169 END AcctDerRule_8;
1170 --
1171
1172 ---------------------------------------
1173 --
1174 -- PRIVATE FUNCTION
1175 -- AcctDerRule_9
1176 --
1177 ---------------------------------------
1178 FUNCTION AcctDerRule_9 (
1179 p_application_id IN NUMBER
1180 , p_ae_header_id IN NUMBER
1181 , p_side IN VARCHAR2
1182 , p_override_seg_flag IN VARCHAR2
1183 --Transaction Default Receivable Account
1184 , p_source_8 IN NUMBER
1185 , x_transaction_coa_id OUT NOCOPY NUMBER
1186 , x_accounting_coa_id OUT NOCOPY NUMBER
1187 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1188 , x_flex_value_set_id OUT NOCOPY NUMBER
1189 , x_value_type_code OUT NOCOPY VARCHAR2
1190 , x_value_combination_id OUT NOCOPY NUMBER
1191 , x_value_segment_code OUT NOCOPY VARCHAR2
1192 )
1193 RETURN VARCHAR2
1194 IS
1195 l_component_type VARCHAR2(80) ;
1196 l_component_code VARCHAR2(30) ;
1197 l_component_type_code VARCHAR2(1) ;
1198 l_component_appl_id INTEGER ;
1199 l_amb_context_code VARCHAR2(30) ;
1200 l_log_module VARCHAR2(240) ;
1201 l_output_value VARCHAR2(30) ;
1202 BEGIN
1203 IF g_log_enabled THEN
1204 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_9';
1205 END IF;
1206 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1207
1208 trace
1209 (p_msg => 'BEGIN of AcctDerRule_9'
1210 ,p_level => C_LEVEL_PROCEDURE
1211 ,p_module => l_log_module);
1212
1213 END IF;
1214
1218 l_component_appl_id := 222;
1215 l_component_type := 'AMB_ADR';
1216 l_component_code := 'MFAR_TRX_NATURAL_SEGMENT';
1217 l_component_type_code := 'S';
1219 l_amb_context_code := 'DEFAULT';
1220 x_transaction_coa_id := null;
1221 x_accounting_coa_id := null;
1222 x_flexfield_segment_code := 'GL_ACCOUNT';
1223 x_flex_value_set_id := null ;
1224
1225
1226 --
1227 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1228
1229 trace
1230 (p_msg => 'END of AcctDerRule_9'
1231 ,p_level => C_LEVEL_PROCEDURE
1232 ,p_module => l_log_module);
1233
1234 END IF;
1235 x_value_combination_id := TO_NUMBER(p_source_8) ;
1236 x_value_segment_code := 'GL_ACCOUNT' ;
1237 x_value_type_code := 'S';
1238 l_output_value := null;
1239 RETURN l_output_value;
1240
1241
1242 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1243
1244 trace
1245 (p_msg => 'END of AcctDerRule_9(invalid)'
1246 ,p_level => C_LEVEL_PROCEDURE
1247 ,p_module => l_log_module);
1248
1249 END IF;
1250
1251 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1252 x_value_combination_id := null;
1253 x_value_segment_code := null;
1254 x_value_type_code := null;
1255 l_output_value := null;
1256 xla_accounting_err_pkg.build_message
1257 (p_appli_s_name => 'XLA'
1258 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1259 ,p_token_1 => 'COMPONENT_NAME'
1260 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1261 l_component_type
1262 , l_component_code
1263 , l_component_type_code
1264 , l_component_appl_id
1265 , l_amb_context_code
1266 )
1267 ,p_token_2 => 'OWNER'
1268 ,p_value_2 => xla_lookups_pkg.get_meaning(
1269 'XLA_OWNER_TYPE'
1270 ,l_component_type_code
1271 )
1272 ,p_token_3 => 'PAD_NAME'
1273 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1274 ,p_token_4 => 'PAD_OWNER'
1275 ,p_value_4 => xla_lookups_pkg.get_meaning(
1276 'XLA_OWNER_TYPE'
1277 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1278 )
1279 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1280 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1281 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1282 ,p_ae_header_id => NULL
1283 );
1284 RETURN l_output_value;
1285 EXCEPTION
1286 WHEN xla_exceptions_pkg.application_exception THEN
1287 RAISE;
1288 WHEN OTHERS THEN
1289 xla_exceptions_pkg.raise_message
1290 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_9');
1291 END AcctDerRule_9;
1292 --
1293
1294 ---------------------------------------
1295 --
1296 -- PRIVATE FUNCTION
1297 -- AcctDerRule_10
1298 --
1299 ---------------------------------------
1300 FUNCTION AcctDerRule_10 (
1301 p_application_id IN NUMBER
1302 , p_ae_header_id IN NUMBER
1303 , p_side IN VARCHAR2
1304 --Credit Memo Distribution GL Account
1305 , p_source_9 IN NUMBER
1306 , x_transaction_coa_id OUT NOCOPY NUMBER
1307 , x_accounting_coa_id OUT NOCOPY NUMBER
1308 , x_value_type_code OUT NOCOPY VARCHAR2
1309 )
1310 RETURN NUMBER
1311 IS
1312 l_component_type VARCHAR2(80) ;
1313 l_component_code VARCHAR2(30) ;
1314 l_component_type_code VARCHAR2(1) ;
1315 l_component_appl_id INTEGER ;
1316 l_amb_context_code VARCHAR2(30) ;
1317 l_log_module VARCHAR2(240) ;
1318 l_output_value NUMBER ;
1319 BEGIN
1320 IF g_log_enabled THEN
1321 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_10';
1322 END IF;
1323 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1324 trace
1325 (p_msg => 'BEGIN of AcctDerRule_10'
1326 ,p_level => C_LEVEL_PROCEDURE
1327 ,p_module => l_log_module);
1328 END IF;
1329 --
1330 l_component_type := 'AMB_ADR';
1331 l_component_code := 'CM_DIST_CCID';
1332 l_component_type_code := 'S';
1333 l_component_appl_id := 222;
1334 l_amb_context_code := 'DEFAULT';
1335 x_transaction_coa_id := null;
1336 x_accounting_coa_id := null;
1337 --
1338
1339 --
1343 ,p_level => C_LEVEL_PROCEDURE
1340 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1341 trace
1342 (p_msg => 'END of AcctDerRule_10'
1344 ,p_module => l_log_module);
1345 END IF;
1346 x_value_type_code := 'S';
1347 l_output_value := TO_NUMBER(TO_NUMBER(p_source_9));
1348 RETURN l_output_value;
1349
1350 --
1351 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1352 trace
1353 (p_msg => 'END of AcctDerRule_10(invalid)'
1354 ,p_level => C_LEVEL_PROCEDURE
1355 ,p_module => l_log_module);
1356 END IF;
1357 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1358 x_value_type_code := null;
1359 l_output_value := null;
1360 xla_accounting_err_pkg.build_message
1361 (p_appli_s_name => 'XLA'
1362 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1363 ,p_token_1 => 'COMPONENT_NAME'
1364 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1365 l_component_type
1366 , l_component_code
1367 , l_component_type_code
1368 , l_component_appl_id
1369 , l_amb_context_code
1370 )
1371 ,p_token_2 => 'OWNER'
1372 ,p_value_2 => xla_lookups_pkg.get_meaning(
1373 'XLA_OWNER_TYPE'
1374 ,l_component_type_code
1375 )
1376 ,p_token_3 => 'PAD_NAME'
1377 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1378 ,p_token_4 => 'PAD_OWNER'
1379 ,p_value_4 => xla_lookups_pkg.get_meaning(
1380 'XLA_OWNER_TYPE'
1381 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1382 )
1383 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1384 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1385 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1386 ,p_ae_header_id => NULL
1387 );
1388 RETURN l_output_value;
1389 EXCEPTION
1390 WHEN xla_exceptions_pkg.application_exception THEN
1391 RAISE;
1392 WHEN OTHERS THEN
1393 xla_exceptions_pkg.raise_message
1394 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_10');
1395 END AcctDerRule_10;
1396 --
1397
1398 ---------------------------------------
1399 --
1400 -- PRIVATE FUNCTION
1401 -- AcctDerRule_11
1402 --
1403 ---------------------------------------
1404 FUNCTION AcctDerRule_11 (
1405 p_application_id IN NUMBER
1406 , p_ae_header_id IN NUMBER
1407 , p_side IN VARCHAR2
1408 --Distribution GL Account
1409 , p_source_10 IN NUMBER
1410 , x_transaction_coa_id OUT NOCOPY NUMBER
1411 , x_accounting_coa_id OUT NOCOPY NUMBER
1412 , x_value_type_code OUT NOCOPY VARCHAR2
1413 )
1414 RETURN NUMBER
1415 IS
1416 l_component_type VARCHAR2(80) ;
1417 l_component_code VARCHAR2(30) ;
1418 l_component_type_code VARCHAR2(1) ;
1419 l_component_appl_id INTEGER ;
1420 l_amb_context_code VARCHAR2(30) ;
1421 l_log_module VARCHAR2(240) ;
1422 l_output_value NUMBER ;
1423 BEGIN
1424 IF g_log_enabled THEN
1425 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_11';
1426 END IF;
1427 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1428 trace
1429 (p_msg => 'BEGIN of AcctDerRule_11'
1430 ,p_level => C_LEVEL_PROCEDURE
1431 ,p_module => l_log_module);
1432 END IF;
1433 --
1434 l_component_type := 'AMB_ADR';
1435 l_component_code := 'DIST_CCID';
1436 l_component_type_code := 'S';
1437 l_component_appl_id := 222;
1438 l_amb_context_code := 'DEFAULT';
1439 x_transaction_coa_id := null;
1440 x_accounting_coa_id := null;
1441 --
1442
1443 --
1444 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1445 trace
1446 (p_msg => 'END of AcctDerRule_11'
1447 ,p_level => C_LEVEL_PROCEDURE
1448 ,p_module => l_log_module);
1449 END IF;
1450 x_value_type_code := 'S';
1451 l_output_value := TO_NUMBER(TO_NUMBER(p_source_10));
1452 RETURN l_output_value;
1453
1454 --
1455 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1456 trace
1457 (p_msg => 'END of AcctDerRule_11(invalid)'
1458 ,p_level => C_LEVEL_PROCEDURE
1459 ,p_module => l_log_module);
1460 END IF;
1461 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1465 (p_appli_s_name => 'XLA'
1462 x_value_type_code := null;
1463 l_output_value := null;
1464 xla_accounting_err_pkg.build_message
1466 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1467 ,p_token_1 => 'COMPONENT_NAME'
1468 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1469 l_component_type
1470 , l_component_code
1471 , l_component_type_code
1472 , l_component_appl_id
1473 , l_amb_context_code
1474 )
1475 ,p_token_2 => 'OWNER'
1476 ,p_value_2 => xla_lookups_pkg.get_meaning(
1477 'XLA_OWNER_TYPE'
1478 ,l_component_type_code
1479 )
1480 ,p_token_3 => 'PAD_NAME'
1481 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1482 ,p_token_4 => 'PAD_OWNER'
1483 ,p_value_4 => xla_lookups_pkg.get_meaning(
1484 'XLA_OWNER_TYPE'
1485 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1486 )
1487 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1488 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1489 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1490 ,p_ae_header_id => NULL
1491 );
1492 RETURN l_output_value;
1493 EXCEPTION
1494 WHEN xla_exceptions_pkg.application_exception THEN
1495 RAISE;
1496 WHEN OTHERS THEN
1497 xla_exceptions_pkg.raise_message
1498 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_11');
1499 END AcctDerRule_11;
1500 --
1501
1502 ---------------------------------------
1503 --
1504 -- PRIVATE FUNCTION
1505 -- AcctDerRule_12
1506 --
1507 ---------------------------------------
1508 FUNCTION AcctDerRule_12 (
1509 p_application_id IN NUMBER
1510 , p_ae_header_id IN NUMBER
1511 , p_side IN VARCHAR2
1512 , p_override_seg_flag IN VARCHAR2
1513 --Federal Fund Category
1514 , p_source_11 IN VARCHAR2
1515 , x_transaction_coa_id OUT NOCOPY NUMBER
1516 , x_accounting_coa_id OUT NOCOPY NUMBER
1517 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1518 , x_flex_value_set_id OUT NOCOPY NUMBER
1519 , x_value_type_code OUT NOCOPY VARCHAR2
1520 , x_value_combination_id OUT NOCOPY NUMBER
1521 , x_value_segment_code OUT NOCOPY VARCHAR2
1522 )
1523 RETURN VARCHAR2
1524 IS
1525 l_component_type VARCHAR2(80) ;
1526 l_component_code VARCHAR2(30) ;
1527 l_component_type_code VARCHAR2(1) ;
1528 l_component_appl_id INTEGER ;
1529 l_amb_context_code VARCHAR2(30) ;
1530 l_log_module VARCHAR2(240) ;
1531 l_output_value VARCHAR2(30) ;
1532 BEGIN
1533 IF g_log_enabled THEN
1534 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_12';
1535 END IF;
1536 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1537
1538 trace
1539 (p_msg => 'BEGIN of AcctDerRule_12'
1540 ,p_level => C_LEVEL_PROCEDURE
1541 ,p_module => l_log_module);
1542
1543 END IF;
1544
1545 l_component_type := 'AMB_ADR';
1546 l_component_code := 'FV_AR_422101_MISC_RCT_CR';
1547 l_component_type_code := 'S';
1548 l_component_appl_id := 222;
1549 l_amb_context_code := 'DEFAULT';
1550 x_transaction_coa_id := null;
1551 x_accounting_coa_id := null;
1552 x_flexfield_segment_code := null;
1553 x_flex_value_set_id := 1009988 ;
1554
1555
1556 IF NVL(p_source_11,'
1557 ') = 'Reimbursable'
1558 THEN
1559 --
1560 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1561
1562 trace
1563 (p_msg => 'END of AcctDerRule_12'
1564 ,p_level => C_LEVEL_PROCEDURE
1565 ,p_module => l_log_module);
1566
1567 END IF;
1568 x_value_combination_id := null ;
1569 x_value_segment_code := null ;
1570 x_value_type_code := 'C';
1571 l_output_value := '422101';
1572 RETURN l_output_value;
1573
1574 ELSE
1575 IF p_override_seg_flag = 'Y' THEN
1576 RETURN '#$NO_OVERRIDE#$';
1577 END IF;
1578 END IF;
1579
1580 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1581
1582 trace
1583 (p_msg => 'END of AcctDerRule_12(invalid)'
1584 ,p_level => C_LEVEL_PROCEDURE
1585 ,p_module => l_log_module);
1586
1587 END IF;
1588
1592 x_value_type_code := null;
1589 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1590 x_value_combination_id := null;
1591 x_value_segment_code := null;
1593 l_output_value := null;
1594 xla_accounting_err_pkg.build_message
1595 (p_appli_s_name => 'XLA'
1596 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1597 ,p_token_1 => 'COMPONENT_NAME'
1598 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1599 l_component_type
1600 , l_component_code
1601 , l_component_type_code
1602 , l_component_appl_id
1603 , l_amb_context_code
1604 )
1605 ,p_token_2 => 'OWNER'
1606 ,p_value_2 => xla_lookups_pkg.get_meaning(
1607 'XLA_OWNER_TYPE'
1608 ,l_component_type_code
1609 )
1610 ,p_token_3 => 'PAD_NAME'
1611 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1612 ,p_token_4 => 'PAD_OWNER'
1613 ,p_value_4 => xla_lookups_pkg.get_meaning(
1614 'XLA_OWNER_TYPE'
1615 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1616 )
1617 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1618 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1619 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1620 ,p_ae_header_id => NULL
1621 );
1622 RETURN l_output_value;
1623 EXCEPTION
1624 WHEN xla_exceptions_pkg.application_exception THEN
1625 RAISE;
1626 WHEN OTHERS THEN
1627 xla_exceptions_pkg.raise_message
1628 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_12');
1629 END AcctDerRule_12;
1630 --
1631
1632 ---------------------------------------
1633 --
1634 -- PRIVATE FUNCTION
1635 -- AcctDerRule_13
1636 --
1637 ---------------------------------------
1638 FUNCTION AcctDerRule_13 (
1639 p_application_id IN NUMBER
1640 , p_ae_header_id IN NUMBER
1641 , p_side IN VARCHAR2
1642 , p_override_seg_flag IN VARCHAR2
1643 --Federal Fund Category
1644 , p_source_11 IN VARCHAR2
1645 --Bill To Customer Classification
1646 , p_source_12 IN VARCHAR2
1647 , x_transaction_coa_id OUT NOCOPY NUMBER
1648 , x_accounting_coa_id OUT NOCOPY NUMBER
1649 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1650 , x_flex_value_set_id OUT NOCOPY NUMBER
1651 , x_value_type_code OUT NOCOPY VARCHAR2
1652 , x_value_combination_id OUT NOCOPY NUMBER
1653 , x_value_segment_code OUT NOCOPY VARCHAR2
1654 )
1655 RETURN VARCHAR2
1656 IS
1657 l_component_type VARCHAR2(80) ;
1658 l_component_code VARCHAR2(30) ;
1659 l_component_type_code VARCHAR2(1) ;
1660 l_component_appl_id INTEGER ;
1661 l_amb_context_code VARCHAR2(30) ;
1662 l_log_module VARCHAR2(240) ;
1663 l_output_value VARCHAR2(30) ;
1664 BEGIN
1665 IF g_log_enabled THEN
1666 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_13';
1667 END IF;
1668 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1669
1670 trace
1671 (p_msg => 'BEGIN of AcctDerRule_13'
1672 ,p_level => C_LEVEL_PROCEDURE
1673 ,p_module => l_log_module);
1674
1675 END IF;
1676
1677 l_component_type := 'AMB_ADR';
1678 l_component_code := 'FV_AR_422X0X_INV_REIM_CR';
1679 l_component_type_code := 'S';
1680 l_component_appl_id := 222;
1681 l_amb_context_code := 'DEFAULT';
1682 x_transaction_coa_id := null;
1683 x_accounting_coa_id := null;
1684 x_flexfield_segment_code := null;
1685 x_flex_value_set_id := 1009988 ;
1686
1687
1688 IF NVL(p_source_12,'
1689 ') = 'FEDERAL' AND
1690 NVL(p_source_11,'
1691 ') = 'Reimbursable'
1692 THEN
1693 --
1694 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1695
1696 trace
1697 (p_msg => 'END of AcctDerRule_13'
1698 ,p_level => C_LEVEL_PROCEDURE
1699 ,p_module => l_log_module);
1700
1701 END IF;
1702 x_value_combination_id := null ;
1703 x_value_segment_code := null ;
1704 x_value_type_code := 'C';
1705 l_output_value := '422101';
1706 RETURN l_output_value;
1707
1708 ELSIF NVL(p_source_12,'
1709 ') <> 'FEDERAL' AND
1710 NVL(p_source_11,'
1711 ') = 'Reimbursable'
1712 THEN
1713 --
1714 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1715
1719 ,p_module => l_log_module);
1716 trace
1717 (p_msg => 'END of AcctDerRule_13'
1718 ,p_level => C_LEVEL_PROCEDURE
1720
1721 END IF;
1722 x_value_combination_id := null ;
1723 x_value_segment_code := null ;
1724 x_value_type_code := 'C';
1725 l_output_value := '422202';
1726 RETURN l_output_value;
1727
1728 ELSE
1729 IF p_override_seg_flag = 'Y' THEN
1730 RETURN '#$NO_OVERRIDE#$';
1731 END IF;
1732 END IF;
1733
1734 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1735
1736 trace
1737 (p_msg => 'END of AcctDerRule_13(invalid)'
1738 ,p_level => C_LEVEL_PROCEDURE
1739 ,p_module => l_log_module);
1740
1741 END IF;
1742
1743 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1744 x_value_combination_id := null;
1745 x_value_segment_code := null;
1746 x_value_type_code := null;
1747 l_output_value := null;
1748 xla_accounting_err_pkg.build_message
1749 (p_appli_s_name => 'XLA'
1750 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1751 ,p_token_1 => 'COMPONENT_NAME'
1752 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1753 l_component_type
1754 , l_component_code
1755 , l_component_type_code
1756 , l_component_appl_id
1757 , l_amb_context_code
1758 )
1759 ,p_token_2 => 'OWNER'
1760 ,p_value_2 => xla_lookups_pkg.get_meaning(
1761 'XLA_OWNER_TYPE'
1762 ,l_component_type_code
1763 )
1764 ,p_token_3 => 'PAD_NAME'
1765 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1766 ,p_token_4 => 'PAD_OWNER'
1767 ,p_value_4 => xla_lookups_pkg.get_meaning(
1768 'XLA_OWNER_TYPE'
1769 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1770 )
1771 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1772 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1773 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1774 ,p_ae_header_id => NULL
1775 );
1776 RETURN l_output_value;
1777 EXCEPTION
1778 WHEN xla_exceptions_pkg.application_exception THEN
1779 RAISE;
1780 WHEN OTHERS THEN
1781 xla_exceptions_pkg.raise_message
1782 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_13');
1783 END AcctDerRule_13;
1784 --
1785
1786 ---------------------------------------
1787 --
1788 -- PRIVATE FUNCTION
1789 -- AcctDerRule_14
1790 --
1791 ---------------------------------------
1792 FUNCTION AcctDerRule_14 (
1793 p_application_id IN NUMBER
1794 , p_ae_header_id IN NUMBER
1795 , p_side IN VARCHAR2
1796 , p_override_seg_flag IN VARCHAR2
1797 --Federal Account Rule
1798 , p_source_13 IN VARCHAR2
1799 , x_transaction_coa_id OUT NOCOPY NUMBER
1800 , x_accounting_coa_id OUT NOCOPY NUMBER
1801 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1802 , x_flex_value_set_id OUT NOCOPY NUMBER
1803 , x_value_type_code OUT NOCOPY VARCHAR2
1804 , x_value_combination_id OUT NOCOPY NUMBER
1805 , x_value_segment_code OUT NOCOPY VARCHAR2
1806 )
1807 RETURN VARCHAR2
1808 IS
1809 l_component_type VARCHAR2(80) ;
1810 l_component_code VARCHAR2(30) ;
1811 l_component_type_code VARCHAR2(1) ;
1812 l_component_appl_id INTEGER ;
1813 l_amb_context_code VARCHAR2(30) ;
1814 l_log_module VARCHAR2(240) ;
1815 l_output_value VARCHAR2(30) ;
1816 BEGIN
1817 IF g_log_enabled THEN
1818 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_14';
1819 END IF;
1820 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1821
1822 trace
1823 (p_msg => 'BEGIN of AcctDerRule_14'
1824 ,p_level => C_LEVEL_PROCEDURE
1825 ,p_module => l_log_module);
1826
1827 END IF;
1828
1829 l_component_type := 'AMB_ADR';
1830 l_component_code := 'FV_AR_425101_RCT_CR';
1831 l_component_type_code := 'S';
1832 l_component_appl_id := 222;
1833 l_amb_context_code := 'DEFAULT';
1834 x_transaction_coa_id := null;
1835 x_accounting_coa_id := null;
1836 x_flexfield_segment_code := null;
1837 x_flex_value_set_id := 1009988 ;
1838
1839
1840 IF NVL(p_source_13,'
1841 ') = 'Order No Advance'
1845
1842 THEN
1843 --
1844 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1846 trace
1847 (p_msg => 'END of AcctDerRule_14'
1848 ,p_level => C_LEVEL_PROCEDURE
1849 ,p_module => l_log_module);
1850
1851 END IF;
1852 x_value_combination_id := null ;
1853 x_value_segment_code := null ;
1854 x_value_type_code := 'C';
1855 l_output_value := '425101';
1856 RETURN l_output_value;
1857
1858 ELSE
1859 IF p_override_seg_flag = 'Y' THEN
1860 RETURN '#$NO_OVERRIDE#$';
1861 END IF;
1862 END IF;
1863
1864 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1865
1866 trace
1867 (p_msg => 'END of AcctDerRule_14(invalid)'
1868 ,p_level => C_LEVEL_PROCEDURE
1869 ,p_module => l_log_module);
1870
1871 END IF;
1872
1873 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1874 x_value_combination_id := null;
1875 x_value_segment_code := null;
1876 x_value_type_code := null;
1877 l_output_value := null;
1878 xla_accounting_err_pkg.build_message
1879 (p_appli_s_name => 'XLA'
1880 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1881 ,p_token_1 => 'COMPONENT_NAME'
1882 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1883 l_component_type
1884 , l_component_code
1885 , l_component_type_code
1886 , l_component_appl_id
1887 , l_amb_context_code
1888 )
1889 ,p_token_2 => 'OWNER'
1890 ,p_value_2 => xla_lookups_pkg.get_meaning(
1891 'XLA_OWNER_TYPE'
1892 ,l_component_type_code
1893 )
1894 ,p_token_3 => 'PAD_NAME'
1895 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1896 ,p_token_4 => 'PAD_OWNER'
1897 ,p_value_4 => xla_lookups_pkg.get_meaning(
1898 'XLA_OWNER_TYPE'
1899 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1900 )
1901 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1902 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1903 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1904 ,p_ae_header_id => NULL
1905 );
1906 RETURN l_output_value;
1907 EXCEPTION
1908 WHEN xla_exceptions_pkg.application_exception THEN
1909 RAISE;
1910 WHEN OTHERS THEN
1911 xla_exceptions_pkg.raise_message
1912 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_14');
1913 END AcctDerRule_14;
1914 --
1915
1916 ---------------------------------------
1917 --
1918 -- PRIVATE FUNCTION
1919 -- AcctDerRule_15
1920 --
1921 ---------------------------------------
1922 FUNCTION AcctDerRule_15 (
1923 p_application_id IN NUMBER
1924 , p_ae_header_id IN NUMBER
1925 , p_side IN VARCHAR2
1926 , p_override_seg_flag IN VARCHAR2
1927 --Federal Fund Category
1928 , p_source_11 IN VARCHAR2
1929 , x_transaction_coa_id OUT NOCOPY NUMBER
1930 , x_accounting_coa_id OUT NOCOPY NUMBER
1931 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1932 , x_flex_value_set_id OUT NOCOPY NUMBER
1933 , x_value_type_code OUT NOCOPY VARCHAR2
1934 , x_value_combination_id OUT NOCOPY NUMBER
1935 , x_value_segment_code OUT NOCOPY VARCHAR2
1936 )
1937 RETURN VARCHAR2
1938 IS
1939 l_component_type VARCHAR2(80) ;
1940 l_component_code VARCHAR2(30) ;
1941 l_component_type_code VARCHAR2(1) ;
1942 l_component_appl_id INTEGER ;
1943 l_amb_context_code VARCHAR2(30) ;
1944 l_log_module VARCHAR2(240) ;
1945 l_output_value VARCHAR2(30) ;
1946 BEGIN
1947 IF g_log_enabled THEN
1948 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_15';
1949 END IF;
1950 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1951
1952 trace
1953 (p_msg => 'BEGIN of AcctDerRule_15'
1954 ,p_level => C_LEVEL_PROCEDURE
1955 ,p_module => l_log_module);
1956
1957 END IF;
1958
1959 l_component_type := 'AMB_ADR';
1960 l_component_code := 'FV_AR_425201_MISC_RCT_DR';
1961 l_component_type_code := 'S';
1962 l_component_appl_id := 222;
1963 l_amb_context_code := 'DEFAULT';
1964 x_transaction_coa_id := null;
1965 x_accounting_coa_id := null;
1966 x_flexfield_segment_code := null;
1967 x_flex_value_set_id := 1009988 ;
1971 ') = 'Reimbursable'
1968
1969
1970 IF NVL(p_source_11,'
1972 THEN
1973 --
1974 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1975
1976 trace
1977 (p_msg => 'END of AcctDerRule_15'
1978 ,p_level => C_LEVEL_PROCEDURE
1979 ,p_module => l_log_module);
1980
1981 END IF;
1982 x_value_combination_id := null ;
1983 x_value_segment_code := null ;
1984 x_value_type_code := 'C';
1985 l_output_value := '425201';
1986 RETURN l_output_value;
1987
1988 ELSE
1989 IF p_override_seg_flag = 'Y' THEN
1990 RETURN '#$NO_OVERRIDE#$';
1991 END IF;
1992 END IF;
1993
1994 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1995
1996 trace
1997 (p_msg => 'END of AcctDerRule_15(invalid)'
1998 ,p_level => C_LEVEL_PROCEDURE
1999 ,p_module => l_log_module);
2000
2001 END IF;
2002
2003 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2004 x_value_combination_id := null;
2005 x_value_segment_code := null;
2006 x_value_type_code := null;
2007 l_output_value := null;
2008 xla_accounting_err_pkg.build_message
2009 (p_appli_s_name => 'XLA'
2010 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2011 ,p_token_1 => 'COMPONENT_NAME'
2012 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2013 l_component_type
2014 , l_component_code
2015 , l_component_type_code
2016 , l_component_appl_id
2017 , l_amb_context_code
2018 )
2019 ,p_token_2 => 'OWNER'
2020 ,p_value_2 => xla_lookups_pkg.get_meaning(
2021 'XLA_OWNER_TYPE'
2022 ,l_component_type_code
2023 )
2024 ,p_token_3 => 'PAD_NAME'
2025 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2026 ,p_token_4 => 'PAD_OWNER'
2027 ,p_value_4 => xla_lookups_pkg.get_meaning(
2028 'XLA_OWNER_TYPE'
2029 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2030 )
2031 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2032 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2033 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2034 ,p_ae_header_id => NULL
2035 );
2036 RETURN l_output_value;
2037 EXCEPTION
2038 WHEN xla_exceptions_pkg.application_exception THEN
2039 RAISE;
2040 WHEN OTHERS THEN
2041 xla_exceptions_pkg.raise_message
2042 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_15');
2043 END AcctDerRule_15;
2044 --
2045
2046 ---------------------------------------
2047 --
2048 -- PRIVATE FUNCTION
2049 -- AcctDerRule_16
2050 --
2051 ---------------------------------------
2052 FUNCTION AcctDerRule_16 (
2053 p_application_id IN NUMBER
2054 , p_ae_header_id IN NUMBER
2055 , p_side IN VARCHAR2
2056 , p_override_seg_flag IN VARCHAR2
2057 --Federal Account Rule
2058 , p_source_13 IN VARCHAR2
2059 , x_transaction_coa_id OUT NOCOPY NUMBER
2060 , x_accounting_coa_id OUT NOCOPY NUMBER
2061 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2062 , x_flex_value_set_id OUT NOCOPY NUMBER
2063 , x_value_type_code OUT NOCOPY VARCHAR2
2064 , x_value_combination_id OUT NOCOPY NUMBER
2065 , x_value_segment_code OUT NOCOPY VARCHAR2
2066 )
2067 RETURN VARCHAR2
2068 IS
2069 l_component_type VARCHAR2(80) ;
2070 l_component_code VARCHAR2(30) ;
2071 l_component_type_code VARCHAR2(1) ;
2072 l_component_appl_id INTEGER ;
2073 l_amb_context_code VARCHAR2(30) ;
2074 l_log_module VARCHAR2(240) ;
2075 l_output_value VARCHAR2(30) ;
2076 BEGIN
2077 IF g_log_enabled THEN
2078 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_16';
2079 END IF;
2080 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2081
2082 trace
2083 (p_msg => 'BEGIN of AcctDerRule_16'
2084 ,p_level => C_LEVEL_PROCEDURE
2085 ,p_module => l_log_module);
2086
2087 END IF;
2088
2089 l_component_type := 'AMB_ADR';
2090 l_component_code := 'FV_AR_425201_RCT_DR';
2091 l_component_type_code := 'S';
2092 l_component_appl_id := 222;
2093 l_amb_context_code := 'DEFAULT';
2094 x_transaction_coa_id := null;
2095 x_accounting_coa_id := null;
2096 x_flexfield_segment_code := null;
2100 IF NVL(p_source_13,'
2097 x_flex_value_set_id := 1009988 ;
2098
2099
2101 ') = 'Order No Advance'
2102 THEN
2103 --
2104 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2105
2106 trace
2107 (p_msg => 'END of AcctDerRule_16'
2108 ,p_level => C_LEVEL_PROCEDURE
2109 ,p_module => l_log_module);
2110
2111 END IF;
2112 x_value_combination_id := null ;
2113 x_value_segment_code := null ;
2114 x_value_type_code := 'C';
2115 l_output_value := '425201';
2116 RETURN l_output_value;
2117
2118 ELSE
2119 IF p_override_seg_flag = 'Y' THEN
2120 RETURN '#$NO_OVERRIDE#$';
2121 END IF;
2122 END IF;
2123
2124 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2125
2126 trace
2127 (p_msg => 'END of AcctDerRule_16(invalid)'
2128 ,p_level => C_LEVEL_PROCEDURE
2129 ,p_module => l_log_module);
2130
2131 END IF;
2132
2133 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2134 x_value_combination_id := null;
2135 x_value_segment_code := null;
2136 x_value_type_code := null;
2137 l_output_value := null;
2138 xla_accounting_err_pkg.build_message
2139 (p_appli_s_name => 'XLA'
2140 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2141 ,p_token_1 => 'COMPONENT_NAME'
2142 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2143 l_component_type
2144 , l_component_code
2145 , l_component_type_code
2146 , l_component_appl_id
2147 , l_amb_context_code
2148 )
2149 ,p_token_2 => 'OWNER'
2150 ,p_value_2 => xla_lookups_pkg.get_meaning(
2151 'XLA_OWNER_TYPE'
2152 ,l_component_type_code
2153 )
2154 ,p_token_3 => 'PAD_NAME'
2155 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2156 ,p_token_4 => 'PAD_OWNER'
2157 ,p_value_4 => xla_lookups_pkg.get_meaning(
2158 'XLA_OWNER_TYPE'
2159 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2160 )
2161 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2162 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2163 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2164 ,p_ae_header_id => NULL
2165 );
2166 RETURN l_output_value;
2167 EXCEPTION
2168 WHEN xla_exceptions_pkg.application_exception THEN
2169 RAISE;
2170 WHEN OTHERS THEN
2171 xla_exceptions_pkg.raise_message
2172 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_16');
2173 END AcctDerRule_16;
2174 --
2175
2176 ---------------------------------------
2177 --
2178 -- PRIVATE FUNCTION
2179 -- AcctDerRule_17
2180 --
2181 ---------------------------------------
2182 FUNCTION AcctDerRule_17 (
2183 p_application_id IN NUMBER
2184 , p_ae_header_id IN NUMBER
2185 , p_side IN VARCHAR2
2186 , p_override_seg_flag IN VARCHAR2
2187 --Federal Fund Category
2188 , p_source_11 IN VARCHAR2
2189 --Bill To Customer Classification
2190 , p_source_12 IN VARCHAR2
2191 , x_transaction_coa_id OUT NOCOPY NUMBER
2192 , x_accounting_coa_id OUT NOCOPY NUMBER
2193 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2194 , x_flex_value_set_id OUT NOCOPY NUMBER
2195 , x_value_type_code OUT NOCOPY VARCHAR2
2196 , x_value_combination_id OUT NOCOPY NUMBER
2197 , x_value_segment_code OUT NOCOPY VARCHAR2
2198 )
2199 RETURN VARCHAR2
2200 IS
2201 l_component_type VARCHAR2(80) ;
2202 l_component_code VARCHAR2(30) ;
2203 l_component_type_code VARCHAR2(1) ;
2204 l_component_appl_id INTEGER ;
2205 l_amb_context_code VARCHAR2(30) ;
2206 l_log_module VARCHAR2(240) ;
2207 l_output_value VARCHAR2(30) ;
2208 BEGIN
2209 IF g_log_enabled THEN
2210 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_17';
2211 END IF;
2212 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2213
2214 trace
2215 (p_msg => 'BEGIN of AcctDerRule_17'
2216 ,p_level => C_LEVEL_PROCEDURE
2217 ,p_module => l_log_module);
2218
2219 END IF;
2220
2221 l_component_type := 'AMB_ADR';
2222 l_component_code := 'FV_AR_425X0X_INV_REIM_DR';
2226 x_transaction_coa_id := null;
2223 l_component_type_code := 'S';
2224 l_component_appl_id := 222;
2225 l_amb_context_code := 'DEFAULT';
2227 x_accounting_coa_id := null;
2228 x_flexfield_segment_code := null;
2229 x_flex_value_set_id := 1009988 ;
2230
2231
2232 IF NVL(p_source_12,'
2233 ') = 'FEDERAL' AND
2234 NVL(p_source_11,'
2235 ') = 'Reimbursable'
2236 THEN
2237 --
2238 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2239
2240 trace
2241 (p_msg => 'END of AcctDerRule_17'
2242 ,p_level => C_LEVEL_PROCEDURE
2243 ,p_module => l_log_module);
2244
2245 END IF;
2246 x_value_combination_id := null ;
2247 x_value_segment_code := null ;
2248 x_value_type_code := 'C';
2249 l_output_value := '425101';
2250 RETURN l_output_value;
2251
2252 ELSIF NVL(p_source_12,'
2253 ') <> 'FEDERAL' AND
2254 NVL(p_source_11,'
2255 ') = 'Reimbursable'
2256 THEN
2257 --
2258 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2259
2260 trace
2261 (p_msg => 'END of AcctDerRule_17'
2262 ,p_level => C_LEVEL_PROCEDURE
2263 ,p_module => l_log_module);
2264
2265 END IF;
2266 x_value_combination_id := null ;
2267 x_value_segment_code := null ;
2268 x_value_type_code := 'C';
2269 l_output_value := '425202';
2270 RETURN l_output_value;
2271
2272 ELSE
2273 IF p_override_seg_flag = 'Y' THEN
2274 RETURN '#$NO_OVERRIDE#$';
2275 END IF;
2276 END IF;
2277
2278 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2279
2280 trace
2281 (p_msg => 'END of AcctDerRule_17(invalid)'
2282 ,p_level => C_LEVEL_PROCEDURE
2283 ,p_module => l_log_module);
2284
2285 END IF;
2286
2287 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2288 x_value_combination_id := null;
2289 x_value_segment_code := null;
2290 x_value_type_code := null;
2291 l_output_value := null;
2292 xla_accounting_err_pkg.build_message
2293 (p_appli_s_name => 'XLA'
2294 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2295 ,p_token_1 => 'COMPONENT_NAME'
2296 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2297 l_component_type
2298 , l_component_code
2299 , l_component_type_code
2300 , l_component_appl_id
2301 , l_amb_context_code
2302 )
2303 ,p_token_2 => 'OWNER'
2304 ,p_value_2 => xla_lookups_pkg.get_meaning(
2305 'XLA_OWNER_TYPE'
2306 ,l_component_type_code
2307 )
2308 ,p_token_3 => 'PAD_NAME'
2309 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2310 ,p_token_4 => 'PAD_OWNER'
2311 ,p_value_4 => xla_lookups_pkg.get_meaning(
2312 'XLA_OWNER_TYPE'
2313 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2314 )
2315 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2316 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2317 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2318 ,p_ae_header_id => NULL
2319 );
2320 RETURN l_output_value;
2321 EXCEPTION
2322 WHEN xla_exceptions_pkg.application_exception THEN
2323 RAISE;
2324 WHEN OTHERS THEN
2325 xla_exceptions_pkg.raise_message
2326 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_17');
2327 END AcctDerRule_17;
2328 --
2329
2330 ---------------------------------------
2331 --
2332 -- PRIVATE FUNCTION
2333 -- AcctDerRule_18
2334 --
2335 ---------------------------------------
2336 FUNCTION AcctDerRule_18 (
2337 p_application_id IN NUMBER
2338 , p_ae_header_id IN NUMBER
2339 , p_side IN VARCHAR2
2340 , p_override_seg_flag IN VARCHAR2
2341 --Federal Fund Expired Status
2342 , p_source_14 IN VARCHAR2
2343 --Federal Prior Year Flag
2344 , p_source_15 IN VARCHAR2
2345 --Federal Fund Time Frame
2346 , p_source_16 IN VARCHAR2
2347 , x_transaction_coa_id OUT NOCOPY NUMBER
2348 , x_accounting_coa_id OUT NOCOPY NUMBER
2349 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2350 , x_flex_value_set_id OUT NOCOPY NUMBER
2351 , x_value_type_code OUT NOCOPY VARCHAR2
2352 , x_value_combination_id OUT NOCOPY NUMBER
2353 , x_value_segment_code OUT NOCOPY VARCHAR2
2354 )
2355 RETURN VARCHAR2
2356 IS
2360 l_component_appl_id INTEGER ;
2357 l_component_type VARCHAR2(80) ;
2358 l_component_code VARCHAR2(30) ;
2359 l_component_type_code VARCHAR2(1) ;
2361 l_amb_context_code VARCHAR2(30) ;
2362 l_log_module VARCHAR2(240) ;
2363 l_output_value VARCHAR2(30) ;
2364 BEGIN
2365 IF g_log_enabled THEN
2366 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_18';
2367 END IF;
2368 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2369
2370 trace
2371 (p_msg => 'BEGIN of AcctDerRule_18'
2372 ,p_level => C_LEVEL_PROCEDURE
2373 ,p_module => l_log_module);
2374
2375 END IF;
2376
2377 l_component_type := 'AMB_ADR';
2378 l_component_code := 'FV_AR_445001_MISC_RCT_CR';
2379 l_component_type_code := 'S';
2380 l_component_appl_id := 222;
2381 l_amb_context_code := 'DEFAULT';
2382 x_transaction_coa_id := null;
2383 x_accounting_coa_id := null;
2384 x_flexfield_segment_code := null;
2385 x_flex_value_set_id := 1009988 ;
2386
2387
2388 IF NVL(p_source_14,'
2389 ') = 'Unexpired' AND
2390 NVL(p_source_15,'
2391 ') = 'Y' AND
2392 (NVL(p_source_16,'
2393 ') = 'MULTIPLE' OR
2394 NVL(p_source_16,'
2395 ') = 'NO_YEAR')
2396 THEN
2397 --
2398 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2399
2400 trace
2401 (p_msg => 'END of AcctDerRule_18'
2402 ,p_level => C_LEVEL_PROCEDURE
2403 ,p_module => l_log_module);
2404
2405 END IF;
2406 x_value_combination_id := null ;
2407 x_value_segment_code := null ;
2408 x_value_type_code := 'C';
2409 l_output_value := '445001';
2410 RETURN l_output_value;
2411
2412 ELSE
2413 IF p_override_seg_flag = 'Y' THEN
2414 RETURN '#$NO_OVERRIDE#$';
2415 END IF;
2416 END IF;
2417
2418 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2419
2420 trace
2421 (p_msg => 'END of AcctDerRule_18(invalid)'
2422 ,p_level => C_LEVEL_PROCEDURE
2423 ,p_module => l_log_module);
2424
2425 END IF;
2426
2427 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2428 x_value_combination_id := null;
2429 x_value_segment_code := null;
2430 x_value_type_code := null;
2431 l_output_value := null;
2432 xla_accounting_err_pkg.build_message
2433 (p_appli_s_name => 'XLA'
2434 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2435 ,p_token_1 => 'COMPONENT_NAME'
2436 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2437 l_component_type
2438 , l_component_code
2439 , l_component_type_code
2440 , l_component_appl_id
2441 , l_amb_context_code
2442 )
2443 ,p_token_2 => 'OWNER'
2444 ,p_value_2 => xla_lookups_pkg.get_meaning(
2445 'XLA_OWNER_TYPE'
2446 ,l_component_type_code
2447 )
2448 ,p_token_3 => 'PAD_NAME'
2449 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2450 ,p_token_4 => 'PAD_OWNER'
2451 ,p_value_4 => xla_lookups_pkg.get_meaning(
2452 'XLA_OWNER_TYPE'
2453 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2454 )
2455 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2456 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2457 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2458 ,p_ae_header_id => NULL
2459 );
2460 RETURN l_output_value;
2461 EXCEPTION
2462 WHEN xla_exceptions_pkg.application_exception THEN
2463 RAISE;
2464 WHEN OTHERS THEN
2465 xla_exceptions_pkg.raise_message
2466 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_18');
2467 END AcctDerRule_18;
2468 --
2469
2470 ---------------------------------------
2471 --
2472 -- PRIVATE FUNCTION
2473 -- AcctDerRule_19
2474 --
2475 ---------------------------------------
2476 FUNCTION AcctDerRule_19 (
2477 p_application_id IN NUMBER
2478 , p_ae_header_id IN NUMBER
2479 , p_side IN VARCHAR2
2480 , p_override_seg_flag IN VARCHAR2
2481 --Federal Fund Expired Status
2482 , p_source_14 IN VARCHAR2
2483 --Federal Prior Year Flag
2484 , p_source_15 IN VARCHAR2
2485 --Federal Fund Time Frame
2486 , p_source_16 IN VARCHAR2
2490 , x_flex_value_set_id OUT NOCOPY NUMBER
2487 , x_transaction_coa_id OUT NOCOPY NUMBER
2488 , x_accounting_coa_id OUT NOCOPY NUMBER
2489 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2491 , x_value_type_code OUT NOCOPY VARCHAR2
2492 , x_value_combination_id OUT NOCOPY NUMBER
2493 , x_value_segment_code OUT NOCOPY VARCHAR2
2494 )
2495 RETURN VARCHAR2
2496 IS
2497 l_component_type VARCHAR2(80) ;
2498 l_component_code VARCHAR2(30) ;
2499 l_component_type_code VARCHAR2(1) ;
2500 l_component_appl_id INTEGER ;
2501 l_amb_context_code VARCHAR2(30) ;
2502 l_log_module VARCHAR2(240) ;
2503 l_output_value VARCHAR2(30) ;
2504 BEGIN
2505 IF g_log_enabled THEN
2506 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_19';
2507 END IF;
2508 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2509
2510 trace
2511 (p_msg => 'BEGIN of AcctDerRule_19'
2512 ,p_level => C_LEVEL_PROCEDURE
2513 ,p_module => l_log_module);
2514
2515 END IF;
2516
2517 l_component_type := 'AMB_ADR';
2518 l_component_code := 'FV_AR_445001_RCT_CR';
2519 l_component_type_code := 'S';
2520 l_component_appl_id := 222;
2521 l_amb_context_code := 'DEFAULT';
2522 x_transaction_coa_id := null;
2523 x_accounting_coa_id := null;
2524 x_flexfield_segment_code := null;
2525 x_flex_value_set_id := 1009988 ;
2526
2527
2528 IF NVL(p_source_14,'
2529 ') = 'Unexpired' AND
2530 NVL(p_source_15,'
2531 ') = 'Y' AND
2532 (NVL(p_source_16,'
2533 ') = 'MULTIPLE' OR
2534 NVL(p_source_16,'
2535 ') = 'NO_YEAR')
2536 THEN
2537 --
2538 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2539
2540 trace
2541 (p_msg => 'END of AcctDerRule_19'
2542 ,p_level => C_LEVEL_PROCEDURE
2543 ,p_module => l_log_module);
2544
2545 END IF;
2546 x_value_combination_id := null ;
2547 x_value_segment_code := null ;
2548 x_value_type_code := 'C';
2549 l_output_value := '445001';
2550 RETURN l_output_value;
2551
2552 ELSE
2553 IF p_override_seg_flag = 'Y' THEN
2554 RETURN '#$NO_OVERRIDE#$';
2555 END IF;
2556 END IF;
2557
2558 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2559
2560 trace
2561 (p_msg => 'END of AcctDerRule_19(invalid)'
2562 ,p_level => C_LEVEL_PROCEDURE
2563 ,p_module => l_log_module);
2564
2565 END IF;
2566
2567 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2568 x_value_combination_id := null;
2569 x_value_segment_code := null;
2570 x_value_type_code := null;
2571 l_output_value := null;
2572 xla_accounting_err_pkg.build_message
2573 (p_appli_s_name => 'XLA'
2574 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2575 ,p_token_1 => 'COMPONENT_NAME'
2576 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2577 l_component_type
2578 , l_component_code
2579 , l_component_type_code
2580 , l_component_appl_id
2581 , l_amb_context_code
2582 )
2583 ,p_token_2 => 'OWNER'
2584 ,p_value_2 => xla_lookups_pkg.get_meaning(
2585 'XLA_OWNER_TYPE'
2586 ,l_component_type_code
2587 )
2588 ,p_token_3 => 'PAD_NAME'
2589 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2590 ,p_token_4 => 'PAD_OWNER'
2591 ,p_value_4 => xla_lookups_pkg.get_meaning(
2592 'XLA_OWNER_TYPE'
2593 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2594 )
2595 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2596 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2597 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2598 ,p_ae_header_id => NULL
2599 );
2600 RETURN l_output_value;
2601 EXCEPTION
2602 WHEN xla_exceptions_pkg.application_exception THEN
2603 RAISE;
2604 WHEN OTHERS THEN
2605 xla_exceptions_pkg.raise_message
2606 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_19');
2607 END AcctDerRule_19;
2608 --
2609
2610 ---------------------------------------
2611 --
2612 -- PRIVATE FUNCTION
2613 -- AcctDerRule_20
2614 --
2615 ---------------------------------------
2616 FUNCTION AcctDerRule_20 (
2620 , p_override_seg_flag IN VARCHAR2
2617 p_application_id IN NUMBER
2618 , p_ae_header_id IN NUMBER
2619 , p_side IN VARCHAR2
2621 --Federal Fund Expired Status
2622 , p_source_14 IN VARCHAR2
2623 --Federal Prior Year Flag
2624 , p_source_15 IN VARCHAR2
2625 --Federal Fund Time Frame
2626 , p_source_16 IN VARCHAR2
2627 , x_transaction_coa_id OUT NOCOPY NUMBER
2628 , x_accounting_coa_id OUT NOCOPY NUMBER
2629 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2630 , x_flex_value_set_id OUT NOCOPY NUMBER
2631 , x_value_type_code OUT NOCOPY VARCHAR2
2632 , x_value_combination_id OUT NOCOPY NUMBER
2633 , x_value_segment_code OUT NOCOPY VARCHAR2
2634 )
2635 RETURN VARCHAR2
2636 IS
2637 l_component_type VARCHAR2(80) ;
2638 l_component_code VARCHAR2(30) ;
2639 l_component_type_code VARCHAR2(1) ;
2640 l_component_appl_id INTEGER ;
2641 l_amb_context_code VARCHAR2(30) ;
2642 l_log_module VARCHAR2(240) ;
2643 l_output_value VARCHAR2(30) ;
2644 BEGIN
2645 IF g_log_enabled THEN
2646 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_20';
2647 END IF;
2648 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2649
2650 trace
2651 (p_msg => 'BEGIN of AcctDerRule_20'
2652 ,p_level => C_LEVEL_PROCEDURE
2653 ,p_module => l_log_module);
2654
2655 END IF;
2656
2657 l_component_type := 'AMB_ADR';
2658 l_component_code := 'FV_AR_465002_MISC_RCT_CR';
2659 l_component_type_code := 'S';
2660 l_component_appl_id := 222;
2661 l_amb_context_code := 'DEFAULT';
2662 x_transaction_coa_id := null;
2663 x_accounting_coa_id := null;
2664 x_flexfield_segment_code := null;
2665 x_flex_value_set_id := 1009988 ;
2666
2667
2668 IF NVL(p_source_14,'
2669 ') = 'Expired' AND
2670 NVL(p_source_15,'
2671 ') = 'Y' AND
2672 (NVL(p_source_16,'
2673 ') = 'SINGLE' OR
2674 NVL(p_source_16,'
2675 ') = 'MULTIPLE' OR
2676 NVL(p_source_16,'
2677 ') = 'NO_YEAR')
2678 THEN
2679 --
2680 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2681
2682 trace
2683 (p_msg => 'END of AcctDerRule_20'
2684 ,p_level => C_LEVEL_PROCEDURE
2685 ,p_module => l_log_module);
2686
2687 END IF;
2688 x_value_combination_id := null ;
2689 x_value_segment_code := null ;
2690 x_value_type_code := 'C';
2691 l_output_value := '465002';
2692 RETURN l_output_value;
2693
2694 ELSE
2695 IF p_override_seg_flag = 'Y' THEN
2696 RETURN '#$NO_OVERRIDE#$';
2697 END IF;
2698 END IF;
2699
2700 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2701
2702 trace
2703 (p_msg => 'END of AcctDerRule_20(invalid)'
2704 ,p_level => C_LEVEL_PROCEDURE
2705 ,p_module => l_log_module);
2706
2707 END IF;
2708
2709 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2710 x_value_combination_id := null;
2711 x_value_segment_code := null;
2712 x_value_type_code := null;
2713 l_output_value := null;
2714 xla_accounting_err_pkg.build_message
2715 (p_appli_s_name => 'XLA'
2716 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2717 ,p_token_1 => 'COMPONENT_NAME'
2718 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2719 l_component_type
2720 , l_component_code
2721 , l_component_type_code
2722 , l_component_appl_id
2723 , l_amb_context_code
2724 )
2725 ,p_token_2 => 'OWNER'
2726 ,p_value_2 => xla_lookups_pkg.get_meaning(
2727 'XLA_OWNER_TYPE'
2728 ,l_component_type_code
2729 )
2730 ,p_token_3 => 'PAD_NAME'
2731 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2732 ,p_token_4 => 'PAD_OWNER'
2733 ,p_value_4 => xla_lookups_pkg.get_meaning(
2734 'XLA_OWNER_TYPE'
2735 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2736 )
2737 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2738 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2739 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2740 ,p_ae_header_id => NULL
2741 );
2742 RETURN l_output_value;
2743 EXCEPTION
2744 WHEN xla_exceptions_pkg.application_exception THEN
2745 RAISE;
2746 WHEN OTHERS THEN
2750 --
2747 xla_exceptions_pkg.raise_message
2748 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_20');
2749 END AcctDerRule_20;
2751
2752 ---------------------------------------
2753 --
2754 -- PRIVATE FUNCTION
2755 -- AcctDerRule_21
2756 --
2757 ---------------------------------------
2758 FUNCTION AcctDerRule_21 (
2759 p_application_id IN NUMBER
2760 , p_ae_header_id IN NUMBER
2761 , p_side IN VARCHAR2
2762 , p_override_seg_flag IN VARCHAR2
2763 --Federal Fund Expired Status
2764 , p_source_14 IN VARCHAR2
2765 --Federal Prior Year Flag
2766 , p_source_15 IN VARCHAR2
2767 --Federal Fund Time Frame
2768 , p_source_16 IN VARCHAR2
2769 , x_transaction_coa_id OUT NOCOPY NUMBER
2770 , x_accounting_coa_id OUT NOCOPY NUMBER
2771 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2772 , x_flex_value_set_id OUT NOCOPY NUMBER
2773 , x_value_type_code OUT NOCOPY VARCHAR2
2774 , x_value_combination_id OUT NOCOPY NUMBER
2775 , x_value_segment_code OUT NOCOPY VARCHAR2
2776 )
2777 RETURN VARCHAR2
2778 IS
2779 l_component_type VARCHAR2(80) ;
2780 l_component_code VARCHAR2(30) ;
2781 l_component_type_code VARCHAR2(1) ;
2782 l_component_appl_id INTEGER ;
2783 l_amb_context_code VARCHAR2(30) ;
2784 l_log_module VARCHAR2(240) ;
2785 l_output_value VARCHAR2(30) ;
2786 BEGIN
2787 IF g_log_enabled THEN
2788 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_21';
2789 END IF;
2790 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2791
2792 trace
2793 (p_msg => 'BEGIN of AcctDerRule_21'
2794 ,p_level => C_LEVEL_PROCEDURE
2795 ,p_module => l_log_module);
2796
2797 END IF;
2798
2799 l_component_type := 'AMB_ADR';
2800 l_component_code := 'FV_AR_465002_RCT_CR';
2801 l_component_type_code := 'S';
2802 l_component_appl_id := 222;
2803 l_amb_context_code := 'DEFAULT';
2804 x_transaction_coa_id := null;
2805 x_accounting_coa_id := null;
2806 x_flexfield_segment_code := null;
2807 x_flex_value_set_id := 1009988 ;
2808
2809
2810 IF NVL(p_source_14,'
2811 ') = 'Expired' AND
2812 NVL(p_source_15,'
2813 ') = 'Y' AND
2814 (NVL(p_source_16,'
2815 ') = 'SINGLE' OR
2816 NVL(p_source_16,'
2817 ') = 'MULTIPLE' OR
2818 NVL(p_source_16,'
2819 ') = 'NO_YEAR')
2820 THEN
2821 --
2822 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2823
2824 trace
2825 (p_msg => 'END of AcctDerRule_21'
2826 ,p_level => C_LEVEL_PROCEDURE
2827 ,p_module => l_log_module);
2828
2829 END IF;
2830 x_value_combination_id := null ;
2831 x_value_segment_code := null ;
2832 x_value_type_code := 'C';
2833 l_output_value := '465002';
2834 RETURN l_output_value;
2835
2836 ELSE
2837 IF p_override_seg_flag = 'Y' THEN
2838 RETURN '#$NO_OVERRIDE#$';
2839 END IF;
2840 END IF;
2841
2842 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2843
2844 trace
2845 (p_msg => 'END of AcctDerRule_21(invalid)'
2846 ,p_level => C_LEVEL_PROCEDURE
2847 ,p_module => l_log_module);
2848
2849 END IF;
2850
2851 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2852 x_value_combination_id := null;
2853 x_value_segment_code := null;
2854 x_value_type_code := null;
2855 l_output_value := null;
2856 xla_accounting_err_pkg.build_message
2857 (p_appli_s_name => 'XLA'
2858 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2859 ,p_token_1 => 'COMPONENT_NAME'
2860 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2861 l_component_type
2862 , l_component_code
2863 , l_component_type_code
2864 , l_component_appl_id
2865 , l_amb_context_code
2866 )
2867 ,p_token_2 => 'OWNER'
2868 ,p_value_2 => xla_lookups_pkg.get_meaning(
2869 'XLA_OWNER_TYPE'
2870 ,l_component_type_code
2871 )
2872 ,p_token_3 => 'PAD_NAME'
2873 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2874 ,p_token_4 => 'PAD_OWNER'
2875 ,p_value_4 => xla_lookups_pkg.get_meaning(
2876 'XLA_OWNER_TYPE'
2877 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2878 )
2879 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2880 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2884 RETURN l_output_value;
2881 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2882 ,p_ae_header_id => NULL
2883 );
2885 EXCEPTION
2886 WHEN xla_exceptions_pkg.application_exception THEN
2887 RAISE;
2888 WHEN OTHERS THEN
2889 xla_exceptions_pkg.raise_message
2890 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_21');
2891 END AcctDerRule_21;
2892 --
2893
2894 ---------------------------------------
2895 --
2896 -- PRIVATE FUNCTION
2897 -- AcctDerRule_22
2898 --
2899 ---------------------------------------
2900 FUNCTION AcctDerRule_22 (
2901 p_application_id IN NUMBER
2902 , p_ae_header_id IN NUMBER
2903 , p_side IN VARCHAR2
2904 , p_override_seg_flag IN VARCHAR2
2905 --Federal Fund Expired Status
2906 , p_source_14 IN VARCHAR2
2907 --Federal Prior Year Flag
2908 , p_source_15 IN VARCHAR2
2909 --Federal Fund Time Frame
2910 , p_source_16 IN VARCHAR2
2911 --Federal Apportionment Category
2912 , p_source_17 IN VARCHAR2
2913 , x_transaction_coa_id OUT NOCOPY NUMBER
2914 , x_accounting_coa_id OUT NOCOPY NUMBER
2915 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2916 , x_flex_value_set_id OUT NOCOPY NUMBER
2917 , x_value_type_code OUT NOCOPY VARCHAR2
2918 , x_value_combination_id OUT NOCOPY NUMBER
2919 , x_value_segment_code OUT NOCOPY VARCHAR2
2920 )
2921 RETURN VARCHAR2
2922 IS
2923 l_component_type VARCHAR2(80) ;
2924 l_component_code VARCHAR2(30) ;
2925 l_component_type_code VARCHAR2(1) ;
2926 l_component_appl_id INTEGER ;
2927 l_amb_context_code VARCHAR2(30) ;
2928 l_log_module VARCHAR2(240) ;
2929 l_output_value VARCHAR2(30) ;
2930 BEGIN
2931 IF g_log_enabled THEN
2932 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_22';
2933 END IF;
2934 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2935
2936 trace
2937 (p_msg => 'BEGIN of AcctDerRule_22'
2938 ,p_level => C_LEVEL_PROCEDURE
2939 ,p_module => l_log_module);
2940
2941 END IF;
2942
2943 l_component_type := 'AMB_ADR';
2944 l_component_code := 'FV_AR_46X002_MISC_RCT_CR';
2945 l_component_type_code := 'S';
2946 l_component_appl_id := 222;
2947 l_amb_context_code := 'DEFAULT';
2948 x_transaction_coa_id := null;
2949 x_accounting_coa_id := null;
2950 x_flexfield_segment_code := null;
2951 x_flex_value_set_id := 1009988 ;
2952
2953
2954 IF NVL(p_source_14,'
2955 ') = 'Unexpired' AND
2956 NVL(p_source_15,'
2957 ') = 'N' AND
2958 (NVL(p_source_17,'
2959 ') = 'A' OR
2960 NVL(p_source_17,'
2961 ') = 'B') AND
2962 (NVL(p_source_16,'
2963 ') = 'SINGLE' OR
2964 NVL(p_source_16,'
2965 ') = 'MULTIPLE' OR
2966 NVL(p_source_16,'
2967 ') = 'NO_YEAR')
2968 THEN
2969 --
2970 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2971
2972 trace
2973 (p_msg => 'END of AcctDerRule_22'
2974 ,p_level => C_LEVEL_PROCEDURE
2975 ,p_module => l_log_module);
2976
2977 END IF;
2978 x_value_combination_id := null ;
2979 x_value_segment_code := null ;
2980 x_value_type_code := 'C';
2981 l_output_value := '461002';
2982 RETURN l_output_value;
2983
2984 ELSIF NVL(p_source_14,'
2985 ') = 'Unexpired' AND
2986 NVL(p_source_15,'
2987 ') = 'N' AND
2988 NVL(p_source_17,'
2989 ') = 'C' AND
2990 (NVL(p_source_16,'
2991 ') = 'SINGLE' OR
2992 NVL(p_source_16,'
2993 ') = 'MULTIPLE' OR
2994 NVL(p_source_16,'
2995 ') = 'NO_YEAR')
2996 THEN
2997 --
2998 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2999
3000 trace
3001 (p_msg => 'END of AcctDerRule_22'
3002 ,p_level => C_LEVEL_PROCEDURE
3003 ,p_module => l_log_module);
3004
3005 END IF;
3006 x_value_combination_id := null ;
3007 x_value_segment_code := null ;
3008 x_value_type_code := 'C';
3009 l_output_value := '462002';
3010 RETURN l_output_value;
3011
3012 ELSE
3013 IF p_override_seg_flag = 'Y' THEN
3014 RETURN '#$NO_OVERRIDE#$';
3015 END IF;
3016 END IF;
3017
3018 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3019
3020 trace
3021 (p_msg => 'END of AcctDerRule_22(invalid)'
3022 ,p_level => C_LEVEL_PROCEDURE
3023 ,p_module => l_log_module);
3024
3025 END IF;
3026
3027 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3028 x_value_combination_id := null;
3029 x_value_segment_code := null;
3030 x_value_type_code := null;
3031 l_output_value := null;
3032 xla_accounting_err_pkg.build_message
3033 (p_appli_s_name => 'XLA'
3034 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3035 ,p_token_1 => 'COMPONENT_NAME'
3036 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3037 l_component_type
3041 , l_amb_context_code
3038 , l_component_code
3039 , l_component_type_code
3040 , l_component_appl_id
3042 )
3043 ,p_token_2 => 'OWNER'
3044 ,p_value_2 => xla_lookups_pkg.get_meaning(
3045 'XLA_OWNER_TYPE'
3046 ,l_component_type_code
3047 )
3048 ,p_token_3 => 'PAD_NAME'
3049 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3050 ,p_token_4 => 'PAD_OWNER'
3051 ,p_value_4 => xla_lookups_pkg.get_meaning(
3052 'XLA_OWNER_TYPE'
3053 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3054 )
3055 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3056 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3057 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3058 ,p_ae_header_id => NULL
3059 );
3060 RETURN l_output_value;
3061 EXCEPTION
3062 WHEN xla_exceptions_pkg.application_exception THEN
3063 RAISE;
3064 WHEN OTHERS THEN
3065 xla_exceptions_pkg.raise_message
3066 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_22');
3067 END AcctDerRule_22;
3068 --
3069
3070 ---------------------------------------
3071 --
3072 -- PRIVATE FUNCTION
3073 -- AcctDerRule_23
3074 --
3075 ---------------------------------------
3076 FUNCTION AcctDerRule_23 (
3077 p_application_id IN NUMBER
3078 , p_ae_header_id IN NUMBER
3079 , p_side IN VARCHAR2
3080 , p_override_seg_flag IN VARCHAR2
3081 --Federal Fund Expired Status
3082 , p_source_14 IN VARCHAR2
3083 --Federal Prior Year Flag
3084 , p_source_15 IN VARCHAR2
3085 --Federal Fund Time Frame
3086 , p_source_16 IN VARCHAR2
3087 --Federal Apportionment Category
3088 , p_source_17 IN VARCHAR2
3089 , x_transaction_coa_id OUT NOCOPY NUMBER
3090 , x_accounting_coa_id OUT NOCOPY NUMBER
3091 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
3092 , x_flex_value_set_id OUT NOCOPY NUMBER
3093 , x_value_type_code OUT NOCOPY VARCHAR2
3094 , x_value_combination_id OUT NOCOPY NUMBER
3095 , x_value_segment_code OUT NOCOPY VARCHAR2
3096 )
3097 RETURN VARCHAR2
3098 IS
3099 l_component_type VARCHAR2(80) ;
3100 l_component_code VARCHAR2(30) ;
3101 l_component_type_code VARCHAR2(1) ;
3102 l_component_appl_id INTEGER ;
3103 l_amb_context_code VARCHAR2(30) ;
3104 l_log_module VARCHAR2(240) ;
3105 l_output_value VARCHAR2(30) ;
3106 BEGIN
3107 IF g_log_enabled THEN
3108 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_23';
3109 END IF;
3110 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3111
3112 trace
3113 (p_msg => 'BEGIN of AcctDerRule_23'
3114 ,p_level => C_LEVEL_PROCEDURE
3115 ,p_module => l_log_module);
3116
3117 END IF;
3118
3119 l_component_type := 'AMB_ADR';
3120 l_component_code := 'FV_AR_46X002_RCT_CR';
3121 l_component_type_code := 'S';
3122 l_component_appl_id := 222;
3123 l_amb_context_code := 'DEFAULT';
3124 x_transaction_coa_id := null;
3125 x_accounting_coa_id := null;
3126 x_flexfield_segment_code := null;
3127 x_flex_value_set_id := 1009988 ;
3128
3129
3130 IF NVL(p_source_14,'
3131 ') = 'Unexpired' AND
3132 NVL(p_source_15,'
3133 ') = 'N' AND
3134 (NVL(p_source_17,'
3135 ') = 'A' OR
3136 NVL(p_source_17,'
3137 ') = 'B') AND
3138 (NVL(p_source_16,'
3139 ') = 'SINGLE' OR
3140 NVL(p_source_16,'
3141 ') = 'MULTIPLE' OR
3142 NVL(p_source_16,'
3143 ') = 'NO_YEAR')
3144 THEN
3145 --
3146 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3147
3148 trace
3149 (p_msg => 'END of AcctDerRule_23'
3150 ,p_level => C_LEVEL_PROCEDURE
3151 ,p_module => l_log_module);
3152
3153 END IF;
3154 x_value_combination_id := null ;
3155 x_value_segment_code := null ;
3156 x_value_type_code := 'C';
3157 l_output_value := '461002';
3158 RETURN l_output_value;
3159
3160 ELSIF NVL(p_source_14,'
3161 ') = 'Unexpired' AND
3162 NVL(p_source_15,'
3163 ') = 'N' AND
3164 NVL(p_source_17,'
3165 ') = 'C' AND
3166 (NVL(p_source_16,'
3167 ') = 'SINGLE' OR
3168 NVL(p_source_16,'
3169 ') = 'MULTIPLE' OR
3170 NVL(p_source_16,'
3171 ') = 'NO_YEAR')
3172 THEN
3173 --
3174 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3175
3176 trace
3180
3177 (p_msg => 'END of AcctDerRule_23'
3178 ,p_level => C_LEVEL_PROCEDURE
3179 ,p_module => l_log_module);
3181 END IF;
3182 x_value_combination_id := null ;
3183 x_value_segment_code := null ;
3184 x_value_type_code := 'C';
3185 l_output_value := '462002';
3186 RETURN l_output_value;
3187
3188 ELSE
3189 IF p_override_seg_flag = 'Y' THEN
3190 RETURN '#$NO_OVERRIDE#$';
3191 END IF;
3192 END IF;
3193
3194 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3195
3196 trace
3197 (p_msg => 'END of AcctDerRule_23(invalid)'
3198 ,p_level => C_LEVEL_PROCEDURE
3199 ,p_module => l_log_module);
3200
3201 END IF;
3202
3203 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3204 x_value_combination_id := null;
3205 x_value_segment_code := null;
3206 x_value_type_code := null;
3207 l_output_value := null;
3208 xla_accounting_err_pkg.build_message
3209 (p_appli_s_name => 'XLA'
3210 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3211 ,p_token_1 => 'COMPONENT_NAME'
3212 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3213 l_component_type
3214 , l_component_code
3215 , l_component_type_code
3216 , l_component_appl_id
3217 , l_amb_context_code
3218 )
3219 ,p_token_2 => 'OWNER'
3220 ,p_value_2 => xla_lookups_pkg.get_meaning(
3221 'XLA_OWNER_TYPE'
3222 ,l_component_type_code
3223 )
3224 ,p_token_3 => 'PAD_NAME'
3225 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3226 ,p_token_4 => 'PAD_OWNER'
3227 ,p_value_4 => xla_lookups_pkg.get_meaning(
3228 'XLA_OWNER_TYPE'
3229 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3230 )
3231 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3232 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3233 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3234 ,p_ae_header_id => NULL
3235 );
3236 RETURN l_output_value;
3237 EXCEPTION
3238 WHEN xla_exceptions_pkg.application_exception THEN
3239 RAISE;
3240 WHEN OTHERS THEN
3241 xla_exceptions_pkg.raise_message
3242 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_23');
3243 END AcctDerRule_23;
3244 --
3245
3246 ---------------------------------------
3247 --
3248 -- PRIVATE FUNCTION
3249 -- AcctDerRule_24
3250 --
3251 ---------------------------------------
3252 FUNCTION AcctDerRule_24 (
3253 p_application_id IN NUMBER
3254 , p_ae_header_id IN NUMBER
3255 , p_side IN VARCHAR2
3256 , p_override_seg_flag IN VARCHAR2
3257 --Federal Fund Expired Status
3258 , p_source_14 IN VARCHAR2
3259 --Federal Prior Year Flag
3260 , p_source_15 IN VARCHAR2
3261 --Federal Fund Time Frame
3262 , p_source_16 IN VARCHAR2
3263 --Federal Apportionment Category
3264 , p_source_17 IN VARCHAR2
3265 , x_transaction_coa_id OUT NOCOPY NUMBER
3266 , x_accounting_coa_id OUT NOCOPY NUMBER
3267 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
3268 , x_flex_value_set_id OUT NOCOPY NUMBER
3269 , x_value_type_code OUT NOCOPY VARCHAR2
3270 , x_value_combination_id OUT NOCOPY NUMBER
3271 , x_value_segment_code OUT NOCOPY VARCHAR2
3272 )
3273 RETURN VARCHAR2
3274 IS
3275 l_component_type VARCHAR2(80) ;
3276 l_component_code VARCHAR2(30) ;
3277 l_component_type_code VARCHAR2(1) ;
3278 l_component_appl_id INTEGER ;
3279 l_amb_context_code VARCHAR2(30) ;
3280 l_log_module VARCHAR2(240) ;
3281 l_output_value VARCHAR2(30) ;
3282 BEGIN
3283 IF g_log_enabled THEN
3284 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_24';
3285 END IF;
3286 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3287
3288 trace
3289 (p_msg => 'BEGIN of AcctDerRule_24'
3290 ,p_level => C_LEVEL_PROCEDURE
3291 ,p_module => l_log_module);
3292
3293 END IF;
3294
3295 l_component_type := 'AMB_ADR';
3296 l_component_code := 'FV_AR_490201_MISC_RCT_DR';
3297 l_component_type_code := 'S';
3298 l_component_appl_id := 222;
3299 l_amb_context_code := 'DEFAULT';
3300 x_transaction_coa_id := null;
3304
3301 x_accounting_coa_id := null;
3302 x_flexfield_segment_code := null;
3303 x_flex_value_set_id := 1009988 ;
3305
3306 IF NVL(p_source_14,'
3307 ') = 'Unexpired' AND
3308 NVL(p_source_15,'
3309 ') = 'N' AND
3310 (NVL(p_source_17,'
3311 ') = 'A' OR
3312 NVL(p_source_17,'
3313 ') = 'B' OR
3314 NVL(p_source_17,'
3315 ') = 'C') AND
3316 (NVL(p_source_16,'
3317 ') = 'SINGLE' OR
3318 NVL(p_source_16,'
3319 ') = 'MULTIPLE' OR
3320 NVL(p_source_16,'
3321 ') = 'NO_YEAR')
3322 THEN
3323 --
3324 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3325
3326 trace
3327 (p_msg => 'END of AcctDerRule_24'
3328 ,p_level => C_LEVEL_PROCEDURE
3329 ,p_module => l_log_module);
3330
3331 END IF;
3332 x_value_combination_id := null ;
3333 x_value_segment_code := null ;
3334 x_value_type_code := 'C';
3335 l_output_value := '490201';
3336 RETURN l_output_value;
3337
3338 ELSE
3339 IF p_override_seg_flag = 'Y' THEN
3340 RETURN '#$NO_OVERRIDE#$';
3341 END IF;
3342 END IF;
3343
3344 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3345
3346 trace
3347 (p_msg => 'END of AcctDerRule_24(invalid)'
3348 ,p_level => C_LEVEL_PROCEDURE
3349 ,p_module => l_log_module);
3350
3351 END IF;
3352
3353 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3354 x_value_combination_id := null;
3355 x_value_segment_code := null;
3356 x_value_type_code := null;
3357 l_output_value := null;
3358 xla_accounting_err_pkg.build_message
3359 (p_appli_s_name => 'XLA'
3360 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3361 ,p_token_1 => 'COMPONENT_NAME'
3362 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3363 l_component_type
3364 , l_component_code
3365 , l_component_type_code
3366 , l_component_appl_id
3367 , l_amb_context_code
3368 )
3369 ,p_token_2 => 'OWNER'
3370 ,p_value_2 => xla_lookups_pkg.get_meaning(
3371 'XLA_OWNER_TYPE'
3372 ,l_component_type_code
3373 )
3374 ,p_token_3 => 'PAD_NAME'
3375 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3376 ,p_token_4 => 'PAD_OWNER'
3377 ,p_value_4 => xla_lookups_pkg.get_meaning(
3378 'XLA_OWNER_TYPE'
3379 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3380 )
3381 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3382 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3383 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3384 ,p_ae_header_id => NULL
3385 );
3386 RETURN l_output_value;
3387 EXCEPTION
3388 WHEN xla_exceptions_pkg.application_exception THEN
3389 RAISE;
3390 WHEN OTHERS THEN
3391 xla_exceptions_pkg.raise_message
3392 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_24');
3393 END AcctDerRule_24;
3394 --
3395
3396 ---------------------------------------
3397 --
3398 -- PRIVATE FUNCTION
3399 -- AcctDerRule_25
3400 --
3401 ---------------------------------------
3402 FUNCTION AcctDerRule_25 (
3403 p_application_id IN NUMBER
3404 , p_ae_header_id IN NUMBER
3405 , p_side IN VARCHAR2
3406 , p_override_seg_flag IN VARCHAR2
3407 --Federal Fund Expired Status
3408 , p_source_14 IN VARCHAR2
3409 --Federal Prior Year Flag
3410 , p_source_15 IN VARCHAR2
3411 --Federal Fund Time Frame
3412 , p_source_16 IN VARCHAR2
3413 , x_transaction_coa_id OUT NOCOPY NUMBER
3414 , x_accounting_coa_id OUT NOCOPY NUMBER
3415 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
3416 , x_flex_value_set_id OUT NOCOPY NUMBER
3417 , x_value_type_code OUT NOCOPY VARCHAR2
3418 , x_value_combination_id OUT NOCOPY NUMBER
3419 , x_value_segment_code OUT NOCOPY VARCHAR2
3420 )
3421 RETURN VARCHAR2
3422 IS
3423 l_component_type VARCHAR2(80) ;
3424 l_component_code VARCHAR2(30) ;
3425 l_component_type_code VARCHAR2(1) ;
3426 l_component_appl_id INTEGER ;
3427 l_amb_context_code VARCHAR2(30) ;
3428 l_log_module VARCHAR2(240) ;
3429 l_output_value VARCHAR2(30) ;
3430 BEGIN
3431 IF g_log_enabled THEN
3435
3432 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_25';
3433 END IF;
3434 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3436 trace
3437 (p_msg => 'BEGIN of AcctDerRule_25'
3438 ,p_level => C_LEVEL_PROCEDURE
3439 ,p_module => l_log_module);
3440
3441 END IF;
3442
3443 l_component_type := 'AMB_ADR';
3444 l_component_code := 'FV_AR_497201_MISC_RCT_DR';
3445 l_component_type_code := 'S';
3446 l_component_appl_id := 222;
3447 l_amb_context_code := 'DEFAULT';
3448 x_transaction_coa_id := null;
3449 x_accounting_coa_id := null;
3450 x_flexfield_segment_code := null;
3451 x_flex_value_set_id := 1009988 ;
3452
3453
3454 IF ((NVL(p_source_14,'
3455 ') = 'Expired' AND
3456 NVL(p_source_15,'
3457 ') = 'Y' AND
3458 (NVL(p_source_16,'
3459 ') = 'SINGLE' OR
3460 NVL(p_source_16,'
3461 ') = 'MULTIPLE' OR
3462 NVL(p_source_16,'
3463 ') = 'NO_YEAR')
3464 ) OR (NVL(p_source_14,'
3465 ') = 'Unexpired' AND
3466 NVL(p_source_15,'
3467 ') = 'Y' AND
3468 (NVL(p_source_16,'
3469 ') = 'MULTIPLE' OR
3470 NVL(p_source_16,'
3471 ') = 'NO_YEAR')
3472 )) THEN
3473 --
3474 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3475
3476 trace
3477 (p_msg => 'END of AcctDerRule_25'
3478 ,p_level => C_LEVEL_PROCEDURE
3479 ,p_module => l_log_module);
3480
3481 END IF;
3482 x_value_combination_id := null ;
3483 x_value_segment_code := null ;
3484 x_value_type_code := 'C';
3485 l_output_value := '497201';
3486 RETURN l_output_value;
3487
3488 ELSE
3489 IF p_override_seg_flag = 'Y' THEN
3490 RETURN '#$NO_OVERRIDE#$';
3491 END IF;
3492 END IF;
3493
3494 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3495
3496 trace
3497 (p_msg => 'END of AcctDerRule_25(invalid)'
3498 ,p_level => C_LEVEL_PROCEDURE
3499 ,p_module => l_log_module);
3500
3501 END IF;
3502
3503 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3504 x_value_combination_id := null;
3505 x_value_segment_code := null;
3506 x_value_type_code := null;
3507 l_output_value := null;
3508 xla_accounting_err_pkg.build_message
3509 (p_appli_s_name => 'XLA'
3510 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3511 ,p_token_1 => 'COMPONENT_NAME'
3512 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3513 l_component_type
3514 , l_component_code
3515 , l_component_type_code
3516 , l_component_appl_id
3517 , l_amb_context_code
3518 )
3519 ,p_token_2 => 'OWNER'
3520 ,p_value_2 => xla_lookups_pkg.get_meaning(
3521 'XLA_OWNER_TYPE'
3522 ,l_component_type_code
3523 )
3524 ,p_token_3 => 'PAD_NAME'
3525 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3526 ,p_token_4 => 'PAD_OWNER'
3527 ,p_value_4 => xla_lookups_pkg.get_meaning(
3528 'XLA_OWNER_TYPE'
3529 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3530 )
3531 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3532 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3533 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3534 ,p_ae_header_id => NULL
3535 );
3536 RETURN l_output_value;
3537 EXCEPTION
3538 WHEN xla_exceptions_pkg.application_exception THEN
3539 RAISE;
3540 WHEN OTHERS THEN
3541 xla_exceptions_pkg.raise_message
3542 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_25');
3543 END AcctDerRule_25;
3544 --
3545
3546 ---------------------------------------
3547 --
3548 -- PRIVATE FUNCTION
3549 -- AcctDerRule_26
3550 --
3551 ---------------------------------------
3552 FUNCTION AcctDerRule_26 (
3553 p_application_id IN NUMBER
3554 , p_ae_header_id IN NUMBER
3555 , p_side IN VARCHAR2
3556 , p_override_seg_flag IN VARCHAR2
3557 --Federal Account Rule
3558 , p_source_13 IN VARCHAR2
3559 --Federal Fund Expired Status
3560 , p_source_14 IN VARCHAR2
3561 --Federal Prior Year Flag
3562 , p_source_15 IN VARCHAR2
3563 --Federal Fund Time Frame
3567 , x_transaction_coa_id OUT NOCOPY NUMBER
3564 , p_source_16 IN VARCHAR2
3565 --Federal Apportionment Category
3566 , p_source_17 IN VARCHAR2
3568 , x_accounting_coa_id OUT NOCOPY NUMBER
3569 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
3570 , x_flex_value_set_id OUT NOCOPY NUMBER
3571 , x_value_type_code OUT NOCOPY VARCHAR2
3572 , x_value_combination_id OUT NOCOPY NUMBER
3573 , x_value_segment_code OUT NOCOPY VARCHAR2
3574 )
3575 RETURN VARCHAR2
3576 IS
3577 l_component_type VARCHAR2(80) ;
3578 l_component_code VARCHAR2(30) ;
3579 l_component_type_code VARCHAR2(1) ;
3580 l_component_appl_id INTEGER ;
3581 l_amb_context_code VARCHAR2(30) ;
3582 l_log_module VARCHAR2(240) ;
3583 l_output_value VARCHAR2(30) ;
3584 BEGIN
3585 IF g_log_enabled THEN
3586 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_26';
3587 END IF;
3588 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3589
3590 trace
3591 (p_msg => 'BEGIN of AcctDerRule_26'
3592 ,p_level => C_LEVEL_PROCEDURE
3593 ,p_module => l_log_module);
3594
3595 END IF;
3596
3597 l_component_type := 'AMB_ADR';
3598 l_component_code := 'FV_AR_4X0201_RCT_DR';
3599 l_component_type_code := 'S';
3600 l_component_appl_id := 222;
3601 l_amb_context_code := 'DEFAULT';
3602 x_transaction_coa_id := null;
3603 x_accounting_coa_id := null;
3604 x_flexfield_segment_code := null;
3605 x_flex_value_set_id := 1009988 ;
3606
3607
3608 IF NVL(p_source_14,'
3609 ') = 'Unexpired' AND
3610 NVL(p_source_15,'
3611 ') = 'N' AND
3612 (NVL(p_source_17,'
3613 ') = 'A' OR
3614 NVL(p_source_17,'
3615 ') = 'B' OR
3616 NVL(p_source_17,'
3617 ') = 'C') AND
3618 (NVL(p_source_16,'
3619 ') = 'SINGLE' OR
3620 NVL(p_source_16,'
3621 ') = 'MULTIPLE' OR
3622 NVL(p_source_16,'
3623 ') = 'NO_YEAR') AND
3624 NVL(p_source_13,'
3625 ') = 'Overpayment Refund'
3626 THEN
3627 --
3628 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3629
3630 trace
3631 (p_msg => 'END of AcctDerRule_26'
3632 ,p_level => C_LEVEL_PROCEDURE
3633 ,p_module => l_log_module);
3634
3635 END IF;
3636 x_value_combination_id := null ;
3637 x_value_segment_code := null ;
3638 x_value_type_code := 'C';
3639 l_output_value := '490201';
3640 RETURN l_output_value;
3641
3642 ELSIF NVL(p_source_14,'
3643 ') = 'Unexpired' AND
3644 NVL(p_source_15,'
3645 ') = 'N' AND
3646 (NVL(p_source_17,'
3647 ') = 'A' OR
3648 NVL(p_source_17,'
3649 ') = 'B' OR
3650 NVL(p_source_17,'
3651 ') = 'C') AND
3652 (NVL(p_source_16,'
3653 ') = 'SINGLE' OR
3654 NVL(p_source_16,'
3655 ') = 'MULTIPLE' OR
3656 NVL(p_source_16,'
3657 ') = 'NO_YEAR') AND
3658 NVL(p_source_13,'
3659 ') = 'Advance Refund'
3660 THEN
3661 --
3662 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3663
3664 trace
3665 (p_msg => 'END of AcctDerRule_26'
3666 ,p_level => C_LEVEL_PROCEDURE
3667 ,p_module => l_log_module);
3668
3669 END IF;
3670 x_value_combination_id := null ;
3671 x_value_segment_code := null ;
3672 x_value_type_code := 'C';
3673 l_output_value := '480201';
3674 RETURN l_output_value;
3675
3676 ELSE
3677 IF p_override_seg_flag = 'Y' THEN
3678 RETURN '#$NO_OVERRIDE#$';
3679 END IF;
3680 END IF;
3681
3682 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3683
3684 trace
3685 (p_msg => 'END of AcctDerRule_26(invalid)'
3686 ,p_level => C_LEVEL_PROCEDURE
3687 ,p_module => l_log_module);
3688
3689 END IF;
3690
3691 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3692 x_value_combination_id := null;
3693 x_value_segment_code := null;
3694 x_value_type_code := null;
3695 l_output_value := null;
3696 xla_accounting_err_pkg.build_message
3697 (p_appli_s_name => 'XLA'
3698 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3699 ,p_token_1 => 'COMPONENT_NAME'
3700 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3701 l_component_type
3702 , l_component_code
3703 , l_component_type_code
3704 , l_component_appl_id
3705 , l_amb_context_code
3706 )
3707 ,p_token_2 => 'OWNER'
3708 ,p_value_2 => xla_lookups_pkg.get_meaning(
3709 'XLA_OWNER_TYPE'
3710 ,l_component_type_code
3714 ,p_token_4 => 'PAD_OWNER'
3711 )
3712 ,p_token_3 => 'PAD_NAME'
3713 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3715 ,p_value_4 => xla_lookups_pkg.get_meaning(
3716 'XLA_OWNER_TYPE'
3717 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3718 )
3719 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3720 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3721 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3722 ,p_ae_header_id => NULL
3723 );
3724 RETURN l_output_value;
3725 EXCEPTION
3726 WHEN xla_exceptions_pkg.application_exception THEN
3727 RAISE;
3728 WHEN OTHERS THEN
3729 xla_exceptions_pkg.raise_message
3730 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_26');
3731 END AcctDerRule_26;
3732 --
3733
3734 ---------------------------------------
3735 --
3736 -- PRIVATE FUNCTION
3737 -- AcctDerRule_27
3738 --
3739 ---------------------------------------
3740 FUNCTION AcctDerRule_27 (
3741 p_application_id IN NUMBER
3742 , p_ae_header_id IN NUMBER
3743 , p_side IN VARCHAR2
3744 , p_override_seg_flag IN VARCHAR2
3745 --Federal Account Rule
3746 , p_source_13 IN VARCHAR2
3747 --Federal Fund Expired Status
3748 , p_source_14 IN VARCHAR2
3749 --Federal Prior Year Flag
3750 , p_source_15 IN VARCHAR2
3751 --Federal Fund Time Frame
3752 , p_source_16 IN VARCHAR2
3753 , x_transaction_coa_id OUT NOCOPY NUMBER
3754 , x_accounting_coa_id OUT NOCOPY NUMBER
3755 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
3756 , x_flex_value_set_id OUT NOCOPY NUMBER
3757 , x_value_type_code OUT NOCOPY VARCHAR2
3758 , x_value_combination_id OUT NOCOPY NUMBER
3759 , x_value_segment_code OUT NOCOPY VARCHAR2
3760 )
3761 RETURN VARCHAR2
3762 IS
3763 l_component_type VARCHAR2(80) ;
3764 l_component_code VARCHAR2(30) ;
3765 l_component_type_code VARCHAR2(1) ;
3766 l_component_appl_id INTEGER ;
3767 l_amb_context_code VARCHAR2(30) ;
3768 l_log_module VARCHAR2(240) ;
3769 l_output_value VARCHAR2(30) ;
3770 BEGIN
3771 IF g_log_enabled THEN
3772 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_27';
3773 END IF;
3774 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3775
3776 trace
3777 (p_msg => 'BEGIN of AcctDerRule_27'
3778 ,p_level => C_LEVEL_PROCEDURE
3779 ,p_module => l_log_module);
3780
3781 END IF;
3782
3783 l_component_type := 'AMB_ADR';
3784 l_component_code := 'FV_AR_4X7201_RCT_DR';
3785 l_component_type_code := 'S';
3786 l_component_appl_id := 222;
3787 l_amb_context_code := 'DEFAULT';
3788 x_transaction_coa_id := null;
3789 x_accounting_coa_id := null;
3790 x_flexfield_segment_code := null;
3791 x_flex_value_set_id := 1009988 ;
3792
3793
3794 IF ((NVL(p_source_14,'
3795 ') = 'Expired' AND
3796 NVL(p_source_15,'
3797 ') = 'Y' AND
3798 (NVL(p_source_16,'
3799 ') = 'SINGLE' OR
3800 NVL(p_source_16,'
3801 ') = 'MULTIPLE' OR
3802 NVL(p_source_16,'
3803 ') = 'NO_YEAR')
3804 ) OR (NVL(p_source_14,'
3805 ') = 'Unexpired' AND
3806 NVL(p_source_15,'
3807 ') = 'Y' AND
3808 (NVL(p_source_16,'
3809 ') = 'MULTIPLE' OR
3810 NVL(p_source_16,'
3811 ') = 'NO_YEAR')
3812 )) AND NVL(p_source_13,'
3813 ') = 'Overpayment Refund'
3814 THEN
3815 --
3816 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3817
3818 trace
3819 (p_msg => 'END of AcctDerRule_27'
3820 ,p_level => C_LEVEL_PROCEDURE
3821 ,p_module => l_log_module);
3822
3823 END IF;
3824 x_value_combination_id := null ;
3825 x_value_segment_code := null ;
3826 x_value_type_code := 'C';
3827 l_output_value := '497201';
3828 RETURN l_output_value;
3829
3830 ELSIF ((NVL(p_source_14,'
3831 ') = 'Expired' AND
3832 NVL(p_source_15,'
3833 ') = 'Y' AND
3834 (NVL(p_source_16,'
3835 ') = 'SINGLE' OR
3836 NVL(p_source_16,'
3837 ') = 'MUTIPLE' OR
3838 NVL(p_source_16,'
3839 ') = 'NO_YEAR')
3840 ) OR (NVL(p_source_14,'
3841 ') = 'Unexpired' AND
3842 NVL(p_source_15,'
3843 ') = 'Y' AND
3844 (NVL(p_source_16,'
3845 ') = 'MUTIPLE' OR
3846 NVL(p_source_16,'
3847 ') = 'NO_YEAR')
3848 )) AND NVL(p_source_13,'
3849 ') = 'Advance Refund'
3850 THEN
3851 --
3852 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3853
3854 trace
3855 (p_msg => 'END of AcctDerRule_27'
3856 ,p_level => C_LEVEL_PROCEDURE
3857 ,p_module => l_log_module);
3858
3859 END IF;
3863 l_output_value := '487201';
3860 x_value_combination_id := null ;
3861 x_value_segment_code := null ;
3862 x_value_type_code := 'C';
3864 RETURN l_output_value;
3865
3866 ELSE
3867 IF p_override_seg_flag = 'Y' THEN
3868 RETURN '#$NO_OVERRIDE#$';
3869 END IF;
3870 END IF;
3871
3872 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3873
3874 trace
3875 (p_msg => 'END of AcctDerRule_27(invalid)'
3876 ,p_level => C_LEVEL_PROCEDURE
3877 ,p_module => l_log_module);
3878
3879 END IF;
3880
3881 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3882 x_value_combination_id := null;
3883 x_value_segment_code := null;
3884 x_value_type_code := null;
3885 l_output_value := null;
3886 xla_accounting_err_pkg.build_message
3887 (p_appli_s_name => 'XLA'
3888 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3889 ,p_token_1 => 'COMPONENT_NAME'
3890 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3891 l_component_type
3892 , l_component_code
3893 , l_component_type_code
3894 , l_component_appl_id
3895 , l_amb_context_code
3896 )
3897 ,p_token_2 => 'OWNER'
3898 ,p_value_2 => xla_lookups_pkg.get_meaning(
3899 'XLA_OWNER_TYPE'
3900 ,l_component_type_code
3901 )
3902 ,p_token_3 => 'PAD_NAME'
3903 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3904 ,p_token_4 => 'PAD_OWNER'
3905 ,p_value_4 => xla_lookups_pkg.get_meaning(
3906 'XLA_OWNER_TYPE'
3907 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3908 )
3909 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3910 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3911 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3912 ,p_ae_header_id => NULL
3913 );
3914 RETURN l_output_value;
3915 EXCEPTION
3916 WHEN xla_exceptions_pkg.application_exception THEN
3917 RAISE;
3918 WHEN OTHERS THEN
3919 xla_exceptions_pkg.raise_message
3920 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_27');
3921 END AcctDerRule_27;
3922 --
3923
3924 ---------------------------------------
3925 --
3926 -- PRIVATE FUNCTION
3927 -- AcctDerRule_28
3928 --
3929 ---------------------------------------
3930 FUNCTION AcctDerRule_28 (
3931 p_application_id IN NUMBER
3932 , p_ae_header_id IN NUMBER
3933 , p_side IN VARCHAR2
3934 --Remittance Bank Account Cash Account
3935 , p_source_5 IN NUMBER
3936 , x_transaction_coa_id OUT NOCOPY NUMBER
3937 , x_accounting_coa_id OUT NOCOPY NUMBER
3938 , x_value_type_code OUT NOCOPY VARCHAR2
3939 )
3940 RETURN NUMBER
3941 IS
3942 l_component_type VARCHAR2(80) ;
3943 l_component_code VARCHAR2(30) ;
3944 l_component_type_code VARCHAR2(1) ;
3945 l_component_appl_id INTEGER ;
3946 l_amb_context_code VARCHAR2(30) ;
3947 l_log_module VARCHAR2(240) ;
3948 l_output_value NUMBER ;
3949 BEGIN
3950 IF g_log_enabled THEN
3951 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_28';
3952 END IF;
3953 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3954 trace
3955 (p_msg => 'BEGIN of AcctDerRule_28'
3956 ,p_level => C_LEVEL_PROCEDURE
3957 ,p_module => l_log_module);
3958 END IF;
3959 --
3960 l_component_type := 'AMB_ADR';
3961 l_component_code := 'MFAR_RCT_DEF_CASH_CCID';
3962 l_component_type_code := 'S';
3963 l_component_appl_id := 222;
3964 l_amb_context_code := 'DEFAULT';
3965 x_transaction_coa_id := null;
3966 x_accounting_coa_id := null;
3967 --
3968
3969 --
3970 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3971 trace
3972 (p_msg => 'END of AcctDerRule_28'
3973 ,p_level => C_LEVEL_PROCEDURE
3974 ,p_module => l_log_module);
3975 END IF;
3976 x_value_type_code := 'S';
3977 l_output_value := TO_NUMBER(TO_NUMBER(p_source_5));
3978 RETURN l_output_value;
3979
3980 --
3981 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3982 trace
3983 (p_msg => 'END of AcctDerRule_28(invalid)'
3984 ,p_level => C_LEVEL_PROCEDURE
3988 x_value_type_code := null;
3985 ,p_module => l_log_module);
3986 END IF;
3987 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3989 l_output_value := null;
3990 xla_accounting_err_pkg.build_message
3991 (p_appli_s_name => 'XLA'
3992 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3993 ,p_token_1 => 'COMPONENT_NAME'
3994 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3995 l_component_type
3996 , l_component_code
3997 , l_component_type_code
3998 , l_component_appl_id
3999 , l_amb_context_code
4000 )
4001 ,p_token_2 => 'OWNER'
4002 ,p_value_2 => xla_lookups_pkg.get_meaning(
4003 'XLA_OWNER_TYPE'
4004 ,l_component_type_code
4005 )
4006 ,p_token_3 => 'PAD_NAME'
4007 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4008 ,p_token_4 => 'PAD_OWNER'
4009 ,p_value_4 => xla_lookups_pkg.get_meaning(
4010 'XLA_OWNER_TYPE'
4011 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
4012 )
4013 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4014 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4015 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
4016 ,p_ae_header_id => NULL
4017 );
4018 RETURN l_output_value;
4019 EXCEPTION
4020 WHEN xla_exceptions_pkg.application_exception THEN
4021 RAISE;
4022 WHEN OTHERS THEN
4023 xla_exceptions_pkg.raise_message
4024 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_28');
4025 END AcctDerRule_28;
4026 --
4027
4028 ---------------------------------------
4029 --
4030 -- PRIVATE FUNCTION
4031 -- AcctDerRule_29
4032 --
4033 ---------------------------------------
4034 FUNCTION AcctDerRule_29 (
4035 p_application_id IN NUMBER
4036 , p_ae_header_id IN NUMBER
4037 , p_side IN VARCHAR2
4038 --Remittance Bank Account Confirmation Account
4039 , p_source_3 IN NUMBER
4040 , x_transaction_coa_id OUT NOCOPY NUMBER
4041 , x_accounting_coa_id OUT NOCOPY NUMBER
4042 , x_value_type_code OUT NOCOPY VARCHAR2
4043 )
4044 RETURN NUMBER
4045 IS
4046 l_component_type VARCHAR2(80) ;
4047 l_component_code VARCHAR2(30) ;
4048 l_component_type_code VARCHAR2(1) ;
4049 l_component_appl_id INTEGER ;
4050 l_amb_context_code VARCHAR2(30) ;
4051 l_log_module VARCHAR2(240) ;
4052 l_output_value NUMBER ;
4053 BEGIN
4054 IF g_log_enabled THEN
4055 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_29';
4056 END IF;
4057 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4058 trace
4059 (p_msg => 'BEGIN of AcctDerRule_29'
4060 ,p_level => C_LEVEL_PROCEDURE
4061 ,p_module => l_log_module);
4062 END IF;
4063 --
4064 l_component_type := 'AMB_ADR';
4065 l_component_code := 'MFAR_RCT_DEF_CONFIRMATION_CCID';
4066 l_component_type_code := 'S';
4067 l_component_appl_id := 222;
4068 l_amb_context_code := 'DEFAULT';
4069 x_transaction_coa_id := null;
4070 x_accounting_coa_id := null;
4071 --
4072
4073 --
4074 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4075 trace
4076 (p_msg => 'END of AcctDerRule_29'
4077 ,p_level => C_LEVEL_PROCEDURE
4078 ,p_module => l_log_module);
4079 END IF;
4080 x_value_type_code := 'S';
4081 l_output_value := TO_NUMBER(TO_NUMBER(p_source_3));
4082 RETURN l_output_value;
4083
4084 --
4085 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4086 trace
4087 (p_msg => 'END of AcctDerRule_29(invalid)'
4088 ,p_level => C_LEVEL_PROCEDURE
4089 ,p_module => l_log_module);
4090 END IF;
4091 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4092 x_value_type_code := null;
4093 l_output_value := null;
4094 xla_accounting_err_pkg.build_message
4095 (p_appli_s_name => 'XLA'
4096 ,p_msg_name => 'XLA_AP_INVALID_ADR'
4097 ,p_token_1 => 'COMPONENT_NAME'
4098 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
4099 l_component_type
4100 , l_component_code
4104 )
4101 , l_component_type_code
4102 , l_component_appl_id
4103 , l_amb_context_code
4105 ,p_token_2 => 'OWNER'
4106 ,p_value_2 => xla_lookups_pkg.get_meaning(
4107 'XLA_OWNER_TYPE'
4108 ,l_component_type_code
4109 )
4110 ,p_token_3 => 'PAD_NAME'
4111 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4112 ,p_token_4 => 'PAD_OWNER'
4113 ,p_value_4 => xla_lookups_pkg.get_meaning(
4114 'XLA_OWNER_TYPE'
4115 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
4116 )
4117 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4118 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4119 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
4120 ,p_ae_header_id => NULL
4121 );
4122 RETURN l_output_value;
4123 EXCEPTION
4124 WHEN xla_exceptions_pkg.application_exception THEN
4125 RAISE;
4126 WHEN OTHERS THEN
4127 xla_exceptions_pkg.raise_message
4128 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_29');
4129 END AcctDerRule_29;
4130 --
4131
4132 ---------------------------------------
4133 --
4134 -- PRIVATE FUNCTION
4135 -- AcctDerRule_30
4136 --
4137 ---------------------------------------
4138 FUNCTION AcctDerRule_30 (
4139 p_application_id IN NUMBER
4140 , p_ae_header_id IN NUMBER
4141 , p_side IN VARCHAR2
4142 --Remittance Bank Account Remittance Account
4143 , p_source_6 IN NUMBER
4144 , x_transaction_coa_id OUT NOCOPY NUMBER
4145 , x_accounting_coa_id OUT NOCOPY NUMBER
4146 , x_value_type_code OUT NOCOPY VARCHAR2
4147 )
4148 RETURN NUMBER
4149 IS
4150 l_component_type VARCHAR2(80) ;
4151 l_component_code VARCHAR2(30) ;
4152 l_component_type_code VARCHAR2(1) ;
4153 l_component_appl_id INTEGER ;
4154 l_amb_context_code VARCHAR2(30) ;
4155 l_log_module VARCHAR2(240) ;
4156 l_output_value NUMBER ;
4157 BEGIN
4158 IF g_log_enabled THEN
4159 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_30';
4160 END IF;
4161 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4162 trace
4163 (p_msg => 'BEGIN of AcctDerRule_30'
4164 ,p_level => C_LEVEL_PROCEDURE
4165 ,p_module => l_log_module);
4166 END IF;
4167 --
4168 l_component_type := 'AMB_ADR';
4169 l_component_code := 'MFAR_RCT_DEF_REMITTANCE_CCID';
4170 l_component_type_code := 'S';
4171 l_component_appl_id := 222;
4172 l_amb_context_code := 'DEFAULT';
4173 x_transaction_coa_id := null;
4174 x_accounting_coa_id := null;
4175 --
4176
4177 --
4178 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4179 trace
4180 (p_msg => 'END of AcctDerRule_30'
4181 ,p_level => C_LEVEL_PROCEDURE
4182 ,p_module => l_log_module);
4183 END IF;
4184 x_value_type_code := 'S';
4185 l_output_value := TO_NUMBER(TO_NUMBER(p_source_6));
4186 RETURN l_output_value;
4187
4188 --
4189 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4190 trace
4191 (p_msg => 'END of AcctDerRule_30(invalid)'
4192 ,p_level => C_LEVEL_PROCEDURE
4193 ,p_module => l_log_module);
4194 END IF;
4195 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4196 x_value_type_code := null;
4197 l_output_value := null;
4198 xla_accounting_err_pkg.build_message
4199 (p_appli_s_name => 'XLA'
4200 ,p_msg_name => 'XLA_AP_INVALID_ADR'
4201 ,p_token_1 => 'COMPONENT_NAME'
4202 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
4203 l_component_type
4204 , l_component_code
4205 , l_component_type_code
4206 , l_component_appl_id
4207 , l_amb_context_code
4208 )
4209 ,p_token_2 => 'OWNER'
4210 ,p_value_2 => xla_lookups_pkg.get_meaning(
4211 'XLA_OWNER_TYPE'
4212 ,l_component_type_code
4213 )
4214 ,p_token_3 => 'PAD_NAME'
4218 'XLA_OWNER_TYPE'
4215 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4216 ,p_token_4 => 'PAD_OWNER'
4217 ,p_value_4 => xla_lookups_pkg.get_meaning(
4219 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
4220 )
4221 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4222 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4223 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
4224 ,p_ae_header_id => NULL
4225 );
4226 RETURN l_output_value;
4227 EXCEPTION
4228 WHEN xla_exceptions_pkg.application_exception THEN
4229 RAISE;
4230 WHEN OTHERS THEN
4231 xla_exceptions_pkg.raise_message
4232 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_30');
4233 END AcctDerRule_30;
4234 --
4235
4236 ---------------------------------------
4237 --
4238 -- PRIVATE FUNCTION
4239 -- AcctDerRule_31
4240 --
4241 ---------------------------------------
4242 FUNCTION AcctDerRule_31 (
4243 p_application_id IN NUMBER
4244 , p_ae_header_id IN NUMBER
4245 , p_side IN VARCHAR2
4246 --Remittance Bank Account Unapplied Account
4247 , p_source_18 IN NUMBER
4248 , x_transaction_coa_id OUT NOCOPY NUMBER
4249 , x_accounting_coa_id OUT NOCOPY NUMBER
4250 , x_value_type_code OUT NOCOPY VARCHAR2
4251 )
4252 RETURN NUMBER
4253 IS
4254 l_component_type VARCHAR2(80) ;
4255 l_component_code VARCHAR2(30) ;
4256 l_component_type_code VARCHAR2(1) ;
4257 l_component_appl_id INTEGER ;
4258 l_amb_context_code VARCHAR2(30) ;
4259 l_log_module VARCHAR2(240) ;
4260 l_output_value NUMBER ;
4261 BEGIN
4262 IF g_log_enabled THEN
4263 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_31';
4264 END IF;
4265 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4266 trace
4267 (p_msg => 'BEGIN of AcctDerRule_31'
4268 ,p_level => C_LEVEL_PROCEDURE
4269 ,p_module => l_log_module);
4270 END IF;
4271 --
4272 l_component_type := 'AMB_ADR';
4273 l_component_code := 'RMT_BNK_UNAPP_CCID';
4274 l_component_type_code := 'S';
4275 l_component_appl_id := 222;
4276 l_amb_context_code := 'DEFAULT';
4277 x_transaction_coa_id := null;
4278 x_accounting_coa_id := null;
4279 --
4280
4281 --
4282 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4283 trace
4284 (p_msg => 'END of AcctDerRule_31'
4285 ,p_level => C_LEVEL_PROCEDURE
4286 ,p_module => l_log_module);
4287 END IF;
4288 x_value_type_code := 'S';
4289 l_output_value := TO_NUMBER(TO_NUMBER(p_source_18));
4290 RETURN l_output_value;
4291
4292 --
4293 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4294 trace
4295 (p_msg => 'END of AcctDerRule_31(invalid)'
4296 ,p_level => C_LEVEL_PROCEDURE
4297 ,p_module => l_log_module);
4298 END IF;
4299 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4300 x_value_type_code := null;
4301 l_output_value := null;
4302 xla_accounting_err_pkg.build_message
4303 (p_appli_s_name => 'XLA'
4304 ,p_msg_name => 'XLA_AP_INVALID_ADR'
4305 ,p_token_1 => 'COMPONENT_NAME'
4306 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
4307 l_component_type
4308 , l_component_code
4309 , l_component_type_code
4310 , l_component_appl_id
4311 , l_amb_context_code
4312 )
4313 ,p_token_2 => 'OWNER'
4314 ,p_value_2 => xla_lookups_pkg.get_meaning(
4315 'XLA_OWNER_TYPE'
4316 ,l_component_type_code
4317 )
4318 ,p_token_3 => 'PAD_NAME'
4319 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4320 ,p_token_4 => 'PAD_OWNER'
4321 ,p_value_4 => xla_lookups_pkg.get_meaning(
4322 'XLA_OWNER_TYPE'
4323 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
4324 )
4325 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4326 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4327 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
4328 ,p_ae_header_id => NULL
4329 );
4333 RAISE;
4330 RETURN l_output_value;
4331 EXCEPTION
4332 WHEN xla_exceptions_pkg.application_exception THEN
4334 WHEN OTHERS THEN
4335 xla_exceptions_pkg.raise_message
4336 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_31');
4337 END AcctDerRule_31;
4338 --
4339
4340 ---------------------------------------
4341 --
4342 -- PRIVATE FUNCTION
4343 -- AcctDerRule_32
4344 --
4345 ---------------------------------------
4346 FUNCTION AcctDerRule_32 (
4347 p_application_id IN NUMBER
4348 , p_ae_header_id IN NUMBER
4349 , p_side IN VARCHAR2
4350 --System Gain Account
4351 , p_source_19 IN NUMBER
4352 , x_transaction_coa_id OUT NOCOPY NUMBER
4353 , x_accounting_coa_id OUT NOCOPY NUMBER
4354 , x_value_type_code OUT NOCOPY VARCHAR2
4355 )
4356 RETURN NUMBER
4357 IS
4358 l_component_type VARCHAR2(80) ;
4359 l_component_code VARCHAR2(30) ;
4360 l_component_type_code VARCHAR2(1) ;
4361 l_component_appl_id INTEGER ;
4362 l_amb_context_code VARCHAR2(30) ;
4363 l_log_module VARCHAR2(240) ;
4364 l_output_value NUMBER ;
4365 BEGIN
4366 IF g_log_enabled THEN
4367 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_32';
4368 END IF;
4369 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4370 trace
4371 (p_msg => 'BEGIN of AcctDerRule_32'
4372 ,p_level => C_LEVEL_PROCEDURE
4373 ,p_module => l_log_module);
4374 END IF;
4375 --
4376 l_component_type := 'AMB_ADR';
4377 l_component_code := 'SYS_GAIN_CCID';
4378 l_component_type_code := 'S';
4379 l_component_appl_id := 222;
4380 l_amb_context_code := 'DEFAULT';
4381 x_transaction_coa_id := null;
4382 x_accounting_coa_id := null;
4383 --
4384
4385 --
4386 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4387 trace
4388 (p_msg => 'END of AcctDerRule_32'
4389 ,p_level => C_LEVEL_PROCEDURE
4390 ,p_module => l_log_module);
4391 END IF;
4392 x_value_type_code := 'S';
4393 l_output_value := TO_NUMBER(TO_NUMBER(p_source_19));
4394 RETURN l_output_value;
4395
4396 --
4397 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4398 trace
4399 (p_msg => 'END of AcctDerRule_32(invalid)'
4400 ,p_level => C_LEVEL_PROCEDURE
4401 ,p_module => l_log_module);
4402 END IF;
4403 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4404 x_value_type_code := null;
4405 l_output_value := null;
4406 xla_accounting_err_pkg.build_message
4407 (p_appli_s_name => 'XLA'
4408 ,p_msg_name => 'XLA_AP_INVALID_ADR'
4409 ,p_token_1 => 'COMPONENT_NAME'
4410 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
4411 l_component_type
4412 , l_component_code
4413 , l_component_type_code
4414 , l_component_appl_id
4415 , l_amb_context_code
4416 )
4417 ,p_token_2 => 'OWNER'
4418 ,p_value_2 => xla_lookups_pkg.get_meaning(
4419 'XLA_OWNER_TYPE'
4420 ,l_component_type_code
4421 )
4422 ,p_token_3 => 'PAD_NAME'
4423 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4424 ,p_token_4 => 'PAD_OWNER'
4425 ,p_value_4 => xla_lookups_pkg.get_meaning(
4426 'XLA_OWNER_TYPE'
4427 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
4428 )
4429 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4430 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4431 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
4432 ,p_ae_header_id => NULL
4433 );
4434 RETURN l_output_value;
4435 EXCEPTION
4436 WHEN xla_exceptions_pkg.application_exception THEN
4437 RAISE;
4438 WHEN OTHERS THEN
4439 xla_exceptions_pkg.raise_message
4440 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_32');
4441 END AcctDerRule_32;
4442 --
4443
4444 ---------------------------------------
4445 --
4446 -- PRIVATE FUNCTION
4447 -- AcctDerRule_33
4448 --
4449 ---------------------------------------
4450 FUNCTION AcctDerRule_33 (
4451 p_application_id IN NUMBER
4452 , p_ae_header_id IN NUMBER
4453 , p_side IN VARCHAR2
4454 --System Loss Account
4458 , x_value_type_code OUT NOCOPY VARCHAR2
4455 , p_source_20 IN NUMBER
4456 , x_transaction_coa_id OUT NOCOPY NUMBER
4457 , x_accounting_coa_id OUT NOCOPY NUMBER
4459 )
4460 RETURN NUMBER
4461 IS
4462 l_component_type VARCHAR2(80) ;
4463 l_component_code VARCHAR2(30) ;
4464 l_component_type_code VARCHAR2(1) ;
4465 l_component_appl_id INTEGER ;
4466 l_amb_context_code VARCHAR2(30) ;
4467 l_log_module VARCHAR2(240) ;
4468 l_output_value NUMBER ;
4469 BEGIN
4470 IF g_log_enabled THEN
4471 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_33';
4472 END IF;
4473 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4474 trace
4475 (p_msg => 'BEGIN of AcctDerRule_33'
4476 ,p_level => C_LEVEL_PROCEDURE
4477 ,p_module => l_log_module);
4478 END IF;
4479 --
4480 l_component_type := 'AMB_ADR';
4481 l_component_code := 'SYS_LOSS_CCID';
4482 l_component_type_code := 'S';
4483 l_component_appl_id := 222;
4484 l_amb_context_code := 'DEFAULT';
4485 x_transaction_coa_id := null;
4486 x_accounting_coa_id := null;
4487 --
4488
4489 --
4490 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4491 trace
4492 (p_msg => 'END of AcctDerRule_33'
4493 ,p_level => C_LEVEL_PROCEDURE
4494 ,p_module => l_log_module);
4495 END IF;
4496 x_value_type_code := 'S';
4497 l_output_value := TO_NUMBER(TO_NUMBER(p_source_20));
4498 RETURN l_output_value;
4499
4500 --
4501 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4502 trace
4503 (p_msg => 'END of AcctDerRule_33(invalid)'
4504 ,p_level => C_LEVEL_PROCEDURE
4505 ,p_module => l_log_module);
4506 END IF;
4507 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4508 x_value_type_code := null;
4509 l_output_value := null;
4510 xla_accounting_err_pkg.build_message
4511 (p_appli_s_name => 'XLA'
4512 ,p_msg_name => 'XLA_AP_INVALID_ADR'
4513 ,p_token_1 => 'COMPONENT_NAME'
4514 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
4515 l_component_type
4516 , l_component_code
4517 , l_component_type_code
4518 , l_component_appl_id
4519 , l_amb_context_code
4520 )
4521 ,p_token_2 => 'OWNER'
4522 ,p_value_2 => xla_lookups_pkg.get_meaning(
4523 'XLA_OWNER_TYPE'
4524 ,l_component_type_code
4525 )
4526 ,p_token_3 => 'PAD_NAME'
4527 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4528 ,p_token_4 => 'PAD_OWNER'
4529 ,p_value_4 => xla_lookups_pkg.get_meaning(
4530 'XLA_OWNER_TYPE'
4531 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
4532 )
4533 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4534 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4535 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
4536 ,p_ae_header_id => NULL
4537 );
4538 RETURN l_output_value;
4539 EXCEPTION
4540 WHEN xla_exceptions_pkg.application_exception THEN
4541 RAISE;
4542 WHEN OTHERS THEN
4543 xla_exceptions_pkg.raise_message
4544 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_33');
4545 END AcctDerRule_33;
4546 --
4547
4548 ---------------------------------------
4549 --
4550 -- PRIVATE FUNCTION
4551 -- AcctDerRule_34
4552 --
4553 ---------------------------------------
4554 FUNCTION AcctDerRule_34 (
4555 p_application_id IN NUMBER
4556 , p_ae_header_id IN NUMBER
4557 , p_side IN VARCHAR2
4558 --Transaction Distribution GL Account
4559 , p_source_21 IN NUMBER
4560 , x_transaction_coa_id OUT NOCOPY NUMBER
4561 , x_accounting_coa_id OUT NOCOPY NUMBER
4562 , x_value_type_code OUT NOCOPY VARCHAR2
4563 )
4564 RETURN NUMBER
4565 IS
4566 l_component_type VARCHAR2(80) ;
4567 l_component_code VARCHAR2(30) ;
4568 l_component_type_code VARCHAR2(1) ;
4569 l_component_appl_id INTEGER ;
4570 l_amb_context_code VARCHAR2(30) ;
4571 l_log_module VARCHAR2(240) ;
4572 l_output_value NUMBER ;
4573 BEGIN
4574 IF g_log_enabled THEN
4575 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_34';
4576 END IF;
4580 ,p_level => C_LEVEL_PROCEDURE
4577 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4578 trace
4579 (p_msg => 'BEGIN of AcctDerRule_34'
4581 ,p_module => l_log_module);
4582 END IF;
4583 --
4584 l_component_type := 'AMB_ADR';
4585 l_component_code := 'TRX_DIST_CCID';
4586 l_component_type_code := 'S';
4587 l_component_appl_id := 222;
4588 l_amb_context_code := 'DEFAULT';
4589 x_transaction_coa_id := null;
4590 x_accounting_coa_id := null;
4591 --
4592
4593 --
4594 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4595 trace
4596 (p_msg => 'END of AcctDerRule_34'
4597 ,p_level => C_LEVEL_PROCEDURE
4598 ,p_module => l_log_module);
4599 END IF;
4600 x_value_type_code := 'S';
4601 l_output_value := TO_NUMBER(TO_NUMBER(p_source_21));
4602 RETURN l_output_value;
4603
4604 --
4605 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4606 trace
4607 (p_msg => 'END of AcctDerRule_34(invalid)'
4608 ,p_level => C_LEVEL_PROCEDURE
4609 ,p_module => l_log_module);
4610 END IF;
4611 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4612 x_value_type_code := null;
4613 l_output_value := null;
4614 xla_accounting_err_pkg.build_message
4615 (p_appli_s_name => 'XLA'
4616 ,p_msg_name => 'XLA_AP_INVALID_ADR'
4617 ,p_token_1 => 'COMPONENT_NAME'
4618 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
4619 l_component_type
4620 , l_component_code
4621 , l_component_type_code
4622 , l_component_appl_id
4623 , l_amb_context_code
4624 )
4625 ,p_token_2 => 'OWNER'
4626 ,p_value_2 => xla_lookups_pkg.get_meaning(
4627 'XLA_OWNER_TYPE'
4628 ,l_component_type_code
4629 )
4630 ,p_token_3 => 'PAD_NAME'
4631 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4632 ,p_token_4 => 'PAD_OWNER'
4633 ,p_value_4 => xla_lookups_pkg.get_meaning(
4634 'XLA_OWNER_TYPE'
4635 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
4636 )
4637 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4638 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4639 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
4640 ,p_ae_header_id => NULL
4641 );
4642 RETURN l_output_value;
4643 EXCEPTION
4644 WHEN xla_exceptions_pkg.application_exception THEN
4645 RAISE;
4646 WHEN OTHERS THEN
4647 xla_exceptions_pkg.raise_message
4648 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctDerRule_34');
4649 END AcctDerRule_34;
4650 --
4651
4652 ---------------------------------------
4653 --
4654 -- PRIVATE FUNCTION
4655 -- AcctLineType_35
4656 --
4657 ---------------------------------------
4658 PROCEDURE AcctLineType_35 (
4659 p_application_id IN NUMBER
4660 ,p_event_id IN NUMBER
4661 ,p_calculate_acctd_flag IN VARCHAR2
4662 ,p_calculate_g_l_flag IN VARCHAR2
4663 ,p_actual_flag IN OUT VARCHAR2
4664 ,p_balance_type_code OUT VARCHAR2
4665 ,p_gain_or_loss_ref OUT VARCHAR2
4666
4667 --Distribution GL Account
4668 , p_source_10 IN NUMBER
4669 --Distribution Source Type
4670 , p_source_22 IN VARCHAR2
4671 --Receivable Activity Type
4672 , p_source_23 IN VARCHAR2
4673 --Distribution Line Identifier
4674 , p_source_24 IN NUMBER
4675 --Distribution Type
4676 , p_source_25 IN VARCHAR2
4677 --Entered Amount
4678 , p_source_26 IN NUMBER
4679 --Currency Code
4680 , p_source_27 IN VARCHAR2
4681 --Exchange Date
4682 , p_source_28 IN DATE
4683 --Exchange Rate
4684 , p_source_29 IN NUMBER
4685 --Exchange Rate Type
4686 , p_source_30 IN VARCHAR2
4687 --Applied To Document Accounting Amount
4688 , p_source_31 IN NUMBER
4689 --Bill To Customer Account Identifier
4690 , p_source_32 IN NUMBER
4691 --Bill To Customer Site Use Identifier
4692 , p_source_33 IN NUMBER
4693 --SLA Party Type
4694 , p_source_34 IN VARCHAR2
4695 )
4696 IS
4697
4698 l_component_type VARCHAR2(80);
4699 l_component_code VARCHAR2(30);
4700 l_component_type_code VARCHAR2(1);
4701 l_component_appl_id INTEGER;
4702 l_amb_context_code VARCHAR2(30);
4703 l_entity_code VARCHAR2(30);
4704 l_event_class_code VARCHAR2(30);
4708 l_line_definition_owner_code VARCHAR2(1);
4705 l_ae_header_id NUMBER;
4706 l_event_type_code VARCHAR2(30);
4707 l_line_definition_code VARCHAR2(30);
4709 --
4710 -- adr variables
4711 l_segment VARCHAR2(30);
4712 l_ccid NUMBER;
4713 l_adr_transaction_coa_id NUMBER;
4714 l_adr_accounting_coa_id NUMBER;
4715 l_adr_flexfield_segment_code VARCHAR2(30);
4716 l_adr_flex_value_set_id NUMBER;
4717 l_adr_value_type_code VARCHAR2(30);
4718 l_adr_value_combination_id NUMBER;
4719 l_adr_value_segment_code VARCHAR2(30);
4720
4721 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
4722 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
4723 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
4724 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
4725
4726 -- 4262811 Variables ------------------------------------------------------------------------------------------
4727 l_entered_amt_idx NUMBER;
4728 l_accted_amt_idx NUMBER;
4729 l_acc_rev_flag VARCHAR2(1);
4730 l_accrual_line_num NUMBER;
4731 l_tmp_amt NUMBER;
4732 l_acc_rev_natural_side_code VARCHAR2(1);
4733
4734 l_num_entries NUMBER;
4735 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
4736 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
4737 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
4738 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
4739 l_recog_line_1 NUMBER;
4740 l_recog_line_2 NUMBER;
4741
4742 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
4743 l_bflow_applied_to_amt NUMBER; -- 5132302
4744 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
4745
4746 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
4747
4748 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
4749 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
4750
4751 ---------------------------------------------------------------------------------------------------------------
4752
4753
4754 --
4755 -- bulk performance
4756 --
4757 l_balance_type_code VARCHAR2(1);
4758 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
4759 l_log_module VARCHAR2(240);
4760
4761 --
4762 -- Upgrade strategy
4763 --
4764 l_actual_upg_option VARCHAR2(1);
4765 l_enc_upg_option VARCHAR2(1);
4766
4767 --
4768 BEGIN
4769 --
4770 IF g_log_enabled THEN
4771 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_35';
4772 END IF;
4773 --
4774 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4775
4776 trace
4777 (p_msg => 'BEGIN of AcctLineType_35'
4778 ,p_level => C_LEVEL_PROCEDURE
4779 ,p_module => l_log_module);
4780
4781 END IF;
4782 --
4783 l_component_type := 'AMB_JLT';
4784 l_component_code := 'ADJ';
4785 l_component_type_code := 'S';
4786 l_component_appl_id := 222;
4787 l_amb_context_code := 'DEFAULT';
4788 l_entity_code := 'ADJUSTMENTS';
4789 l_event_class_code := 'ADJUSTMENT';
4790 l_event_type_code := 'ADJUSTMENT_ALL';
4791 l_line_definition_owner_code := 'S';
4792 l_line_definition_code := 'MFAR_ADJ_ACCRUAL_ACCOUNT';
4793 --
4794 l_balance_type_code := 'A';
4795 l_segment := NULL;
4796 l_ccid := NULL;
4797 l_adr_transaction_coa_id := NULL;
4798 l_adr_accounting_coa_id := NULL;
4799 l_adr_flexfield_segment_code := NULL;
4800 l_adr_flex_value_set_id := NULL;
4801 l_adr_value_type_code := NULL;
4802 l_adr_value_combination_id := NULL;
4803 l_adr_value_segment_code := NULL;
4804
4805 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
4806 l_bflow_class_code := ''; -- 4219869 Business Flow
4807 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
4808 l_budgetary_control_flag := 'N';
4809
4810 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4811 l_bflow_applied_to_amt := NULL; -- 5132302
4812 l_entered_amt_idx := NULL; -- 4262811
4813 l_accted_amt_idx := NULL; -- 4262811
4814 l_acc_rev_flag := NULL; -- 4262811
4815 l_accrual_line_num := NULL; -- 4262811
4816 l_tmp_amt := NULL; -- 4262811
4817 --
4818
4819 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
4820 l_balance_type_code <> 'B' THEN
4821 IF NVL(p_source_22,'
4822 ') = 'ADJ' AND
4823 NVL(p_source_23,'
4824 ') <> 'ENDORSEMENT'
4825 THEN
4826
4827 --
4828 XLA_AE_LINES_PKG.SetNewLine;
4829
4830 p_balance_type_code := l_balance_type_code;
4831 -- set the flag so later we will know whether the gain loss line needs to be created
4832
4833 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
4834 p_actual_flag :='A';
4835 END IF;
4836
4837 --
4841 p_header_num => 0); -- 4262811
4838 -- bulk performance
4839 --
4840 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
4842 --
4843 -- set accounting line options
4844 --
4845 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
4846 p_natural_side_code => 'C'
4847 , p_gain_or_loss_flag => 'N'
4848 , p_gl_transfer_mode_code => 'S'
4849 , p_acct_entry_type_code => 'A'
4850 , p_switch_side_flag => 'Y'
4851 , p_merge_duplicate_code => 'A'
4852 );
4853 --
4854 l_acc_rev_natural_side_code := 'D'; -- 4262811
4855 --
4856 --
4857 -- set accounting line type info
4858 --
4859 xla_ae_lines_pkg.SetAcctLineType
4860 (p_component_type => l_component_type
4861 ,p_event_type_code => l_event_type_code
4862 ,p_line_definition_owner_code => l_line_definition_owner_code
4863 ,p_line_definition_code => l_line_definition_code
4864 ,p_accounting_line_code => l_component_code
4865 ,p_accounting_line_type_code => l_component_type_code
4866 ,p_accounting_line_appl_id => l_component_appl_id
4867 ,p_amb_context_code => l_amb_context_code
4868 ,p_entity_code => l_entity_code
4869 ,p_event_class_code => l_event_class_code);
4870 --
4871 -- set accounting class
4872 --
4873 xla_ae_lines_pkg.SetAcctClass(
4874 p_accounting_class_code => 'ADJ'
4875 , p_ae_header_id => l_ae_header_id
4876 );
4877
4878 --
4879 -- set rounding class
4880 --
4881 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
4882 'RECEIVABLE';
4883
4884 --
4885 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
4886 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
4887 --
4888 -- bulk performance
4889 --
4890 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
4891
4892 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
4893 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
4894
4895 -- 4955764
4896 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
4897 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
4898
4899 -- 4458381 Public Sector Enh
4900
4901 --
4902 -- set accounting attributes for the line type
4903 --
4904 l_entered_amt_idx := 3;
4905 l_accted_amt_idx := 8;
4906 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4907 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
4908 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
4909 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
4910 l_rec_acct_attrs.array_char_value(2) := p_source_25;
4911 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
4912 l_rec_acct_attrs.array_num_value(3) := p_source_26;
4913 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
4914 l_rec_acct_attrs.array_char_value(4) := p_source_27;
4915 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
4916 l_rec_acct_attrs.array_date_value(5) := p_source_28;
4917 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
4918 l_rec_acct_attrs.array_num_value(6) := p_source_29;
4919 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
4920 l_rec_acct_attrs.array_char_value(7) := p_source_30;
4921 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
4922 l_rec_acct_attrs.array_num_value(8) := p_source_31;
4923 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
4924 l_rec_acct_attrs.array_num_value(9) := p_source_32;
4925 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
4926 l_rec_acct_attrs.array_num_value(10) := p_source_33;
4927 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
4928 l_rec_acct_attrs.array_char_value(11) := p_source_34;
4929
4930 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
4931 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
4932
4933 ---------------------------------------------------------------------------------------------------------------
4934 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
4935 ---------------------------------------------------------------------------------------------------------------
4936 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
4937
4938 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4939 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4940
4941 IF xla_accounting_cache_pkg.GetValueChar
4942 (p_source_code => 'LEDGER_CATEGORY_CODE'
4943 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
4944 AND l_bflow_method_code = 'PRIOR_ENTRY'
4948 )
4945 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
4946 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
4947 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
4949 THEN
4950 xla_ae_lines_pkg.BflowUpgEntry
4951 (p_business_method_code => l_bflow_method_code
4952 ,p_business_class_code => l_bflow_class_code
4953 ,p_balance_type => l_balance_type_code);
4954 ELSE
4955 NULL;
4956 -- No business flow processing for business flow method of NONE.
4957 END IF;
4958
4959 --
4960 -- call analytical criteria
4961 --
4962
4963 --
4964 -- call description
4965 --
4966 -- No description or it is inherited.
4967 --
4968 -- call ADRs
4969 -- Bug 4922099
4970 --
4971 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4972 (NVL(l_actual_upg_option, 'N') = 'O') OR
4973 (NVL(l_enc_upg_option, 'N') = 'O')
4974 )
4975 THEN
4976 NULL;
4977 --
4978 --
4979
4980 l_ccid := AcctDerRule_11(
4981 p_application_id => p_application_id
4982 , p_ae_header_id => l_ae_header_id
4983 , p_source_10 => p_source_10
4984 , x_transaction_coa_id => l_adr_transaction_coa_id
4985 , x_accounting_coa_id => l_adr_accounting_coa_id
4986 , x_value_type_code => l_adr_value_type_code
4987 , p_side => 'NA'
4988 );
4989
4990 xla_ae_lines_pkg.set_ccid(
4991 p_code_combination_id => l_ccid
4992 , p_value_type_code => l_adr_value_type_code
4993 , p_transaction_coa_id => l_adr_transaction_coa_id
4994 , p_accounting_coa_id => l_adr_accounting_coa_id
4995 , p_adr_code => 'DIST_CCID'
4996 , p_adr_type_code => 'S'
4997 , p_component_type => l_component_type
4998 , p_component_code => l_component_code
4999 , p_component_type_code => l_component_type_code
5000 , p_component_appl_id => l_component_appl_id
5001 , p_amb_context_code => l_amb_context_code
5002 , p_side => 'NA'
5003 );
5004
5005
5006 --
5007 --
5008 END IF;
5009 --
5010 -- Bug 4922099
5011 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
5012 (NVL(l_enc_upg_option, 'N') = 'O')
5013 ) AND
5014 (l_bflow_method_code = 'PRIOR_ENTRY')
5015 )
5016 THEN
5017 IF
5018 --
5019 1 = 2
5020 --
5021 THEN
5022 xla_accounting_err_pkg.build_message
5023 (p_appli_s_name => 'XLA'
5024 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5025 ,p_token_1 => 'LINE_NUMBER'
5026 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
5027 ,p_token_2 => 'LINE_TYPE_NAME'
5028 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
5029 l_component_type
5030 ,l_component_code
5031 ,l_component_type_code
5032 ,l_component_appl_id
5033 ,l_amb_context_code
5034 ,l_entity_code
5035 ,l_event_class_code
5036 )
5037 ,p_token_3 => 'OWNER'
5038 ,p_value_3 => xla_lookups_pkg.get_meaning(
5039 p_lookup_type => 'XLA_OWNER_TYPE'
5040 ,p_lookup_code => l_component_type_code
5041 )
5042 ,p_token_4 => 'PRODUCT_NAME'
5043 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
5044 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
5045 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
5046 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
5047 ,p_ae_header_id => NULL
5048 );
5049
5050 IF (C_LEVEL_ERROR>= g_log_level) THEN
5051 trace
5052 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5053 ,p_level => C_LEVEL_ERROR
5054 ,p_module => l_log_module);
5055 END IF;
5056 END IF;
5057 END IF;
5058 --
5062 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
5059 --
5060 ------------------------------------------------------------------------------------------------
5061 -- 4219869 Business Flow
5063 -- Prior Entry. Currently, the following code is always generated.
5064 ------------------------------------------------------------------------------------------------
5065 XLA_AE_LINES_PKG.ValidateCurrentLine;
5066
5067 ------------------------------------------------------------------------------------
5068 -- 4219869 Business Flow
5069 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
5070 ------------------------------------------------------------------------------------
5071 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5072
5073 ----------------------------------------------------------------------------------
5074 -- 4219869 Business Flow
5075 -- Update journal entry status -- Need to generate this within IF <condition>
5076 ----------------------------------------------------------------------------------
5077 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5078 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
5079 ,p_balance_type_code => l_balance_type_code
5080 );
5081
5082 -------------------------------------------------------------------------------------------
5083 -- 4262811 - Generate the Accrual Reversal lines
5084 -------------------------------------------------------------------------------------------
5085 BEGIN
5086 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
5087 (g_array_event(p_event_id).array_value_num('header_index'));
5088 IF l_acc_rev_flag IS NULL THEN
5089 l_acc_rev_flag := 'N';
5090 END IF;
5091 EXCEPTION
5092 WHEN OTHERS THEN
5093 l_acc_rev_flag := 'N';
5094 END;
5095 --
5096 IF (l_acc_rev_flag = 'Y') THEN
5097
5098 -- 4645092 ------------------------------------------------------------------------------
5099 -- To allow MPA report to determine if it should generate report process
5100 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
5101 ------------------------------------------------------------------------------------------
5102
5103 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
5104 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
5105 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
5106 -- call ADRs
5107 -- Bug 4922099
5108 --
5109 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5110 (NVL(l_actual_upg_option, 'N') = 'O') OR
5111 (NVL(l_enc_upg_option, 'N') = 'O')
5112 )
5113 THEN
5114 NULL;
5115 --
5116 --
5117
5118 l_ccid := AcctDerRule_11(
5119 p_application_id => p_application_id
5120 , p_ae_header_id => l_ae_header_id
5121 , p_source_10 => p_source_10
5122 , x_transaction_coa_id => l_adr_transaction_coa_id
5123 , x_accounting_coa_id => l_adr_accounting_coa_id
5124 , x_value_type_code => l_adr_value_type_code
5125 , p_side => 'NA'
5126 );
5127
5128 xla_ae_lines_pkg.set_ccid(
5129 p_code_combination_id => l_ccid
5130 , p_value_type_code => l_adr_value_type_code
5131 , p_transaction_coa_id => l_adr_transaction_coa_id
5132 , p_accounting_coa_id => l_adr_accounting_coa_id
5133 , p_adr_code => 'DIST_CCID'
5134 , p_adr_type_code => 'S'
5135 , p_component_type => l_component_type
5136 , p_component_code => l_component_code
5137 , p_component_type_code => l_component_type_code
5138 , p_component_appl_id => l_component_appl_id
5139 , p_amb_context_code => l_amb_context_code
5140 , p_side => 'NA'
5141 );
5142
5143
5144 --
5145 --
5146 END IF;
5147
5148 --
5149 -- Update the line information that should be overwritten
5150 --
5151 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
5152 p_header_num => 1);
5153 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
5154
5155 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
5156
5157 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
5158 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
5159 END IF;
5160
5161 --
5162 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
5163 --
5164 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
5165 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
5166 ELSE
5167 ---------------------------------------------------------------------------------------------------
5168 -- 4262811a Switch Sign
5172 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5169 ---------------------------------------------------------------------------------------------------
5170 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
5171 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5173 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5174 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5175 -- 5132302
5176 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
5177 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5178
5179 END IF;
5180
5181 -- 4955764
5182 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5183 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
5184
5185
5186 XLA_AE_LINES_PKG.ValidateCurrentLine;
5187 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5188
5189 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5190 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
5191 ,p_balance_type_code => l_balance_type_code);
5192
5193 END IF;
5194
5195 -----------------------------------------------------------------------------------------
5196 -- 4262811 Multiperiod Accounting
5197 -----------------------------------------------------------------------------------------
5198 -- No MPA option is assigned.
5199
5200
5201 END IF;
5202 END IF;
5203 --
5204
5205 --
5206 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5207 trace
5208 (p_msg => 'END of AcctLineType_35'
5209 ,p_level => C_LEVEL_PROCEDURE
5210 ,p_module => l_log_module);
5211 END IF;
5212 --
5213 EXCEPTION
5214 WHEN xla_exceptions_pkg.application_exception THEN
5215 RAISE;
5216 WHEN OTHERS THEN
5217 xla_exceptions_pkg.raise_message
5218 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_35');
5219 END AcctLineType_35;
5220 --
5221
5222 ---------------------------------------
5223 --
5224 -- PRIVATE FUNCTION
5225 -- AcctLineType_36
5226 --
5227 ---------------------------------------
5228 PROCEDURE AcctLineType_36 (
5229 p_application_id IN NUMBER
5230 ,p_event_id IN NUMBER
5231 ,p_calculate_acctd_flag IN VARCHAR2
5232 ,p_calculate_g_l_flag IN VARCHAR2
5233 ,p_actual_flag IN OUT VARCHAR2
5234 ,p_balance_type_code OUT VARCHAR2
5235 ,p_gain_or_loss_ref OUT VARCHAR2
5236
5237 --Distribution GL Account
5238 , p_source_10 IN NUMBER
5239 --Distribution Source Type
5240 , p_source_22 IN VARCHAR2
5241 --Receivable Activity Type
5242 , p_source_23 IN VARCHAR2
5243 --Distribution Line Identifier
5244 , p_source_24 IN NUMBER
5245 --Distribution Type
5246 , p_source_25 IN VARCHAR2
5247 --Entered Amount
5248 , p_source_26 IN NUMBER
5249 --Currency Code
5250 , p_source_27 IN VARCHAR2
5251 --Exchange Date
5252 , p_source_28 IN DATE
5253 --Exchange Rate
5254 , p_source_29 IN NUMBER
5255 --Exchange Rate Type
5256 , p_source_30 IN VARCHAR2
5257 --Applied To Document Accounting Amount
5258 , p_source_31 IN NUMBER
5259 --Bill To Customer Account Identifier
5260 , p_source_32 IN NUMBER
5261 --Bill To Customer Site Use Identifier
5262 , p_source_33 IN NUMBER
5263 --SLA Party Type
5264 , p_source_34 IN VARCHAR2
5265 )
5266 IS
5267
5268 l_component_type VARCHAR2(80);
5269 l_component_code VARCHAR2(30);
5270 l_component_type_code VARCHAR2(1);
5271 l_component_appl_id INTEGER;
5272 l_amb_context_code VARCHAR2(30);
5273 l_entity_code VARCHAR2(30);
5274 l_event_class_code VARCHAR2(30);
5275 l_ae_header_id NUMBER;
5276 l_event_type_code VARCHAR2(30);
5277 l_line_definition_code VARCHAR2(30);
5278 l_line_definition_owner_code VARCHAR2(1);
5279 --
5280 -- adr variables
5281 l_segment VARCHAR2(30);
5282 l_ccid NUMBER;
5283 l_adr_transaction_coa_id NUMBER;
5284 l_adr_accounting_coa_id NUMBER;
5285 l_adr_flexfield_segment_code VARCHAR2(30);
5286 l_adr_flex_value_set_id NUMBER;
5287 l_adr_value_type_code VARCHAR2(30);
5288 l_adr_value_combination_id NUMBER;
5289 l_adr_value_segment_code VARCHAR2(30);
5290
5291 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
5292 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
5293 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
5294 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
5295
5296 -- 4262811 Variables ------------------------------------------------------------------------------------------
5297 l_entered_amt_idx NUMBER;
5298 l_accted_amt_idx NUMBER;
5302 l_acc_rev_natural_side_code VARCHAR2(1);
5299 l_acc_rev_flag VARCHAR2(1);
5300 l_accrual_line_num NUMBER;
5301 l_tmp_amt NUMBER;
5303
5304 l_num_entries NUMBER;
5305 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
5306 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
5307 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
5308 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
5309 l_recog_line_1 NUMBER;
5310 l_recog_line_2 NUMBER;
5311
5312 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
5313 l_bflow_applied_to_amt NUMBER; -- 5132302
5314 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
5315
5316 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
5317
5318 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
5319 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
5320
5321 ---------------------------------------------------------------------------------------------------------------
5322
5323
5324 --
5325 -- bulk performance
5326 --
5327 l_balance_type_code VARCHAR2(1);
5328 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
5329 l_log_module VARCHAR2(240);
5330
5331 --
5332 -- Upgrade strategy
5333 --
5334 l_actual_upg_option VARCHAR2(1);
5335 l_enc_upg_option VARCHAR2(1);
5336
5337 --
5338 BEGIN
5339 --
5340 IF g_log_enabled THEN
5341 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_36';
5342 END IF;
5343 --
5344 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5345
5346 trace
5347 (p_msg => 'BEGIN of AcctLineType_36'
5348 ,p_level => C_LEVEL_PROCEDURE
5349 ,p_module => l_log_module);
5350
5351 END IF;
5352 --
5353 l_component_type := 'AMB_JLT';
5354 l_component_code := 'ADJ_BR_ENDORSE';
5355 l_component_type_code := 'S';
5356 l_component_appl_id := 222;
5357 l_amb_context_code := 'DEFAULT';
5358 l_entity_code := 'ADJUSTMENTS';
5359 l_event_class_code := 'ADJUSTMENT';
5360 l_event_type_code := 'ADJUSTMENT_ALL';
5361 l_line_definition_owner_code := 'S';
5362 l_line_definition_code := 'MFAR_ADJ_ACCRUAL_ACCOUNT';
5363 --
5364 l_balance_type_code := 'A';
5365 l_segment := NULL;
5366 l_ccid := NULL;
5367 l_adr_transaction_coa_id := NULL;
5368 l_adr_accounting_coa_id := NULL;
5369 l_adr_flexfield_segment_code := NULL;
5370 l_adr_flex_value_set_id := NULL;
5371 l_adr_value_type_code := NULL;
5372 l_adr_value_combination_id := NULL;
5373 l_adr_value_segment_code := NULL;
5374
5375 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
5376 l_bflow_class_code := ''; -- 4219869 Business Flow
5377 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
5378 l_budgetary_control_flag := 'N';
5379
5380 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5381 l_bflow_applied_to_amt := NULL; -- 5132302
5382 l_entered_amt_idx := NULL; -- 4262811
5383 l_accted_amt_idx := NULL; -- 4262811
5384 l_acc_rev_flag := NULL; -- 4262811
5385 l_accrual_line_num := NULL; -- 4262811
5386 l_tmp_amt := NULL; -- 4262811
5387 --
5388
5389 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
5390 l_balance_type_code <> 'B' THEN
5391 IF NVL(p_source_22,'
5392 ') = 'ADJ' AND
5393 NVL(p_source_23,'
5394 ') = 'ENDORSEMENT'
5395 THEN
5396
5397 --
5398 XLA_AE_LINES_PKG.SetNewLine;
5399
5400 p_balance_type_code := l_balance_type_code;
5401 -- set the flag so later we will know whether the gain loss line needs to be created
5402
5403 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
5404 p_actual_flag :='A';
5405 END IF;
5406
5407 --
5408 -- bulk performance
5409 --
5410 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
5411 p_header_num => 0); -- 4262811
5412 --
5413 -- set accounting line options
5414 --
5415 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
5416 p_natural_side_code => 'C'
5417 , p_gain_or_loss_flag => 'N'
5418 , p_gl_transfer_mode_code => 'S'
5419 , p_acct_entry_type_code => 'A'
5420 , p_switch_side_flag => 'Y'
5421 , p_merge_duplicate_code => 'A'
5422 );
5423 --
5424 l_acc_rev_natural_side_code := 'D'; -- 4262811
5425 --
5426 --
5427 -- set accounting line type info
5428 --
5429 xla_ae_lines_pkg.SetAcctLineType
5430 (p_component_type => l_component_type
5431 ,p_event_type_code => l_event_type_code
5432 ,p_line_definition_owner_code => l_line_definition_owner_code
5436 ,p_accounting_line_appl_id => l_component_appl_id
5433 ,p_line_definition_code => l_line_definition_code
5434 ,p_accounting_line_code => l_component_code
5435 ,p_accounting_line_type_code => l_component_type_code
5437 ,p_amb_context_code => l_amb_context_code
5438 ,p_entity_code => l_entity_code
5439 ,p_event_class_code => l_event_class_code);
5440 --
5441 -- set accounting class
5442 --
5443 xla_ae_lines_pkg.SetAcctClass(
5444 p_accounting_class_code => 'ENDORSEMENT'
5445 , p_ae_header_id => l_ae_header_id
5446 );
5447
5448 --
5449 -- set rounding class
5450 --
5451 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
5452 'RECEIVABLE';
5453
5454 --
5455 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
5456 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
5457 --
5458 -- bulk performance
5459 --
5460 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
5461
5462 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
5463 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
5464
5465 -- 4955764
5466 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5467 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
5468
5469 -- 4458381 Public Sector Enh
5470
5471 --
5472 -- set accounting attributes for the line type
5473 --
5474 l_entered_amt_idx := 3;
5475 l_accted_amt_idx := 8;
5476 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5477 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
5478 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
5479 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
5480 l_rec_acct_attrs.array_char_value(2) := p_source_25;
5481 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
5482 l_rec_acct_attrs.array_num_value(3) := p_source_26;
5483 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
5484 l_rec_acct_attrs.array_char_value(4) := p_source_27;
5485 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
5486 l_rec_acct_attrs.array_date_value(5) := p_source_28;
5487 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
5488 l_rec_acct_attrs.array_num_value(6) := p_source_29;
5489 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
5490 l_rec_acct_attrs.array_char_value(7) := p_source_30;
5491 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
5492 l_rec_acct_attrs.array_num_value(8) := p_source_31;
5493 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
5494 l_rec_acct_attrs.array_num_value(9) := p_source_32;
5495 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
5496 l_rec_acct_attrs.array_num_value(10) := p_source_33;
5497 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
5498 l_rec_acct_attrs.array_char_value(11) := p_source_34;
5499
5500 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
5501 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
5502
5503 ---------------------------------------------------------------------------------------------------------------
5504 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
5505 ---------------------------------------------------------------------------------------------------------------
5506 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
5507
5508 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5509 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5510
5511 IF xla_accounting_cache_pkg.GetValueChar
5512 (p_source_code => 'LEDGER_CATEGORY_CODE'
5513 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
5514 AND l_bflow_method_code = 'PRIOR_ENTRY'
5515 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
5516 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
5517 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
5518 )
5519 THEN
5520 xla_ae_lines_pkg.BflowUpgEntry
5521 (p_business_method_code => l_bflow_method_code
5522 ,p_business_class_code => l_bflow_class_code
5523 ,p_balance_type => l_balance_type_code);
5524 ELSE
5525 NULL;
5526 -- No business flow processing for business flow method of NONE.
5527 END IF;
5528
5529 --
5530 -- call analytical criteria
5531 --
5532
5533 --
5534 -- call description
5535 --
5536 -- No description or it is inherited.
5537 --
5538 -- call ADRs
5539 -- Bug 4922099
5540 --
5541 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5542 (NVL(l_actual_upg_option, 'N') = 'O') OR
5543 (NVL(l_enc_upg_option, 'N') = 'O')
5544 )
5545 THEN
5546 NULL;
5547 --
5548 --
5549
5550 l_ccid := AcctDerRule_11(
5551 p_application_id => p_application_id
5552 , p_ae_header_id => l_ae_header_id
5556 , x_value_type_code => l_adr_value_type_code
5553 , p_source_10 => p_source_10
5554 , x_transaction_coa_id => l_adr_transaction_coa_id
5555 , x_accounting_coa_id => l_adr_accounting_coa_id
5557 , p_side => 'NA'
5558 );
5559
5560 xla_ae_lines_pkg.set_ccid(
5561 p_code_combination_id => l_ccid
5562 , p_value_type_code => l_adr_value_type_code
5563 , p_transaction_coa_id => l_adr_transaction_coa_id
5564 , p_accounting_coa_id => l_adr_accounting_coa_id
5565 , p_adr_code => 'DIST_CCID'
5566 , p_adr_type_code => 'S'
5567 , p_component_type => l_component_type
5568 , p_component_code => l_component_code
5569 , p_component_type_code => l_component_type_code
5570 , p_component_appl_id => l_component_appl_id
5571 , p_amb_context_code => l_amb_context_code
5572 , p_side => 'NA'
5573 );
5574
5575
5576 --
5577 --
5578 END IF;
5579 --
5580 -- Bug 4922099
5581 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
5582 (NVL(l_enc_upg_option, 'N') = 'O')
5583 ) AND
5584 (l_bflow_method_code = 'PRIOR_ENTRY')
5585 )
5586 THEN
5587 IF
5588 --
5589 1 = 2
5590 --
5591 THEN
5592 xla_accounting_err_pkg.build_message
5593 (p_appli_s_name => 'XLA'
5594 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5595 ,p_token_1 => 'LINE_NUMBER'
5596 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
5597 ,p_token_2 => 'LINE_TYPE_NAME'
5598 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
5599 l_component_type
5600 ,l_component_code
5601 ,l_component_type_code
5602 ,l_component_appl_id
5603 ,l_amb_context_code
5604 ,l_entity_code
5605 ,l_event_class_code
5606 )
5607 ,p_token_3 => 'OWNER'
5608 ,p_value_3 => xla_lookups_pkg.get_meaning(
5609 p_lookup_type => 'XLA_OWNER_TYPE'
5610 ,p_lookup_code => l_component_type_code
5611 )
5612 ,p_token_4 => 'PRODUCT_NAME'
5613 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
5614 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
5615 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
5616 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
5617 ,p_ae_header_id => NULL
5618 );
5619
5620 IF (C_LEVEL_ERROR>= g_log_level) THEN
5621 trace
5622 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5623 ,p_level => C_LEVEL_ERROR
5624 ,p_module => l_log_module);
5625 END IF;
5626 END IF;
5627 END IF;
5628 --
5629 --
5630 ------------------------------------------------------------------------------------------------
5631 -- 4219869 Business Flow
5632 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
5633 -- Prior Entry. Currently, the following code is always generated.
5634 ------------------------------------------------------------------------------------------------
5635 XLA_AE_LINES_PKG.ValidateCurrentLine;
5636
5637 ------------------------------------------------------------------------------------
5638 -- 4219869 Business Flow
5639 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
5640 ------------------------------------------------------------------------------------
5641 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5642
5643 ----------------------------------------------------------------------------------
5644 -- 4219869 Business Flow
5645 -- Update journal entry status -- Need to generate this within IF <condition>
5646 ----------------------------------------------------------------------------------
5647 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5648 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
5652 -------------------------------------------------------------------------------------------
5649 ,p_balance_type_code => l_balance_type_code
5650 );
5651
5653 -- 4262811 - Generate the Accrual Reversal lines
5654 -------------------------------------------------------------------------------------------
5655 BEGIN
5656 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
5657 (g_array_event(p_event_id).array_value_num('header_index'));
5658 IF l_acc_rev_flag IS NULL THEN
5659 l_acc_rev_flag := 'N';
5660 END IF;
5661 EXCEPTION
5662 WHEN OTHERS THEN
5663 l_acc_rev_flag := 'N';
5664 END;
5665 --
5666 IF (l_acc_rev_flag = 'Y') THEN
5667
5668 -- 4645092 ------------------------------------------------------------------------------
5669 -- To allow MPA report to determine if it should generate report process
5670 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
5671 ------------------------------------------------------------------------------------------
5672
5673 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
5674 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
5675 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
5676 -- call ADRs
5677 -- Bug 4922099
5678 --
5679 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5680 (NVL(l_actual_upg_option, 'N') = 'O') OR
5681 (NVL(l_enc_upg_option, 'N') = 'O')
5682 )
5683 THEN
5684 NULL;
5685 --
5686 --
5687
5688 l_ccid := AcctDerRule_11(
5689 p_application_id => p_application_id
5690 , p_ae_header_id => l_ae_header_id
5691 , p_source_10 => p_source_10
5692 , x_transaction_coa_id => l_adr_transaction_coa_id
5693 , x_accounting_coa_id => l_adr_accounting_coa_id
5694 , x_value_type_code => l_adr_value_type_code
5695 , p_side => 'NA'
5696 );
5697
5698 xla_ae_lines_pkg.set_ccid(
5699 p_code_combination_id => l_ccid
5700 , p_value_type_code => l_adr_value_type_code
5701 , p_transaction_coa_id => l_adr_transaction_coa_id
5702 , p_accounting_coa_id => l_adr_accounting_coa_id
5703 , p_adr_code => 'DIST_CCID'
5704 , p_adr_type_code => 'S'
5705 , p_component_type => l_component_type
5706 , p_component_code => l_component_code
5707 , p_component_type_code => l_component_type_code
5708 , p_component_appl_id => l_component_appl_id
5709 , p_amb_context_code => l_amb_context_code
5710 , p_side => 'NA'
5711 );
5712
5713
5714 --
5715 --
5716 END IF;
5717
5718 --
5719 -- Update the line information that should be overwritten
5720 --
5721 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
5722 p_header_num => 1);
5723 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
5724
5725 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
5726
5727 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
5728 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
5729 END IF;
5730
5731 --
5732 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
5733 --
5734 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
5735 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
5736 ELSE
5737 ---------------------------------------------------------------------------------------------------
5738 -- 4262811a Switch Sign
5739 ---------------------------------------------------------------------------------------------------
5740 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
5741 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5742 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5743 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5744 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5745 -- 5132302
5746 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
5747 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5748
5749 END IF;
5750
5751 -- 4955764
5752 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5753 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
5754
5755
5756 XLA_AE_LINES_PKG.ValidateCurrentLine;
5757 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5758
5759 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5760 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
5764
5761 ,p_balance_type_code => l_balance_type_code);
5762
5763 END IF;
5765 -----------------------------------------------------------------------------------------
5766 -- 4262811 Multiperiod Accounting
5767 -----------------------------------------------------------------------------------------
5768 -- No MPA option is assigned.
5769
5770
5771 END IF;
5772 END IF;
5773 --
5774
5775 --
5776 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5777 trace
5778 (p_msg => 'END of AcctLineType_36'
5779 ,p_level => C_LEVEL_PROCEDURE
5780 ,p_module => l_log_module);
5781 END IF;
5782 --
5783 EXCEPTION
5784 WHEN xla_exceptions_pkg.application_exception THEN
5785 RAISE;
5786 WHEN OTHERS THEN
5787 xla_exceptions_pkg.raise_message
5788 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_36');
5789 END AcctLineType_36;
5790 --
5791
5792 ---------------------------------------
5793 --
5794 -- PRIVATE FUNCTION
5795 -- AcctLineType_37
5796 --
5797 ---------------------------------------
5798 PROCEDURE AcctLineType_37 (
5799 p_application_id IN NUMBER
5800 ,p_event_id IN NUMBER
5801 ,p_calculate_acctd_flag IN VARCHAR2
5802 ,p_calculate_g_l_flag IN VARCHAR2
5803 ,p_actual_flag IN OUT VARCHAR2
5804 ,p_balance_type_code OUT VARCHAR2
5805 ,p_gain_or_loss_ref OUT VARCHAR2
5806
5807 --Distribution GL Account
5808 , p_source_10 IN NUMBER
5809 --Distribution Source Type
5810 , p_source_22 IN VARCHAR2
5811 --Distribution Line Identifier
5812 , p_source_24 IN NUMBER
5813 --Distribution Type
5814 , p_source_25 IN VARCHAR2
5815 --Entered Amount
5816 , p_source_26 IN NUMBER
5817 --Currency Code
5818 , p_source_27 IN VARCHAR2
5819 --Exchange Date
5820 , p_source_28 IN DATE
5821 --Exchange Rate
5822 , p_source_29 IN NUMBER
5823 --Exchange Rate Type
5824 , p_source_30 IN VARCHAR2
5825 --Applied To Document Accounting Amount
5826 , p_source_31 IN NUMBER
5827 --Bill To Customer Account Identifier
5828 , p_source_32 IN NUMBER
5829 --Bill To Customer Site Use Identifier
5830 , p_source_33 IN NUMBER
5831 --SLA Party Type
5832 , p_source_34 IN VARCHAR2
5833 )
5834 IS
5835
5836 l_component_type VARCHAR2(80);
5837 l_component_code VARCHAR2(30);
5838 l_component_type_code VARCHAR2(1);
5839 l_component_appl_id INTEGER;
5840 l_amb_context_code VARCHAR2(30);
5841 l_entity_code VARCHAR2(30);
5842 l_event_class_code VARCHAR2(30);
5843 l_ae_header_id NUMBER;
5844 l_event_type_code VARCHAR2(30);
5845 l_line_definition_code VARCHAR2(30);
5846 l_line_definition_owner_code VARCHAR2(1);
5847 --
5848 -- adr variables
5849 l_segment VARCHAR2(30);
5850 l_ccid NUMBER;
5851 l_adr_transaction_coa_id NUMBER;
5852 l_adr_accounting_coa_id NUMBER;
5853 l_adr_flexfield_segment_code VARCHAR2(30);
5854 l_adr_flex_value_set_id NUMBER;
5855 l_adr_value_type_code VARCHAR2(30);
5856 l_adr_value_combination_id NUMBER;
5857 l_adr_value_segment_code VARCHAR2(30);
5858
5859 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
5860 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
5861 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
5862 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
5863
5864 -- 4262811 Variables ------------------------------------------------------------------------------------------
5865 l_entered_amt_idx NUMBER;
5866 l_accted_amt_idx NUMBER;
5867 l_acc_rev_flag VARCHAR2(1);
5868 l_accrual_line_num NUMBER;
5869 l_tmp_amt NUMBER;
5870 l_acc_rev_natural_side_code VARCHAR2(1);
5871
5872 l_num_entries NUMBER;
5873 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
5874 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
5875 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
5876 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
5877 l_recog_line_1 NUMBER;
5878 l_recog_line_2 NUMBER;
5879
5880 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
5881 l_bflow_applied_to_amt NUMBER; -- 5132302
5882 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
5883
5884 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
5885
5886 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
5887 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
5888
5889 ---------------------------------------------------------------------------------------------------------------
5890
5891
5892 --
5893 -- bulk performance
5894 --
5895 l_balance_type_code VARCHAR2(1);
5896 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
5897 l_log_module VARCHAR2(240);
5898
5902 l_actual_upg_option VARCHAR2(1);
5899 --
5900 -- Upgrade strategy
5901 --
5903 l_enc_upg_option VARCHAR2(1);
5904
5905 --
5906 BEGIN
5907 --
5908 IF g_log_enabled THEN
5909 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_37';
5910 END IF;
5911 --
5912 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5913
5914 trace
5915 (p_msg => 'BEGIN of AcctLineType_37'
5916 ,p_level => C_LEVEL_PROCEDURE
5917 ,p_module => l_log_module);
5918
5919 END IF;
5920 --
5921 l_component_type := 'AMB_JLT';
5922 l_component_code := 'ADJ_CHRG';
5923 l_component_type_code := 'S';
5924 l_component_appl_id := 222;
5925 l_amb_context_code := 'DEFAULT';
5926 l_entity_code := 'ADJUSTMENTS';
5927 l_event_class_code := 'ADJUSTMENT';
5928 l_event_type_code := 'ADJUSTMENT_ALL';
5929 l_line_definition_owner_code := 'S';
5930 l_line_definition_code := 'MFAR_ADJ_ACCRUAL_ACCOUNT';
5931 --
5932 l_balance_type_code := 'A';
5933 l_segment := NULL;
5934 l_ccid := NULL;
5935 l_adr_transaction_coa_id := NULL;
5936 l_adr_accounting_coa_id := NULL;
5937 l_adr_flexfield_segment_code := NULL;
5938 l_adr_flex_value_set_id := NULL;
5939 l_adr_value_type_code := NULL;
5940 l_adr_value_combination_id := NULL;
5941 l_adr_value_segment_code := NULL;
5942
5943 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
5944 l_bflow_class_code := ''; -- 4219869 Business Flow
5945 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
5946 l_budgetary_control_flag := 'N';
5947
5948 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5949 l_bflow_applied_to_amt := NULL; -- 5132302
5950 l_entered_amt_idx := NULL; -- 4262811
5951 l_accted_amt_idx := NULL; -- 4262811
5952 l_acc_rev_flag := NULL; -- 4262811
5953 l_accrual_line_num := NULL; -- 4262811
5954 l_tmp_amt := NULL; -- 4262811
5955 --
5956
5957 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
5958 l_balance_type_code <> 'B' THEN
5959 IF NVL(p_source_22,'
5960 ') = 'FINCHRG' OR
5961 NVL(p_source_22,'
5962 ') = 'FINCHRG_NON_REC_TAX'
5963 THEN
5964
5965 --
5966 XLA_AE_LINES_PKG.SetNewLine;
5967
5968 p_balance_type_code := l_balance_type_code;
5969 -- set the flag so later we will know whether the gain loss line needs to be created
5970
5971 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
5972 p_actual_flag :='A';
5973 END IF;
5974
5975 --
5976 -- bulk performance
5977 --
5978 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
5979 p_header_num => 0); -- 4262811
5980 --
5981 -- set accounting line options
5982 --
5983 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
5984 p_natural_side_code => 'C'
5985 , p_gain_or_loss_flag => 'N'
5986 , p_gl_transfer_mode_code => 'S'
5987 , p_acct_entry_type_code => 'A'
5988 , p_switch_side_flag => 'Y'
5989 , p_merge_duplicate_code => 'A'
5990 );
5991 --
5992 l_acc_rev_natural_side_code := 'D'; -- 4262811
5993 --
5994 --
5995 -- set accounting line type info
5996 --
5997 xla_ae_lines_pkg.SetAcctLineType
5998 (p_component_type => l_component_type
5999 ,p_event_type_code => l_event_type_code
6000 ,p_line_definition_owner_code => l_line_definition_owner_code
6001 ,p_line_definition_code => l_line_definition_code
6002 ,p_accounting_line_code => l_component_code
6003 ,p_accounting_line_type_code => l_component_type_code
6004 ,p_accounting_line_appl_id => l_component_appl_id
6005 ,p_amb_context_code => l_amb_context_code
6006 ,p_entity_code => l_entity_code
6007 ,p_event_class_code => l_event_class_code);
6008 --
6009 -- set accounting class
6010 --
6011 xla_ae_lines_pkg.SetAcctClass(
6012 p_accounting_class_code => 'CHARGES'
6013 , p_ae_header_id => l_ae_header_id
6014 );
6015
6016 --
6017 -- set rounding class
6018 --
6019 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
6020 'RECEIVABLE';
6021
6022 --
6023 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
6024 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
6025 --
6026 -- bulk performance
6027 --
6028 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
6029
6030 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
6031 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
6032
6033 -- 4955764
6037 -- 4458381 Public Sector Enh
6034 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6035 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
6036
6038
6039 --
6040 -- set accounting attributes for the line type
6041 --
6042 l_entered_amt_idx := 3;
6043 l_accted_amt_idx := 8;
6044 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6045 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
6046 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
6047 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
6048 l_rec_acct_attrs.array_char_value(2) := p_source_25;
6049 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
6050 l_rec_acct_attrs.array_num_value(3) := p_source_26;
6051 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
6052 l_rec_acct_attrs.array_char_value(4) := p_source_27;
6053 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
6054 l_rec_acct_attrs.array_date_value(5) := p_source_28;
6055 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
6056 l_rec_acct_attrs.array_num_value(6) := p_source_29;
6057 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
6058 l_rec_acct_attrs.array_char_value(7) := p_source_30;
6059 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
6060 l_rec_acct_attrs.array_num_value(8) := p_source_31;
6061 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
6062 l_rec_acct_attrs.array_num_value(9) := p_source_32;
6063 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
6064 l_rec_acct_attrs.array_num_value(10) := p_source_33;
6065 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
6066 l_rec_acct_attrs.array_char_value(11) := p_source_34;
6067
6068 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
6069 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
6070
6071 ---------------------------------------------------------------------------------------------------------------
6072 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
6073 ---------------------------------------------------------------------------------------------------------------
6074 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
6075
6076 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6077 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6078
6079 IF xla_accounting_cache_pkg.GetValueChar
6080 (p_source_code => 'LEDGER_CATEGORY_CODE'
6081 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
6082 AND l_bflow_method_code = 'PRIOR_ENTRY'
6083 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
6084 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
6085 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
6086 )
6087 THEN
6088 xla_ae_lines_pkg.BflowUpgEntry
6089 (p_business_method_code => l_bflow_method_code
6090 ,p_business_class_code => l_bflow_class_code
6091 ,p_balance_type => l_balance_type_code);
6092 ELSE
6093 NULL;
6094 -- No business flow processing for business flow method of NONE.
6095 END IF;
6096
6097 --
6098 -- call analytical criteria
6099 --
6100
6101 --
6102 -- call description
6103 --
6104 -- No description or it is inherited.
6105 --
6106 -- call ADRs
6107 -- Bug 4922099
6108 --
6109 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6110 (NVL(l_actual_upg_option, 'N') = 'O') OR
6111 (NVL(l_enc_upg_option, 'N') = 'O')
6112 )
6113 THEN
6114 NULL;
6115 --
6116 --
6117
6118 l_ccid := AcctDerRule_11(
6119 p_application_id => p_application_id
6120 , p_ae_header_id => l_ae_header_id
6121 , p_source_10 => p_source_10
6122 , x_transaction_coa_id => l_adr_transaction_coa_id
6123 , x_accounting_coa_id => l_adr_accounting_coa_id
6124 , x_value_type_code => l_adr_value_type_code
6125 , p_side => 'NA'
6126 );
6127
6128 xla_ae_lines_pkg.set_ccid(
6129 p_code_combination_id => l_ccid
6130 , p_value_type_code => l_adr_value_type_code
6131 , p_transaction_coa_id => l_adr_transaction_coa_id
6132 , p_accounting_coa_id => l_adr_accounting_coa_id
6133 , p_adr_code => 'DIST_CCID'
6134 , p_adr_type_code => 'S'
6135 , p_component_type => l_component_type
6136 , p_component_code => l_component_code
6137 , p_component_type_code => l_component_type_code
6138 , p_component_appl_id => l_component_appl_id
6139 , p_amb_context_code => l_amb_context_code
6140 , p_side => 'NA'
6141 );
6142
6143
6144 --
6145 --
6146 END IF;
6147 --
6148 -- Bug 4922099
6149 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
6150 (NVL(l_enc_upg_option, 'N') = 'O')
6151 ) AND
6152 (l_bflow_method_code = 'PRIOR_ENTRY')
6153 )
6157 1 = 2
6154 THEN
6155 IF
6156 --
6158 --
6159 THEN
6160 xla_accounting_err_pkg.build_message
6161 (p_appli_s_name => 'XLA'
6162 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6163 ,p_token_1 => 'LINE_NUMBER'
6164 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
6165 ,p_token_2 => 'LINE_TYPE_NAME'
6166 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
6167 l_component_type
6168 ,l_component_code
6169 ,l_component_type_code
6170 ,l_component_appl_id
6171 ,l_amb_context_code
6172 ,l_entity_code
6173 ,l_event_class_code
6174 )
6175 ,p_token_3 => 'OWNER'
6176 ,p_value_3 => xla_lookups_pkg.get_meaning(
6177 p_lookup_type => 'XLA_OWNER_TYPE'
6178 ,p_lookup_code => l_component_type_code
6179 )
6180 ,p_token_4 => 'PRODUCT_NAME'
6181 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
6182 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
6183 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
6184 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
6185 ,p_ae_header_id => NULL
6186 );
6187
6188 IF (C_LEVEL_ERROR>= g_log_level) THEN
6189 trace
6190 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6191 ,p_level => C_LEVEL_ERROR
6192 ,p_module => l_log_module);
6193 END IF;
6194 END IF;
6195 END IF;
6196 --
6197 --
6198 ------------------------------------------------------------------------------------------------
6199 -- 4219869 Business Flow
6200 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
6201 -- Prior Entry. Currently, the following code is always generated.
6202 ------------------------------------------------------------------------------------------------
6203 XLA_AE_LINES_PKG.ValidateCurrentLine;
6204
6205 ------------------------------------------------------------------------------------
6206 -- 4219869 Business Flow
6207 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
6208 ------------------------------------------------------------------------------------
6209 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6210
6211 ----------------------------------------------------------------------------------
6212 -- 4219869 Business Flow
6213 -- Update journal entry status -- Need to generate this within IF <condition>
6214 ----------------------------------------------------------------------------------
6215 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6216 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
6217 ,p_balance_type_code => l_balance_type_code
6218 );
6219
6220 -------------------------------------------------------------------------------------------
6221 -- 4262811 - Generate the Accrual Reversal lines
6222 -------------------------------------------------------------------------------------------
6223 BEGIN
6224 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
6225 (g_array_event(p_event_id).array_value_num('header_index'));
6226 IF l_acc_rev_flag IS NULL THEN
6227 l_acc_rev_flag := 'N';
6228 END IF;
6229 EXCEPTION
6230 WHEN OTHERS THEN
6231 l_acc_rev_flag := 'N';
6232 END;
6233 --
6234 IF (l_acc_rev_flag = 'Y') THEN
6235
6236 -- 4645092 ------------------------------------------------------------------------------
6237 -- To allow MPA report to determine if it should generate report process
6238 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
6239 ------------------------------------------------------------------------------------------
6240
6241 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
6242 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
6243 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
6244 -- call ADRs
6245 -- Bug 4922099
6246 --
6250 )
6247 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6248 (NVL(l_actual_upg_option, 'N') = 'O') OR
6249 (NVL(l_enc_upg_option, 'N') = 'O')
6251 THEN
6252 NULL;
6253 --
6254 --
6255
6256 l_ccid := AcctDerRule_11(
6257 p_application_id => p_application_id
6258 , p_ae_header_id => l_ae_header_id
6259 , p_source_10 => p_source_10
6260 , x_transaction_coa_id => l_adr_transaction_coa_id
6261 , x_accounting_coa_id => l_adr_accounting_coa_id
6262 , x_value_type_code => l_adr_value_type_code
6263 , p_side => 'NA'
6264 );
6265
6266 xla_ae_lines_pkg.set_ccid(
6267 p_code_combination_id => l_ccid
6268 , p_value_type_code => l_adr_value_type_code
6269 , p_transaction_coa_id => l_adr_transaction_coa_id
6270 , p_accounting_coa_id => l_adr_accounting_coa_id
6271 , p_adr_code => 'DIST_CCID'
6272 , p_adr_type_code => 'S'
6273 , p_component_type => l_component_type
6274 , p_component_code => l_component_code
6275 , p_component_type_code => l_component_type_code
6276 , p_component_appl_id => l_component_appl_id
6277 , p_amb_context_code => l_amb_context_code
6278 , p_side => 'NA'
6279 );
6280
6281
6282 --
6283 --
6284 END IF;
6285
6286 --
6287 -- Update the line information that should be overwritten
6288 --
6289 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
6290 p_header_num => 1);
6291 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
6292
6293 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
6294
6295 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
6296 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
6297 END IF;
6298
6299 --
6300 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
6301 --
6302 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
6303 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
6304 ELSE
6305 ---------------------------------------------------------------------------------------------------
6306 -- 4262811a Switch Sign
6307 ---------------------------------------------------------------------------------------------------
6308 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
6309 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6310 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6311 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6312 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6313 -- 5132302
6314 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
6315 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6316
6317 END IF;
6318
6319 -- 4955764
6320 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6321 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
6322
6323
6324 XLA_AE_LINES_PKG.ValidateCurrentLine;
6325 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6326
6327 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6328 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
6329 ,p_balance_type_code => l_balance_type_code);
6330
6331 END IF;
6332
6333 -----------------------------------------------------------------------------------------
6334 -- 4262811 Multiperiod Accounting
6335 -----------------------------------------------------------------------------------------
6336 -- No MPA option is assigned.
6337
6338
6339 END IF;
6340 END IF;
6341 --
6342
6343 --
6344 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6345 trace
6346 (p_msg => 'END of AcctLineType_37'
6347 ,p_level => C_LEVEL_PROCEDURE
6348 ,p_module => l_log_module);
6349 END IF;
6350 --
6351 EXCEPTION
6352 WHEN xla_exceptions_pkg.application_exception THEN
6353 RAISE;
6354 WHEN OTHERS THEN
6355 xla_exceptions_pkg.raise_message
6356 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_37');
6357 END AcctLineType_37;
6358 --
6359
6360 ---------------------------------------
6361 --
6362 -- PRIVATE FUNCTION
6363 -- AcctLineType_38
6364 --
6365 ---------------------------------------
6366 PROCEDURE AcctLineType_38 (
6367 p_application_id IN NUMBER
6368 ,p_event_id IN NUMBER
6369 ,p_calculate_acctd_flag IN VARCHAR2
6370 ,p_calculate_g_l_flag IN VARCHAR2
6374
6371 ,p_actual_flag IN OUT VARCHAR2
6372 ,p_balance_type_code OUT VARCHAR2
6373 ,p_gain_or_loss_ref OUT VARCHAR2
6375 --Distribution GL Account
6376 , p_source_10 IN NUMBER
6377 --Distribution Source Type
6378 , p_source_22 IN VARCHAR2
6379 --Distribution Line Identifier
6380 , p_source_24 IN NUMBER
6381 --Distribution Type
6382 , p_source_25 IN VARCHAR2
6383 --Entered Amount
6384 , p_source_26 IN NUMBER
6385 --Currency Code
6386 , p_source_27 IN VARCHAR2
6387 --Exchange Date
6388 , p_source_28 IN DATE
6389 --Exchange Rate
6390 , p_source_29 IN NUMBER
6391 --Exchange Rate Type
6392 , p_source_30 IN VARCHAR2
6393 --Applied To Document Accounting Amount
6394 , p_source_31 IN NUMBER
6395 --Bill To Customer Account Identifier
6396 , p_source_32 IN NUMBER
6397 --Bill To Customer Site Use Identifier
6398 , p_source_33 IN NUMBER
6399 --SLA Party Type
6400 , p_source_34 IN VARCHAR2
6401 )
6402 IS
6403
6404 l_component_type VARCHAR2(80);
6405 l_component_code VARCHAR2(30);
6406 l_component_type_code VARCHAR2(1);
6407 l_component_appl_id INTEGER;
6408 l_amb_context_code VARCHAR2(30);
6409 l_entity_code VARCHAR2(30);
6410 l_event_class_code VARCHAR2(30);
6411 l_ae_header_id NUMBER;
6412 l_event_type_code VARCHAR2(30);
6413 l_line_definition_code VARCHAR2(30);
6414 l_line_definition_owner_code VARCHAR2(1);
6415 --
6416 -- adr variables
6417 l_segment VARCHAR2(30);
6418 l_ccid NUMBER;
6419 l_adr_transaction_coa_id NUMBER;
6420 l_adr_accounting_coa_id NUMBER;
6421 l_adr_flexfield_segment_code VARCHAR2(30);
6422 l_adr_flex_value_set_id NUMBER;
6423 l_adr_value_type_code VARCHAR2(30);
6424 l_adr_value_combination_id NUMBER;
6425 l_adr_value_segment_code VARCHAR2(30);
6426
6427 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
6428 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
6429 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
6430 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
6431
6432 -- 4262811 Variables ------------------------------------------------------------------------------------------
6433 l_entered_amt_idx NUMBER;
6434 l_accted_amt_idx NUMBER;
6435 l_acc_rev_flag VARCHAR2(1);
6436 l_accrual_line_num NUMBER;
6437 l_tmp_amt NUMBER;
6438 l_acc_rev_natural_side_code VARCHAR2(1);
6439
6440 l_num_entries NUMBER;
6441 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
6442 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
6443 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
6444 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
6445 l_recog_line_1 NUMBER;
6446 l_recog_line_2 NUMBER;
6447
6448 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
6449 l_bflow_applied_to_amt NUMBER; -- 5132302
6450 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
6451
6452 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
6453
6454 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
6455 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
6456
6457 ---------------------------------------------------------------------------------------------------------------
6458
6459
6460 --
6461 -- bulk performance
6462 --
6463 l_balance_type_code VARCHAR2(1);
6464 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
6465 l_log_module VARCHAR2(240);
6466
6467 --
6468 -- Upgrade strategy
6469 --
6470 l_actual_upg_option VARCHAR2(1);
6471 l_enc_upg_option VARCHAR2(1);
6472
6473 --
6474 BEGIN
6475 --
6476 IF g_log_enabled THEN
6477 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_38';
6478 END IF;
6479 --
6480 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6481
6482 trace
6483 (p_msg => 'BEGIN of AcctLineType_38'
6484 ,p_level => C_LEVEL_PROCEDURE
6485 ,p_module => l_log_module);
6486
6487 END IF;
6488 --
6489 l_component_type := 'AMB_JLT';
6490 l_component_code := 'ADJ_TAX';
6491 l_component_type_code := 'S';
6492 l_component_appl_id := 222;
6493 l_amb_context_code := 'DEFAULT';
6494 l_entity_code := 'ADJUSTMENTS';
6495 l_event_class_code := 'ADJUSTMENT';
6496 l_event_type_code := 'ADJUSTMENT_ALL';
6497 l_line_definition_owner_code := 'S';
6498 l_line_definition_code := 'MFAR_ADJ_ACCRUAL_ACCOUNT';
6499 --
6500 l_balance_type_code := 'A';
6501 l_segment := NULL;
6502 l_ccid := NULL;
6503 l_adr_transaction_coa_id := NULL;
6504 l_adr_accounting_coa_id := NULL;
6505 l_adr_flexfield_segment_code := NULL;
6509 l_adr_value_segment_code := NULL;
6506 l_adr_flex_value_set_id := NULL;
6507 l_adr_value_type_code := NULL;
6508 l_adr_value_combination_id := NULL;
6510
6511 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
6512 l_bflow_class_code := ''; -- 4219869 Business Flow
6513 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
6514 l_budgetary_control_flag := 'N';
6515
6516 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6517 l_bflow_applied_to_amt := NULL; -- 5132302
6518 l_entered_amt_idx := NULL; -- 4262811
6519 l_accted_amt_idx := NULL; -- 4262811
6520 l_acc_rev_flag := NULL; -- 4262811
6521 l_accrual_line_num := NULL; -- 4262811
6522 l_tmp_amt := NULL; -- 4262811
6523 --
6524
6525 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
6526 l_balance_type_code <> 'B' THEN
6527 IF NVL(p_source_22,'
6528 ') = 'TAX'
6529 THEN
6530
6531 --
6532 XLA_AE_LINES_PKG.SetNewLine;
6533
6534 p_balance_type_code := l_balance_type_code;
6535 -- set the flag so later we will know whether the gain loss line needs to be created
6536
6537 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
6538 p_actual_flag :='A';
6539 END IF;
6540
6541 --
6542 -- bulk performance
6543 --
6544 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
6545 p_header_num => 0); -- 4262811
6546 --
6547 -- set accounting line options
6548 --
6549 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
6550 p_natural_side_code => 'C'
6551 , p_gain_or_loss_flag => 'N'
6552 , p_gl_transfer_mode_code => 'S'
6553 , p_acct_entry_type_code => 'A'
6554 , p_switch_side_flag => 'Y'
6555 , p_merge_duplicate_code => 'A'
6556 );
6557 --
6558 l_acc_rev_natural_side_code := 'D'; -- 4262811
6559 --
6560 --
6561 -- set accounting line type info
6562 --
6563 xla_ae_lines_pkg.SetAcctLineType
6564 (p_component_type => l_component_type
6565 ,p_event_type_code => l_event_type_code
6566 ,p_line_definition_owner_code => l_line_definition_owner_code
6567 ,p_line_definition_code => l_line_definition_code
6568 ,p_accounting_line_code => l_component_code
6569 ,p_accounting_line_type_code => l_component_type_code
6570 ,p_accounting_line_appl_id => l_component_appl_id
6571 ,p_amb_context_code => l_amb_context_code
6572 ,p_entity_code => l_entity_code
6573 ,p_event_class_code => l_event_class_code);
6574 --
6575 -- set accounting class
6576 --
6577 xla_ae_lines_pkg.SetAcctClass(
6578 p_accounting_class_code => 'TAX'
6579 , p_ae_header_id => l_ae_header_id
6580 );
6581
6582 --
6583 -- set rounding class
6584 --
6585 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
6586 'RECEIVABLE';
6587
6588 --
6589 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
6590 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
6591 --
6592 -- bulk performance
6593 --
6594 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
6595
6596 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
6597 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
6598
6599 -- 4955764
6600 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6601 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
6602
6603 -- 4458381 Public Sector Enh
6604
6605 --
6606 -- set accounting attributes for the line type
6607 --
6608 l_entered_amt_idx := 3;
6609 l_accted_amt_idx := 8;
6610 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6611 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
6612 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
6613 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
6614 l_rec_acct_attrs.array_char_value(2) := p_source_25;
6615 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
6616 l_rec_acct_attrs.array_num_value(3) := p_source_26;
6617 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
6618 l_rec_acct_attrs.array_char_value(4) := p_source_27;
6619 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
6620 l_rec_acct_attrs.array_date_value(5) := p_source_28;
6621 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
6622 l_rec_acct_attrs.array_num_value(6) := p_source_29;
6623 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
6624 l_rec_acct_attrs.array_char_value(7) := p_source_30;
6625 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
6629 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
6626 l_rec_acct_attrs.array_num_value(8) := p_source_31;
6627 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
6628 l_rec_acct_attrs.array_num_value(9) := p_source_32;
6630 l_rec_acct_attrs.array_num_value(10) := p_source_33;
6631 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
6632 l_rec_acct_attrs.array_char_value(11) := p_source_34;
6633
6634 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
6635 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
6636
6637 ---------------------------------------------------------------------------------------------------------------
6638 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
6639 ---------------------------------------------------------------------------------------------------------------
6640 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
6641
6642 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6643 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6644
6645 IF xla_accounting_cache_pkg.GetValueChar
6646 (p_source_code => 'LEDGER_CATEGORY_CODE'
6647 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
6648 AND l_bflow_method_code = 'PRIOR_ENTRY'
6649 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
6650 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
6651 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
6652 )
6653 THEN
6654 xla_ae_lines_pkg.BflowUpgEntry
6655 (p_business_method_code => l_bflow_method_code
6656 ,p_business_class_code => l_bflow_class_code
6657 ,p_balance_type => l_balance_type_code);
6658 ELSE
6659 NULL;
6660 -- No business flow processing for business flow method of NONE.
6661 END IF;
6662
6663 --
6664 -- call analytical criteria
6665 --
6666
6667 --
6668 -- call description
6669 --
6670 -- No description or it is inherited.
6671 --
6672 -- call ADRs
6673 -- Bug 4922099
6674 --
6675 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6676 (NVL(l_actual_upg_option, 'N') = 'O') OR
6677 (NVL(l_enc_upg_option, 'N') = 'O')
6678 )
6679 THEN
6680 NULL;
6681 --
6682 --
6683
6684 l_ccid := AcctDerRule_11(
6685 p_application_id => p_application_id
6686 , p_ae_header_id => l_ae_header_id
6687 , p_source_10 => p_source_10
6688 , x_transaction_coa_id => l_adr_transaction_coa_id
6689 , x_accounting_coa_id => l_adr_accounting_coa_id
6690 , x_value_type_code => l_adr_value_type_code
6691 , p_side => 'NA'
6692 );
6693
6694 xla_ae_lines_pkg.set_ccid(
6695 p_code_combination_id => l_ccid
6696 , p_value_type_code => l_adr_value_type_code
6697 , p_transaction_coa_id => l_adr_transaction_coa_id
6698 , p_accounting_coa_id => l_adr_accounting_coa_id
6699 , p_adr_code => 'DIST_CCID'
6700 , p_adr_type_code => 'S'
6701 , p_component_type => l_component_type
6702 , p_component_code => l_component_code
6703 , p_component_type_code => l_component_type_code
6704 , p_component_appl_id => l_component_appl_id
6705 , p_amb_context_code => l_amb_context_code
6706 , p_side => 'NA'
6707 );
6708
6709
6710 --
6711 --
6712 END IF;
6713 --
6714 -- Bug 4922099
6715 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
6716 (NVL(l_enc_upg_option, 'N') = 'O')
6717 ) AND
6718 (l_bflow_method_code = 'PRIOR_ENTRY')
6719 )
6720 THEN
6721 IF
6722 --
6723 1 = 2
6724 --
6725 THEN
6726 xla_accounting_err_pkg.build_message
6727 (p_appli_s_name => 'XLA'
6728 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6729 ,p_token_1 => 'LINE_NUMBER'
6730 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
6731 ,p_token_2 => 'LINE_TYPE_NAME'
6732 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
6733 l_component_type
6734 ,l_component_code
6735 ,l_component_type_code
6736 ,l_component_appl_id
6737 ,l_amb_context_code
6738 ,l_entity_code
6739 ,l_event_class_code
6743 p_lookup_type => 'XLA_OWNER_TYPE'
6740 )
6741 ,p_token_3 => 'OWNER'
6742 ,p_value_3 => xla_lookups_pkg.get_meaning(
6744 ,p_lookup_code => l_component_type_code
6745 )
6746 ,p_token_4 => 'PRODUCT_NAME'
6747 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
6748 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
6749 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
6750 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
6751 ,p_ae_header_id => NULL
6752 );
6753
6754 IF (C_LEVEL_ERROR>= g_log_level) THEN
6755 trace
6756 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6757 ,p_level => C_LEVEL_ERROR
6758 ,p_module => l_log_module);
6759 END IF;
6760 END IF;
6761 END IF;
6762 --
6763 --
6764 ------------------------------------------------------------------------------------------------
6765 -- 4219869 Business Flow
6766 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
6767 -- Prior Entry. Currently, the following code is always generated.
6768 ------------------------------------------------------------------------------------------------
6769 XLA_AE_LINES_PKG.ValidateCurrentLine;
6770
6771 ------------------------------------------------------------------------------------
6772 -- 4219869 Business Flow
6773 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
6774 ------------------------------------------------------------------------------------
6775 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6776
6777 ----------------------------------------------------------------------------------
6778 -- 4219869 Business Flow
6779 -- Update journal entry status -- Need to generate this within IF <condition>
6780 ----------------------------------------------------------------------------------
6781 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6782 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
6783 ,p_balance_type_code => l_balance_type_code
6784 );
6785
6786 -------------------------------------------------------------------------------------------
6787 -- 4262811 - Generate the Accrual Reversal lines
6788 -------------------------------------------------------------------------------------------
6789 BEGIN
6790 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
6791 (g_array_event(p_event_id).array_value_num('header_index'));
6792 IF l_acc_rev_flag IS NULL THEN
6793 l_acc_rev_flag := 'N';
6794 END IF;
6795 EXCEPTION
6796 WHEN OTHERS THEN
6797 l_acc_rev_flag := 'N';
6798 END;
6799 --
6800 IF (l_acc_rev_flag = 'Y') THEN
6801
6802 -- 4645092 ------------------------------------------------------------------------------
6803 -- To allow MPA report to determine if it should generate report process
6804 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
6805 ------------------------------------------------------------------------------------------
6806
6807 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
6808 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
6809 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
6810 -- call ADRs
6811 -- Bug 4922099
6812 --
6813 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6814 (NVL(l_actual_upg_option, 'N') = 'O') OR
6815 (NVL(l_enc_upg_option, 'N') = 'O')
6816 )
6817 THEN
6818 NULL;
6819 --
6820 --
6821
6822 l_ccid := AcctDerRule_11(
6823 p_application_id => p_application_id
6824 , p_ae_header_id => l_ae_header_id
6825 , p_source_10 => p_source_10
6826 , x_transaction_coa_id => l_adr_transaction_coa_id
6827 , x_accounting_coa_id => l_adr_accounting_coa_id
6828 , x_value_type_code => l_adr_value_type_code
6829 , p_side => 'NA'
6830 );
6831
6832 xla_ae_lines_pkg.set_ccid(
6833 p_code_combination_id => l_ccid
6834 , p_value_type_code => l_adr_value_type_code
6835 , p_transaction_coa_id => l_adr_transaction_coa_id
6836 , p_accounting_coa_id => l_adr_accounting_coa_id
6837 , p_adr_code => 'DIST_CCID'
6838 , p_adr_type_code => 'S'
6839 , p_component_type => l_component_type
6840 , p_component_code => l_component_code
6841 , p_component_type_code => l_component_type_code
6845 );
6842 , p_component_appl_id => l_component_appl_id
6843 , p_amb_context_code => l_amb_context_code
6844 , p_side => 'NA'
6846
6847
6848 --
6849 --
6850 END IF;
6851
6852 --
6853 -- Update the line information that should be overwritten
6854 --
6855 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
6856 p_header_num => 1);
6857 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
6858
6859 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
6860
6861 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
6862 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
6863 END IF;
6864
6865 --
6866 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
6867 --
6868 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
6869 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
6870 ELSE
6871 ---------------------------------------------------------------------------------------------------
6872 -- 4262811a Switch Sign
6873 ---------------------------------------------------------------------------------------------------
6874 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
6875 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6876 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6877 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6878 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6879 -- 5132302
6880 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
6881 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6882
6883 END IF;
6884
6885 -- 4955764
6886 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6887 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
6888
6889
6890 XLA_AE_LINES_PKG.ValidateCurrentLine;
6891 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6892
6893 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6894 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
6895 ,p_balance_type_code => l_balance_type_code);
6896
6897 END IF;
6898
6899 -----------------------------------------------------------------------------------------
6900 -- 4262811 Multiperiod Accounting
6901 -----------------------------------------------------------------------------------------
6902 -- No MPA option is assigned.
6903
6904
6905 END IF;
6906 END IF;
6907 --
6908
6909 --
6910 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6911 trace
6912 (p_msg => 'END of AcctLineType_38'
6913 ,p_level => C_LEVEL_PROCEDURE
6914 ,p_module => l_log_module);
6915 END IF;
6916 --
6917 EXCEPTION
6918 WHEN xla_exceptions_pkg.application_exception THEN
6919 RAISE;
6920 WHEN OTHERS THEN
6921 xla_exceptions_pkg.raise_message
6922 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_38');
6923 END AcctLineType_38;
6924 --
6925
6926 ---------------------------------------
6927 --
6928 -- PRIVATE FUNCTION
6929 -- AcctLineType_39
6930 --
6931 ---------------------------------------
6932 PROCEDURE AcctLineType_39 (
6933 p_application_id IN NUMBER
6934 ,p_event_id IN NUMBER
6935 ,p_calculate_acctd_flag IN VARCHAR2
6936 ,p_calculate_g_l_flag IN VARCHAR2
6937 ,p_actual_flag IN OUT VARCHAR2
6938 ,p_balance_type_code OUT VARCHAR2
6939 ,p_gain_or_loss_ref OUT VARCHAR2
6940
6941 --Transaction Distribution GL Account
6942 , p_source_21 IN NUMBER
6943 --Bill To Customer Account Identifier
6944 , p_source_32 IN NUMBER
6945 --Bill To Customer Site Use Identifier
6946 , p_source_33 IN NUMBER
6947 --SLA Party Type
6948 , p_source_34 IN VARCHAR2
6949 --Transaction Distribution Account Class
6950 , p_source_35 IN VARCHAR2
6951 --Transaction Distribution Identifier
6952 , p_source_36 IN NUMBER
6953 --Transaction Distribution Type
6954 , p_source_37 IN VARCHAR2
6955 --Transaction Distribution Entered Amount
6956 , p_source_38 IN NUMBER
6957 --Transaction Currency Code
6958 , p_source_39 IN VARCHAR2
6959 --Transaction Exchange Date
6960 , p_source_40 IN DATE
6961 --Transaction Exchange Rate
6962 , p_source_41 IN NUMBER
6963 --Transaction Exchange Rate Type
6964 , p_source_42 IN VARCHAR2
6965 --Transaction Accounting Amount
6966 , p_source_43 IN NUMBER
6967 )
6968 IS
6969
6970 l_component_type VARCHAR2(80);
6974 l_amb_context_code VARCHAR2(30);
6971 l_component_code VARCHAR2(30);
6972 l_component_type_code VARCHAR2(1);
6973 l_component_appl_id INTEGER;
6975 l_entity_code VARCHAR2(30);
6976 l_event_class_code VARCHAR2(30);
6977 l_ae_header_id NUMBER;
6978 l_event_type_code VARCHAR2(30);
6979 l_line_definition_code VARCHAR2(30);
6980 l_line_definition_owner_code VARCHAR2(1);
6981 --
6982 -- adr variables
6983 l_segment VARCHAR2(30);
6984 l_ccid NUMBER;
6985 l_adr_transaction_coa_id NUMBER;
6986 l_adr_accounting_coa_id NUMBER;
6987 l_adr_flexfield_segment_code VARCHAR2(30);
6988 l_adr_flex_value_set_id NUMBER;
6989 l_adr_value_type_code VARCHAR2(30);
6990 l_adr_value_combination_id NUMBER;
6991 l_adr_value_segment_code VARCHAR2(30);
6992
6993 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
6994 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
6995 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
6996 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
6997
6998 -- 4262811 Variables ------------------------------------------------------------------------------------------
6999 l_entered_amt_idx NUMBER;
7000 l_accted_amt_idx NUMBER;
7001 l_acc_rev_flag VARCHAR2(1);
7002 l_accrual_line_num NUMBER;
7003 l_tmp_amt NUMBER;
7004 l_acc_rev_natural_side_code VARCHAR2(1);
7005
7006 l_num_entries NUMBER;
7007 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
7008 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
7009 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
7010 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
7011 l_recog_line_1 NUMBER;
7012 l_recog_line_2 NUMBER;
7013
7014 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
7015 l_bflow_applied_to_amt NUMBER; -- 5132302
7016 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
7017
7018 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
7019
7020 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
7021 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
7022
7023 ---------------------------------------------------------------------------------------------------------------
7024
7025
7026 --
7027 -- bulk performance
7028 --
7029 l_balance_type_code VARCHAR2(1);
7030 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
7031 l_log_module VARCHAR2(240);
7032
7033 --
7034 -- Upgrade strategy
7035 --
7036 l_actual_upg_option VARCHAR2(1);
7037 l_enc_upg_option VARCHAR2(1);
7038
7039 --
7040 BEGIN
7041 --
7042 IF g_log_enabled THEN
7043 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_39';
7044 END IF;
7045 --
7046 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7047
7048 trace
7049 (p_msg => 'BEGIN of AcctLineType_39'
7050 ,p_level => C_LEVEL_PROCEDURE
7051 ,p_module => l_log_module);
7052
7053 END IF;
7054 --
7055 l_component_type := 'AMB_JLT';
7056 l_component_code := 'CB_DEFAULT_REC';
7057 l_component_type_code := 'S';
7058 l_component_appl_id := 222;
7059 l_amb_context_code := 'DEFAULT';
7060 l_entity_code := 'TRANSACTIONS';
7061 l_event_class_code := 'CHARGEBACK';
7062 l_event_type_code := 'CHARGEBACK_ALL';
7063 l_line_definition_owner_code := 'S';
7064 l_line_definition_code := 'AR_CB_DEFAULT_ACCRUAL';
7065 --
7066 l_balance_type_code := 'A';
7067 l_segment := NULL;
7068 l_ccid := NULL;
7069 l_adr_transaction_coa_id := NULL;
7070 l_adr_accounting_coa_id := NULL;
7071 l_adr_flexfield_segment_code := NULL;
7072 l_adr_flex_value_set_id := NULL;
7073 l_adr_value_type_code := NULL;
7074 l_adr_value_combination_id := NULL;
7075 l_adr_value_segment_code := NULL;
7076
7077 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
7078 l_bflow_class_code := ''; -- 4219869 Business Flow
7079 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
7080 l_budgetary_control_flag := 'N';
7081
7082 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7083 l_bflow_applied_to_amt := NULL; -- 5132302
7084 l_entered_amt_idx := NULL; -- 4262811
7085 l_accted_amt_idx := NULL; -- 4262811
7086 l_acc_rev_flag := NULL; -- 4262811
7087 l_accrual_line_num := NULL; -- 4262811
7088 l_tmp_amt := NULL; -- 4262811
7089 --
7090
7091 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
7092 l_balance_type_code <> 'B' THEN
7093 IF NVL(p_source_35,'
7094 ') = 'REC'
7095 THEN
7096
7097 --
7098 XLA_AE_LINES_PKG.SetNewLine;
7099
7100 p_balance_type_code := l_balance_type_code;
7104 p_actual_flag :='A';
7101 -- set the flag so later we will know whether the gain loss line needs to be created
7102
7103 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
7105 END IF;
7106
7107 --
7108 -- bulk performance
7109 --
7110 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
7111 p_header_num => 0); -- 4262811
7112 --
7113 -- set accounting line options
7114 --
7115 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
7116 p_natural_side_code => 'D'
7117 , p_gain_or_loss_flag => 'N'
7118 , p_gl_transfer_mode_code => 'S'
7119 , p_acct_entry_type_code => 'A'
7120 , p_switch_side_flag => 'Y'
7121 , p_merge_duplicate_code => 'A'
7122 );
7123 --
7124 l_acc_rev_natural_side_code := 'C'; -- 4262811
7125 --
7126 --
7127 -- set accounting line type info
7128 --
7129 xla_ae_lines_pkg.SetAcctLineType
7130 (p_component_type => l_component_type
7131 ,p_event_type_code => l_event_type_code
7132 ,p_line_definition_owner_code => l_line_definition_owner_code
7133 ,p_line_definition_code => l_line_definition_code
7134 ,p_accounting_line_code => l_component_code
7135 ,p_accounting_line_type_code => l_component_type_code
7136 ,p_accounting_line_appl_id => l_component_appl_id
7137 ,p_amb_context_code => l_amb_context_code
7138 ,p_entity_code => l_entity_code
7139 ,p_event_class_code => l_event_class_code);
7140 --
7141 -- set accounting class
7142 --
7143 xla_ae_lines_pkg.SetAcctClass(
7144 p_accounting_class_code => 'RECEIVABLE'
7145 , p_ae_header_id => l_ae_header_id
7146 );
7147
7148 --
7149 -- set rounding class
7150 --
7151 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
7152 'RECEIVABLE';
7153
7154 --
7155 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
7156 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
7157 --
7158 -- bulk performance
7159 --
7160 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
7161
7162 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
7163 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
7164
7165 -- 4955764
7166 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7167 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
7168
7169 -- 4458381 Public Sector Enh
7170
7171 --
7172 -- set accounting attributes for the line type
7173 --
7174 l_entered_amt_idx := 3;
7175 l_accted_amt_idx := 8;
7176 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7177 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
7178 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
7179 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
7180 l_rec_acct_attrs.array_char_value(2) := p_source_37;
7181 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
7182 l_rec_acct_attrs.array_num_value(3) := p_source_38;
7183 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
7184 l_rec_acct_attrs.array_char_value(4) := p_source_39;
7185 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
7186 l_rec_acct_attrs.array_date_value(5) := p_source_40;
7187 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
7188 l_rec_acct_attrs.array_num_value(6) := p_source_41;
7189 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
7190 l_rec_acct_attrs.array_char_value(7) := p_source_42;
7191 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
7192 l_rec_acct_attrs.array_num_value(8) := p_source_43;
7193 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
7194 l_rec_acct_attrs.array_num_value(9) := p_source_32;
7195 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
7196 l_rec_acct_attrs.array_num_value(10) := p_source_33;
7197 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
7198 l_rec_acct_attrs.array_char_value(11) := p_source_34;
7199
7200 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
7201 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
7202
7203 ---------------------------------------------------------------------------------------------------------------
7204 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
7205 ---------------------------------------------------------------------------------------------------------------
7206 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
7207
7208 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7212 (p_source_code => 'LEDGER_CATEGORY_CODE'
7209 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7210
7211 IF xla_accounting_cache_pkg.GetValueChar
7213 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
7214 AND l_bflow_method_code = 'PRIOR_ENTRY'
7215 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
7216 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
7217 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
7218 )
7219 THEN
7220 xla_ae_lines_pkg.BflowUpgEntry
7221 (p_business_method_code => l_bflow_method_code
7222 ,p_business_class_code => l_bflow_class_code
7223 ,p_balance_type => l_balance_type_code);
7224 ELSE
7225 NULL;
7226 -- No business flow processing for business flow method of NONE.
7227 END IF;
7228
7229 --
7230 -- call analytical criteria
7231 --
7232
7233 --
7234 -- call description
7235 --
7236 -- No description or it is inherited.
7237 --
7238 -- call ADRs
7239 -- Bug 4922099
7240 --
7241 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7242 (NVL(l_actual_upg_option, 'N') = 'O') OR
7243 (NVL(l_enc_upg_option, 'N') = 'O')
7244 )
7245 THEN
7246 NULL;
7247 --
7248 --
7249
7250 l_ccid := AcctDerRule_34(
7251 p_application_id => p_application_id
7252 , p_ae_header_id => l_ae_header_id
7253 , p_source_21 => p_source_21
7254 , x_transaction_coa_id => l_adr_transaction_coa_id
7255 , x_accounting_coa_id => l_adr_accounting_coa_id
7256 , x_value_type_code => l_adr_value_type_code
7257 , p_side => 'NA'
7258 );
7259
7260 xla_ae_lines_pkg.set_ccid(
7261 p_code_combination_id => l_ccid
7262 , p_value_type_code => l_adr_value_type_code
7263 , p_transaction_coa_id => l_adr_transaction_coa_id
7264 , p_accounting_coa_id => l_adr_accounting_coa_id
7265 , p_adr_code => 'TRX_DIST_CCID'
7266 , p_adr_type_code => 'S'
7267 , p_component_type => l_component_type
7268 , p_component_code => l_component_code
7269 , p_component_type_code => l_component_type_code
7270 , p_component_appl_id => l_component_appl_id
7271 , p_amb_context_code => l_amb_context_code
7272 , p_side => 'NA'
7273 );
7274
7275
7276 --
7277 --
7278 END IF;
7279 --
7280 -- Bug 4922099
7281 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
7282 (NVL(l_enc_upg_option, 'N') = 'O')
7283 ) AND
7284 (l_bflow_method_code = 'PRIOR_ENTRY')
7285 )
7286 THEN
7287 IF
7288 --
7289 1 = 2
7290 --
7291 THEN
7292 xla_accounting_err_pkg.build_message
7293 (p_appli_s_name => 'XLA'
7294 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7295 ,p_token_1 => 'LINE_NUMBER'
7296 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
7297 ,p_token_2 => 'LINE_TYPE_NAME'
7298 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
7299 l_component_type
7300 ,l_component_code
7301 ,l_component_type_code
7302 ,l_component_appl_id
7303 ,l_amb_context_code
7304 ,l_entity_code
7305 ,l_event_class_code
7306 )
7307 ,p_token_3 => 'OWNER'
7308 ,p_value_3 => xla_lookups_pkg.get_meaning(
7309 p_lookup_type => 'XLA_OWNER_TYPE'
7310 ,p_lookup_code => l_component_type_code
7311 )
7312 ,p_token_4 => 'PRODUCT_NAME'
7313 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
7314 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
7315 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
7316 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
7317 ,p_ae_header_id => NULL
7318 );
7319
7320 IF (C_LEVEL_ERROR>= g_log_level) THEN
7321 trace
7325 END IF;
7322 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7323 ,p_level => C_LEVEL_ERROR
7324 ,p_module => l_log_module);
7326 END IF;
7327 END IF;
7328 --
7329 --
7330 ------------------------------------------------------------------------------------------------
7331 -- 4219869 Business Flow
7332 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
7333 -- Prior Entry. Currently, the following code is always generated.
7334 ------------------------------------------------------------------------------------------------
7335 XLA_AE_LINES_PKG.ValidateCurrentLine;
7336
7337 ------------------------------------------------------------------------------------
7338 -- 4219869 Business Flow
7339 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
7340 ------------------------------------------------------------------------------------
7341 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7342
7343 ----------------------------------------------------------------------------------
7344 -- 4219869 Business Flow
7345 -- Update journal entry status -- Need to generate this within IF <condition>
7346 ----------------------------------------------------------------------------------
7347 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7348 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
7349 ,p_balance_type_code => l_balance_type_code
7350 );
7351
7352 -------------------------------------------------------------------------------------------
7353 -- 4262811 - Generate the Accrual Reversal lines
7354 -------------------------------------------------------------------------------------------
7355 BEGIN
7356 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
7357 (g_array_event(p_event_id).array_value_num('header_index'));
7358 IF l_acc_rev_flag IS NULL THEN
7359 l_acc_rev_flag := 'N';
7360 END IF;
7361 EXCEPTION
7362 WHEN OTHERS THEN
7363 l_acc_rev_flag := 'N';
7364 END;
7365 --
7366 IF (l_acc_rev_flag = 'Y') THEN
7367
7368 -- 4645092 ------------------------------------------------------------------------------
7369 -- To allow MPA report to determine if it should generate report process
7370 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
7371 ------------------------------------------------------------------------------------------
7372
7373 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
7374 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
7375 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
7376 -- call ADRs
7377 -- Bug 4922099
7378 --
7379 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7380 (NVL(l_actual_upg_option, 'N') = 'O') OR
7381 (NVL(l_enc_upg_option, 'N') = 'O')
7382 )
7383 THEN
7384 NULL;
7385 --
7386 --
7387
7388 l_ccid := AcctDerRule_34(
7389 p_application_id => p_application_id
7390 , p_ae_header_id => l_ae_header_id
7391 , p_source_21 => p_source_21
7392 , x_transaction_coa_id => l_adr_transaction_coa_id
7393 , x_accounting_coa_id => l_adr_accounting_coa_id
7394 , x_value_type_code => l_adr_value_type_code
7395 , p_side => 'NA'
7396 );
7397
7398 xla_ae_lines_pkg.set_ccid(
7399 p_code_combination_id => l_ccid
7400 , p_value_type_code => l_adr_value_type_code
7401 , p_transaction_coa_id => l_adr_transaction_coa_id
7402 , p_accounting_coa_id => l_adr_accounting_coa_id
7403 , p_adr_code => 'TRX_DIST_CCID'
7404 , p_adr_type_code => 'S'
7405 , p_component_type => l_component_type
7406 , p_component_code => l_component_code
7407 , p_component_type_code => l_component_type_code
7408 , p_component_appl_id => l_component_appl_id
7409 , p_amb_context_code => l_amb_context_code
7410 , p_side => 'NA'
7411 );
7412
7413
7414 --
7415 --
7416 END IF;
7417
7418 --
7419 -- Update the line information that should be overwritten
7420 --
7421 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
7422 p_header_num => 1);
7423 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
7424
7425 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
7426
7427 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
7428 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
7429 END IF;
7430
7431 --
7432 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
7433 --
7434 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
7435 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
7436 ELSE
7440 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
7437 ---------------------------------------------------------------------------------------------------
7438 -- 4262811a Switch Sign
7439 ---------------------------------------------------------------------------------------------------
7441 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7442 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7443 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7444 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7445 -- 5132302
7446 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
7447 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7448
7449 END IF;
7450
7451 -- 4955764
7452 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7453 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
7454
7455
7456 XLA_AE_LINES_PKG.ValidateCurrentLine;
7457 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7458
7459 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7460 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
7461 ,p_balance_type_code => l_balance_type_code);
7462
7463 END IF;
7464
7465 -----------------------------------------------------------------------------------------
7466 -- 4262811 Multiperiod Accounting
7467 -----------------------------------------------------------------------------------------
7468 -- No MPA option is assigned.
7469
7470
7471 END IF;
7472 END IF;
7473 --
7474
7475 --
7476 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7477 trace
7478 (p_msg => 'END of AcctLineType_39'
7479 ,p_level => C_LEVEL_PROCEDURE
7480 ,p_module => l_log_module);
7481 END IF;
7482 --
7483 EXCEPTION
7484 WHEN xla_exceptions_pkg.application_exception THEN
7485 RAISE;
7486 WHEN OTHERS THEN
7487 xla_exceptions_pkg.raise_message
7488 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_39');
7489 END AcctLineType_39;
7490 --
7491
7492 ---------------------------------------
7493 --
7494 -- PRIVATE FUNCTION
7495 -- AcctLineType_40
7496 --
7497 ---------------------------------------
7498 PROCEDURE AcctLineType_40 (
7499 p_application_id IN NUMBER
7500 ,p_event_id IN NUMBER
7501 ,p_calculate_acctd_flag IN VARCHAR2
7502 ,p_calculate_g_l_flag IN VARCHAR2
7503 ,p_actual_flag IN OUT VARCHAR2
7504 ,p_balance_type_code OUT VARCHAR2
7505 ,p_gain_or_loss_ref OUT VARCHAR2
7506
7507 --Transaction Distribution GL Account
7508 , p_source_21 IN NUMBER
7509 --Bill To Customer Account Identifier
7510 , p_source_32 IN NUMBER
7511 --Bill To Customer Site Use Identifier
7512 , p_source_33 IN NUMBER
7513 --SLA Party Type
7514 , p_source_34 IN VARCHAR2
7515 --Transaction Distribution Account Class
7516 , p_source_35 IN VARCHAR2
7517 --Transaction Distribution Identifier
7518 , p_source_36 IN NUMBER
7519 --Transaction Distribution Type
7520 , p_source_37 IN VARCHAR2
7521 --Transaction Distribution Entered Amount
7522 , p_source_38 IN NUMBER
7523 --Transaction Currency Code
7524 , p_source_39 IN VARCHAR2
7525 --Transaction Exchange Date
7526 , p_source_40 IN DATE
7527 --Transaction Exchange Rate
7528 , p_source_41 IN NUMBER
7529 --Transaction Exchange Rate Type
7530 , p_source_42 IN VARCHAR2
7531 --Transaction Accounting Amount
7532 , p_source_43 IN NUMBER
7533 )
7534 IS
7535
7536 l_component_type VARCHAR2(80);
7537 l_component_code VARCHAR2(30);
7538 l_component_type_code VARCHAR2(1);
7539 l_component_appl_id INTEGER;
7540 l_amb_context_code VARCHAR2(30);
7541 l_entity_code VARCHAR2(30);
7542 l_event_class_code VARCHAR2(30);
7543 l_ae_header_id NUMBER;
7544 l_event_type_code VARCHAR2(30);
7545 l_line_definition_code VARCHAR2(30);
7546 l_line_definition_owner_code VARCHAR2(1);
7547 --
7548 -- adr variables
7549 l_segment VARCHAR2(30);
7550 l_ccid NUMBER;
7551 l_adr_transaction_coa_id NUMBER;
7552 l_adr_accounting_coa_id NUMBER;
7553 l_adr_flexfield_segment_code VARCHAR2(30);
7554 l_adr_flex_value_set_id NUMBER;
7555 l_adr_value_type_code VARCHAR2(30);
7556 l_adr_value_combination_id NUMBER;
7557 l_adr_value_segment_code VARCHAR2(30);
7558
7559 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
7560 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
7561 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
7562 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
7563
7567 l_acc_rev_flag VARCHAR2(1);
7564 -- 4262811 Variables ------------------------------------------------------------------------------------------
7565 l_entered_amt_idx NUMBER;
7566 l_accted_amt_idx NUMBER;
7568 l_accrual_line_num NUMBER;
7569 l_tmp_amt NUMBER;
7570 l_acc_rev_natural_side_code VARCHAR2(1);
7571
7572 l_num_entries NUMBER;
7573 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
7574 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
7575 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
7576 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
7577 l_recog_line_1 NUMBER;
7578 l_recog_line_2 NUMBER;
7579
7580 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
7581 l_bflow_applied_to_amt NUMBER; -- 5132302
7582 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
7583
7584 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
7585
7586 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
7587 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
7588
7589 ---------------------------------------------------------------------------------------------------------------
7590
7591
7592 --
7593 -- bulk performance
7594 --
7595 l_balance_type_code VARCHAR2(1);
7596 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
7597 l_log_module VARCHAR2(240);
7598
7599 --
7600 -- Upgrade strategy
7601 --
7602 l_actual_upg_option VARCHAR2(1);
7603 l_enc_upg_option VARCHAR2(1);
7604
7605 --
7606 BEGIN
7607 --
7608 IF g_log_enabled THEN
7609 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_40';
7610 END IF;
7611 --
7612 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7613
7614 trace
7615 (p_msg => 'BEGIN of AcctLineType_40'
7616 ,p_level => C_LEVEL_PROCEDURE
7617 ,p_module => l_log_module);
7618
7619 END IF;
7620 --
7621 l_component_type := 'AMB_JLT';
7622 l_component_code := 'CB_REV';
7623 l_component_type_code := 'S';
7624 l_component_appl_id := 222;
7625 l_amb_context_code := 'DEFAULT';
7626 l_entity_code := 'TRANSACTIONS';
7627 l_event_class_code := 'CHARGEBACK';
7628 l_event_type_code := 'CHARGEBACK_ALL';
7629 l_line_definition_owner_code := 'S';
7630 l_line_definition_code := 'AR_CB_DEFAULT_ACCRUAL';
7631 --
7632 l_balance_type_code := 'A';
7633 l_segment := NULL;
7634 l_ccid := NULL;
7635 l_adr_transaction_coa_id := NULL;
7636 l_adr_accounting_coa_id := NULL;
7637 l_adr_flexfield_segment_code := NULL;
7638 l_adr_flex_value_set_id := NULL;
7639 l_adr_value_type_code := NULL;
7640 l_adr_value_combination_id := NULL;
7641 l_adr_value_segment_code := NULL;
7642
7643 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
7644 l_bflow_class_code := ''; -- 4219869 Business Flow
7645 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
7646 l_budgetary_control_flag := 'N';
7647
7648 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7649 l_bflow_applied_to_amt := NULL; -- 5132302
7650 l_entered_amt_idx := NULL; -- 4262811
7651 l_accted_amt_idx := NULL; -- 4262811
7652 l_acc_rev_flag := NULL; -- 4262811
7653 l_accrual_line_num := NULL; -- 4262811
7654 l_tmp_amt := NULL; -- 4262811
7655 --
7656
7657 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
7658 l_balance_type_code <> 'B' THEN
7659 IF NVL(p_source_35,'
7660 ') = 'REV'
7661 THEN
7662
7663 --
7664 XLA_AE_LINES_PKG.SetNewLine;
7665
7666 p_balance_type_code := l_balance_type_code;
7667 -- set the flag so later we will know whether the gain loss line needs to be created
7668
7669 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
7670 p_actual_flag :='A';
7671 END IF;
7672
7673 --
7674 -- bulk performance
7675 --
7676 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
7677 p_header_num => 0); -- 4262811
7678 --
7679 -- set accounting line options
7680 --
7681 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
7682 p_natural_side_code => 'C'
7683 , p_gain_or_loss_flag => 'N'
7684 , p_gl_transfer_mode_code => 'S'
7685 , p_acct_entry_type_code => 'A'
7686 , p_switch_side_flag => 'Y'
7687 , p_merge_duplicate_code => 'A'
7688 );
7689 --
7690 l_acc_rev_natural_side_code := 'D'; -- 4262811
7691 --
7692 --
7693 -- set accounting line type info
7694 --
7695 xla_ae_lines_pkg.SetAcctLineType
7696 (p_component_type => l_component_type
7700 ,p_accounting_line_code => l_component_code
7697 ,p_event_type_code => l_event_type_code
7698 ,p_line_definition_owner_code => l_line_definition_owner_code
7699 ,p_line_definition_code => l_line_definition_code
7701 ,p_accounting_line_type_code => l_component_type_code
7702 ,p_accounting_line_appl_id => l_component_appl_id
7703 ,p_amb_context_code => l_amb_context_code
7704 ,p_entity_code => l_entity_code
7705 ,p_event_class_code => l_event_class_code);
7706 --
7707 -- set accounting class
7708 --
7709 xla_ae_lines_pkg.SetAcctClass(
7710 p_accounting_class_code => 'REVENUE'
7711 , p_ae_header_id => l_ae_header_id
7712 );
7713
7714 --
7715 -- set rounding class
7716 --
7717 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
7718 'RECEIVABLE';
7719
7720 --
7721 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
7722 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
7723 --
7724 -- bulk performance
7725 --
7726 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
7727
7728 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
7729 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
7730
7731 -- 4955764
7732 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7733 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
7734
7735 -- 4458381 Public Sector Enh
7736
7737 --
7738 -- set accounting attributes for the line type
7739 --
7740 l_entered_amt_idx := 3;
7741 l_accted_amt_idx := 8;
7742 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7743 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
7744 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
7745 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
7746 l_rec_acct_attrs.array_char_value(2) := p_source_37;
7747 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
7748 l_rec_acct_attrs.array_num_value(3) := p_source_38;
7749 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
7750 l_rec_acct_attrs.array_char_value(4) := p_source_39;
7751 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
7752 l_rec_acct_attrs.array_date_value(5) := p_source_40;
7753 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
7754 l_rec_acct_attrs.array_num_value(6) := p_source_41;
7755 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
7756 l_rec_acct_attrs.array_char_value(7) := p_source_42;
7757 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
7758 l_rec_acct_attrs.array_num_value(8) := p_source_43;
7759 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
7760 l_rec_acct_attrs.array_num_value(9) := p_source_32;
7761 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
7762 l_rec_acct_attrs.array_num_value(10) := p_source_33;
7763 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
7764 l_rec_acct_attrs.array_char_value(11) := p_source_34;
7765
7766 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
7767 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
7768
7769 ---------------------------------------------------------------------------------------------------------------
7770 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
7771 ---------------------------------------------------------------------------------------------------------------
7772 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
7773
7774 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7775 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7776
7777 IF xla_accounting_cache_pkg.GetValueChar
7778 (p_source_code => 'LEDGER_CATEGORY_CODE'
7779 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
7780 AND l_bflow_method_code = 'PRIOR_ENTRY'
7781 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
7782 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
7783 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
7784 )
7785 THEN
7786 xla_ae_lines_pkg.BflowUpgEntry
7787 (p_business_method_code => l_bflow_method_code
7788 ,p_business_class_code => l_bflow_class_code
7789 ,p_balance_type => l_balance_type_code);
7790 ELSE
7791 NULL;
7792 -- No business flow processing for business flow method of NONE.
7793 END IF;
7794
7795 --
7796 -- call analytical criteria
7797 --
7798
7799 --
7800 -- call description
7801 --
7802 -- No description or it is inherited.
7803 --
7804 -- call ADRs
7805 -- Bug 4922099
7806 --
7810 )
7807 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7808 (NVL(l_actual_upg_option, 'N') = 'O') OR
7809 (NVL(l_enc_upg_option, 'N') = 'O')
7811 THEN
7812 NULL;
7813 --
7814 --
7815
7816 l_ccid := AcctDerRule_34(
7817 p_application_id => p_application_id
7818 , p_ae_header_id => l_ae_header_id
7819 , p_source_21 => p_source_21
7820 , x_transaction_coa_id => l_adr_transaction_coa_id
7821 , x_accounting_coa_id => l_adr_accounting_coa_id
7822 , x_value_type_code => l_adr_value_type_code
7823 , p_side => 'NA'
7824 );
7825
7826 xla_ae_lines_pkg.set_ccid(
7827 p_code_combination_id => l_ccid
7828 , p_value_type_code => l_adr_value_type_code
7829 , p_transaction_coa_id => l_adr_transaction_coa_id
7830 , p_accounting_coa_id => l_adr_accounting_coa_id
7831 , p_adr_code => 'TRX_DIST_CCID'
7832 , p_adr_type_code => 'S'
7833 , p_component_type => l_component_type
7834 , p_component_code => l_component_code
7835 , p_component_type_code => l_component_type_code
7836 , p_component_appl_id => l_component_appl_id
7837 , p_amb_context_code => l_amb_context_code
7838 , p_side => 'NA'
7839 );
7840
7841
7842 --
7843 --
7844 END IF;
7845 --
7846 -- Bug 4922099
7847 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
7848 (NVL(l_enc_upg_option, 'N') = 'O')
7849 ) AND
7850 (l_bflow_method_code = 'PRIOR_ENTRY')
7851 )
7852 THEN
7853 IF
7854 --
7855 1 = 2
7856 --
7857 THEN
7858 xla_accounting_err_pkg.build_message
7859 (p_appli_s_name => 'XLA'
7860 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7861 ,p_token_1 => 'LINE_NUMBER'
7862 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
7863 ,p_token_2 => 'LINE_TYPE_NAME'
7864 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
7865 l_component_type
7866 ,l_component_code
7867 ,l_component_type_code
7868 ,l_component_appl_id
7869 ,l_amb_context_code
7870 ,l_entity_code
7871 ,l_event_class_code
7872 )
7873 ,p_token_3 => 'OWNER'
7874 ,p_value_3 => xla_lookups_pkg.get_meaning(
7875 p_lookup_type => 'XLA_OWNER_TYPE'
7876 ,p_lookup_code => l_component_type_code
7877 )
7878 ,p_token_4 => 'PRODUCT_NAME'
7879 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
7880 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
7881 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
7882 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
7883 ,p_ae_header_id => NULL
7884 );
7885
7886 IF (C_LEVEL_ERROR>= g_log_level) THEN
7887 trace
7888 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7889 ,p_level => C_LEVEL_ERROR
7890 ,p_module => l_log_module);
7891 END IF;
7892 END IF;
7893 END IF;
7894 --
7895 --
7896 ------------------------------------------------------------------------------------------------
7897 -- 4219869 Business Flow
7898 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
7899 -- Prior Entry. Currently, the following code is always generated.
7900 ------------------------------------------------------------------------------------------------
7901 XLA_AE_LINES_PKG.ValidateCurrentLine;
7902
7903 ------------------------------------------------------------------------------------
7904 -- 4219869 Business Flow
7905 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
7906 ------------------------------------------------------------------------------------
7907 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7908
7909 ----------------------------------------------------------------------------------
7913 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7910 -- 4219869 Business Flow
7911 -- Update journal entry status -- Need to generate this within IF <condition>
7912 ----------------------------------------------------------------------------------
7914 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
7915 ,p_balance_type_code => l_balance_type_code
7916 );
7917
7918 -------------------------------------------------------------------------------------------
7919 -- 4262811 - Generate the Accrual Reversal lines
7920 -------------------------------------------------------------------------------------------
7921 BEGIN
7922 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
7923 (g_array_event(p_event_id).array_value_num('header_index'));
7924 IF l_acc_rev_flag IS NULL THEN
7925 l_acc_rev_flag := 'N';
7926 END IF;
7927 EXCEPTION
7928 WHEN OTHERS THEN
7929 l_acc_rev_flag := 'N';
7930 END;
7931 --
7932 IF (l_acc_rev_flag = 'Y') THEN
7933
7934 -- 4645092 ------------------------------------------------------------------------------
7935 -- To allow MPA report to determine if it should generate report process
7936 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
7937 ------------------------------------------------------------------------------------------
7938
7939 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
7940 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
7941 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
7942 -- call ADRs
7943 -- Bug 4922099
7944 --
7945 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7946 (NVL(l_actual_upg_option, 'N') = 'O') OR
7947 (NVL(l_enc_upg_option, 'N') = 'O')
7948 )
7949 THEN
7950 NULL;
7951 --
7952 --
7953
7954 l_ccid := AcctDerRule_34(
7955 p_application_id => p_application_id
7956 , p_ae_header_id => l_ae_header_id
7957 , p_source_21 => p_source_21
7958 , x_transaction_coa_id => l_adr_transaction_coa_id
7959 , x_accounting_coa_id => l_adr_accounting_coa_id
7960 , x_value_type_code => l_adr_value_type_code
7961 , p_side => 'NA'
7962 );
7963
7964 xla_ae_lines_pkg.set_ccid(
7965 p_code_combination_id => l_ccid
7966 , p_value_type_code => l_adr_value_type_code
7967 , p_transaction_coa_id => l_adr_transaction_coa_id
7968 , p_accounting_coa_id => l_adr_accounting_coa_id
7969 , p_adr_code => 'TRX_DIST_CCID'
7970 , p_adr_type_code => 'S'
7971 , p_component_type => l_component_type
7972 , p_component_code => l_component_code
7973 , p_component_type_code => l_component_type_code
7974 , p_component_appl_id => l_component_appl_id
7975 , p_amb_context_code => l_amb_context_code
7976 , p_side => 'NA'
7977 );
7978
7979
7980 --
7981 --
7982 END IF;
7983
7984 --
7985 -- Update the line information that should be overwritten
7986 --
7987 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
7988 p_header_num => 1);
7989 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
7990
7991 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
7992
7993 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
7994 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
7995 END IF;
7996
7997 --
7998 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
7999 --
8000 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
8001 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
8002 ELSE
8003 ---------------------------------------------------------------------------------------------------
8004 -- 4262811a Switch Sign
8005 ---------------------------------------------------------------------------------------------------
8006 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
8007 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8008 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8009 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8010 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8011 -- 5132302
8012 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
8013 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8014
8015 END IF;
8016
8017 -- 4955764
8021
8018 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8019 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
8020
8022 XLA_AE_LINES_PKG.ValidateCurrentLine;
8023 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8024
8025 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8026 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
8027 ,p_balance_type_code => l_balance_type_code);
8028
8029 END IF;
8030
8031 -----------------------------------------------------------------------------------------
8032 -- 4262811 Multiperiod Accounting
8033 -----------------------------------------------------------------------------------------
8034 -- No MPA option is assigned.
8035
8036
8037 END IF;
8038 END IF;
8039 --
8040
8041 --
8042 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8043 trace
8044 (p_msg => 'END of AcctLineType_40'
8045 ,p_level => C_LEVEL_PROCEDURE
8046 ,p_module => l_log_module);
8047 END IF;
8048 --
8049 EXCEPTION
8050 WHEN xla_exceptions_pkg.application_exception THEN
8051 RAISE;
8052 WHEN OTHERS THEN
8053 xla_exceptions_pkg.raise_message
8054 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_40');
8055 END AcctLineType_40;
8056 --
8057
8058 ---------------------------------------
8059 --
8060 -- PRIVATE FUNCTION
8061 -- AcctLineType_41
8062 --
8063 ---------------------------------------
8064 PROCEDURE AcctLineType_41 (
8065 p_application_id IN NUMBER
8066 ,p_event_id IN NUMBER
8067 ,p_calculate_acctd_flag IN VARCHAR2
8068 ,p_calculate_g_l_flag IN VARCHAR2
8069 ,p_actual_flag IN OUT VARCHAR2
8070 ,p_balance_type_code OUT VARCHAR2
8071 ,p_gain_or_loss_ref OUT VARCHAR2
8072
8073 --Distribution GL Account
8074 , p_source_10 IN NUMBER
8075 --Distribution Source Type
8076 , p_source_22 IN VARCHAR2
8077 --Entered Amount
8078 , p_source_26 IN NUMBER
8079 --SLA Party Type
8080 , p_source_34 IN VARCHAR2
8081 --Credit Memo Distribution Identifier
8082 , p_source_44 IN NUMBER
8083 --Credit memo distributions type
8084 , p_source_45 IN VARCHAR2
8085 --Credit Memo Currency Code
8086 , p_source_46 IN VARCHAR2
8087 --Credit Memo Exchange Date
8088 , p_source_47 IN DATE
8089 --Credit Memo Exchange Rate
8090 , p_source_48 IN NUMBER
8091 --Credit Memo Exchange Rate Type
8092 , p_source_49 IN VARCHAR2
8093 --Gain Loss Reference
8094 , p_source_50 IN VARCHAR2
8095 --Credit Memo Accounting Amount
8096 , p_source_51 IN NUMBER
8097 --Credit Memo Bill To Customer Account Identifier
8098 , p_source_52 IN NUMBER
8099 --Credit Memo Bill To Customer Site Use Identifier
8100 , p_source_53 IN NUMBER
8101 --Credit Memo Tax Line Identifier
8102 , p_source_54 IN NUMBER
8103 )
8104 IS
8105
8106 l_component_type VARCHAR2(80);
8107 l_component_code VARCHAR2(30);
8108 l_component_type_code VARCHAR2(1);
8109 l_component_appl_id INTEGER;
8110 l_amb_context_code VARCHAR2(30);
8111 l_entity_code VARCHAR2(30);
8112 l_event_class_code VARCHAR2(30);
8113 l_ae_header_id NUMBER;
8114 l_event_type_code VARCHAR2(30);
8115 l_line_definition_code VARCHAR2(30);
8116 l_line_definition_owner_code VARCHAR2(1);
8117 --
8118 -- adr variables
8119 l_segment VARCHAR2(30);
8120 l_ccid NUMBER;
8121 l_adr_transaction_coa_id NUMBER;
8122 l_adr_accounting_coa_id NUMBER;
8123 l_adr_flexfield_segment_code VARCHAR2(30);
8124 l_adr_flex_value_set_id NUMBER;
8125 l_adr_value_type_code VARCHAR2(30);
8126 l_adr_value_combination_id NUMBER;
8127 l_adr_value_segment_code VARCHAR2(30);
8128
8129 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
8130 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
8131 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
8132 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
8133
8134 -- 4262811 Variables ------------------------------------------------------------------------------------------
8135 l_entered_amt_idx NUMBER;
8136 l_accted_amt_idx NUMBER;
8137 l_acc_rev_flag VARCHAR2(1);
8138 l_accrual_line_num NUMBER;
8139 l_tmp_amt NUMBER;
8140 l_acc_rev_natural_side_code VARCHAR2(1);
8141
8142 l_num_entries NUMBER;
8143 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
8144 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
8145 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
8146 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
8147 l_recog_line_1 NUMBER;
8148 l_recog_line_2 NUMBER;
8149
8150 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
8151 l_bflow_applied_to_amt NUMBER; -- 5132302
8152 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
8153
8157 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
8154 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
8155
8156 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
8158
8159 ---------------------------------------------------------------------------------------------------------------
8160
8161
8162 --
8163 -- bulk performance
8164 --
8165 l_balance_type_code VARCHAR2(1);
8166 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
8167 l_log_module VARCHAR2(240);
8168
8169 --
8170 -- Upgrade strategy
8171 --
8172 l_actual_upg_option VARCHAR2(1);
8173 l_enc_upg_option VARCHAR2(1);
8174
8175 --
8176 BEGIN
8177 --
8178 IF g_log_enabled THEN
8179 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_41';
8180 END IF;
8181 --
8182 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8183
8184 trace
8185 (p_msg => 'BEGIN of AcctLineType_41'
8186 ,p_level => C_LEVEL_PROCEDURE
8187 ,p_module => l_log_module);
8188
8189 END IF;
8190 --
8191 l_component_type := 'AMB_JLT';
8192 l_component_code := 'CM_APP_DEFAULT_REC';
8193 l_component_type_code := 'S';
8194 l_component_appl_id := 222;
8195 l_amb_context_code := 'DEFAULT';
8196 l_entity_code := 'TRANSACTIONS';
8197 l_event_class_code := 'CREDIT_MEMO';
8198 l_event_type_code := 'CREDIT_MEMO_ALL';
8199 l_line_definition_owner_code := 'S';
8200 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
8201 --
8202 l_balance_type_code := 'A';
8203 l_segment := NULL;
8204 l_ccid := NULL;
8205 l_adr_transaction_coa_id := NULL;
8206 l_adr_accounting_coa_id := NULL;
8207 l_adr_flexfield_segment_code := NULL;
8208 l_adr_flex_value_set_id := NULL;
8209 l_adr_value_type_code := NULL;
8210 l_adr_value_combination_id := NULL;
8211 l_adr_value_segment_code := NULL;
8212
8213 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
8214 l_bflow_class_code := ''; -- 4219869 Business Flow
8215 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
8216 l_budgetary_control_flag := 'N';
8217
8218 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8219 l_bflow_applied_to_amt := NULL; -- 5132302
8220 l_entered_amt_idx := NULL; -- 4262811
8221 l_accted_amt_idx := NULL; -- 4262811
8222 l_acc_rev_flag := NULL; -- 4262811
8223 l_accrual_line_num := NULL; -- 4262811
8224 l_tmp_amt := NULL; -- 4262811
8225 --
8226
8227 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
8228 l_balance_type_code <> 'B' THEN
8229 IF NVL(p_source_22,'
8230 ') = 'REC'
8231 THEN
8232
8233 --
8234 XLA_AE_LINES_PKG.SetNewLine;
8235
8236 p_balance_type_code := l_balance_type_code;
8237 -- set the flag so later we will know whether the gain loss line needs to be created
8238
8239 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
8240 p_actual_flag :='A';
8241 END IF;
8242
8243 --
8244 -- bulk performance
8245 --
8246 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
8247 p_header_num => 0); -- 4262811
8248 --
8249 -- set accounting line options
8250 --
8251 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
8252 p_natural_side_code => 'C'
8253 , p_gain_or_loss_flag => 'N'
8254 , p_gl_transfer_mode_code => 'S'
8255 , p_acct_entry_type_code => 'A'
8256 , p_switch_side_flag => 'Y'
8257 , p_merge_duplicate_code => 'A'
8258 );
8259 --
8260 l_acc_rev_natural_side_code := 'D'; -- 4262811
8261 --
8262 --
8263 -- set accounting line type info
8264 --
8265 xla_ae_lines_pkg.SetAcctLineType
8266 (p_component_type => l_component_type
8267 ,p_event_type_code => l_event_type_code
8268 ,p_line_definition_owner_code => l_line_definition_owner_code
8269 ,p_line_definition_code => l_line_definition_code
8270 ,p_accounting_line_code => l_component_code
8271 ,p_accounting_line_type_code => l_component_type_code
8272 ,p_accounting_line_appl_id => l_component_appl_id
8273 ,p_amb_context_code => l_amb_context_code
8274 ,p_entity_code => l_entity_code
8275 ,p_event_class_code => l_event_class_code);
8276 --
8277 -- set accounting class
8278 --
8279 xla_ae_lines_pkg.SetAcctClass(
8280 p_accounting_class_code => 'RECEIVABLE'
8281 , p_ae_header_id => l_ae_header_id
8282 );
8283
8284 --
8285 -- set rounding class
8286 --
8287 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
8288 'RECEIVABLE';
8289
8290 --
8294 -- bulk performance
8291 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
8292 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
8293 --
8295 --
8296 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
8297
8298 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
8299 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
8300
8301 -- 4955764
8302 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8303 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
8304
8305 -- 4458381 Public Sector Enh
8306
8307 --
8308 -- set accounting attributes for the line type
8309 --
8310 l_entered_amt_idx := 3;
8311 l_accted_amt_idx := 9;
8312 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8313 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
8314 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_44);
8315 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
8316 l_rec_acct_attrs.array_char_value(2) := p_source_45;
8317 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
8318 l_rec_acct_attrs.array_num_value(3) := p_source_26;
8319 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
8320 l_rec_acct_attrs.array_char_value(4) := p_source_46;
8321 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
8322 l_rec_acct_attrs.array_date_value(5) := p_source_47;
8323 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
8324 l_rec_acct_attrs.array_num_value(6) := p_source_48;
8325 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
8326 l_rec_acct_attrs.array_char_value(7) := p_source_49;
8327 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
8328 l_rec_acct_attrs.array_char_value(8) := p_source_50;
8329 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
8330 l_rec_acct_attrs.array_num_value(9) := p_source_51;
8331 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
8332 l_rec_acct_attrs.array_num_value(10) := p_source_52;
8333 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
8334 l_rec_acct_attrs.array_num_value(11) := p_source_53;
8335 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
8336 l_rec_acct_attrs.array_char_value(12) := p_source_34;
8337 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
8338 l_rec_acct_attrs.array_num_value(13) := p_source_54;
8339
8340 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
8341 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
8342
8343 ---------------------------------------------------------------------------------------------------------------
8344 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
8345 ---------------------------------------------------------------------------------------------------------------
8346 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
8347
8348 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8349 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8350
8351 IF xla_accounting_cache_pkg.GetValueChar
8352 (p_source_code => 'LEDGER_CATEGORY_CODE'
8353 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
8354 AND l_bflow_method_code = 'PRIOR_ENTRY'
8355 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
8356 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
8357 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
8358 )
8359 THEN
8360 xla_ae_lines_pkg.BflowUpgEntry
8361 (p_business_method_code => l_bflow_method_code
8362 ,p_business_class_code => l_bflow_class_code
8363 ,p_balance_type => l_balance_type_code);
8364 ELSE
8365 NULL;
8366 -- No business flow processing for business flow method of NONE.
8367 END IF;
8368
8369 --
8370 -- call analytical criteria
8371 --
8372
8373 --
8374 -- call description
8375 --
8376 -- No description or it is inherited.
8377 --
8378 -- call ADRs
8379 -- Bug 4922099
8380 --
8381 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8382 (NVL(l_actual_upg_option, 'N') = 'O') OR
8383 (NVL(l_enc_upg_option, 'N') = 'O')
8384 )
8385 THEN
8386 NULL;
8387 --
8388 --
8389
8390 l_ccid := AcctDerRule_11(
8391 p_application_id => p_application_id
8392 , p_ae_header_id => l_ae_header_id
8393 , p_source_10 => p_source_10
8394 , x_transaction_coa_id => l_adr_transaction_coa_id
8395 , x_accounting_coa_id => l_adr_accounting_coa_id
8396 , x_value_type_code => l_adr_value_type_code
8397 , p_side => 'NA'
8398 );
8399
8400 xla_ae_lines_pkg.set_ccid(
8401 p_code_combination_id => l_ccid
8405 , p_adr_code => 'DIST_CCID'
8402 , p_value_type_code => l_adr_value_type_code
8403 , p_transaction_coa_id => l_adr_transaction_coa_id
8404 , p_accounting_coa_id => l_adr_accounting_coa_id
8406 , p_adr_type_code => 'S'
8407 , p_component_type => l_component_type
8408 , p_component_code => l_component_code
8409 , p_component_type_code => l_component_type_code
8410 , p_component_appl_id => l_component_appl_id
8411 , p_amb_context_code => l_amb_context_code
8412 , p_side => 'NA'
8413 );
8414
8415
8416 --
8417 --
8418 END IF;
8419 --
8420 -- Bug 4922099
8421 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
8422 (NVL(l_enc_upg_option, 'N') = 'O')
8423 ) AND
8424 (l_bflow_method_code = 'PRIOR_ENTRY')
8425 )
8426 THEN
8427 IF
8428 --
8429 1 = 2
8430 --
8431 THEN
8432 xla_accounting_err_pkg.build_message
8433 (p_appli_s_name => 'XLA'
8434 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8435 ,p_token_1 => 'LINE_NUMBER'
8436 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
8437 ,p_token_2 => 'LINE_TYPE_NAME'
8438 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
8439 l_component_type
8440 ,l_component_code
8441 ,l_component_type_code
8442 ,l_component_appl_id
8443 ,l_amb_context_code
8444 ,l_entity_code
8445 ,l_event_class_code
8446 )
8447 ,p_token_3 => 'OWNER'
8448 ,p_value_3 => xla_lookups_pkg.get_meaning(
8449 p_lookup_type => 'XLA_OWNER_TYPE'
8450 ,p_lookup_code => l_component_type_code
8451 )
8452 ,p_token_4 => 'PRODUCT_NAME'
8453 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
8454 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
8455 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
8456 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
8457 ,p_ae_header_id => NULL
8458 );
8459
8460 IF (C_LEVEL_ERROR>= g_log_level) THEN
8461 trace
8462 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8463 ,p_level => C_LEVEL_ERROR
8464 ,p_module => l_log_module);
8465 END IF;
8466 END IF;
8467 END IF;
8468 --
8469 --
8470 ------------------------------------------------------------------------------------------------
8471 -- 4219869 Business Flow
8472 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
8473 -- Prior Entry. Currently, the following code is always generated.
8474 ------------------------------------------------------------------------------------------------
8475 XLA_AE_LINES_PKG.ValidateCurrentLine;
8476
8477 ------------------------------------------------------------------------------------
8478 -- 4219869 Business Flow
8479 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
8480 ------------------------------------------------------------------------------------
8481 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8482
8483 ----------------------------------------------------------------------------------
8484 -- 4219869 Business Flow
8485 -- Update journal entry status -- Need to generate this within IF <condition>
8486 ----------------------------------------------------------------------------------
8487 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8488 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
8489 ,p_balance_type_code => l_balance_type_code
8490 );
8491
8492 -------------------------------------------------------------------------------------------
8493 -- 4262811 - Generate the Accrual Reversal lines
8494 -------------------------------------------------------------------------------------------
8495 BEGIN
8496 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
8500 END IF;
8497 (g_array_event(p_event_id).array_value_num('header_index'));
8498 IF l_acc_rev_flag IS NULL THEN
8499 l_acc_rev_flag := 'N';
8501 EXCEPTION
8502 WHEN OTHERS THEN
8503 l_acc_rev_flag := 'N';
8504 END;
8505 --
8506 IF (l_acc_rev_flag = 'Y') THEN
8507
8508 -- 4645092 ------------------------------------------------------------------------------
8509 -- To allow MPA report to determine if it should generate report process
8510 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
8511 ------------------------------------------------------------------------------------------
8512
8513 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
8514 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
8515 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
8516 -- call ADRs
8517 -- Bug 4922099
8518 --
8519 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8520 (NVL(l_actual_upg_option, 'N') = 'O') OR
8521 (NVL(l_enc_upg_option, 'N') = 'O')
8522 )
8523 THEN
8524 NULL;
8525 --
8526 --
8527
8528 l_ccid := AcctDerRule_11(
8529 p_application_id => p_application_id
8530 , p_ae_header_id => l_ae_header_id
8531 , p_source_10 => p_source_10
8532 , x_transaction_coa_id => l_adr_transaction_coa_id
8533 , x_accounting_coa_id => l_adr_accounting_coa_id
8534 , x_value_type_code => l_adr_value_type_code
8535 , p_side => 'NA'
8536 );
8537
8538 xla_ae_lines_pkg.set_ccid(
8539 p_code_combination_id => l_ccid
8540 , p_value_type_code => l_adr_value_type_code
8541 , p_transaction_coa_id => l_adr_transaction_coa_id
8542 , p_accounting_coa_id => l_adr_accounting_coa_id
8543 , p_adr_code => 'DIST_CCID'
8544 , p_adr_type_code => 'S'
8545 , p_component_type => l_component_type
8546 , p_component_code => l_component_code
8547 , p_component_type_code => l_component_type_code
8548 , p_component_appl_id => l_component_appl_id
8549 , p_amb_context_code => l_amb_context_code
8550 , p_side => 'NA'
8551 );
8552
8553
8554 --
8555 --
8556 END IF;
8557
8558 --
8559 -- Update the line information that should be overwritten
8560 --
8561 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
8562 p_header_num => 1);
8563 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
8564
8565 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
8566
8567 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
8568 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
8569 END IF;
8570
8571 --
8572 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
8573 --
8574 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
8575 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
8576 ELSE
8577 ---------------------------------------------------------------------------------------------------
8578 -- 4262811a Switch Sign
8579 ---------------------------------------------------------------------------------------------------
8580 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
8581 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8582 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8583 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8584 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8585 -- 5132302
8586 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
8587 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8588
8589 END IF;
8590
8591 -- 4955764
8592 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8593 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
8594
8595
8596 XLA_AE_LINES_PKG.ValidateCurrentLine;
8597 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8598
8599 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8600 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
8601 ,p_balance_type_code => l_balance_type_code);
8602
8603 END IF;
8604
8605 -----------------------------------------------------------------------------------------
8606 -- 4262811 Multiperiod Accounting
8607 -----------------------------------------------------------------------------------------
8608 -- No MPA option is assigned.
8612 END IF;
8609
8610
8611 END IF;
8613 --
8614
8615 --
8616 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8617 trace
8618 (p_msg => 'END of AcctLineType_41'
8619 ,p_level => C_LEVEL_PROCEDURE
8620 ,p_module => l_log_module);
8621 END IF;
8622 --
8623 EXCEPTION
8624 WHEN xla_exceptions_pkg.application_exception THEN
8625 RAISE;
8626 WHEN OTHERS THEN
8627 xla_exceptions_pkg.raise_message
8628 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_41');
8629 END AcctLineType_41;
8630 --
8631
8632 ---------------------------------------
8633 --
8634 -- PRIVATE FUNCTION
8635 -- AcctLineType_42
8636 --
8637 ---------------------------------------
8638 PROCEDURE AcctLineType_42 (
8639 p_application_id IN NUMBER
8640 ,p_event_id IN NUMBER
8641 ,p_calculate_acctd_flag IN VARCHAR2
8642 ,p_calculate_g_l_flag IN VARCHAR2
8643 ,p_actual_flag IN OUT VARCHAR2
8644 ,p_balance_type_code OUT VARCHAR2
8645 ,p_gain_or_loss_ref OUT VARCHAR2
8646
8647 --Distribution GL Account
8648 , p_source_10 IN NUMBER
8649 --Distribution Source Type
8650 , p_source_22 IN VARCHAR2
8651 --Receivable Activity Type
8652 , p_source_23 IN VARCHAR2
8653 --Entered Amount
8654 , p_source_26 IN NUMBER
8655 --SLA Party Type
8656 , p_source_34 IN VARCHAR2
8657 --Credit Memo Distribution Identifier
8658 , p_source_44 IN NUMBER
8659 --Credit memo distributions type
8660 , p_source_45 IN VARCHAR2
8661 --Credit Memo Currency Code
8662 , p_source_46 IN VARCHAR2
8663 --Credit Memo Exchange Date
8664 , p_source_47 IN DATE
8665 --Credit Memo Exchange Rate
8666 , p_source_48 IN NUMBER
8667 --Credit Memo Exchange Rate Type
8668 , p_source_49 IN VARCHAR2
8669 --Gain Loss Reference
8670 , p_source_50 IN VARCHAR2
8671 --Credit Memo Accounting Amount
8672 , p_source_51 IN NUMBER
8673 --Credit Memo Bill To Customer Account Identifier
8674 , p_source_52 IN NUMBER
8675 --Credit Memo Bill To Customer Site Use Identifier
8676 , p_source_53 IN NUMBER
8677 --Credit Memo Tax Line Identifier
8678 , p_source_54 IN NUMBER
8679 )
8680 IS
8681
8682 l_component_type VARCHAR2(80);
8683 l_component_code VARCHAR2(30);
8684 l_component_type_code VARCHAR2(1);
8685 l_component_appl_id INTEGER;
8686 l_amb_context_code VARCHAR2(30);
8687 l_entity_code VARCHAR2(30);
8688 l_event_class_code VARCHAR2(30);
8689 l_ae_header_id NUMBER;
8690 l_event_type_code VARCHAR2(30);
8691 l_line_definition_code VARCHAR2(30);
8692 l_line_definition_owner_code VARCHAR2(1);
8693 --
8694 -- adr variables
8695 l_segment VARCHAR2(30);
8696 l_ccid NUMBER;
8697 l_adr_transaction_coa_id NUMBER;
8698 l_adr_accounting_coa_id NUMBER;
8699 l_adr_flexfield_segment_code VARCHAR2(30);
8700 l_adr_flex_value_set_id NUMBER;
8701 l_adr_value_type_code VARCHAR2(30);
8702 l_adr_value_combination_id NUMBER;
8703 l_adr_value_segment_code VARCHAR2(30);
8704
8705 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
8706 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
8707 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
8708 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
8709
8710 -- 4262811 Variables ------------------------------------------------------------------------------------------
8711 l_entered_amt_idx NUMBER;
8712 l_accted_amt_idx NUMBER;
8713 l_acc_rev_flag VARCHAR2(1);
8714 l_accrual_line_num NUMBER;
8715 l_tmp_amt NUMBER;
8716 l_acc_rev_natural_side_code VARCHAR2(1);
8717
8718 l_num_entries NUMBER;
8719 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
8720 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
8721 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
8722 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
8723 l_recog_line_1 NUMBER;
8724 l_recog_line_2 NUMBER;
8725
8726 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
8727 l_bflow_applied_to_amt NUMBER; -- 5132302
8728 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
8729
8730 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
8731
8732 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
8733 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
8734
8735 ---------------------------------------------------------------------------------------------------------------
8736
8737
8738 --
8739 -- bulk performance
8740 --
8741 l_balance_type_code VARCHAR2(1);
8742 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
8743 l_log_module VARCHAR2(240);
8744
8748 l_actual_upg_option VARCHAR2(1);
8745 --
8746 -- Upgrade strategy
8747 --
8749 l_enc_upg_option VARCHAR2(1);
8750
8751 --
8752 BEGIN
8753 --
8754 IF g_log_enabled THEN
8755 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_42';
8756 END IF;
8757 --
8758 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8759
8760 trace
8761 (p_msg => 'BEGIN of AcctLineType_42'
8762 ,p_level => C_LEVEL_PROCEDURE
8763 ,p_module => l_log_module);
8764
8765 END IF;
8766 --
8767 l_component_type := 'AMB_JLT';
8768 l_component_code := 'CM_APP_REFUND';
8769 l_component_type_code := 'S';
8770 l_component_appl_id := 222;
8771 l_amb_context_code := 'DEFAULT';
8772 l_entity_code := 'TRANSACTIONS';
8773 l_event_class_code := 'CREDIT_MEMO';
8774 l_event_type_code := 'CREDIT_MEMO_ALL';
8775 l_line_definition_owner_code := 'S';
8776 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
8777 --
8778 l_balance_type_code := 'A';
8779 l_segment := NULL;
8780 l_ccid := NULL;
8781 l_adr_transaction_coa_id := NULL;
8782 l_adr_accounting_coa_id := NULL;
8783 l_adr_flexfield_segment_code := NULL;
8784 l_adr_flex_value_set_id := NULL;
8785 l_adr_value_type_code := NULL;
8786 l_adr_value_combination_id := NULL;
8787 l_adr_value_segment_code := NULL;
8788
8789 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
8790 l_bflow_class_code := ''; -- 4219869 Business Flow
8791 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
8792 l_budgetary_control_flag := 'N';
8793
8794 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8795 l_bflow_applied_to_amt := NULL; -- 5132302
8796 l_entered_amt_idx := NULL; -- 4262811
8797 l_accted_amt_idx := NULL; -- 4262811
8798 l_acc_rev_flag := NULL; -- 4262811
8799 l_accrual_line_num := NULL; -- 4262811
8800 l_tmp_amt := NULL; -- 4262811
8801 --
8802
8803 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
8804 l_balance_type_code <> 'B' THEN
8805 IF (NVL(p_source_22,'
8806 ') = 'ACTIVITY' AND
8807 NVL(p_source_23,'
8808 ') = 'REFUND') OR
8809 (NVL(p_source_22,'
8810 ') = 'ACTIVITY' AND
8811 NVL(p_source_23,'
8812 ') = 'CM_REFUND')
8813 THEN
8814
8815 --
8816 XLA_AE_LINES_PKG.SetNewLine;
8817
8818 p_balance_type_code := l_balance_type_code;
8819 -- set the flag so later we will know whether the gain loss line needs to be created
8820
8821 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
8822 p_actual_flag :='A';
8823 END IF;
8824
8825 --
8826 -- bulk performance
8827 --
8828 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
8829 p_header_num => 0); -- 4262811
8830 --
8831 -- set accounting line options
8832 --
8833 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
8834 p_natural_side_code => 'C'
8835 , p_gain_or_loss_flag => 'N'
8836 , p_gl_transfer_mode_code => 'S'
8837 , p_acct_entry_type_code => 'A'
8838 , p_switch_side_flag => 'Y'
8839 , p_merge_duplicate_code => 'A'
8840 );
8841 --
8842 l_acc_rev_natural_side_code := 'D'; -- 4262811
8843 --
8844 --
8845 -- set accounting line type info
8846 --
8847 xla_ae_lines_pkg.SetAcctLineType
8848 (p_component_type => l_component_type
8849 ,p_event_type_code => l_event_type_code
8850 ,p_line_definition_owner_code => l_line_definition_owner_code
8851 ,p_line_definition_code => l_line_definition_code
8852 ,p_accounting_line_code => l_component_code
8853 ,p_accounting_line_type_code => l_component_type_code
8854 ,p_accounting_line_appl_id => l_component_appl_id
8855 ,p_amb_context_code => l_amb_context_code
8856 ,p_entity_code => l_entity_code
8857 ,p_event_class_code => l_event_class_code);
8858 --
8859 -- set accounting class
8860 --
8861 xla_ae_lines_pkg.SetAcctClass(
8862 p_accounting_class_code => 'REFUND'
8863 , p_ae_header_id => l_ae_header_id
8864 );
8865
8866 --
8867 -- set rounding class
8868 --
8869 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
8870 'REFUND';
8871
8872 --
8873 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
8874 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
8875 --
8876 -- bulk performance
8877 --
8878 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
8879
8880 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
8884 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8881 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
8882
8883 -- 4955764
8885 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
8886
8887 -- 4458381 Public Sector Enh
8888
8889 --
8890 -- set accounting attributes for the line type
8891 --
8892 l_entered_amt_idx := 3;
8893 l_accted_amt_idx := 9;
8894 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8895 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
8896 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_44);
8897 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
8898 l_rec_acct_attrs.array_char_value(2) := p_source_45;
8899 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
8900 l_rec_acct_attrs.array_num_value(3) := p_source_26;
8901 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
8902 l_rec_acct_attrs.array_char_value(4) := p_source_46;
8903 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
8904 l_rec_acct_attrs.array_date_value(5) := p_source_47;
8905 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
8906 l_rec_acct_attrs.array_num_value(6) := p_source_48;
8907 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
8908 l_rec_acct_attrs.array_char_value(7) := p_source_49;
8909 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
8910 l_rec_acct_attrs.array_char_value(8) := p_source_50;
8911 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
8912 l_rec_acct_attrs.array_num_value(9) := p_source_51;
8913 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
8914 l_rec_acct_attrs.array_num_value(10) := p_source_52;
8915 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
8916 l_rec_acct_attrs.array_num_value(11) := p_source_53;
8917 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
8918 l_rec_acct_attrs.array_char_value(12) := p_source_34;
8919 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
8920 l_rec_acct_attrs.array_num_value(13) := p_source_54;
8921
8922 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
8923 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
8924
8925 ---------------------------------------------------------------------------------------------------------------
8926 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
8927 ---------------------------------------------------------------------------------------------------------------
8928 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
8929
8930 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8931 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8932
8933 IF xla_accounting_cache_pkg.GetValueChar
8934 (p_source_code => 'LEDGER_CATEGORY_CODE'
8935 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
8936 AND l_bflow_method_code = 'PRIOR_ENTRY'
8937 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
8938 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
8939 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
8940 )
8941 THEN
8942 xla_ae_lines_pkg.BflowUpgEntry
8943 (p_business_method_code => l_bflow_method_code
8944 ,p_business_class_code => l_bflow_class_code
8945 ,p_balance_type => l_balance_type_code);
8946 ELSE
8947 NULL;
8948 -- No business flow processing for business flow method of NONE.
8949 END IF;
8950
8951 --
8952 -- call analytical criteria
8953 --
8954
8955 --
8956 -- call description
8957 --
8958 -- No description or it is inherited.
8959 --
8960 -- call ADRs
8961 -- Bug 4922099
8962 --
8963 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8964 (NVL(l_actual_upg_option, 'N') = 'O') OR
8965 (NVL(l_enc_upg_option, 'N') = 'O')
8966 )
8967 THEN
8968 NULL;
8969 --
8970 --
8971
8972 l_ccid := AcctDerRule_11(
8973 p_application_id => p_application_id
8974 , p_ae_header_id => l_ae_header_id
8975 , p_source_10 => p_source_10
8976 , x_transaction_coa_id => l_adr_transaction_coa_id
8977 , x_accounting_coa_id => l_adr_accounting_coa_id
8978 , x_value_type_code => l_adr_value_type_code
8979 , p_side => 'NA'
8980 );
8981
8982 xla_ae_lines_pkg.set_ccid(
8983 p_code_combination_id => l_ccid
8984 , p_value_type_code => l_adr_value_type_code
8985 , p_transaction_coa_id => l_adr_transaction_coa_id
8986 , p_accounting_coa_id => l_adr_accounting_coa_id
8987 , p_adr_code => 'DIST_CCID'
8988 , p_adr_type_code => 'S'
8989 , p_component_type => l_component_type
8990 , p_component_code => l_component_code
8991 , p_component_type_code => l_component_type_code
8992 , p_component_appl_id => l_component_appl_id
8996
8993 , p_amb_context_code => l_amb_context_code
8994 , p_side => 'NA'
8995 );
8997
8998 --
8999 --
9000 END IF;
9001 --
9002 -- Bug 4922099
9003 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
9004 (NVL(l_enc_upg_option, 'N') = 'O')
9005 ) AND
9006 (l_bflow_method_code = 'PRIOR_ENTRY')
9007 )
9008 THEN
9009 IF
9010 --
9011 1 = 2
9012 --
9013 THEN
9014 xla_accounting_err_pkg.build_message
9015 (p_appli_s_name => 'XLA'
9016 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9017 ,p_token_1 => 'LINE_NUMBER'
9018 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
9019 ,p_token_2 => 'LINE_TYPE_NAME'
9020 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
9021 l_component_type
9022 ,l_component_code
9023 ,l_component_type_code
9024 ,l_component_appl_id
9025 ,l_amb_context_code
9026 ,l_entity_code
9027 ,l_event_class_code
9028 )
9029 ,p_token_3 => 'OWNER'
9030 ,p_value_3 => xla_lookups_pkg.get_meaning(
9031 p_lookup_type => 'XLA_OWNER_TYPE'
9032 ,p_lookup_code => l_component_type_code
9033 )
9034 ,p_token_4 => 'PRODUCT_NAME'
9035 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
9036 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
9037 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
9038 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
9039 ,p_ae_header_id => NULL
9040 );
9041
9042 IF (C_LEVEL_ERROR>= g_log_level) THEN
9043 trace
9044 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9045 ,p_level => C_LEVEL_ERROR
9046 ,p_module => l_log_module);
9047 END IF;
9048 END IF;
9049 END IF;
9050 --
9051 --
9052 ------------------------------------------------------------------------------------------------
9053 -- 4219869 Business Flow
9054 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
9055 -- Prior Entry. Currently, the following code is always generated.
9056 ------------------------------------------------------------------------------------------------
9057 XLA_AE_LINES_PKG.ValidateCurrentLine;
9058
9059 ------------------------------------------------------------------------------------
9060 -- 4219869 Business Flow
9061 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
9062 ------------------------------------------------------------------------------------
9063 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9064
9065 ----------------------------------------------------------------------------------
9066 -- 4219869 Business Flow
9067 -- Update journal entry status -- Need to generate this within IF <condition>
9068 ----------------------------------------------------------------------------------
9069 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9070 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
9071 ,p_balance_type_code => l_balance_type_code
9072 );
9073
9074 -------------------------------------------------------------------------------------------
9075 -- 4262811 - Generate the Accrual Reversal lines
9076 -------------------------------------------------------------------------------------------
9077 BEGIN
9078 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
9079 (g_array_event(p_event_id).array_value_num('header_index'));
9080 IF l_acc_rev_flag IS NULL THEN
9081 l_acc_rev_flag := 'N';
9082 END IF;
9083 EXCEPTION
9084 WHEN OTHERS THEN
9085 l_acc_rev_flag := 'N';
9086 END;
9087 --
9088 IF (l_acc_rev_flag = 'Y') THEN
9089
9090 -- 4645092 ------------------------------------------------------------------------------
9091 -- To allow MPA report to determine if it should generate report process
9095 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
9092 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
9093 ------------------------------------------------------------------------------------------
9094
9096 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
9097 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
9098 -- call ADRs
9099 -- Bug 4922099
9100 --
9101 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9102 (NVL(l_actual_upg_option, 'N') = 'O') OR
9103 (NVL(l_enc_upg_option, 'N') = 'O')
9104 )
9105 THEN
9106 NULL;
9107 --
9108 --
9109
9110 l_ccid := AcctDerRule_11(
9111 p_application_id => p_application_id
9112 , p_ae_header_id => l_ae_header_id
9113 , p_source_10 => p_source_10
9114 , x_transaction_coa_id => l_adr_transaction_coa_id
9115 , x_accounting_coa_id => l_adr_accounting_coa_id
9116 , x_value_type_code => l_adr_value_type_code
9117 , p_side => 'NA'
9118 );
9119
9120 xla_ae_lines_pkg.set_ccid(
9121 p_code_combination_id => l_ccid
9122 , p_value_type_code => l_adr_value_type_code
9123 , p_transaction_coa_id => l_adr_transaction_coa_id
9124 , p_accounting_coa_id => l_adr_accounting_coa_id
9125 , p_adr_code => 'DIST_CCID'
9126 , p_adr_type_code => 'S'
9127 , p_component_type => l_component_type
9128 , p_component_code => l_component_code
9129 , p_component_type_code => l_component_type_code
9130 , p_component_appl_id => l_component_appl_id
9131 , p_amb_context_code => l_amb_context_code
9132 , p_side => 'NA'
9133 );
9134
9135
9136 --
9137 --
9138 END IF;
9139
9140 --
9141 -- Update the line information that should be overwritten
9142 --
9143 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
9144 p_header_num => 1);
9145 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
9146
9147 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
9148
9149 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
9150 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
9151 END IF;
9152
9153 --
9154 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
9155 --
9156 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
9157 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
9158 ELSE
9159 ---------------------------------------------------------------------------------------------------
9160 -- 4262811a Switch Sign
9161 ---------------------------------------------------------------------------------------------------
9162 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
9163 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9164 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9165 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9166 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9167 -- 5132302
9168 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
9169 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9170
9171 END IF;
9172
9173 -- 4955764
9174 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9175 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
9176
9177
9178 XLA_AE_LINES_PKG.ValidateCurrentLine;
9179 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9180
9181 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9182 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
9183 ,p_balance_type_code => l_balance_type_code);
9184
9185 END IF;
9186
9187 -----------------------------------------------------------------------------------------
9188 -- 4262811 Multiperiod Accounting
9189 -----------------------------------------------------------------------------------------
9190 -- No MPA option is assigned.
9191
9192
9193 END IF;
9194 END IF;
9195 --
9196
9197 --
9198 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9199 trace
9200 (p_msg => 'END of AcctLineType_42'
9201 ,p_level => C_LEVEL_PROCEDURE
9202 ,p_module => l_log_module);
9203 END IF;
9204 --
9205 EXCEPTION
9206 WHEN xla_exceptions_pkg.application_exception THEN
9207 RAISE;
9208 WHEN OTHERS THEN
9209 xla_exceptions_pkg.raise_message
9210 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_42');
9211 END AcctLineType_42;
9212 --
9213
9217 -- AcctLineType_43
9214 ---------------------------------------
9215 --
9216 -- PRIVATE FUNCTION
9218 --
9219 ---------------------------------------
9220 PROCEDURE AcctLineType_43 (
9221 p_application_id IN NUMBER
9222 ,p_event_id IN NUMBER
9223 ,p_calculate_acctd_flag IN VARCHAR2
9224 ,p_calculate_g_l_flag IN VARCHAR2
9225 ,p_actual_flag IN OUT VARCHAR2
9226 ,p_balance_type_code OUT VARCHAR2
9227 ,p_gain_or_loss_ref OUT VARCHAR2
9228
9229 --Credit Memo Distribution GL Account
9230 , p_source_9 IN NUMBER
9231 --SLA Party Type
9232 , p_source_34 IN VARCHAR2
9233 --Credit Memo Distribution Identifier
9234 , p_source_44 IN NUMBER
9235 --Credit memo distributions type
9236 , p_source_45 IN VARCHAR2
9237 --Credit Memo Currency Code
9238 , p_source_46 IN VARCHAR2
9239 --Credit Memo Exchange Date
9240 , p_source_47 IN DATE
9241 --Credit Memo Exchange Rate
9242 , p_source_48 IN NUMBER
9243 --Credit Memo Exchange Rate Type
9244 , p_source_49 IN VARCHAR2
9245 --Gain Loss Reference
9246 , p_source_50 IN VARCHAR2
9247 --Credit Memo Accounting Amount
9248 , p_source_51 IN NUMBER
9249 --Credit Memo Bill To Customer Account Identifier
9250 , p_source_52 IN NUMBER
9251 --Credit Memo Bill To Customer Site Use Identifier
9252 , p_source_53 IN NUMBER
9253 --Credit Memo Tax Line Identifier
9254 , p_source_54 IN NUMBER
9255 --Credit Memo Distribution Account Class
9256 , p_source_55 IN VARCHAR2
9257 --Credit Memo Distribution Entered Amount
9258 , p_source_56 IN NUMBER
9259 )
9260 IS
9261
9262 l_component_type VARCHAR2(80);
9263 l_component_code VARCHAR2(30);
9264 l_component_type_code VARCHAR2(1);
9265 l_component_appl_id INTEGER;
9266 l_amb_context_code VARCHAR2(30);
9267 l_entity_code VARCHAR2(30);
9268 l_event_class_code VARCHAR2(30);
9269 l_ae_header_id NUMBER;
9270 l_event_type_code VARCHAR2(30);
9271 l_line_definition_code VARCHAR2(30);
9272 l_line_definition_owner_code VARCHAR2(1);
9273 --
9274 -- adr variables
9275 l_segment VARCHAR2(30);
9276 l_ccid NUMBER;
9277 l_adr_transaction_coa_id NUMBER;
9278 l_adr_accounting_coa_id NUMBER;
9279 l_adr_flexfield_segment_code VARCHAR2(30);
9280 l_adr_flex_value_set_id NUMBER;
9281 l_adr_value_type_code VARCHAR2(30);
9282 l_adr_value_combination_id NUMBER;
9283 l_adr_value_segment_code VARCHAR2(30);
9284
9285 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
9286 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
9287 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
9288 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
9289
9290 -- 4262811 Variables ------------------------------------------------------------------------------------------
9291 l_entered_amt_idx NUMBER;
9292 l_accted_amt_idx NUMBER;
9293 l_acc_rev_flag VARCHAR2(1);
9294 l_accrual_line_num NUMBER;
9295 l_tmp_amt NUMBER;
9296 l_acc_rev_natural_side_code VARCHAR2(1);
9297
9298 l_num_entries NUMBER;
9299 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
9300 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
9301 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
9302 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
9303 l_recog_line_1 NUMBER;
9304 l_recog_line_2 NUMBER;
9305
9306 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
9307 l_bflow_applied_to_amt NUMBER; -- 5132302
9308 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
9309
9310 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
9311
9312 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
9313 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
9314
9315 ---------------------------------------------------------------------------------------------------------------
9316
9317
9318 --
9319 -- bulk performance
9320 --
9321 l_balance_type_code VARCHAR2(1);
9322 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
9323 l_log_module VARCHAR2(240);
9324
9325 --
9326 -- Upgrade strategy
9327 --
9328 l_actual_upg_option VARCHAR2(1);
9329 l_enc_upg_option VARCHAR2(1);
9330
9331 --
9332 BEGIN
9333 --
9334 IF g_log_enabled THEN
9335 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_43';
9336 END IF;
9337 --
9338 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9339
9340 trace
9341 (p_msg => 'BEGIN of AcctLineType_43'
9342 ,p_level => C_LEVEL_PROCEDURE
9343 ,p_module => l_log_module);
9344
9345 END IF;
9346 --
9347 l_component_type := 'AMB_JLT';
9351 l_amb_context_code := 'DEFAULT';
9348 l_component_code := 'CM_CHARGES';
9349 l_component_type_code := 'S';
9350 l_component_appl_id := 222;
9352 l_entity_code := 'TRANSACTIONS';
9353 l_event_class_code := 'CREDIT_MEMO';
9354 l_event_type_code := 'CREDIT_MEMO_ALL';
9355 l_line_definition_owner_code := 'S';
9356 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
9357 --
9358 l_balance_type_code := 'A';
9359 l_segment := NULL;
9360 l_ccid := NULL;
9361 l_adr_transaction_coa_id := NULL;
9362 l_adr_accounting_coa_id := NULL;
9363 l_adr_flexfield_segment_code := NULL;
9364 l_adr_flex_value_set_id := NULL;
9365 l_adr_value_type_code := NULL;
9366 l_adr_value_combination_id := NULL;
9367 l_adr_value_segment_code := NULL;
9368
9369 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
9370 l_bflow_class_code := ''; -- 4219869 Business Flow
9371 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
9372 l_budgetary_control_flag := 'N';
9373
9374 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9375 l_bflow_applied_to_amt := NULL; -- 5132302
9376 l_entered_amt_idx := NULL; -- 4262811
9377 l_accted_amt_idx := NULL; -- 4262811
9378 l_acc_rev_flag := NULL; -- 4262811
9379 l_accrual_line_num := NULL; -- 4262811
9380 l_tmp_amt := NULL; -- 4262811
9381 --
9382
9383 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
9384 l_balance_type_code <> 'B' THEN
9385 IF NVL(p_source_55,'
9386 ') = 'CHARGES'
9387 THEN
9388
9389 --
9390 XLA_AE_LINES_PKG.SetNewLine;
9391
9392 p_balance_type_code := l_balance_type_code;
9393 -- set the flag so later we will know whether the gain loss line needs to be created
9394
9395 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
9396 p_actual_flag :='A';
9397 END IF;
9398
9399 --
9400 -- bulk performance
9401 --
9402 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
9403 p_header_num => 0); -- 4262811
9404 --
9405 -- set accounting line options
9406 --
9407 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
9408 p_natural_side_code => 'C'
9409 , p_gain_or_loss_flag => 'N'
9410 , p_gl_transfer_mode_code => 'S'
9411 , p_acct_entry_type_code => 'A'
9412 , p_switch_side_flag => 'Y'
9413 , p_merge_duplicate_code => 'A'
9414 );
9415 --
9416 l_acc_rev_natural_side_code := 'D'; -- 4262811
9417 --
9418 --
9419 -- set accounting line type info
9420 --
9421 xla_ae_lines_pkg.SetAcctLineType
9422 (p_component_type => l_component_type
9423 ,p_event_type_code => l_event_type_code
9424 ,p_line_definition_owner_code => l_line_definition_owner_code
9425 ,p_line_definition_code => l_line_definition_code
9426 ,p_accounting_line_code => l_component_code
9427 ,p_accounting_line_type_code => l_component_type_code
9428 ,p_accounting_line_appl_id => l_component_appl_id
9429 ,p_amb_context_code => l_amb_context_code
9430 ,p_entity_code => l_entity_code
9431 ,p_event_class_code => l_event_class_code);
9432 --
9433 -- set accounting class
9434 --
9435 xla_ae_lines_pkg.SetAcctClass(
9436 p_accounting_class_code => 'CHARGES'
9437 , p_ae_header_id => l_ae_header_id
9438 );
9439
9440 --
9441 -- set rounding class
9442 --
9443 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
9444 'RECEIVABLE';
9445
9446 --
9447 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
9448 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
9449 --
9450 -- bulk performance
9451 --
9452 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
9453
9454 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
9455 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
9456
9457 -- 4955764
9458 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9459 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
9460
9461 -- 4458381 Public Sector Enh
9462
9463 --
9464 -- set accounting attributes for the line type
9465 --
9466 l_entered_amt_idx := 3;
9467 l_accted_amt_idx := 9;
9468 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9469 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
9470 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_44);
9471 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
9472 l_rec_acct_attrs.array_char_value(2) := p_source_45;
9473 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
9474 l_rec_acct_attrs.array_num_value(3) := p_source_56;
9478 l_rec_acct_attrs.array_date_value(5) := p_source_47;
9475 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
9476 l_rec_acct_attrs.array_char_value(4) := p_source_46;
9477 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
9479 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
9480 l_rec_acct_attrs.array_num_value(6) := p_source_48;
9481 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
9482 l_rec_acct_attrs.array_char_value(7) := p_source_49;
9483 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
9484 l_rec_acct_attrs.array_char_value(8) := p_source_50;
9485 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
9486 l_rec_acct_attrs.array_num_value(9) := p_source_51;
9487 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
9488 l_rec_acct_attrs.array_num_value(10) := p_source_52;
9489 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
9490 l_rec_acct_attrs.array_num_value(11) := p_source_53;
9491 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
9492 l_rec_acct_attrs.array_char_value(12) := p_source_34;
9493 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
9494 l_rec_acct_attrs.array_num_value(13) := p_source_54;
9495
9496 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
9497 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
9498
9499 ---------------------------------------------------------------------------------------------------------------
9500 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
9501 ---------------------------------------------------------------------------------------------------------------
9502 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
9503
9504 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9505 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9506
9507 IF xla_accounting_cache_pkg.GetValueChar
9508 (p_source_code => 'LEDGER_CATEGORY_CODE'
9509 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
9510 AND l_bflow_method_code = 'PRIOR_ENTRY'
9511 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
9512 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
9513 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
9514 )
9515 THEN
9516 xla_ae_lines_pkg.BflowUpgEntry
9517 (p_business_method_code => l_bflow_method_code
9518 ,p_business_class_code => l_bflow_class_code
9519 ,p_balance_type => l_balance_type_code);
9520 ELSE
9521 NULL;
9522 -- No business flow processing for business flow method of NONE.
9523 END IF;
9524
9525 --
9526 -- call analytical criteria
9527 --
9528
9529 --
9530 -- call description
9531 --
9532 -- No description or it is inherited.
9533 --
9534 -- call ADRs
9535 -- Bug 4922099
9536 --
9537 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9538 (NVL(l_actual_upg_option, 'N') = 'O') OR
9539 (NVL(l_enc_upg_option, 'N') = 'O')
9540 )
9541 THEN
9542 NULL;
9543 --
9544 --
9545
9546 l_ccid := AcctDerRule_10(
9547 p_application_id => p_application_id
9548 , p_ae_header_id => l_ae_header_id
9549 , p_source_9 => p_source_9
9550 , x_transaction_coa_id => l_adr_transaction_coa_id
9551 , x_accounting_coa_id => l_adr_accounting_coa_id
9552 , x_value_type_code => l_adr_value_type_code
9553 , p_side => 'NA'
9554 );
9555
9556 xla_ae_lines_pkg.set_ccid(
9557 p_code_combination_id => l_ccid
9558 , p_value_type_code => l_adr_value_type_code
9559 , p_transaction_coa_id => l_adr_transaction_coa_id
9560 , p_accounting_coa_id => l_adr_accounting_coa_id
9561 , p_adr_code => 'CM_DIST_CCID'
9562 , p_adr_type_code => 'S'
9563 , p_component_type => l_component_type
9564 , p_component_code => l_component_code
9565 , p_component_type_code => l_component_type_code
9566 , p_component_appl_id => l_component_appl_id
9567 , p_amb_context_code => l_amb_context_code
9568 , p_side => 'NA'
9569 );
9570
9571
9572 --
9573 --
9574 END IF;
9575 --
9576 -- Bug 4922099
9577 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
9578 (NVL(l_enc_upg_option, 'N') = 'O')
9579 ) AND
9580 (l_bflow_method_code = 'PRIOR_ENTRY')
9581 )
9582 THEN
9583 IF
9584 --
9585 1 = 2
9586 --
9587 THEN
9588 xla_accounting_err_pkg.build_message
9589 (p_appli_s_name => 'XLA'
9590 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9591 ,p_token_1 => 'LINE_NUMBER'
9595 l_component_type
9592 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
9593 ,p_token_2 => 'LINE_TYPE_NAME'
9594 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
9596 ,l_component_code
9597 ,l_component_type_code
9598 ,l_component_appl_id
9599 ,l_amb_context_code
9600 ,l_entity_code
9601 ,l_event_class_code
9602 )
9603 ,p_token_3 => 'OWNER'
9604 ,p_value_3 => xla_lookups_pkg.get_meaning(
9605 p_lookup_type => 'XLA_OWNER_TYPE'
9606 ,p_lookup_code => l_component_type_code
9607 )
9608 ,p_token_4 => 'PRODUCT_NAME'
9609 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
9610 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
9611 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
9612 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
9613 ,p_ae_header_id => NULL
9614 );
9615
9616 IF (C_LEVEL_ERROR>= g_log_level) THEN
9617 trace
9618 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9619 ,p_level => C_LEVEL_ERROR
9620 ,p_module => l_log_module);
9621 END IF;
9622 END IF;
9623 END IF;
9624 --
9625 --
9626 ------------------------------------------------------------------------------------------------
9627 -- 4219869 Business Flow
9628 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
9629 -- Prior Entry. Currently, the following code is always generated.
9630 ------------------------------------------------------------------------------------------------
9631 XLA_AE_LINES_PKG.ValidateCurrentLine;
9632
9633 ------------------------------------------------------------------------------------
9634 -- 4219869 Business Flow
9635 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
9636 ------------------------------------------------------------------------------------
9637 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9638
9639 ----------------------------------------------------------------------------------
9640 -- 4219869 Business Flow
9641 -- Update journal entry status -- Need to generate this within IF <condition>
9642 ----------------------------------------------------------------------------------
9643 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9644 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
9645 ,p_balance_type_code => l_balance_type_code
9646 );
9647
9648 -------------------------------------------------------------------------------------------
9649 -- 4262811 - Generate the Accrual Reversal lines
9650 -------------------------------------------------------------------------------------------
9651 BEGIN
9652 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
9653 (g_array_event(p_event_id).array_value_num('header_index'));
9654 IF l_acc_rev_flag IS NULL THEN
9655 l_acc_rev_flag := 'N';
9656 END IF;
9657 EXCEPTION
9658 WHEN OTHERS THEN
9659 l_acc_rev_flag := 'N';
9660 END;
9661 --
9662 IF (l_acc_rev_flag = 'Y') THEN
9663
9664 -- 4645092 ------------------------------------------------------------------------------
9665 -- To allow MPA report to determine if it should generate report process
9666 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
9667 ------------------------------------------------------------------------------------------
9668
9669 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
9670 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
9671 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
9672 -- call ADRs
9673 -- Bug 4922099
9674 --
9675 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9676 (NVL(l_actual_upg_option, 'N') = 'O') OR
9677 (NVL(l_enc_upg_option, 'N') = 'O')
9678 )
9679 THEN
9680 NULL;
9681 --
9682 --
9683
9684 l_ccid := AcctDerRule_10(
9685 p_application_id => p_application_id
9686 , p_ae_header_id => l_ae_header_id
9687 , p_source_9 => p_source_9
9691 , p_side => 'NA'
9688 , x_transaction_coa_id => l_adr_transaction_coa_id
9689 , x_accounting_coa_id => l_adr_accounting_coa_id
9690 , x_value_type_code => l_adr_value_type_code
9692 );
9693
9694 xla_ae_lines_pkg.set_ccid(
9695 p_code_combination_id => l_ccid
9696 , p_value_type_code => l_adr_value_type_code
9697 , p_transaction_coa_id => l_adr_transaction_coa_id
9698 , p_accounting_coa_id => l_adr_accounting_coa_id
9699 , p_adr_code => 'CM_DIST_CCID'
9700 , p_adr_type_code => 'S'
9701 , p_component_type => l_component_type
9702 , p_component_code => l_component_code
9703 , p_component_type_code => l_component_type_code
9704 , p_component_appl_id => l_component_appl_id
9705 , p_amb_context_code => l_amb_context_code
9706 , p_side => 'NA'
9707 );
9708
9709
9710 --
9711 --
9712 END IF;
9713
9714 --
9715 -- Update the line information that should be overwritten
9716 --
9717 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
9718 p_header_num => 1);
9719 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
9720
9721 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
9722
9723 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
9724 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
9725 END IF;
9726
9727 --
9728 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
9729 --
9730 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
9731 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
9732 ELSE
9733 ---------------------------------------------------------------------------------------------------
9734 -- 4262811a Switch Sign
9735 ---------------------------------------------------------------------------------------------------
9736 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
9737 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9738 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9739 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9740 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9741 -- 5132302
9742 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
9743 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9744
9745 END IF;
9746
9747 -- 4955764
9748 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9749 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
9750
9751
9752 XLA_AE_LINES_PKG.ValidateCurrentLine;
9753 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9754
9755 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9756 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
9757 ,p_balance_type_code => l_balance_type_code);
9758
9759 END IF;
9760
9761 -----------------------------------------------------------------------------------------
9762 -- 4262811 Multiperiod Accounting
9763 -----------------------------------------------------------------------------------------
9764 -- No MPA option is assigned.
9765
9766
9767 END IF;
9768 END IF;
9769 --
9770
9771 --
9772 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9773 trace
9774 (p_msg => 'END of AcctLineType_43'
9775 ,p_level => C_LEVEL_PROCEDURE
9776 ,p_module => l_log_module);
9777 END IF;
9778 --
9779 EXCEPTION
9780 WHEN xla_exceptions_pkg.application_exception THEN
9781 RAISE;
9782 WHEN OTHERS THEN
9783 xla_exceptions_pkg.raise_message
9784 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_43');
9785 END AcctLineType_43;
9786 --
9787
9788 ---------------------------------------
9789 --
9790 -- PRIVATE FUNCTION
9791 -- AcctLineType_44
9792 --
9793 ---------------------------------------
9794 PROCEDURE AcctLineType_44 (
9795 p_application_id IN NUMBER
9796 ,p_event_id IN NUMBER
9797 ,p_calculate_acctd_flag IN VARCHAR2
9798 ,p_calculate_g_l_flag IN VARCHAR2
9799 ,p_actual_flag IN OUT VARCHAR2
9800 ,p_balance_type_code OUT VARCHAR2
9801 ,p_gain_or_loss_ref OUT VARCHAR2
9802
9803 --Credit Memo Distribution GL Account
9804 , p_source_9 IN NUMBER
9805 --SLA Party Type
9806 , p_source_34 IN VARCHAR2
9807 --Credit Memo Distribution Identifier
9808 , p_source_44 IN NUMBER
9809 --Credit memo distributions type
9810 , p_source_45 IN VARCHAR2
9811 --Credit Memo Currency Code
9815 --Credit Memo Exchange Rate
9812 , p_source_46 IN VARCHAR2
9813 --Credit Memo Exchange Date
9814 , p_source_47 IN DATE
9816 , p_source_48 IN NUMBER
9817 --Credit Memo Exchange Rate Type
9818 , p_source_49 IN VARCHAR2
9819 --Gain Loss Reference
9820 , p_source_50 IN VARCHAR2
9821 --Credit Memo Accounting Amount
9822 , p_source_51 IN NUMBER
9823 --Credit Memo Bill To Customer Account Identifier
9824 , p_source_52 IN NUMBER
9825 --Credit Memo Bill To Customer Site Use Identifier
9826 , p_source_53 IN NUMBER
9827 --Credit Memo Tax Line Identifier
9828 , p_source_54 IN NUMBER
9829 --Credit Memo Distribution Account Class
9830 , p_source_55 IN VARCHAR2
9831 --Credit Memo Distribution Entered Amount
9832 , p_source_56 IN NUMBER
9833 )
9834 IS
9835
9836 l_component_type VARCHAR2(80);
9837 l_component_code VARCHAR2(30);
9838 l_component_type_code VARCHAR2(1);
9839 l_component_appl_id INTEGER;
9840 l_amb_context_code VARCHAR2(30);
9841 l_entity_code VARCHAR2(30);
9842 l_event_class_code VARCHAR2(30);
9843 l_ae_header_id NUMBER;
9844 l_event_type_code VARCHAR2(30);
9845 l_line_definition_code VARCHAR2(30);
9846 l_line_definition_owner_code VARCHAR2(1);
9847 --
9848 -- adr variables
9849 l_segment VARCHAR2(30);
9850 l_ccid NUMBER;
9851 l_adr_transaction_coa_id NUMBER;
9852 l_adr_accounting_coa_id NUMBER;
9853 l_adr_flexfield_segment_code VARCHAR2(30);
9854 l_adr_flex_value_set_id NUMBER;
9855 l_adr_value_type_code VARCHAR2(30);
9856 l_adr_value_combination_id NUMBER;
9857 l_adr_value_segment_code VARCHAR2(30);
9858
9859 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
9860 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
9861 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
9862 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
9863
9864 -- 4262811 Variables ------------------------------------------------------------------------------------------
9865 l_entered_amt_idx NUMBER;
9866 l_accted_amt_idx NUMBER;
9867 l_acc_rev_flag VARCHAR2(1);
9868 l_accrual_line_num NUMBER;
9869 l_tmp_amt NUMBER;
9870 l_acc_rev_natural_side_code VARCHAR2(1);
9871
9872 l_num_entries NUMBER;
9873 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
9874 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
9875 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
9876 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
9877 l_recog_line_1 NUMBER;
9878 l_recog_line_2 NUMBER;
9879
9880 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
9881 l_bflow_applied_to_amt NUMBER; -- 5132302
9882 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
9883
9884 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
9885
9886 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
9887 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
9888
9889 ---------------------------------------------------------------------------------------------------------------
9890
9891
9892 --
9893 -- bulk performance
9894 --
9895 l_balance_type_code VARCHAR2(1);
9896 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
9897 l_log_module VARCHAR2(240);
9898
9899 --
9900 -- Upgrade strategy
9901 --
9902 l_actual_upg_option VARCHAR2(1);
9903 l_enc_upg_option VARCHAR2(1);
9904
9905 --
9906 BEGIN
9907 --
9908 IF g_log_enabled THEN
9909 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_44';
9910 END IF;
9911 --
9912 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9913
9914 trace
9915 (p_msg => 'BEGIN of AcctLineType_44'
9916 ,p_level => C_LEVEL_PROCEDURE
9917 ,p_module => l_log_module);
9918
9919 END IF;
9920 --
9921 l_component_type := 'AMB_JLT';
9922 l_component_code := 'CM_DEFAULT_FREIGHT';
9923 l_component_type_code := 'S';
9924 l_component_appl_id := 222;
9925 l_amb_context_code := 'DEFAULT';
9926 l_entity_code := 'TRANSACTIONS';
9927 l_event_class_code := 'CREDIT_MEMO';
9928 l_event_type_code := 'CREDIT_MEMO_ALL';
9929 l_line_definition_owner_code := 'S';
9930 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
9931 --
9932 l_balance_type_code := 'A';
9933 l_segment := NULL;
9934 l_ccid := NULL;
9935 l_adr_transaction_coa_id := NULL;
9936 l_adr_accounting_coa_id := NULL;
9937 l_adr_flexfield_segment_code := NULL;
9938 l_adr_flex_value_set_id := NULL;
9939 l_adr_value_type_code := NULL;
9940 l_adr_value_combination_id := NULL;
9941 l_adr_value_segment_code := NULL;
9942
9943 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
9947
9944 l_bflow_class_code := ''; -- 4219869 Business Flow
9945 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
9946 l_budgetary_control_flag := 'N';
9948 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9949 l_bflow_applied_to_amt := NULL; -- 5132302
9950 l_entered_amt_idx := NULL; -- 4262811
9951 l_accted_amt_idx := NULL; -- 4262811
9952 l_acc_rev_flag := NULL; -- 4262811
9953 l_accrual_line_num := NULL; -- 4262811
9954 l_tmp_amt := NULL; -- 4262811
9955 --
9956
9957 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
9958 l_balance_type_code <> 'B' THEN
9959 IF NVL(p_source_55,'
9960 ') = 'FREIGHT'
9961 THEN
9962
9963 --
9964 XLA_AE_LINES_PKG.SetNewLine;
9965
9966 p_balance_type_code := l_balance_type_code;
9967 -- set the flag so later we will know whether the gain loss line needs to be created
9968
9969 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
9970 p_actual_flag :='A';
9971 END IF;
9972
9973 --
9974 -- bulk performance
9975 --
9976 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
9977 p_header_num => 0); -- 4262811
9978 --
9979 -- set accounting line options
9980 --
9981 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
9982 p_natural_side_code => 'C'
9983 , p_gain_or_loss_flag => 'N'
9984 , p_gl_transfer_mode_code => 'S'
9985 , p_acct_entry_type_code => 'A'
9986 , p_switch_side_flag => 'Y'
9987 , p_merge_duplicate_code => 'A'
9988 );
9989 --
9990 l_acc_rev_natural_side_code := 'D'; -- 4262811
9991 --
9992 --
9993 -- set accounting line type info
9994 --
9995 xla_ae_lines_pkg.SetAcctLineType
9996 (p_component_type => l_component_type
9997 ,p_event_type_code => l_event_type_code
9998 ,p_line_definition_owner_code => l_line_definition_owner_code
9999 ,p_line_definition_code => l_line_definition_code
10000 ,p_accounting_line_code => l_component_code
10001 ,p_accounting_line_type_code => l_component_type_code
10002 ,p_accounting_line_appl_id => l_component_appl_id
10003 ,p_amb_context_code => l_amb_context_code
10004 ,p_entity_code => l_entity_code
10005 ,p_event_class_code => l_event_class_code);
10006 --
10007 -- set accounting class
10008 --
10009 xla_ae_lines_pkg.SetAcctClass(
10010 p_accounting_class_code => 'FREIGHT'
10011 , p_ae_header_id => l_ae_header_id
10012 );
10013
10014 --
10015 -- set rounding class
10016 --
10017 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
10018 'RECEIVABLE';
10019
10020 --
10021 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
10022 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
10023 --
10024 -- bulk performance
10025 --
10026 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
10027
10028 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
10029 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
10030
10031 -- 4955764
10032 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10033 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
10034
10035 -- 4458381 Public Sector Enh
10036
10037 --
10038 -- set accounting attributes for the line type
10039 --
10040 l_entered_amt_idx := 3;
10041 l_accted_amt_idx := 9;
10042 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10043 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
10044 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_44);
10045 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
10046 l_rec_acct_attrs.array_char_value(2) := p_source_45;
10047 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
10048 l_rec_acct_attrs.array_num_value(3) := p_source_56;
10049 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
10050 l_rec_acct_attrs.array_char_value(4) := p_source_46;
10051 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
10052 l_rec_acct_attrs.array_date_value(5) := p_source_47;
10053 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
10054 l_rec_acct_attrs.array_num_value(6) := p_source_48;
10055 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
10056 l_rec_acct_attrs.array_char_value(7) := p_source_49;
10057 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
10058 l_rec_acct_attrs.array_char_value(8) := p_source_50;
10059 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
10060 l_rec_acct_attrs.array_num_value(9) := p_source_51;
10061 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
10065 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
10062 l_rec_acct_attrs.array_num_value(10) := p_source_52;
10063 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
10064 l_rec_acct_attrs.array_num_value(11) := p_source_53;
10066 l_rec_acct_attrs.array_char_value(12) := p_source_34;
10067 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
10068 l_rec_acct_attrs.array_num_value(13) := p_source_54;
10069
10070 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
10071 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
10072
10073 ---------------------------------------------------------------------------------------------------------------
10074 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
10075 ---------------------------------------------------------------------------------------------------------------
10076 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
10077
10078 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10079 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10080
10081 IF xla_accounting_cache_pkg.GetValueChar
10082 (p_source_code => 'LEDGER_CATEGORY_CODE'
10083 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
10084 AND l_bflow_method_code = 'PRIOR_ENTRY'
10085 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
10086 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
10087 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
10088 )
10089 THEN
10090 xla_ae_lines_pkg.BflowUpgEntry
10091 (p_business_method_code => l_bflow_method_code
10092 ,p_business_class_code => l_bflow_class_code
10093 ,p_balance_type => l_balance_type_code);
10094 ELSE
10095 NULL;
10096 -- No business flow processing for business flow method of NONE.
10097 END IF;
10098
10099 --
10100 -- call analytical criteria
10101 --
10102
10103 --
10104 -- call description
10105 --
10106 -- No description or it is inherited.
10107 --
10108 -- call ADRs
10109 -- Bug 4922099
10110 --
10111 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10112 (NVL(l_actual_upg_option, 'N') = 'O') OR
10113 (NVL(l_enc_upg_option, 'N') = 'O')
10114 )
10115 THEN
10116 NULL;
10117 --
10118 --
10119
10120 l_ccid := AcctDerRule_10(
10121 p_application_id => p_application_id
10122 , p_ae_header_id => l_ae_header_id
10123 , p_source_9 => p_source_9
10124 , x_transaction_coa_id => l_adr_transaction_coa_id
10125 , x_accounting_coa_id => l_adr_accounting_coa_id
10126 , x_value_type_code => l_adr_value_type_code
10127 , p_side => 'NA'
10128 );
10129
10130 xla_ae_lines_pkg.set_ccid(
10131 p_code_combination_id => l_ccid
10132 , p_value_type_code => l_adr_value_type_code
10133 , p_transaction_coa_id => l_adr_transaction_coa_id
10134 , p_accounting_coa_id => l_adr_accounting_coa_id
10135 , p_adr_code => 'CM_DIST_CCID'
10136 , p_adr_type_code => 'S'
10137 , p_component_type => l_component_type
10138 , p_component_code => l_component_code
10139 , p_component_type_code => l_component_type_code
10140 , p_component_appl_id => l_component_appl_id
10141 , p_amb_context_code => l_amb_context_code
10142 , p_side => 'NA'
10143 );
10144
10145
10146 --
10147 --
10148 END IF;
10149 --
10150 -- Bug 4922099
10151 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
10152 (NVL(l_enc_upg_option, 'N') = 'O')
10153 ) AND
10154 (l_bflow_method_code = 'PRIOR_ENTRY')
10155 )
10156 THEN
10157 IF
10158 --
10159 1 = 2
10160 --
10161 THEN
10162 xla_accounting_err_pkg.build_message
10163 (p_appli_s_name => 'XLA'
10164 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10165 ,p_token_1 => 'LINE_NUMBER'
10166 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
10167 ,p_token_2 => 'LINE_TYPE_NAME'
10168 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
10169 l_component_type
10170 ,l_component_code
10171 ,l_component_type_code
10172 ,l_component_appl_id
10173 ,l_amb_context_code
10177 ,p_token_3 => 'OWNER'
10174 ,l_entity_code
10175 ,l_event_class_code
10176 )
10178 ,p_value_3 => xla_lookups_pkg.get_meaning(
10179 p_lookup_type => 'XLA_OWNER_TYPE'
10180 ,p_lookup_code => l_component_type_code
10181 )
10182 ,p_token_4 => 'PRODUCT_NAME'
10183 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
10184 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
10185 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
10186 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
10187 ,p_ae_header_id => NULL
10188 );
10189
10190 IF (C_LEVEL_ERROR>= g_log_level) THEN
10191 trace
10192 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10193 ,p_level => C_LEVEL_ERROR
10194 ,p_module => l_log_module);
10195 END IF;
10196 END IF;
10197 END IF;
10198 --
10199 --
10200 ------------------------------------------------------------------------------------------------
10201 -- 4219869 Business Flow
10202 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
10203 -- Prior Entry. Currently, the following code is always generated.
10204 ------------------------------------------------------------------------------------------------
10205 XLA_AE_LINES_PKG.ValidateCurrentLine;
10206
10207 ------------------------------------------------------------------------------------
10208 -- 4219869 Business Flow
10209 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
10210 ------------------------------------------------------------------------------------
10211 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10212
10213 ----------------------------------------------------------------------------------
10214 -- 4219869 Business Flow
10215 -- Update journal entry status -- Need to generate this within IF <condition>
10216 ----------------------------------------------------------------------------------
10217 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10218 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
10219 ,p_balance_type_code => l_balance_type_code
10220 );
10221
10222 -------------------------------------------------------------------------------------------
10223 -- 4262811 - Generate the Accrual Reversal lines
10224 -------------------------------------------------------------------------------------------
10225 BEGIN
10226 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
10227 (g_array_event(p_event_id).array_value_num('header_index'));
10228 IF l_acc_rev_flag IS NULL THEN
10229 l_acc_rev_flag := 'N';
10230 END IF;
10231 EXCEPTION
10232 WHEN OTHERS THEN
10233 l_acc_rev_flag := 'N';
10234 END;
10235 --
10236 IF (l_acc_rev_flag = 'Y') THEN
10237
10238 -- 4645092 ------------------------------------------------------------------------------
10239 -- To allow MPA report to determine if it should generate report process
10240 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
10241 ------------------------------------------------------------------------------------------
10242
10243 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
10244 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
10245 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
10246 -- call ADRs
10247 -- Bug 4922099
10248 --
10249 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10250 (NVL(l_actual_upg_option, 'N') = 'O') OR
10251 (NVL(l_enc_upg_option, 'N') = 'O')
10252 )
10253 THEN
10254 NULL;
10255 --
10256 --
10257
10258 l_ccid := AcctDerRule_10(
10259 p_application_id => p_application_id
10260 , p_ae_header_id => l_ae_header_id
10261 , p_source_9 => p_source_9
10262 , x_transaction_coa_id => l_adr_transaction_coa_id
10263 , x_accounting_coa_id => l_adr_accounting_coa_id
10264 , x_value_type_code => l_adr_value_type_code
10265 , p_side => 'NA'
10266 );
10267
10268 xla_ae_lines_pkg.set_ccid(
10269 p_code_combination_id => l_ccid
10270 , p_value_type_code => l_adr_value_type_code
10271 , p_transaction_coa_id => l_adr_transaction_coa_id
10272 , p_accounting_coa_id => l_adr_accounting_coa_id
10273 , p_adr_code => 'CM_DIST_CCID'
10277 , p_component_type_code => l_component_type_code
10274 , p_adr_type_code => 'S'
10275 , p_component_type => l_component_type
10276 , p_component_code => l_component_code
10278 , p_component_appl_id => l_component_appl_id
10279 , p_amb_context_code => l_amb_context_code
10280 , p_side => 'NA'
10281 );
10282
10283
10284 --
10285 --
10286 END IF;
10287
10288 --
10289 -- Update the line information that should be overwritten
10290 --
10291 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
10292 p_header_num => 1);
10293 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
10294
10295 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
10296
10297 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
10298 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
10299 END IF;
10300
10301 --
10302 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
10303 --
10304 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
10305 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
10306 ELSE
10307 ---------------------------------------------------------------------------------------------------
10308 -- 4262811a Switch Sign
10309 ---------------------------------------------------------------------------------------------------
10310 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
10311 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10312 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10313 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10314 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10315 -- 5132302
10316 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
10317 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10318
10319 END IF;
10320
10321 -- 4955764
10322 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10323 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
10324
10325
10326 XLA_AE_LINES_PKG.ValidateCurrentLine;
10327 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10328
10329 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10330 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
10331 ,p_balance_type_code => l_balance_type_code);
10332
10333 END IF;
10334
10335 -----------------------------------------------------------------------------------------
10336 -- 4262811 Multiperiod Accounting
10337 -----------------------------------------------------------------------------------------
10338 -- No MPA option is assigned.
10339
10340
10341 END IF;
10342 END IF;
10343 --
10344
10345 --
10346 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10347 trace
10348 (p_msg => 'END of AcctLineType_44'
10349 ,p_level => C_LEVEL_PROCEDURE
10350 ,p_module => l_log_module);
10351 END IF;
10352 --
10353 EXCEPTION
10354 WHEN xla_exceptions_pkg.application_exception THEN
10355 RAISE;
10356 WHEN OTHERS THEN
10357 xla_exceptions_pkg.raise_message
10358 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_44');
10359 END AcctLineType_44;
10360 --
10361
10362 ---------------------------------------
10363 --
10364 -- PRIVATE FUNCTION
10365 -- AcctLineType_45
10366 --
10367 ---------------------------------------
10368 PROCEDURE AcctLineType_45 (
10369 p_application_id IN NUMBER
10370 ,p_event_id IN NUMBER
10371 ,p_calculate_acctd_flag IN VARCHAR2
10372 ,p_calculate_g_l_flag IN VARCHAR2
10373 ,p_actual_flag IN OUT VARCHAR2
10374 ,p_balance_type_code OUT VARCHAR2
10375 ,p_gain_or_loss_ref OUT VARCHAR2
10376
10377 --Credit Memo Distribution GL Account
10378 , p_source_9 IN NUMBER
10379 --SLA Party Type
10380 , p_source_34 IN VARCHAR2
10381 --Credit Memo Distribution Identifier
10382 , p_source_44 IN NUMBER
10383 --Credit memo distributions type
10384 , p_source_45 IN VARCHAR2
10385 --Credit Memo Currency Code
10386 , p_source_46 IN VARCHAR2
10387 --Credit Memo Exchange Date
10388 , p_source_47 IN DATE
10389 --Credit Memo Exchange Rate
10390 , p_source_48 IN NUMBER
10391 --Credit Memo Exchange Rate Type
10392 , p_source_49 IN VARCHAR2
10393 --Gain Loss Reference
10394 , p_source_50 IN VARCHAR2
10395 --Credit Memo Accounting Amount
10396 , p_source_51 IN NUMBER
10400 , p_source_53 IN NUMBER
10397 --Credit Memo Bill To Customer Account Identifier
10398 , p_source_52 IN NUMBER
10399 --Credit Memo Bill To Customer Site Use Identifier
10401 --Credit Memo Tax Line Identifier
10402 , p_source_54 IN NUMBER
10403 --Credit Memo Distribution Account Class
10404 , p_source_55 IN VARCHAR2
10405 --Credit Memo Distribution Entered Amount
10406 , p_source_56 IN NUMBER
10407 )
10408 IS
10409
10410 l_component_type VARCHAR2(80);
10411 l_component_code VARCHAR2(30);
10412 l_component_type_code VARCHAR2(1);
10413 l_component_appl_id INTEGER;
10414 l_amb_context_code VARCHAR2(30);
10415 l_entity_code VARCHAR2(30);
10416 l_event_class_code VARCHAR2(30);
10417 l_ae_header_id NUMBER;
10418 l_event_type_code VARCHAR2(30);
10419 l_line_definition_code VARCHAR2(30);
10420 l_line_definition_owner_code VARCHAR2(1);
10421 --
10422 -- adr variables
10423 l_segment VARCHAR2(30);
10424 l_ccid NUMBER;
10425 l_adr_transaction_coa_id NUMBER;
10426 l_adr_accounting_coa_id NUMBER;
10427 l_adr_flexfield_segment_code VARCHAR2(30);
10428 l_adr_flex_value_set_id NUMBER;
10429 l_adr_value_type_code VARCHAR2(30);
10430 l_adr_value_combination_id NUMBER;
10431 l_adr_value_segment_code VARCHAR2(30);
10432
10433 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
10434 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
10435 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
10436 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
10437
10438 -- 4262811 Variables ------------------------------------------------------------------------------------------
10439 l_entered_amt_idx NUMBER;
10440 l_accted_amt_idx NUMBER;
10441 l_acc_rev_flag VARCHAR2(1);
10442 l_accrual_line_num NUMBER;
10443 l_tmp_amt NUMBER;
10444 l_acc_rev_natural_side_code VARCHAR2(1);
10445
10446 l_num_entries NUMBER;
10447 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
10448 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
10449 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
10450 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
10451 l_recog_line_1 NUMBER;
10452 l_recog_line_2 NUMBER;
10453
10454 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
10455 l_bflow_applied_to_amt NUMBER; -- 5132302
10456 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
10457
10458 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
10459
10460 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
10461 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
10462
10463 ---------------------------------------------------------------------------------------------------------------
10464
10465
10466 --
10467 -- bulk performance
10468 --
10469 l_balance_type_code VARCHAR2(1);
10470 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
10471 l_log_module VARCHAR2(240);
10472
10473 --
10474 -- Upgrade strategy
10475 --
10476 l_actual_upg_option VARCHAR2(1);
10477 l_enc_upg_option VARCHAR2(1);
10478
10479 --
10480 BEGIN
10481 --
10482 IF g_log_enabled THEN
10483 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_45';
10484 END IF;
10485 --
10486 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10487
10488 trace
10489 (p_msg => 'BEGIN of AcctLineType_45'
10490 ,p_level => C_LEVEL_PROCEDURE
10491 ,p_module => l_log_module);
10492
10493 END IF;
10494 --
10495 l_component_type := 'AMB_JLT';
10496 l_component_code := 'CM_DEFAULT_REV';
10497 l_component_type_code := 'S';
10498 l_component_appl_id := 222;
10499 l_amb_context_code := 'DEFAULT';
10500 l_entity_code := 'TRANSACTIONS';
10501 l_event_class_code := 'CREDIT_MEMO';
10502 l_event_type_code := 'CREDIT_MEMO_ALL';
10503 l_line_definition_owner_code := 'S';
10504 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
10505 --
10506 l_balance_type_code := 'A';
10507 l_segment := NULL;
10508 l_ccid := NULL;
10509 l_adr_transaction_coa_id := NULL;
10510 l_adr_accounting_coa_id := NULL;
10511 l_adr_flexfield_segment_code := NULL;
10512 l_adr_flex_value_set_id := NULL;
10513 l_adr_value_type_code := NULL;
10514 l_adr_value_combination_id := NULL;
10515 l_adr_value_segment_code := NULL;
10516
10517 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
10518 l_bflow_class_code := ''; -- 4219869 Business Flow
10519 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
10520 l_budgetary_control_flag := 'N';
10521
10522 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10523 l_bflow_applied_to_amt := NULL; -- 5132302
10524 l_entered_amt_idx := NULL; -- 4262811
10528 l_tmp_amt := NULL; -- 4262811
10525 l_accted_amt_idx := NULL; -- 4262811
10526 l_acc_rev_flag := NULL; -- 4262811
10527 l_accrual_line_num := NULL; -- 4262811
10529 --
10530
10531 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
10532 l_balance_type_code <> 'B' THEN
10533 IF NVL(p_source_55,'
10534 ') = 'REV'
10535 THEN
10536
10537 --
10538 XLA_AE_LINES_PKG.SetNewLine;
10539
10540 p_balance_type_code := l_balance_type_code;
10541 -- set the flag so later we will know whether the gain loss line needs to be created
10542
10543 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
10544 p_actual_flag :='A';
10545 END IF;
10546
10547 --
10548 -- bulk performance
10549 --
10550 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
10551 p_header_num => 0); -- 4262811
10552 --
10553 -- set accounting line options
10554 --
10555 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
10556 p_natural_side_code => 'C'
10557 , p_gain_or_loss_flag => 'N'
10558 , p_gl_transfer_mode_code => 'S'
10559 , p_acct_entry_type_code => 'A'
10560 , p_switch_side_flag => 'Y'
10561 , p_merge_duplicate_code => 'A'
10562 );
10563 --
10564 l_acc_rev_natural_side_code := 'D'; -- 4262811
10565 --
10566 --
10567 -- set accounting line type info
10568 --
10569 xla_ae_lines_pkg.SetAcctLineType
10570 (p_component_type => l_component_type
10571 ,p_event_type_code => l_event_type_code
10572 ,p_line_definition_owner_code => l_line_definition_owner_code
10573 ,p_line_definition_code => l_line_definition_code
10574 ,p_accounting_line_code => l_component_code
10575 ,p_accounting_line_type_code => l_component_type_code
10576 ,p_accounting_line_appl_id => l_component_appl_id
10577 ,p_amb_context_code => l_amb_context_code
10578 ,p_entity_code => l_entity_code
10579 ,p_event_class_code => l_event_class_code);
10580 --
10581 -- set accounting class
10582 --
10583 xla_ae_lines_pkg.SetAcctClass(
10584 p_accounting_class_code => 'REVENUE'
10585 , p_ae_header_id => l_ae_header_id
10586 );
10587
10588 --
10589 -- set rounding class
10590 --
10591 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
10592 'RECEIVABLE';
10593
10594 --
10595 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
10596 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
10597 --
10598 -- bulk performance
10599 --
10600 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
10601
10602 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
10603 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
10604
10605 -- 4955764
10606 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10607 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
10608
10609 -- 4458381 Public Sector Enh
10610
10611 --
10612 -- set accounting attributes for the line type
10613 --
10614 l_entered_amt_idx := 3;
10615 l_accted_amt_idx := 9;
10616 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10617 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
10618 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_44);
10619 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
10620 l_rec_acct_attrs.array_char_value(2) := p_source_45;
10621 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
10622 l_rec_acct_attrs.array_num_value(3) := p_source_56;
10623 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
10624 l_rec_acct_attrs.array_char_value(4) := p_source_46;
10625 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
10626 l_rec_acct_attrs.array_date_value(5) := p_source_47;
10627 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
10628 l_rec_acct_attrs.array_num_value(6) := p_source_48;
10629 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
10630 l_rec_acct_attrs.array_char_value(7) := p_source_49;
10631 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
10632 l_rec_acct_attrs.array_char_value(8) := p_source_50;
10633 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
10634 l_rec_acct_attrs.array_num_value(9) := p_source_51;
10635 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
10636 l_rec_acct_attrs.array_num_value(10) := p_source_52;
10637 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
10638 l_rec_acct_attrs.array_num_value(11) := p_source_53;
10639 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
10640 l_rec_acct_attrs.array_char_value(12) := p_source_34;
10644 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
10641 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
10642 l_rec_acct_attrs.array_num_value(13) := p_source_54;
10643
10645 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
10646
10647 ---------------------------------------------------------------------------------------------------------------
10648 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
10649 ---------------------------------------------------------------------------------------------------------------
10650 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
10651
10652 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10653 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10654
10655 IF xla_accounting_cache_pkg.GetValueChar
10656 (p_source_code => 'LEDGER_CATEGORY_CODE'
10657 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
10658 AND l_bflow_method_code = 'PRIOR_ENTRY'
10659 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
10660 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
10661 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
10662 )
10663 THEN
10664 xla_ae_lines_pkg.BflowUpgEntry
10665 (p_business_method_code => l_bflow_method_code
10666 ,p_business_class_code => l_bflow_class_code
10667 ,p_balance_type => l_balance_type_code);
10668 ELSE
10669 NULL;
10670 -- No business flow processing for business flow method of NONE.
10671 END IF;
10672
10673 --
10674 -- call analytical criteria
10675 --
10676
10677 --
10678 -- call description
10679 --
10680 -- No description or it is inherited.
10681 --
10682 -- call ADRs
10683 -- Bug 4922099
10684 --
10685 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10686 (NVL(l_actual_upg_option, 'N') = 'O') OR
10687 (NVL(l_enc_upg_option, 'N') = 'O')
10688 )
10689 THEN
10690 NULL;
10691 --
10692 --
10693
10694 l_ccid := AcctDerRule_10(
10695 p_application_id => p_application_id
10696 , p_ae_header_id => l_ae_header_id
10697 , p_source_9 => p_source_9
10698 , x_transaction_coa_id => l_adr_transaction_coa_id
10699 , x_accounting_coa_id => l_adr_accounting_coa_id
10700 , x_value_type_code => l_adr_value_type_code
10701 , p_side => 'NA'
10702 );
10703
10704 xla_ae_lines_pkg.set_ccid(
10705 p_code_combination_id => l_ccid
10706 , p_value_type_code => l_adr_value_type_code
10707 , p_transaction_coa_id => l_adr_transaction_coa_id
10708 , p_accounting_coa_id => l_adr_accounting_coa_id
10709 , p_adr_code => 'CM_DIST_CCID'
10710 , p_adr_type_code => 'S'
10711 , p_component_type => l_component_type
10712 , p_component_code => l_component_code
10713 , p_component_type_code => l_component_type_code
10714 , p_component_appl_id => l_component_appl_id
10715 , p_amb_context_code => l_amb_context_code
10716 , p_side => 'NA'
10717 );
10718
10719
10720 --
10721 --
10722 END IF;
10723 --
10724 -- Bug 4922099
10725 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
10726 (NVL(l_enc_upg_option, 'N') = 'O')
10727 ) AND
10728 (l_bflow_method_code = 'PRIOR_ENTRY')
10729 )
10730 THEN
10731 IF
10732 --
10733 1 = 2
10734 --
10735 THEN
10736 xla_accounting_err_pkg.build_message
10737 (p_appli_s_name => 'XLA'
10738 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10739 ,p_token_1 => 'LINE_NUMBER'
10740 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
10741 ,p_token_2 => 'LINE_TYPE_NAME'
10742 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
10743 l_component_type
10744 ,l_component_code
10745 ,l_component_type_code
10746 ,l_component_appl_id
10747 ,l_amb_context_code
10748 ,l_entity_code
10749 ,l_event_class_code
10750 )
10751 ,p_token_3 => 'OWNER'
10752 ,p_value_3 => xla_lookups_pkg.get_meaning(
10756 ,p_token_4 => 'PRODUCT_NAME'
10753 p_lookup_type => 'XLA_OWNER_TYPE'
10754 ,p_lookup_code => l_component_type_code
10755 )
10757 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
10758 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
10759 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
10760 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
10761 ,p_ae_header_id => NULL
10762 );
10763
10764 IF (C_LEVEL_ERROR>= g_log_level) THEN
10765 trace
10766 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10767 ,p_level => C_LEVEL_ERROR
10768 ,p_module => l_log_module);
10769 END IF;
10770 END IF;
10771 END IF;
10772 --
10773 --
10774 ------------------------------------------------------------------------------------------------
10775 -- 4219869 Business Flow
10776 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
10777 -- Prior Entry. Currently, the following code is always generated.
10778 ------------------------------------------------------------------------------------------------
10779 XLA_AE_LINES_PKG.ValidateCurrentLine;
10780
10781 ------------------------------------------------------------------------------------
10782 -- 4219869 Business Flow
10783 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
10784 ------------------------------------------------------------------------------------
10785 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10786
10787 ----------------------------------------------------------------------------------
10788 -- 4219869 Business Flow
10789 -- Update journal entry status -- Need to generate this within IF <condition>
10790 ----------------------------------------------------------------------------------
10791 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10792 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
10793 ,p_balance_type_code => l_balance_type_code
10794 );
10795
10796 -------------------------------------------------------------------------------------------
10797 -- 4262811 - Generate the Accrual Reversal lines
10798 -------------------------------------------------------------------------------------------
10799 BEGIN
10800 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
10801 (g_array_event(p_event_id).array_value_num('header_index'));
10802 IF l_acc_rev_flag IS NULL THEN
10803 l_acc_rev_flag := 'N';
10804 END IF;
10805 EXCEPTION
10806 WHEN OTHERS THEN
10807 l_acc_rev_flag := 'N';
10808 END;
10809 --
10810 IF (l_acc_rev_flag = 'Y') THEN
10811
10812 -- 4645092 ------------------------------------------------------------------------------
10813 -- To allow MPA report to determine if it should generate report process
10814 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
10815 ------------------------------------------------------------------------------------------
10816
10817 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
10818 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
10819 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
10820 -- call ADRs
10821 -- Bug 4922099
10822 --
10823 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10824 (NVL(l_actual_upg_option, 'N') = 'O') OR
10825 (NVL(l_enc_upg_option, 'N') = 'O')
10826 )
10827 THEN
10828 NULL;
10829 --
10830 --
10831
10832 l_ccid := AcctDerRule_10(
10833 p_application_id => p_application_id
10834 , p_ae_header_id => l_ae_header_id
10835 , p_source_9 => p_source_9
10836 , x_transaction_coa_id => l_adr_transaction_coa_id
10837 , x_accounting_coa_id => l_adr_accounting_coa_id
10838 , x_value_type_code => l_adr_value_type_code
10839 , p_side => 'NA'
10840 );
10841
10842 xla_ae_lines_pkg.set_ccid(
10843 p_code_combination_id => l_ccid
10844 , p_value_type_code => l_adr_value_type_code
10845 , p_transaction_coa_id => l_adr_transaction_coa_id
10846 , p_accounting_coa_id => l_adr_accounting_coa_id
10847 , p_adr_code => 'CM_DIST_CCID'
10848 , p_adr_type_code => 'S'
10849 , p_component_type => l_component_type
10850 , p_component_code => l_component_code
10851 , p_component_type_code => l_component_type_code
10852 , p_component_appl_id => l_component_appl_id
10853 , p_amb_context_code => l_amb_context_code
10857
10854 , p_side => 'NA'
10855 );
10856
10858 --
10859 --
10860 END IF;
10861
10862 --
10863 -- Update the line information that should be overwritten
10864 --
10865 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
10866 p_header_num => 1);
10867 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
10868
10869 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
10870
10871 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
10872 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
10873 END IF;
10874
10875 --
10876 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
10877 --
10878 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
10879 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
10880 ELSE
10881 ---------------------------------------------------------------------------------------------------
10882 -- 4262811a Switch Sign
10883 ---------------------------------------------------------------------------------------------------
10884 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
10885 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10886 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10887 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10888 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10889 -- 5132302
10890 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
10891 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10892
10893 END IF;
10894
10895 -- 4955764
10896 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10897 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
10898
10899
10900 XLA_AE_LINES_PKG.ValidateCurrentLine;
10901 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10902
10903 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10904 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
10905 ,p_balance_type_code => l_balance_type_code);
10906
10907 END IF;
10908
10909 -----------------------------------------------------------------------------------------
10910 -- 4262811 Multiperiod Accounting
10911 -----------------------------------------------------------------------------------------
10912 -- No MPA option is assigned.
10913
10914
10915 END IF;
10916 END IF;
10917 --
10918
10919 --
10920 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10921 trace
10922 (p_msg => 'END of AcctLineType_45'
10923 ,p_level => C_LEVEL_PROCEDURE
10924 ,p_module => l_log_module);
10925 END IF;
10926 --
10927 EXCEPTION
10928 WHEN xla_exceptions_pkg.application_exception THEN
10929 RAISE;
10930 WHEN OTHERS THEN
10931 xla_exceptions_pkg.raise_message
10932 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_45');
10933 END AcctLineType_45;
10934 --
10935
10936 ---------------------------------------
10937 --
10938 -- PRIVATE FUNCTION
10939 -- AcctLineType_46
10940 --
10941 ---------------------------------------
10942 PROCEDURE AcctLineType_46 (
10943 p_application_id IN NUMBER
10944 ,p_event_id IN NUMBER
10945 ,p_calculate_acctd_flag IN VARCHAR2
10946 ,p_calculate_g_l_flag IN VARCHAR2
10947 ,p_actual_flag IN OUT VARCHAR2
10948 ,p_balance_type_code OUT VARCHAR2
10949 ,p_gain_or_loss_ref OUT VARCHAR2
10950
10951 --Credit Memo Distribution GL Account
10952 , p_source_9 IN NUMBER
10953 --SLA Party Type
10954 , p_source_34 IN VARCHAR2
10955 --Credit Memo Distribution Identifier
10956 , p_source_44 IN NUMBER
10957 --Credit memo distributions type
10958 , p_source_45 IN VARCHAR2
10959 --Credit Memo Currency Code
10960 , p_source_46 IN VARCHAR2
10961 --Credit Memo Exchange Date
10962 , p_source_47 IN DATE
10963 --Credit Memo Exchange Rate
10964 , p_source_48 IN NUMBER
10965 --Credit Memo Exchange Rate Type
10966 , p_source_49 IN VARCHAR2
10967 --Gain Loss Reference
10968 , p_source_50 IN VARCHAR2
10969 --Credit Memo Accounting Amount
10970 , p_source_51 IN NUMBER
10971 --Credit Memo Bill To Customer Account Identifier
10972 , p_source_52 IN NUMBER
10973 --Credit Memo Bill To Customer Site Use Identifier
10974 , p_source_53 IN NUMBER
10975 --Credit Memo Tax Line Identifier
10976 , p_source_54 IN NUMBER
10977 --Credit Memo Distribution Account Class
10978 , p_source_55 IN VARCHAR2
10979 --Credit Memo Distribution Entered Amount
10983
10980 , p_source_56 IN NUMBER
10981 )
10982 IS
10984 l_component_type VARCHAR2(80);
10985 l_component_code VARCHAR2(30);
10986 l_component_type_code VARCHAR2(1);
10987 l_component_appl_id INTEGER;
10988 l_amb_context_code VARCHAR2(30);
10989 l_entity_code VARCHAR2(30);
10990 l_event_class_code VARCHAR2(30);
10991 l_ae_header_id NUMBER;
10992 l_event_type_code VARCHAR2(30);
10993 l_line_definition_code VARCHAR2(30);
10994 l_line_definition_owner_code VARCHAR2(1);
10995 --
10996 -- adr variables
10997 l_segment VARCHAR2(30);
10998 l_ccid NUMBER;
10999 l_adr_transaction_coa_id NUMBER;
11000 l_adr_accounting_coa_id NUMBER;
11001 l_adr_flexfield_segment_code VARCHAR2(30);
11002 l_adr_flex_value_set_id NUMBER;
11003 l_adr_value_type_code VARCHAR2(30);
11004 l_adr_value_combination_id NUMBER;
11005 l_adr_value_segment_code VARCHAR2(30);
11006
11007 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
11008 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
11009 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
11010 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
11011
11012 -- 4262811 Variables ------------------------------------------------------------------------------------------
11013 l_entered_amt_idx NUMBER;
11014 l_accted_amt_idx NUMBER;
11015 l_acc_rev_flag VARCHAR2(1);
11016 l_accrual_line_num NUMBER;
11017 l_tmp_amt NUMBER;
11018 l_acc_rev_natural_side_code VARCHAR2(1);
11019
11020 l_num_entries NUMBER;
11021 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
11022 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
11023 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
11024 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
11025 l_recog_line_1 NUMBER;
11026 l_recog_line_2 NUMBER;
11027
11028 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
11029 l_bflow_applied_to_amt NUMBER; -- 5132302
11030 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
11031
11032 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
11033
11034 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
11035 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
11036
11037 ---------------------------------------------------------------------------------------------------------------
11038
11039
11040 --
11041 -- bulk performance
11042 --
11043 l_balance_type_code VARCHAR2(1);
11044 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
11045 l_log_module VARCHAR2(240);
11046
11047 --
11048 -- Upgrade strategy
11049 --
11050 l_actual_upg_option VARCHAR2(1);
11051 l_enc_upg_option VARCHAR2(1);
11052
11053 --
11054 BEGIN
11055 --
11056 IF g_log_enabled THEN
11057 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_46';
11058 END IF;
11059 --
11060 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11061
11062 trace
11063 (p_msg => 'BEGIN of AcctLineType_46'
11064 ,p_level => C_LEVEL_PROCEDURE
11065 ,p_module => l_log_module);
11066
11067 END IF;
11068 --
11069 l_component_type := 'AMB_JLT';
11070 l_component_code := 'CM_DEFAULT_TAX';
11071 l_component_type_code := 'S';
11072 l_component_appl_id := 222;
11073 l_amb_context_code := 'DEFAULT';
11074 l_entity_code := 'TRANSACTIONS';
11075 l_event_class_code := 'CREDIT_MEMO';
11076 l_event_type_code := 'CREDIT_MEMO_ALL';
11077 l_line_definition_owner_code := 'S';
11078 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
11079 --
11080 l_balance_type_code := 'A';
11081 l_segment := NULL;
11082 l_ccid := NULL;
11083 l_adr_transaction_coa_id := NULL;
11084 l_adr_accounting_coa_id := NULL;
11085 l_adr_flexfield_segment_code := NULL;
11086 l_adr_flex_value_set_id := NULL;
11087 l_adr_value_type_code := NULL;
11088 l_adr_value_combination_id := NULL;
11089 l_adr_value_segment_code := NULL;
11090
11091 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
11092 l_bflow_class_code := ''; -- 4219869 Business Flow
11093 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
11094 l_budgetary_control_flag := 'N';
11095
11096 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11097 l_bflow_applied_to_amt := NULL; -- 5132302
11098 l_entered_amt_idx := NULL; -- 4262811
11099 l_accted_amt_idx := NULL; -- 4262811
11100 l_acc_rev_flag := NULL; -- 4262811
11101 l_accrual_line_num := NULL; -- 4262811
11102 l_tmp_amt := NULL; -- 4262811
11103 --
11104
11105 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
11106 l_balance_type_code <> 'B' THEN
11107 IF NVL(p_source_55,'
11111 --
11108 ') = 'TAX'
11109 THEN
11110
11112 XLA_AE_LINES_PKG.SetNewLine;
11113
11114 p_balance_type_code := l_balance_type_code;
11115 -- set the flag so later we will know whether the gain loss line needs to be created
11116
11117 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
11118 p_actual_flag :='A';
11119 END IF;
11120
11121 --
11122 -- bulk performance
11123 --
11124 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
11125 p_header_num => 0); -- 4262811
11126 --
11127 -- set accounting line options
11128 --
11129 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
11130 p_natural_side_code => 'C'
11131 , p_gain_or_loss_flag => 'N'
11132 , p_gl_transfer_mode_code => 'S'
11133 , p_acct_entry_type_code => 'A'
11134 , p_switch_side_flag => 'Y'
11135 , p_merge_duplicate_code => 'A'
11136 );
11137 --
11138 l_acc_rev_natural_side_code := 'D'; -- 4262811
11139 --
11140 --
11141 -- set accounting line type info
11142 --
11143 xla_ae_lines_pkg.SetAcctLineType
11144 (p_component_type => l_component_type
11145 ,p_event_type_code => l_event_type_code
11146 ,p_line_definition_owner_code => l_line_definition_owner_code
11147 ,p_line_definition_code => l_line_definition_code
11148 ,p_accounting_line_code => l_component_code
11149 ,p_accounting_line_type_code => l_component_type_code
11150 ,p_accounting_line_appl_id => l_component_appl_id
11151 ,p_amb_context_code => l_amb_context_code
11152 ,p_entity_code => l_entity_code
11153 ,p_event_class_code => l_event_class_code);
11154 --
11155 -- set accounting class
11156 --
11157 xla_ae_lines_pkg.SetAcctClass(
11158 p_accounting_class_code => 'TAX'
11159 , p_ae_header_id => l_ae_header_id
11160 );
11161
11162 --
11163 -- set rounding class
11164 --
11165 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
11166 'RECEIVABLE';
11167
11168 --
11169 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
11170 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
11171 --
11172 -- bulk performance
11173 --
11174 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
11175
11176 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
11177 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
11178
11179 -- 4955764
11180 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11181 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
11182
11183 -- 4458381 Public Sector Enh
11184
11185 --
11186 -- set accounting attributes for the line type
11187 --
11188 l_entered_amt_idx := 3;
11189 l_accted_amt_idx := 9;
11190 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11191 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
11192 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_44);
11193 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
11194 l_rec_acct_attrs.array_char_value(2) := p_source_45;
11195 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
11196 l_rec_acct_attrs.array_num_value(3) := p_source_56;
11197 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
11198 l_rec_acct_attrs.array_char_value(4) := p_source_46;
11199 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
11200 l_rec_acct_attrs.array_date_value(5) := p_source_47;
11201 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
11202 l_rec_acct_attrs.array_num_value(6) := p_source_48;
11203 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
11204 l_rec_acct_attrs.array_char_value(7) := p_source_49;
11205 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
11206 l_rec_acct_attrs.array_char_value(8) := p_source_50;
11207 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
11208 l_rec_acct_attrs.array_num_value(9) := p_source_51;
11209 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
11210 l_rec_acct_attrs.array_num_value(10) := p_source_52;
11211 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
11212 l_rec_acct_attrs.array_num_value(11) := p_source_53;
11213 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
11214 l_rec_acct_attrs.array_char_value(12) := p_source_34;
11215 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
11216 l_rec_acct_attrs.array_num_value(13) := p_source_54;
11217
11218 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
11219 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
11220
11221 ---------------------------------------------------------------------------------------------------------------
11222 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
11226 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11223 ---------------------------------------------------------------------------------------------------------------
11224 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
11225
11227 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11228
11229 IF xla_accounting_cache_pkg.GetValueChar
11230 (p_source_code => 'LEDGER_CATEGORY_CODE'
11231 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
11232 AND l_bflow_method_code = 'PRIOR_ENTRY'
11233 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
11234 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
11235 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
11236 )
11237 THEN
11238 xla_ae_lines_pkg.BflowUpgEntry
11239 (p_business_method_code => l_bflow_method_code
11240 ,p_business_class_code => l_bflow_class_code
11241 ,p_balance_type => l_balance_type_code);
11242 ELSE
11243 NULL;
11244 -- No business flow processing for business flow method of NONE.
11245 END IF;
11246
11247 --
11248 -- call analytical criteria
11249 --
11250
11251 --
11252 -- call description
11253 --
11254 -- No description or it is inherited.
11255 --
11256 -- call ADRs
11257 -- Bug 4922099
11258 --
11259 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11260 (NVL(l_actual_upg_option, 'N') = 'O') OR
11261 (NVL(l_enc_upg_option, 'N') = 'O')
11262 )
11263 THEN
11264 NULL;
11265 --
11266 --
11267
11268 l_ccid := AcctDerRule_10(
11269 p_application_id => p_application_id
11270 , p_ae_header_id => l_ae_header_id
11271 , p_source_9 => p_source_9
11272 , x_transaction_coa_id => l_adr_transaction_coa_id
11273 , x_accounting_coa_id => l_adr_accounting_coa_id
11274 , x_value_type_code => l_adr_value_type_code
11275 , p_side => 'NA'
11276 );
11277
11278 xla_ae_lines_pkg.set_ccid(
11279 p_code_combination_id => l_ccid
11280 , p_value_type_code => l_adr_value_type_code
11281 , p_transaction_coa_id => l_adr_transaction_coa_id
11282 , p_accounting_coa_id => l_adr_accounting_coa_id
11283 , p_adr_code => 'CM_DIST_CCID'
11284 , p_adr_type_code => 'S'
11285 , p_component_type => l_component_type
11286 , p_component_code => l_component_code
11287 , p_component_type_code => l_component_type_code
11288 , p_component_appl_id => l_component_appl_id
11289 , p_amb_context_code => l_amb_context_code
11290 , p_side => 'NA'
11291 );
11292
11293
11294 --
11295 --
11296 END IF;
11297 --
11298 -- Bug 4922099
11299 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
11300 (NVL(l_enc_upg_option, 'N') = 'O')
11301 ) AND
11302 (l_bflow_method_code = 'PRIOR_ENTRY')
11303 )
11304 THEN
11305 IF
11306 --
11307 1 = 2
11308 --
11309 THEN
11310 xla_accounting_err_pkg.build_message
11311 (p_appli_s_name => 'XLA'
11312 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11313 ,p_token_1 => 'LINE_NUMBER'
11314 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
11315 ,p_token_2 => 'LINE_TYPE_NAME'
11316 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
11317 l_component_type
11318 ,l_component_code
11319 ,l_component_type_code
11320 ,l_component_appl_id
11321 ,l_amb_context_code
11322 ,l_entity_code
11323 ,l_event_class_code
11324 )
11325 ,p_token_3 => 'OWNER'
11326 ,p_value_3 => xla_lookups_pkg.get_meaning(
11327 p_lookup_type => 'XLA_OWNER_TYPE'
11328 ,p_lookup_code => l_component_type_code
11329 )
11330 ,p_token_4 => 'PRODUCT_NAME'
11334 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
11331 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
11332 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
11333 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
11335 ,p_ae_header_id => NULL
11336 );
11337
11338 IF (C_LEVEL_ERROR>= g_log_level) THEN
11339 trace
11340 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11341 ,p_level => C_LEVEL_ERROR
11342 ,p_module => l_log_module);
11343 END IF;
11344 END IF;
11345 END IF;
11346 --
11347 --
11348 ------------------------------------------------------------------------------------------------
11349 -- 4219869 Business Flow
11350 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
11351 -- Prior Entry. Currently, the following code is always generated.
11352 ------------------------------------------------------------------------------------------------
11353 XLA_AE_LINES_PKG.ValidateCurrentLine;
11354
11355 ------------------------------------------------------------------------------------
11356 -- 4219869 Business Flow
11357 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
11358 ------------------------------------------------------------------------------------
11359 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11360
11361 ----------------------------------------------------------------------------------
11362 -- 4219869 Business Flow
11363 -- Update journal entry status -- Need to generate this within IF <condition>
11364 ----------------------------------------------------------------------------------
11365 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11366 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
11367 ,p_balance_type_code => l_balance_type_code
11368 );
11369
11370 -------------------------------------------------------------------------------------------
11371 -- 4262811 - Generate the Accrual Reversal lines
11372 -------------------------------------------------------------------------------------------
11373 BEGIN
11374 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
11375 (g_array_event(p_event_id).array_value_num('header_index'));
11376 IF l_acc_rev_flag IS NULL THEN
11377 l_acc_rev_flag := 'N';
11378 END IF;
11379 EXCEPTION
11380 WHEN OTHERS THEN
11381 l_acc_rev_flag := 'N';
11382 END;
11383 --
11384 IF (l_acc_rev_flag = 'Y') THEN
11385
11386 -- 4645092 ------------------------------------------------------------------------------
11387 -- To allow MPA report to determine if it should generate report process
11388 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
11389 ------------------------------------------------------------------------------------------
11390
11391 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
11392 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
11393 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
11394 -- call ADRs
11395 -- Bug 4922099
11396 --
11397 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11398 (NVL(l_actual_upg_option, 'N') = 'O') OR
11399 (NVL(l_enc_upg_option, 'N') = 'O')
11400 )
11401 THEN
11402 NULL;
11403 --
11404 --
11405
11406 l_ccid := AcctDerRule_10(
11407 p_application_id => p_application_id
11408 , p_ae_header_id => l_ae_header_id
11409 , p_source_9 => p_source_9
11410 , x_transaction_coa_id => l_adr_transaction_coa_id
11411 , x_accounting_coa_id => l_adr_accounting_coa_id
11412 , x_value_type_code => l_adr_value_type_code
11413 , p_side => 'NA'
11414 );
11415
11416 xla_ae_lines_pkg.set_ccid(
11417 p_code_combination_id => l_ccid
11418 , p_value_type_code => l_adr_value_type_code
11419 , p_transaction_coa_id => l_adr_transaction_coa_id
11420 , p_accounting_coa_id => l_adr_accounting_coa_id
11421 , p_adr_code => 'CM_DIST_CCID'
11422 , p_adr_type_code => 'S'
11423 , p_component_type => l_component_type
11424 , p_component_code => l_component_code
11425 , p_component_type_code => l_component_type_code
11426 , p_component_appl_id => l_component_appl_id
11427 , p_amb_context_code => l_amb_context_code
11428 , p_side => 'NA'
11429 );
11430
11431
11432 --
11433 --
11434 END IF;
11435
11436 --
11437 -- Update the line information that should be overwritten
11438 --
11439 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
11443 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
11440 p_header_num => 1);
11441 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
11442
11444
11445 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
11446 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
11447 END IF;
11448
11449 --
11450 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
11451 --
11452 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
11453 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
11454 ELSE
11455 ---------------------------------------------------------------------------------------------------
11456 -- 4262811a Switch Sign
11457 ---------------------------------------------------------------------------------------------------
11458 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
11459 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11460 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11461 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11462 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11463 -- 5132302
11464 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
11465 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11466
11467 END IF;
11468
11469 -- 4955764
11470 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11471 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
11472
11473
11474 XLA_AE_LINES_PKG.ValidateCurrentLine;
11475 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11476
11477 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11478 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
11479 ,p_balance_type_code => l_balance_type_code);
11480
11481 END IF;
11482
11483 -----------------------------------------------------------------------------------------
11484 -- 4262811 Multiperiod Accounting
11485 -----------------------------------------------------------------------------------------
11486 -- No MPA option is assigned.
11487
11488
11489 END IF;
11490 END IF;
11491 --
11492
11493 --
11494 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11495 trace
11496 (p_msg => 'END of AcctLineType_46'
11497 ,p_level => C_LEVEL_PROCEDURE
11498 ,p_module => l_log_module);
11499 END IF;
11500 --
11501 EXCEPTION
11502 WHEN xla_exceptions_pkg.application_exception THEN
11503 RAISE;
11504 WHEN OTHERS THEN
11505 xla_exceptions_pkg.raise_message
11506 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_46');
11507 END AcctLineType_46;
11508 --
11509
11510 ---------------------------------------
11511 --
11512 -- PRIVATE FUNCTION
11513 -- AcctLineType_47
11514 --
11515 ---------------------------------------
11516 PROCEDURE AcctLineType_47 (
11517 p_application_id IN NUMBER
11518 ,p_event_id IN NUMBER
11519 ,p_calculate_acctd_flag IN VARCHAR2
11520 ,p_calculate_g_l_flag IN VARCHAR2
11521 ,p_actual_flag IN OUT VARCHAR2
11522 ,p_balance_type_code OUT VARCHAR2
11523 ,p_gain_or_loss_ref OUT VARCHAR2
11524
11525 --System Gain Account
11526 , p_source_19 IN NUMBER
11527 --System Loss Account
11528 , p_source_20 IN NUMBER
11529 --SLA Party Type
11530 , p_source_34 IN VARCHAR2
11531 --Credit Memo Distribution Identifier
11532 , p_source_44 IN NUMBER
11533 --Credit memo distributions type
11534 , p_source_45 IN VARCHAR2
11535 --Gain Loss Reference
11536 , p_source_50 IN VARCHAR2
11537 --Credit Memo Accounting Amount
11538 , p_source_51 IN NUMBER
11539 --Credit Memo Bill To Customer Account Identifier
11540 , p_source_52 IN NUMBER
11541 --Credit Memo Bill To Customer Site Use Identifier
11542 , p_source_53 IN NUMBER
11543 --Credit Memo Tax Line Identifier
11544 , p_source_54 IN NUMBER
11545 )
11546 IS
11547
11548 l_component_type VARCHAR2(80);
11549 l_component_code VARCHAR2(30);
11550 l_component_type_code VARCHAR2(1);
11551 l_component_appl_id INTEGER;
11552 l_amb_context_code VARCHAR2(30);
11553 l_entity_code VARCHAR2(30);
11554 l_event_class_code VARCHAR2(30);
11555 l_ae_header_id NUMBER;
11556 l_event_type_code VARCHAR2(30);
11557 l_line_definition_code VARCHAR2(30);
11558 l_line_definition_owner_code VARCHAR2(1);
11559 --
11560 -- adr variables
11561 l_segment VARCHAR2(30);
11562 l_ccid NUMBER;
11566 l_adr_flex_value_set_id NUMBER;
11563 l_adr_transaction_coa_id NUMBER;
11564 l_adr_accounting_coa_id NUMBER;
11565 l_adr_flexfield_segment_code VARCHAR2(30);
11567 l_adr_value_type_code VARCHAR2(30);
11568 l_adr_value_combination_id NUMBER;
11569 l_adr_value_segment_code VARCHAR2(30);
11570
11571 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
11572 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
11573 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
11574 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
11575
11576 -- 4262811 Variables ------------------------------------------------------------------------------------------
11577 l_entered_amt_idx NUMBER;
11578 l_accted_amt_idx NUMBER;
11579 l_acc_rev_flag VARCHAR2(1);
11580 l_accrual_line_num NUMBER;
11581 l_tmp_amt NUMBER;
11582 l_acc_rev_natural_side_code VARCHAR2(1);
11583
11584 l_num_entries NUMBER;
11585 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
11586 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
11587 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
11588 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
11589 l_recog_line_1 NUMBER;
11590 l_recog_line_2 NUMBER;
11591
11592 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
11593 l_bflow_applied_to_amt NUMBER; -- 5132302
11594 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
11595
11596 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
11597
11598 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
11599 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
11600
11601 ---------------------------------------------------------------------------------------------------------------
11602
11603
11604 --
11605 -- bulk performance
11606 --
11607 l_balance_type_code VARCHAR2(1);
11608 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
11609 l_log_module VARCHAR2(240);
11610
11611 --
11612 -- Upgrade strategy
11613 --
11614 l_actual_upg_option VARCHAR2(1);
11615 l_enc_upg_option VARCHAR2(1);
11616
11617 --
11618 BEGIN
11619 --
11620 IF g_log_enabled THEN
11621 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_47';
11622 END IF;
11623 --
11624 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11625
11626 trace
11627 (p_msg => 'BEGIN of AcctLineType_47'
11628 ,p_level => C_LEVEL_PROCEDURE
11629 ,p_module => l_log_module);
11630
11631 END IF;
11632 --
11633 l_component_type := 'AMB_JLT';
11634 l_component_code := 'CM_EXCH_GAIN_LOSS';
11635 l_component_type_code := 'S';
11636 l_component_appl_id := 222;
11637 l_amb_context_code := 'DEFAULT';
11638 l_entity_code := 'TRANSACTIONS';
11639 l_event_class_code := 'CREDIT_MEMO';
11640 l_event_type_code := 'CREDIT_MEMO_ALL';
11641 l_line_definition_owner_code := 'S';
11642 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
11643 --
11644 l_balance_type_code := 'A';
11645 l_segment := NULL;
11646 l_ccid := NULL;
11647 l_adr_transaction_coa_id := NULL;
11648 l_adr_accounting_coa_id := NULL;
11649 l_adr_flexfield_segment_code := NULL;
11650 l_adr_flex_value_set_id := NULL;
11651 l_adr_value_type_code := NULL;
11652 l_adr_value_combination_id := NULL;
11653 l_adr_value_segment_code := NULL;
11654
11655 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
11656 l_bflow_class_code := ''; -- 4219869 Business Flow
11657 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
11658 l_budgetary_control_flag := 'N';
11659
11660 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11661 l_bflow_applied_to_amt := NULL; -- 5132302
11662 l_entered_amt_idx := NULL; -- 4262811
11663 l_accted_amt_idx := NULL; -- 4262811
11664 l_acc_rev_flag := NULL; -- 4262811
11665 l_accrual_line_num := NULL; -- 4262811
11666 l_tmp_amt := NULL; -- 4262811
11667 --
11668 IF NOT ((p_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
11669 (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')) THEN
11670 return;
11671 END IF;
11672
11673 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
11674 l_balance_type_code <> 'B' THEN
11675
11676 --
11677 XLA_AE_LINES_PKG.SetNewLine;
11678
11679 p_balance_type_code := l_balance_type_code;
11680 -- set the flag so later we will know whether the gain loss line needs to be created
11681
11682 IF(l_balance_type_code = 'A' ) THEN
11683 p_actual_flag :='G';
11684 END IF;
11685
11686 --
11690 p_header_num => 0); -- 4262811
11687 -- bulk performance
11688 --
11689 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
11691 --
11692 -- set accounting line options
11693 --
11694 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
11695 p_natural_side_code => 'G'
11696 , p_gain_or_loss_flag => 'N'
11697 , p_gl_transfer_mode_code => 'S'
11698 , p_acct_entry_type_code => 'A'
11699 , p_switch_side_flag => ''
11700 , p_merge_duplicate_code => 'A'
11701 );
11702 --
11703 l_acc_rev_natural_side_code := 'C'; -- 4262811
11704 --
11705 --
11706 -- set accounting line type info
11707 --
11708 xla_ae_lines_pkg.SetAcctLineType
11709 (p_component_type => l_component_type
11710 ,p_event_type_code => l_event_type_code
11711 ,p_line_definition_owner_code => l_line_definition_owner_code
11712 ,p_line_definition_code => l_line_definition_code
11713 ,p_accounting_line_code => l_component_code
11714 ,p_accounting_line_type_code => l_component_type_code
11715 ,p_accounting_line_appl_id => l_component_appl_id
11716 ,p_amb_context_code => l_amb_context_code
11717 ,p_entity_code => l_entity_code
11718 ,p_event_class_code => l_event_class_code);
11719 --
11720 -- set accounting class
11721 --
11722 xla_ae_lines_pkg.SetAcctClass(
11723 p_accounting_class_code => 'EXCHANGE_GAIN_LOSS'
11724 , p_ae_header_id => l_ae_header_id
11725 );
11726
11727 --
11728 -- set rounding class
11729 --
11730 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
11731 'EXCHANGE_GAIN_LOSS';
11732
11733 --
11734 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
11735 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
11736 --
11737 -- bulk performance
11738 --
11739 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
11740
11741 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
11742 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
11743
11744 -- 4955764
11745 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11746 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
11747
11748 -- 4458381 Public Sector Enh
11749
11750 --
11751 -- set accounting attributes for the line type
11752 --
11753 l_entered_amt_idx := NULL;
11754 l_accted_amt_idx := 4;
11755 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11756 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
11757 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_44);
11758 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
11759 l_rec_acct_attrs.array_char_value(2) := p_source_45;
11760 l_rec_acct_attrs.array_acct_attr_code(3) := 'GAIN_LOSS_REFERENCE';
11761 l_rec_acct_attrs.array_char_value(3) := p_source_50;
11762 l_rec_acct_attrs.array_acct_attr_code(4) := 'LEDGER_AMOUNT';
11763 l_rec_acct_attrs.array_num_value(4) := p_source_51;
11764 l_rec_acct_attrs.array_acct_attr_code(5) := 'PARTY_ID';
11765 l_rec_acct_attrs.array_num_value(5) := p_source_52;
11766 l_rec_acct_attrs.array_acct_attr_code(6) := 'PARTY_SITE_ID';
11767 l_rec_acct_attrs.array_num_value(6) := p_source_53;
11768 l_rec_acct_attrs.array_acct_attr_code(7) := 'PARTY_TYPE';
11769 l_rec_acct_attrs.array_char_value(7) := p_source_34;
11770 l_rec_acct_attrs.array_acct_attr_code(8) := 'TAX_LINE_REF_ID';
11771 l_rec_acct_attrs.array_num_value(8) := p_source_54;
11772
11773 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
11774 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
11775
11776 ---------------------------------------------------------------------------------------------------------------
11777 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
11778 ---------------------------------------------------------------------------------------------------------------
11779 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
11780
11781 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11782 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11783
11784 IF xla_accounting_cache_pkg.GetValueChar
11785 (p_source_code => 'LEDGER_CATEGORY_CODE'
11786 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
11787 AND l_bflow_method_code = 'PRIOR_ENTRY'
11788 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
11789 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
11790 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
11791 )
11792 THEN
11793 xla_ae_lines_pkg.BflowUpgEntry
11797 ELSE
11794 (p_business_method_code => l_bflow_method_code
11795 ,p_business_class_code => l_bflow_class_code
11796 ,p_balance_type => l_balance_type_code);
11798 NULL;
11799 -- No business flow processing for business flow method of NONE.
11800 END IF;
11801
11802 --
11803 -- call analytical criteria
11804 --
11805
11806 --
11807 -- call description
11808 --
11809 -- No description or it is inherited.
11810 --
11811 -- call ADRs
11812 -- Bug 4922099
11813 --
11814 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11815 (NVL(l_actual_upg_option, 'N') = 'O') OR
11816 (NVL(l_enc_upg_option, 'N') = 'O')
11817 )
11818 THEN
11819 NULL;
11820 --
11821 --
11822
11823 l_ccid := AcctDerRule_32(
11824 p_application_id => p_application_id
11825 , p_ae_header_id => l_ae_header_id
11826 , p_source_19 => p_source_19
11827 , x_transaction_coa_id => l_adr_transaction_coa_id
11828 , x_accounting_coa_id => l_adr_accounting_coa_id
11829 , x_value_type_code => l_adr_value_type_code
11830 , p_side => 'CREDIT'
11831 );
11832
11833 xla_ae_lines_pkg.set_ccid(
11834 p_code_combination_id => l_ccid
11835 , p_value_type_code => l_adr_value_type_code
11836 , p_transaction_coa_id => l_adr_transaction_coa_id
11837 , p_accounting_coa_id => l_adr_accounting_coa_id
11838 , p_adr_code => 'SYS_GAIN_CCID'
11839 , p_adr_type_code => 'S'
11840 , p_component_type => l_component_type
11841 , p_component_code => l_component_code
11842 , p_component_type_code => l_component_type_code
11843 , p_component_appl_id => l_component_appl_id
11844 , p_amb_context_code => l_amb_context_code
11845 , p_side => 'CREDIT'
11846 );
11847
11848
11849 l_ccid := AcctDerRule_33(
11850 p_application_id => p_application_id
11851 , p_ae_header_id => l_ae_header_id
11852 , p_source_20 => p_source_20
11853 , x_transaction_coa_id => l_adr_transaction_coa_id
11854 , x_accounting_coa_id => l_adr_accounting_coa_id
11855 , x_value_type_code => l_adr_value_type_code
11856 , p_side => 'DEBIT'
11857 );
11858
11859 xla_ae_lines_pkg.set_ccid(
11860 p_code_combination_id => l_ccid
11861 , p_value_type_code => l_adr_value_type_code
11862 , p_transaction_coa_id => l_adr_transaction_coa_id
11863 , p_accounting_coa_id => l_adr_accounting_coa_id
11864 , p_adr_code => 'SYS_LOSS_CCID'
11865 , p_adr_type_code => 'S'
11866 , p_component_type => l_component_type
11867 , p_component_code => l_component_code
11868 , p_component_type_code => l_component_type_code
11869 , p_component_appl_id => l_component_appl_id
11870 , p_amb_context_code => l_amb_context_code
11871 , p_side => 'DEBIT'
11872 );
11873
11874
11875 --
11876 --
11877 END IF;
11878 --
11879 -- Bug 4922099
11880 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
11881 (NVL(l_enc_upg_option, 'N') = 'O')
11882 ) AND
11883 (l_bflow_method_code = 'PRIOR_ENTRY')
11884 )
11885 THEN
11886 IF
11887 --
11888 1 = 2
11889 --
11890 THEN
11891 xla_accounting_err_pkg.build_message
11892 (p_appli_s_name => 'XLA'
11893 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11894 ,p_token_1 => 'LINE_NUMBER'
11895 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
11896 ,p_token_2 => 'LINE_TYPE_NAME'
11897 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
11898 l_component_type
11899 ,l_component_code
11900 ,l_component_type_code
11901 ,l_component_appl_id
11902 ,l_amb_context_code
11903 ,l_entity_code
11904 ,l_event_class_code
11905 )
11906 ,p_token_3 => 'OWNER'
11907 ,p_value_3 => xla_lookups_pkg.get_meaning(
11908 p_lookup_type => 'XLA_OWNER_TYPE'
11909 ,p_lookup_code => l_component_type_code
11913 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
11910 )
11911 ,p_token_4 => 'PRODUCT_NAME'
11912 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
11914 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
11915 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
11916 ,p_ae_header_id => NULL
11917 );
11918
11919 IF (C_LEVEL_ERROR>= g_log_level) THEN
11920 trace
11921 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11922 ,p_level => C_LEVEL_ERROR
11923 ,p_module => l_log_module);
11924 END IF;
11925 END IF;
11926 END IF;
11927 --
11928 --
11929 ------------------------------------------------------------------------------------------------
11930 -- 4219869 Business Flow
11931 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
11932 -- Prior Entry. Currently, the following code is always generated.
11933 ------------------------------------------------------------------------------------------------
11934 XLA_AE_LINES_PKG.ValidateCurrentLine;
11935
11936 ------------------------------------------------------------------------------------
11937 -- 4219869 Business Flow
11938 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
11939 ------------------------------------------------------------------------------------
11940 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11941
11942 ----------------------------------------------------------------------------------
11943 -- 4219869 Business Flow
11944 -- Update journal entry status -- Need to generate this within IF <condition>
11945 ----------------------------------------------------------------------------------
11946 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11947 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
11948 ,p_balance_type_code => l_balance_type_code
11949 );
11950
11951 -------------------------------------------------------------------------------------------
11952 -- 4262811 - Generate the Accrual Reversal lines
11953 -------------------------------------------------------------------------------------------
11954 BEGIN
11955 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
11956 (g_array_event(p_event_id).array_value_num('header_index'));
11957 IF l_acc_rev_flag IS NULL THEN
11958 l_acc_rev_flag := 'N';
11959 END IF;
11960 EXCEPTION
11961 WHEN OTHERS THEN
11962 l_acc_rev_flag := 'N';
11963 END;
11964 --
11965 IF (l_acc_rev_flag = 'Y') THEN
11966
11967 -- 4645092 ------------------------------------------------------------------------------
11968 -- To allow MPA report to determine if it should generate report process
11969 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
11970 ------------------------------------------------------------------------------------------
11971
11972 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
11973 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
11974 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
11975 -- call ADRs
11976 -- Bug 4922099
11977 --
11978 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11979 (NVL(l_actual_upg_option, 'N') = 'O') OR
11980 (NVL(l_enc_upg_option, 'N') = 'O')
11981 )
11982 THEN
11983 NULL;
11984 --
11985 --
11986
11987 l_ccid := AcctDerRule_32(
11988 p_application_id => p_application_id
11989 , p_ae_header_id => l_ae_header_id
11990 , p_source_19 => p_source_19
11991 , x_transaction_coa_id => l_adr_transaction_coa_id
11992 , x_accounting_coa_id => l_adr_accounting_coa_id
11993 , x_value_type_code => l_adr_value_type_code
11994 , p_side => 'CREDIT'
11995 );
11996
11997 xla_ae_lines_pkg.set_ccid(
11998 p_code_combination_id => l_ccid
11999 , p_value_type_code => l_adr_value_type_code
12000 , p_transaction_coa_id => l_adr_transaction_coa_id
12001 , p_accounting_coa_id => l_adr_accounting_coa_id
12002 , p_adr_code => 'SYS_GAIN_CCID'
12003 , p_adr_type_code => 'S'
12004 , p_component_type => l_component_type
12005 , p_component_code => l_component_code
12006 , p_component_type_code => l_component_type_code
12007 , p_component_appl_id => l_component_appl_id
12008 , p_amb_context_code => l_amb_context_code
12009 , p_side => 'CREDIT'
12010 );
12011
12012
12013 l_ccid := AcctDerRule_33(
12014 p_application_id => p_application_id
12015 , p_ae_header_id => l_ae_header_id
12019 , x_value_type_code => l_adr_value_type_code
12016 , p_source_20 => p_source_20
12017 , x_transaction_coa_id => l_adr_transaction_coa_id
12018 , x_accounting_coa_id => l_adr_accounting_coa_id
12020 , p_side => 'DEBIT'
12021 );
12022
12023 xla_ae_lines_pkg.set_ccid(
12024 p_code_combination_id => l_ccid
12025 , p_value_type_code => l_adr_value_type_code
12026 , p_transaction_coa_id => l_adr_transaction_coa_id
12027 , p_accounting_coa_id => l_adr_accounting_coa_id
12028 , p_adr_code => 'SYS_LOSS_CCID'
12029 , p_adr_type_code => 'S'
12030 , p_component_type => l_component_type
12031 , p_component_code => l_component_code
12032 , p_component_type_code => l_component_type_code
12033 , p_component_appl_id => l_component_appl_id
12034 , p_amb_context_code => l_amb_context_code
12035 , p_side => 'DEBIT'
12036 );
12037
12038
12039 --
12040 --
12041 END IF;
12042
12043 --
12044 -- Update the line information that should be overwritten
12045 --
12046 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
12047 p_header_num => 1);
12048 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
12049
12050 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
12051
12052 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
12053 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
12054 END IF;
12055
12056 --
12057 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
12058 --
12059 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
12060 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
12061 ELSE
12062 ---------------------------------------------------------------------------------------------------
12063 -- 4262811a Switch Sign
12064 ---------------------------------------------------------------------------------------------------
12065 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
12066 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12067 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12068 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12069 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12070 -- 5132302
12071 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
12072 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12073
12074 END IF;
12075
12076 -- 4955764
12077 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12078 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
12079
12080
12081 XLA_AE_LINES_PKG.ValidateCurrentLine;
12082 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12083
12084 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12085 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
12086 ,p_balance_type_code => l_balance_type_code);
12087
12088 END IF;
12089
12090 -----------------------------------------------------------------------------------------
12091 -- 4262811 Multiperiod Accounting
12092 -----------------------------------------------------------------------------------------
12093 -- No MPA option is assigned.
12094
12095
12096 END IF;
12097 --
12098
12099 --
12100 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12101 trace
12102 (p_msg => 'END of AcctLineType_47'
12103 ,p_level => C_LEVEL_PROCEDURE
12104 ,p_module => l_log_module);
12105 END IF;
12106 --
12107 EXCEPTION
12108 WHEN xla_exceptions_pkg.application_exception THEN
12109 RAISE;
12110 WHEN OTHERS THEN
12111 xla_exceptions_pkg.raise_message
12112 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_47');
12113 END AcctLineType_47;
12114 --
12115
12116 ---------------------------------------
12117 --
12118 -- PRIVATE FUNCTION
12119 -- AcctLineType_48
12120 --
12121 ---------------------------------------
12122 PROCEDURE AcctLineType_48 (
12123 p_application_id IN NUMBER
12124 ,p_event_id IN NUMBER
12125 ,p_calculate_acctd_flag IN VARCHAR2
12126 ,p_calculate_g_l_flag IN VARCHAR2
12127 ,p_actual_flag IN OUT VARCHAR2
12128 ,p_balance_type_code OUT VARCHAR2
12129 ,p_gain_or_loss_ref OUT VARCHAR2
12130
12131 --Credit Memo Distribution GL Account
12132 , p_source_9 IN NUMBER
12133 --SLA Party Type
12134 , p_source_34 IN VARCHAR2
12135 --Credit Memo Distribution Identifier
12136 , p_source_44 IN NUMBER
12137 --Credit memo distributions type
12141 --Credit Memo Exchange Date
12138 , p_source_45 IN VARCHAR2
12139 --Credit Memo Currency Code
12140 , p_source_46 IN VARCHAR2
12142 , p_source_47 IN DATE
12143 --Credit Memo Exchange Rate
12144 , p_source_48 IN NUMBER
12145 --Credit Memo Exchange Rate Type
12146 , p_source_49 IN VARCHAR2
12147 --Gain Loss Reference
12148 , p_source_50 IN VARCHAR2
12149 --Credit Memo Accounting Amount
12150 , p_source_51 IN NUMBER
12151 --Credit Memo Bill To Customer Account Identifier
12152 , p_source_52 IN NUMBER
12153 --Credit Memo Bill To Customer Site Use Identifier
12154 , p_source_53 IN NUMBER
12155 --Credit Memo Tax Line Identifier
12156 , p_source_54 IN NUMBER
12157 --Credit Memo Distribution Account Class
12158 , p_source_55 IN VARCHAR2
12159 --Credit Memo Distribution Entered Amount
12160 , p_source_56 IN NUMBER
12161 )
12162 IS
12163
12164 l_component_type VARCHAR2(80);
12165 l_component_code VARCHAR2(30);
12166 l_component_type_code VARCHAR2(1);
12167 l_component_appl_id INTEGER;
12168 l_amb_context_code VARCHAR2(30);
12169 l_entity_code VARCHAR2(30);
12170 l_event_class_code VARCHAR2(30);
12171 l_ae_header_id NUMBER;
12172 l_event_type_code VARCHAR2(30);
12173 l_line_definition_code VARCHAR2(30);
12174 l_line_definition_owner_code VARCHAR2(1);
12175 --
12176 -- adr variables
12177 l_segment VARCHAR2(30);
12178 l_ccid NUMBER;
12179 l_adr_transaction_coa_id NUMBER;
12180 l_adr_accounting_coa_id NUMBER;
12181 l_adr_flexfield_segment_code VARCHAR2(30);
12182 l_adr_flex_value_set_id NUMBER;
12183 l_adr_value_type_code VARCHAR2(30);
12184 l_adr_value_combination_id NUMBER;
12185 l_adr_value_segment_code VARCHAR2(30);
12186
12187 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
12188 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
12189 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
12190 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
12191
12192 -- 4262811 Variables ------------------------------------------------------------------------------------------
12193 l_entered_amt_idx NUMBER;
12194 l_accted_amt_idx NUMBER;
12195 l_acc_rev_flag VARCHAR2(1);
12196 l_accrual_line_num NUMBER;
12197 l_tmp_amt NUMBER;
12198 l_acc_rev_natural_side_code VARCHAR2(1);
12199
12200 l_num_entries NUMBER;
12201 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
12202 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
12203 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
12204 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
12205 l_recog_line_1 NUMBER;
12206 l_recog_line_2 NUMBER;
12207
12208 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
12209 l_bflow_applied_to_amt NUMBER; -- 5132302
12210 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
12211
12212 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
12213
12214 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
12215 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
12216
12217 ---------------------------------------------------------------------------------------------------------------
12218
12219
12220 --
12221 -- bulk performance
12222 --
12223 l_balance_type_code VARCHAR2(1);
12224 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
12225 l_log_module VARCHAR2(240);
12226
12227 --
12228 -- Upgrade strategy
12229 --
12230 l_actual_upg_option VARCHAR2(1);
12231 l_enc_upg_option VARCHAR2(1);
12232
12233 --
12234 BEGIN
12235 --
12236 IF g_log_enabled THEN
12237 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_48';
12238 END IF;
12239 --
12240 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12241
12242 trace
12243 (p_msg => 'BEGIN of AcctLineType_48'
12244 ,p_level => C_LEVEL_PROCEDURE
12245 ,p_module => l_log_module);
12246
12247 END IF;
12248 --
12249 l_component_type := 'AMB_JLT';
12250 l_component_code := 'CM_ROUND';
12251 l_component_type_code := 'S';
12252 l_component_appl_id := 222;
12253 l_amb_context_code := 'DEFAULT';
12254 l_entity_code := 'TRANSACTIONS';
12255 l_event_class_code := 'CREDIT_MEMO';
12256 l_event_type_code := 'CREDIT_MEMO_ALL';
12257 l_line_definition_owner_code := 'S';
12258 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
12259 --
12260 l_balance_type_code := 'A';
12261 l_segment := NULL;
12262 l_ccid := NULL;
12263 l_adr_transaction_coa_id := NULL;
12264 l_adr_accounting_coa_id := NULL;
12265 l_adr_flexfield_segment_code := NULL;
12266 l_adr_flex_value_set_id := NULL;
12267 l_adr_value_type_code := NULL;
12271 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
12268 l_adr_value_combination_id := NULL;
12269 l_adr_value_segment_code := NULL;
12270
12272 l_bflow_class_code := ''; -- 4219869 Business Flow
12273 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
12274 l_budgetary_control_flag := 'N';
12275
12276 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12277 l_bflow_applied_to_amt := NULL; -- 5132302
12278 l_entered_amt_idx := NULL; -- 4262811
12279 l_accted_amt_idx := NULL; -- 4262811
12280 l_acc_rev_flag := NULL; -- 4262811
12281 l_accrual_line_num := NULL; -- 4262811
12282 l_tmp_amt := NULL; -- 4262811
12283 --
12284
12285 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
12286 l_balance_type_code <> 'B' THEN
12287 IF NVL(p_source_55,'
12288 ') = 'ROUND'
12289 THEN
12290
12291 --
12292 XLA_AE_LINES_PKG.SetNewLine;
12293
12294 p_balance_type_code := l_balance_type_code;
12295 -- set the flag so later we will know whether the gain loss line needs to be created
12296
12297 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
12298 p_actual_flag :='A';
12299 END IF;
12300
12301 --
12302 -- bulk performance
12303 --
12304 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
12305 p_header_num => 0); -- 4262811
12306 --
12307 -- set accounting line options
12308 --
12309 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
12310 p_natural_side_code => 'C'
12311 , p_gain_or_loss_flag => 'N'
12312 , p_gl_transfer_mode_code => 'S'
12313 , p_acct_entry_type_code => 'A'
12314 , p_switch_side_flag => 'Y'
12315 , p_merge_duplicate_code => 'A'
12316 );
12317 --
12318 l_acc_rev_natural_side_code := 'D'; -- 4262811
12319 --
12320 --
12321 -- set accounting line type info
12322 --
12323 xla_ae_lines_pkg.SetAcctLineType
12324 (p_component_type => l_component_type
12325 ,p_event_type_code => l_event_type_code
12326 ,p_line_definition_owner_code => l_line_definition_owner_code
12327 ,p_line_definition_code => l_line_definition_code
12328 ,p_accounting_line_code => l_component_code
12329 ,p_accounting_line_type_code => l_component_type_code
12330 ,p_accounting_line_appl_id => l_component_appl_id
12331 ,p_amb_context_code => l_amb_context_code
12332 ,p_entity_code => l_entity_code
12333 ,p_event_class_code => l_event_class_code);
12334 --
12335 -- set accounting class
12336 --
12337 xla_ae_lines_pkg.SetAcctClass(
12338 p_accounting_class_code => 'ROUNDING'
12339 , p_ae_header_id => l_ae_header_id
12340 );
12341
12342 --
12343 -- set rounding class
12344 --
12345 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
12346 'RECEIVABLE';
12347
12348 --
12349 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
12350 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
12351 --
12352 -- bulk performance
12353 --
12354 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
12355
12356 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
12357 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
12358
12359 -- 4955764
12360 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12361 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
12362
12363 -- 4458381 Public Sector Enh
12364
12365 --
12366 -- set accounting attributes for the line type
12367 --
12368 l_entered_amt_idx := 3;
12369 l_accted_amt_idx := 9;
12370 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12371 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
12372 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_44);
12373 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
12374 l_rec_acct_attrs.array_char_value(2) := p_source_45;
12375 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
12376 l_rec_acct_attrs.array_num_value(3) := p_source_56;
12377 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
12378 l_rec_acct_attrs.array_char_value(4) := p_source_46;
12379 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
12380 l_rec_acct_attrs.array_date_value(5) := p_source_47;
12381 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
12382 l_rec_acct_attrs.array_num_value(6) := p_source_48;
12383 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
12384 l_rec_acct_attrs.array_char_value(7) := p_source_49;
12385 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
12389 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
12386 l_rec_acct_attrs.array_char_value(8) := p_source_50;
12387 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
12388 l_rec_acct_attrs.array_num_value(9) := p_source_51;
12390 l_rec_acct_attrs.array_num_value(10) := p_source_52;
12391 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
12392 l_rec_acct_attrs.array_num_value(11) := p_source_53;
12393 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
12394 l_rec_acct_attrs.array_char_value(12) := p_source_34;
12395 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
12396 l_rec_acct_attrs.array_num_value(13) := p_source_54;
12397
12398 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
12399 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
12400
12401 ---------------------------------------------------------------------------------------------------------------
12402 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
12403 ---------------------------------------------------------------------------------------------------------------
12404 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
12405
12406 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12407 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12408
12409 IF xla_accounting_cache_pkg.GetValueChar
12410 (p_source_code => 'LEDGER_CATEGORY_CODE'
12411 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
12412 AND l_bflow_method_code = 'PRIOR_ENTRY'
12413 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
12414 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
12415 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
12416 )
12417 THEN
12418 xla_ae_lines_pkg.BflowUpgEntry
12419 (p_business_method_code => l_bflow_method_code
12420 ,p_business_class_code => l_bflow_class_code
12421 ,p_balance_type => l_balance_type_code);
12422 ELSE
12423 NULL;
12424 -- No business flow processing for business flow method of NONE.
12425 END IF;
12426
12427 --
12428 -- call analytical criteria
12429 --
12430
12431 --
12432 -- call description
12433 --
12434 -- No description or it is inherited.
12435 --
12436 -- call ADRs
12437 -- Bug 4922099
12438 --
12439 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12440 (NVL(l_actual_upg_option, 'N') = 'O') OR
12441 (NVL(l_enc_upg_option, 'N') = 'O')
12442 )
12443 THEN
12444 NULL;
12445 --
12446 --
12447
12448 l_ccid := AcctDerRule_10(
12449 p_application_id => p_application_id
12450 , p_ae_header_id => l_ae_header_id
12451 , p_source_9 => p_source_9
12452 , x_transaction_coa_id => l_adr_transaction_coa_id
12453 , x_accounting_coa_id => l_adr_accounting_coa_id
12454 , x_value_type_code => l_adr_value_type_code
12455 , p_side => 'NA'
12456 );
12457
12458 xla_ae_lines_pkg.set_ccid(
12459 p_code_combination_id => l_ccid
12460 , p_value_type_code => l_adr_value_type_code
12461 , p_transaction_coa_id => l_adr_transaction_coa_id
12462 , p_accounting_coa_id => l_adr_accounting_coa_id
12463 , p_adr_code => 'CM_DIST_CCID'
12464 , p_adr_type_code => 'S'
12465 , p_component_type => l_component_type
12466 , p_component_code => l_component_code
12467 , p_component_type_code => l_component_type_code
12468 , p_component_appl_id => l_component_appl_id
12469 , p_amb_context_code => l_amb_context_code
12470 , p_side => 'NA'
12471 );
12472
12473
12474 --
12475 --
12476 END IF;
12477 --
12478 -- Bug 4922099
12479 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
12480 (NVL(l_enc_upg_option, 'N') = 'O')
12481 ) AND
12482 (l_bflow_method_code = 'PRIOR_ENTRY')
12483 )
12484 THEN
12485 IF
12486 --
12487 1 = 2
12488 --
12489 THEN
12490 xla_accounting_err_pkg.build_message
12491 (p_appli_s_name => 'XLA'
12492 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12493 ,p_token_1 => 'LINE_NUMBER'
12494 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
12495 ,p_token_2 => 'LINE_TYPE_NAME'
12496 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
12497 l_component_type
12498 ,l_component_code
12499 ,l_component_type_code
12503 ,l_event_class_code
12500 ,l_component_appl_id
12501 ,l_amb_context_code
12502 ,l_entity_code
12504 )
12505 ,p_token_3 => 'OWNER'
12506 ,p_value_3 => xla_lookups_pkg.get_meaning(
12507 p_lookup_type => 'XLA_OWNER_TYPE'
12508 ,p_lookup_code => l_component_type_code
12509 )
12510 ,p_token_4 => 'PRODUCT_NAME'
12511 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
12512 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
12513 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
12514 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
12515 ,p_ae_header_id => NULL
12516 );
12517
12518 IF (C_LEVEL_ERROR>= g_log_level) THEN
12519 trace
12520 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12521 ,p_level => C_LEVEL_ERROR
12522 ,p_module => l_log_module);
12523 END IF;
12524 END IF;
12525 END IF;
12526 --
12527 --
12528 ------------------------------------------------------------------------------------------------
12529 -- 4219869 Business Flow
12530 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
12531 -- Prior Entry. Currently, the following code is always generated.
12532 ------------------------------------------------------------------------------------------------
12533 XLA_AE_LINES_PKG.ValidateCurrentLine;
12534
12535 ------------------------------------------------------------------------------------
12536 -- 4219869 Business Flow
12537 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
12538 ------------------------------------------------------------------------------------
12539 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12540
12541 ----------------------------------------------------------------------------------
12542 -- 4219869 Business Flow
12543 -- Update journal entry status -- Need to generate this within IF <condition>
12544 ----------------------------------------------------------------------------------
12545 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12546 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
12547 ,p_balance_type_code => l_balance_type_code
12548 );
12549
12550 -------------------------------------------------------------------------------------------
12551 -- 4262811 - Generate the Accrual Reversal lines
12552 -------------------------------------------------------------------------------------------
12553 BEGIN
12554 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
12555 (g_array_event(p_event_id).array_value_num('header_index'));
12556 IF l_acc_rev_flag IS NULL THEN
12557 l_acc_rev_flag := 'N';
12558 END IF;
12559 EXCEPTION
12560 WHEN OTHERS THEN
12561 l_acc_rev_flag := 'N';
12562 END;
12563 --
12564 IF (l_acc_rev_flag = 'Y') THEN
12565
12566 -- 4645092 ------------------------------------------------------------------------------
12567 -- To allow MPA report to determine if it should generate report process
12568 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
12569 ------------------------------------------------------------------------------------------
12570
12571 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
12572 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
12573 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
12574 -- call ADRs
12575 -- Bug 4922099
12576 --
12577 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12578 (NVL(l_actual_upg_option, 'N') = 'O') OR
12579 (NVL(l_enc_upg_option, 'N') = 'O')
12580 )
12581 THEN
12582 NULL;
12583 --
12584 --
12585
12586 l_ccid := AcctDerRule_10(
12587 p_application_id => p_application_id
12588 , p_ae_header_id => l_ae_header_id
12589 , p_source_9 => p_source_9
12590 , x_transaction_coa_id => l_adr_transaction_coa_id
12591 , x_accounting_coa_id => l_adr_accounting_coa_id
12592 , x_value_type_code => l_adr_value_type_code
12593 , p_side => 'NA'
12594 );
12595
12596 xla_ae_lines_pkg.set_ccid(
12597 p_code_combination_id => l_ccid
12598 , p_value_type_code => l_adr_value_type_code
12602 , p_adr_type_code => 'S'
12599 , p_transaction_coa_id => l_adr_transaction_coa_id
12600 , p_accounting_coa_id => l_adr_accounting_coa_id
12601 , p_adr_code => 'CM_DIST_CCID'
12603 , p_component_type => l_component_type
12604 , p_component_code => l_component_code
12605 , p_component_type_code => l_component_type_code
12606 , p_component_appl_id => l_component_appl_id
12607 , p_amb_context_code => l_amb_context_code
12608 , p_side => 'NA'
12609 );
12610
12611
12612 --
12613 --
12614 END IF;
12615
12616 --
12617 -- Update the line information that should be overwritten
12618 --
12619 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
12620 p_header_num => 1);
12621 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
12622
12623 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
12624
12625 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
12626 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
12627 END IF;
12628
12629 --
12630 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
12631 --
12632 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
12633 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
12634 ELSE
12635 ---------------------------------------------------------------------------------------------------
12636 -- 4262811a Switch Sign
12637 ---------------------------------------------------------------------------------------------------
12638 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
12639 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12640 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12641 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12642 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12643 -- 5132302
12644 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
12645 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12646
12647 END IF;
12648
12649 -- 4955764
12650 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12651 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
12652
12653
12654 XLA_AE_LINES_PKG.ValidateCurrentLine;
12655 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12656
12657 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12658 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
12659 ,p_balance_type_code => l_balance_type_code);
12660
12661 END IF;
12662
12663 -----------------------------------------------------------------------------------------
12664 -- 4262811 Multiperiod Accounting
12665 -----------------------------------------------------------------------------------------
12666 -- No MPA option is assigned.
12667
12668
12669 END IF;
12670 END IF;
12671 --
12672
12673 --
12674 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12675 trace
12676 (p_msg => 'END of AcctLineType_48'
12677 ,p_level => C_LEVEL_PROCEDURE
12678 ,p_module => l_log_module);
12679 END IF;
12680 --
12681 EXCEPTION
12682 WHEN xla_exceptions_pkg.application_exception THEN
12683 RAISE;
12684 WHEN OTHERS THEN
12685 xla_exceptions_pkg.raise_message
12686 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_48');
12687 END AcctLineType_48;
12688 --
12689
12690 ---------------------------------------
12691 --
12692 -- PRIVATE FUNCTION
12693 -- AcctLineType_49
12694 --
12695 ---------------------------------------
12696 PROCEDURE AcctLineType_49 (
12697 p_application_id IN NUMBER
12698 ,p_event_id IN NUMBER
12699 ,p_calculate_acctd_flag IN VARCHAR2
12700 ,p_calculate_g_l_flag IN VARCHAR2
12701 ,p_actual_flag IN OUT VARCHAR2
12702 ,p_balance_type_code OUT VARCHAR2
12703 ,p_gain_or_loss_ref OUT VARCHAR2
12704
12705 --Credit Memo Distribution GL Account
12706 , p_source_9 IN NUMBER
12707 --SLA Party Type
12708 , p_source_34 IN VARCHAR2
12709 --Credit Memo Distribution Identifier
12710 , p_source_44 IN NUMBER
12711 --Credit memo distributions type
12712 , p_source_45 IN VARCHAR2
12713 --Credit Memo Currency Code
12714 , p_source_46 IN VARCHAR2
12715 --Credit Memo Exchange Date
12716 , p_source_47 IN DATE
12717 --Credit Memo Exchange Rate
12718 , p_source_48 IN NUMBER
12719 --Credit Memo Exchange Rate Type
12723 --Credit Memo Accounting Amount
12720 , p_source_49 IN VARCHAR2
12721 --Gain Loss Reference
12722 , p_source_50 IN VARCHAR2
12724 , p_source_51 IN NUMBER
12725 --Credit Memo Bill To Customer Account Identifier
12726 , p_source_52 IN NUMBER
12727 --Credit Memo Bill To Customer Site Use Identifier
12728 , p_source_53 IN NUMBER
12729 --Credit Memo Tax Line Identifier
12730 , p_source_54 IN NUMBER
12731 --Credit Memo Distribution Account Class
12732 , p_source_55 IN VARCHAR2
12733 --Credit Memo Distribution Entered Amount
12734 , p_source_56 IN NUMBER
12735 )
12736 IS
12737
12738 l_component_type VARCHAR2(80);
12739 l_component_code VARCHAR2(30);
12740 l_component_type_code VARCHAR2(1);
12741 l_component_appl_id INTEGER;
12742 l_amb_context_code VARCHAR2(30);
12743 l_entity_code VARCHAR2(30);
12744 l_event_class_code VARCHAR2(30);
12745 l_ae_header_id NUMBER;
12746 l_event_type_code VARCHAR2(30);
12747 l_line_definition_code VARCHAR2(30);
12748 l_line_definition_owner_code VARCHAR2(1);
12749 --
12750 -- adr variables
12751 l_segment VARCHAR2(30);
12752 l_ccid NUMBER;
12753 l_adr_transaction_coa_id NUMBER;
12754 l_adr_accounting_coa_id NUMBER;
12755 l_adr_flexfield_segment_code VARCHAR2(30);
12756 l_adr_flex_value_set_id NUMBER;
12757 l_adr_value_type_code VARCHAR2(30);
12758 l_adr_value_combination_id NUMBER;
12759 l_adr_value_segment_code VARCHAR2(30);
12760
12761 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
12762 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
12763 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
12764 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
12765
12766 -- 4262811 Variables ------------------------------------------------------------------------------------------
12767 l_entered_amt_idx NUMBER;
12768 l_accted_amt_idx NUMBER;
12769 l_acc_rev_flag VARCHAR2(1);
12770 l_accrual_line_num NUMBER;
12771 l_tmp_amt NUMBER;
12772 l_acc_rev_natural_side_code VARCHAR2(1);
12773
12774 l_num_entries NUMBER;
12775 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
12776 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
12777 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
12778 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
12779 l_recog_line_1 NUMBER;
12780 l_recog_line_2 NUMBER;
12781
12782 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
12783 l_bflow_applied_to_amt NUMBER; -- 5132302
12784 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
12785
12786 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
12787
12788 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
12789 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
12790
12791 ---------------------------------------------------------------------------------------------------------------
12792
12793
12794 --
12795 -- bulk performance
12796 --
12797 l_balance_type_code VARCHAR2(1);
12798 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
12799 l_log_module VARCHAR2(240);
12800
12801 --
12802 -- Upgrade strategy
12803 --
12804 l_actual_upg_option VARCHAR2(1);
12805 l_enc_upg_option VARCHAR2(1);
12806
12807 --
12808 BEGIN
12809 --
12810 IF g_log_enabled THEN
12811 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_49';
12812 END IF;
12813 --
12814 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12815
12816 trace
12817 (p_msg => 'BEGIN of AcctLineType_49'
12818 ,p_level => C_LEVEL_PROCEDURE
12819 ,p_module => l_log_module);
12820
12821 END IF;
12822 --
12823 l_component_type := 'AMB_JLT';
12824 l_component_code := 'CM_UNBILL';
12825 l_component_type_code := 'S';
12826 l_component_appl_id := 222;
12827 l_amb_context_code := 'DEFAULT';
12828 l_entity_code := 'TRANSACTIONS';
12829 l_event_class_code := 'CREDIT_MEMO';
12830 l_event_type_code := 'CREDIT_MEMO_ALL';
12831 l_line_definition_owner_code := 'S';
12832 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
12833 --
12834 l_balance_type_code := 'A';
12835 l_segment := NULL;
12836 l_ccid := NULL;
12837 l_adr_transaction_coa_id := NULL;
12838 l_adr_accounting_coa_id := NULL;
12839 l_adr_flexfield_segment_code := NULL;
12840 l_adr_flex_value_set_id := NULL;
12841 l_adr_value_type_code := NULL;
12842 l_adr_value_combination_id := NULL;
12843 l_adr_value_segment_code := NULL;
12844
12845 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
12846 l_bflow_class_code := ''; -- 4219869 Business Flow
12847 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
12851 l_bflow_applied_to_amt := NULL; -- 5132302
12848 l_budgetary_control_flag := 'N';
12849
12850 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12852 l_entered_amt_idx := NULL; -- 4262811
12853 l_accted_amt_idx := NULL; -- 4262811
12854 l_acc_rev_flag := NULL; -- 4262811
12855 l_accrual_line_num := NULL; -- 4262811
12856 l_tmp_amt := NULL; -- 4262811
12857 --
12858
12859 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
12860 l_balance_type_code <> 'B' THEN
12861 IF NVL(p_source_55,'
12862 ') = 'UNBILL'
12863 THEN
12864
12865 --
12866 XLA_AE_LINES_PKG.SetNewLine;
12867
12868 p_balance_type_code := l_balance_type_code;
12869 -- set the flag so later we will know whether the gain loss line needs to be created
12870
12871 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
12872 p_actual_flag :='A';
12873 END IF;
12874
12875 --
12876 -- bulk performance
12877 --
12878 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
12879 p_header_num => 0); -- 4262811
12880 --
12881 -- set accounting line options
12882 --
12883 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
12884 p_natural_side_code => 'C'
12885 , p_gain_or_loss_flag => 'N'
12886 , p_gl_transfer_mode_code => 'S'
12887 , p_acct_entry_type_code => 'A'
12888 , p_switch_side_flag => 'Y'
12889 , p_merge_duplicate_code => 'A'
12890 );
12891 --
12892 l_acc_rev_natural_side_code := 'D'; -- 4262811
12893 --
12894 --
12895 -- set accounting line type info
12896 --
12897 xla_ae_lines_pkg.SetAcctLineType
12898 (p_component_type => l_component_type
12899 ,p_event_type_code => l_event_type_code
12900 ,p_line_definition_owner_code => l_line_definition_owner_code
12901 ,p_line_definition_code => l_line_definition_code
12902 ,p_accounting_line_code => l_component_code
12903 ,p_accounting_line_type_code => l_component_type_code
12904 ,p_accounting_line_appl_id => l_component_appl_id
12905 ,p_amb_context_code => l_amb_context_code
12906 ,p_entity_code => l_entity_code
12907 ,p_event_class_code => l_event_class_code);
12908 --
12909 -- set accounting class
12910 --
12911 xla_ae_lines_pkg.SetAcctClass(
12912 p_accounting_class_code => 'UNBILL'
12913 , p_ae_header_id => l_ae_header_id
12914 );
12915
12916 --
12917 -- set rounding class
12918 --
12919 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
12920 'RECEIVABLE';
12921
12922 --
12923 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
12924 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
12925 --
12926 -- bulk performance
12927 --
12928 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
12929
12930 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
12931 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
12932
12933 -- 4955764
12934 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12935 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
12936
12937 -- 4458381 Public Sector Enh
12938
12939 --
12940 -- set accounting attributes for the line type
12941 --
12942 l_entered_amt_idx := 3;
12943 l_accted_amt_idx := 9;
12944 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12945 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
12946 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_44);
12947 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
12948 l_rec_acct_attrs.array_char_value(2) := p_source_45;
12949 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
12950 l_rec_acct_attrs.array_num_value(3) := p_source_56;
12951 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
12952 l_rec_acct_attrs.array_char_value(4) := p_source_46;
12953 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
12954 l_rec_acct_attrs.array_date_value(5) := p_source_47;
12955 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
12956 l_rec_acct_attrs.array_num_value(6) := p_source_48;
12957 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
12958 l_rec_acct_attrs.array_char_value(7) := p_source_49;
12959 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
12960 l_rec_acct_attrs.array_char_value(8) := p_source_50;
12961 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
12962 l_rec_acct_attrs.array_num_value(9) := p_source_51;
12963 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
12964 l_rec_acct_attrs.array_num_value(10) := p_source_52;
12965 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
12969 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
12966 l_rec_acct_attrs.array_num_value(11) := p_source_53;
12967 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
12968 l_rec_acct_attrs.array_char_value(12) := p_source_34;
12970 l_rec_acct_attrs.array_num_value(13) := p_source_54;
12971
12972 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
12973 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
12974
12975 ---------------------------------------------------------------------------------------------------------------
12976 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
12977 ---------------------------------------------------------------------------------------------------------------
12978 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
12979
12980 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12981 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12982
12983 IF xla_accounting_cache_pkg.GetValueChar
12984 (p_source_code => 'LEDGER_CATEGORY_CODE'
12985 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
12986 AND l_bflow_method_code = 'PRIOR_ENTRY'
12987 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
12988 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
12989 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
12990 )
12991 THEN
12992 xla_ae_lines_pkg.BflowUpgEntry
12993 (p_business_method_code => l_bflow_method_code
12994 ,p_business_class_code => l_bflow_class_code
12995 ,p_balance_type => l_balance_type_code);
12996 ELSE
12997 NULL;
12998 -- No business flow processing for business flow method of NONE.
12999 END IF;
13000
13001 --
13002 -- call analytical criteria
13003 --
13004
13005 --
13006 -- call description
13007 --
13008 -- No description or it is inherited.
13009 --
13010 -- call ADRs
13011 -- Bug 4922099
13012 --
13013 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13014 (NVL(l_actual_upg_option, 'N') = 'O') OR
13015 (NVL(l_enc_upg_option, 'N') = 'O')
13016 )
13017 THEN
13018 NULL;
13019 --
13020 --
13021
13022 l_ccid := AcctDerRule_10(
13023 p_application_id => p_application_id
13024 , p_ae_header_id => l_ae_header_id
13025 , p_source_9 => p_source_9
13026 , x_transaction_coa_id => l_adr_transaction_coa_id
13027 , x_accounting_coa_id => l_adr_accounting_coa_id
13028 , x_value_type_code => l_adr_value_type_code
13029 , p_side => 'NA'
13030 );
13031
13032 xla_ae_lines_pkg.set_ccid(
13033 p_code_combination_id => l_ccid
13034 , p_value_type_code => l_adr_value_type_code
13035 , p_transaction_coa_id => l_adr_transaction_coa_id
13036 , p_accounting_coa_id => l_adr_accounting_coa_id
13037 , p_adr_code => 'CM_DIST_CCID'
13038 , p_adr_type_code => 'S'
13039 , p_component_type => l_component_type
13040 , p_component_code => l_component_code
13041 , p_component_type_code => l_component_type_code
13042 , p_component_appl_id => l_component_appl_id
13043 , p_amb_context_code => l_amb_context_code
13044 , p_side => 'NA'
13045 );
13046
13047
13048 --
13049 --
13050 END IF;
13051 --
13052 -- Bug 4922099
13053 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
13054 (NVL(l_enc_upg_option, 'N') = 'O')
13055 ) AND
13056 (l_bflow_method_code = 'PRIOR_ENTRY')
13057 )
13058 THEN
13059 IF
13060 --
13061 1 = 2
13062 --
13063 THEN
13064 xla_accounting_err_pkg.build_message
13065 (p_appli_s_name => 'XLA'
13066 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13067 ,p_token_1 => 'LINE_NUMBER'
13068 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
13069 ,p_token_2 => 'LINE_TYPE_NAME'
13070 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
13071 l_component_type
13072 ,l_component_code
13073 ,l_component_type_code
13074 ,l_component_appl_id
13075 ,l_amb_context_code
13076 ,l_entity_code
13077 ,l_event_class_code
13078 )
13082 ,p_lookup_code => l_component_type_code
13079 ,p_token_3 => 'OWNER'
13080 ,p_value_3 => xla_lookups_pkg.get_meaning(
13081 p_lookup_type => 'XLA_OWNER_TYPE'
13083 )
13084 ,p_token_4 => 'PRODUCT_NAME'
13085 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
13086 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
13087 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
13088 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
13089 ,p_ae_header_id => NULL
13090 );
13091
13092 IF (C_LEVEL_ERROR>= g_log_level) THEN
13093 trace
13094 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13095 ,p_level => C_LEVEL_ERROR
13096 ,p_module => l_log_module);
13097 END IF;
13098 END IF;
13099 END IF;
13100 --
13101 --
13102 ------------------------------------------------------------------------------------------------
13103 -- 4219869 Business Flow
13104 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
13105 -- Prior Entry. Currently, the following code is always generated.
13106 ------------------------------------------------------------------------------------------------
13107 XLA_AE_LINES_PKG.ValidateCurrentLine;
13108
13109 ------------------------------------------------------------------------------------
13110 -- 4219869 Business Flow
13111 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
13112 ------------------------------------------------------------------------------------
13113 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13114
13115 ----------------------------------------------------------------------------------
13116 -- 4219869 Business Flow
13117 -- Update journal entry status -- Need to generate this within IF <condition>
13118 ----------------------------------------------------------------------------------
13119 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13120 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
13121 ,p_balance_type_code => l_balance_type_code
13122 );
13123
13124 -------------------------------------------------------------------------------------------
13125 -- 4262811 - Generate the Accrual Reversal lines
13126 -------------------------------------------------------------------------------------------
13127 BEGIN
13128 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
13129 (g_array_event(p_event_id).array_value_num('header_index'));
13130 IF l_acc_rev_flag IS NULL THEN
13131 l_acc_rev_flag := 'N';
13132 END IF;
13133 EXCEPTION
13134 WHEN OTHERS THEN
13135 l_acc_rev_flag := 'N';
13136 END;
13137 --
13138 IF (l_acc_rev_flag = 'Y') THEN
13139
13140 -- 4645092 ------------------------------------------------------------------------------
13141 -- To allow MPA report to determine if it should generate report process
13142 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
13143 ------------------------------------------------------------------------------------------
13144
13145 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
13146 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
13147 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
13148 -- call ADRs
13149 -- Bug 4922099
13150 --
13151 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13152 (NVL(l_actual_upg_option, 'N') = 'O') OR
13153 (NVL(l_enc_upg_option, 'N') = 'O')
13154 )
13155 THEN
13156 NULL;
13157 --
13158 --
13159
13160 l_ccid := AcctDerRule_10(
13161 p_application_id => p_application_id
13162 , p_ae_header_id => l_ae_header_id
13163 , p_source_9 => p_source_9
13164 , x_transaction_coa_id => l_adr_transaction_coa_id
13165 , x_accounting_coa_id => l_adr_accounting_coa_id
13166 , x_value_type_code => l_adr_value_type_code
13167 , p_side => 'NA'
13168 );
13169
13170 xla_ae_lines_pkg.set_ccid(
13171 p_code_combination_id => l_ccid
13172 , p_value_type_code => l_adr_value_type_code
13173 , p_transaction_coa_id => l_adr_transaction_coa_id
13174 , p_accounting_coa_id => l_adr_accounting_coa_id
13175 , p_adr_code => 'CM_DIST_CCID'
13176 , p_adr_type_code => 'S'
13177 , p_component_type => l_component_type
13178 , p_component_code => l_component_code
13182 , p_side => 'NA'
13179 , p_component_type_code => l_component_type_code
13180 , p_component_appl_id => l_component_appl_id
13181 , p_amb_context_code => l_amb_context_code
13183 );
13184
13185
13186 --
13187 --
13188 END IF;
13189
13190 --
13191 -- Update the line information that should be overwritten
13192 --
13193 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
13194 p_header_num => 1);
13195 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
13196
13197 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
13198
13199 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
13200 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
13201 END IF;
13202
13203 --
13204 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
13205 --
13206 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
13207 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
13208 ELSE
13209 ---------------------------------------------------------------------------------------------------
13210 -- 4262811a Switch Sign
13211 ---------------------------------------------------------------------------------------------------
13212 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
13213 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13214 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13215 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13216 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13217 -- 5132302
13218 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
13219 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13220
13221 END IF;
13222
13223 -- 4955764
13224 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13225 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
13226
13227
13228 XLA_AE_LINES_PKG.ValidateCurrentLine;
13229 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13230
13231 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13232 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
13233 ,p_balance_type_code => l_balance_type_code);
13234
13235 END IF;
13236
13237 -----------------------------------------------------------------------------------------
13238 -- 4262811 Multiperiod Accounting
13239 -----------------------------------------------------------------------------------------
13240 -- No MPA option is assigned.
13241
13242
13243 END IF;
13244 END IF;
13245 --
13246
13247 --
13248 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13249 trace
13250 (p_msg => 'END of AcctLineType_49'
13251 ,p_level => C_LEVEL_PROCEDURE
13252 ,p_module => l_log_module);
13253 END IF;
13254 --
13255 EXCEPTION
13256 WHEN xla_exceptions_pkg.application_exception THEN
13257 RAISE;
13258 WHEN OTHERS THEN
13259 xla_exceptions_pkg.raise_message
13260 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_49');
13261 END AcctLineType_49;
13262 --
13263
13264 ---------------------------------------
13265 --
13266 -- PRIVATE FUNCTION
13267 -- AcctLineType_50
13268 --
13269 ---------------------------------------
13270 PROCEDURE AcctLineType_50 (
13271 p_application_id IN NUMBER
13272 ,p_event_id IN NUMBER
13273 ,p_calculate_acctd_flag IN VARCHAR2
13274 ,p_calculate_g_l_flag IN VARCHAR2
13275 ,p_actual_flag IN OUT VARCHAR2
13276 ,p_balance_type_code OUT VARCHAR2
13277 ,p_gain_or_loss_ref OUT VARCHAR2
13278
13279 --Credit Memo Distribution GL Account
13280 , p_source_9 IN NUMBER
13281 --SLA Party Type
13282 , p_source_34 IN VARCHAR2
13283 --Credit Memo Distribution Identifier
13284 , p_source_44 IN NUMBER
13285 --Credit memo distributions type
13286 , p_source_45 IN VARCHAR2
13287 --Credit Memo Currency Code
13288 , p_source_46 IN VARCHAR2
13289 --Credit Memo Exchange Date
13290 , p_source_47 IN DATE
13291 --Credit Memo Exchange Rate
13292 , p_source_48 IN NUMBER
13293 --Credit Memo Exchange Rate Type
13294 , p_source_49 IN VARCHAR2
13295 --Gain Loss Reference
13296 , p_source_50 IN VARCHAR2
13297 --Credit Memo Accounting Amount
13298 , p_source_51 IN NUMBER
13299 --Credit Memo Bill To Customer Account Identifier
13300 , p_source_52 IN NUMBER
13301 --Credit Memo Bill To Customer Site Use Identifier
13302 , p_source_53 IN NUMBER
13303 --Credit Memo Tax Line Identifier
13307 --Credit Memo Distribution Entered Amount
13304 , p_source_54 IN NUMBER
13305 --Credit Memo Distribution Account Class
13306 , p_source_55 IN VARCHAR2
13308 , p_source_56 IN NUMBER
13309 )
13310 IS
13311
13312 l_component_type VARCHAR2(80);
13313 l_component_code VARCHAR2(30);
13314 l_component_type_code VARCHAR2(1);
13315 l_component_appl_id INTEGER;
13316 l_amb_context_code VARCHAR2(30);
13317 l_entity_code VARCHAR2(30);
13318 l_event_class_code VARCHAR2(30);
13319 l_ae_header_id NUMBER;
13320 l_event_type_code VARCHAR2(30);
13321 l_line_definition_code VARCHAR2(30);
13322 l_line_definition_owner_code VARCHAR2(1);
13323 --
13324 -- adr variables
13325 l_segment VARCHAR2(30);
13326 l_ccid NUMBER;
13327 l_adr_transaction_coa_id NUMBER;
13328 l_adr_accounting_coa_id NUMBER;
13329 l_adr_flexfield_segment_code VARCHAR2(30);
13330 l_adr_flex_value_set_id NUMBER;
13331 l_adr_value_type_code VARCHAR2(30);
13332 l_adr_value_combination_id NUMBER;
13333 l_adr_value_segment_code VARCHAR2(30);
13334
13335 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
13336 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
13337 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
13338 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
13339
13340 -- 4262811 Variables ------------------------------------------------------------------------------------------
13341 l_entered_amt_idx NUMBER;
13342 l_accted_amt_idx NUMBER;
13343 l_acc_rev_flag VARCHAR2(1);
13344 l_accrual_line_num NUMBER;
13345 l_tmp_amt NUMBER;
13346 l_acc_rev_natural_side_code VARCHAR2(1);
13347
13348 l_num_entries NUMBER;
13349 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
13350 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
13351 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
13352 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
13353 l_recog_line_1 NUMBER;
13354 l_recog_line_2 NUMBER;
13355
13356 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
13357 l_bflow_applied_to_amt NUMBER; -- 5132302
13358 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
13359
13360 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
13361
13362 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
13363 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
13364
13365 ---------------------------------------------------------------------------------------------------------------
13366
13367
13368 --
13369 -- bulk performance
13370 --
13371 l_balance_type_code VARCHAR2(1);
13372 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
13373 l_log_module VARCHAR2(240);
13374
13375 --
13376 -- Upgrade strategy
13377 --
13378 l_actual_upg_option VARCHAR2(1);
13379 l_enc_upg_option VARCHAR2(1);
13380
13381 --
13382 BEGIN
13383 --
13384 IF g_log_enabled THEN
13385 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_50';
13386 END IF;
13387 --
13388 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13389
13390 trace
13391 (p_msg => 'BEGIN of AcctLineType_50'
13392 ,p_level => C_LEVEL_PROCEDURE
13393 ,p_module => l_log_module);
13394
13395 END IF;
13396 --
13397 l_component_type := 'AMB_JLT';
13398 l_component_code := 'CM_UNEARN';
13399 l_component_type_code := 'S';
13400 l_component_appl_id := 222;
13401 l_amb_context_code := 'DEFAULT';
13402 l_entity_code := 'TRANSACTIONS';
13403 l_event_class_code := 'CREDIT_MEMO';
13404 l_event_type_code := 'CREDIT_MEMO_ALL';
13405 l_line_definition_owner_code := 'S';
13406 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
13407 --
13408 l_balance_type_code := 'A';
13409 l_segment := NULL;
13410 l_ccid := NULL;
13411 l_adr_transaction_coa_id := NULL;
13412 l_adr_accounting_coa_id := NULL;
13413 l_adr_flexfield_segment_code := NULL;
13414 l_adr_flex_value_set_id := NULL;
13415 l_adr_value_type_code := NULL;
13416 l_adr_value_combination_id := NULL;
13417 l_adr_value_segment_code := NULL;
13418
13419 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
13420 l_bflow_class_code := ''; -- 4219869 Business Flow
13421 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
13422 l_budgetary_control_flag := 'N';
13423
13424 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13425 l_bflow_applied_to_amt := NULL; -- 5132302
13426 l_entered_amt_idx := NULL; -- 4262811
13427 l_accted_amt_idx := NULL; -- 4262811
13428 l_acc_rev_flag := NULL; -- 4262811
13429 l_accrual_line_num := NULL; -- 4262811
13430 l_tmp_amt := NULL; -- 4262811
13431 --
13435 IF NVL(p_source_55,'
13432
13433 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
13434 l_balance_type_code <> 'B' THEN
13436 ') = 'UNEARN'
13437 THEN
13438
13439 --
13440 XLA_AE_LINES_PKG.SetNewLine;
13441
13442 p_balance_type_code := l_balance_type_code;
13443 -- set the flag so later we will know whether the gain loss line needs to be created
13444
13445 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
13446 p_actual_flag :='A';
13447 END IF;
13448
13449 --
13450 -- bulk performance
13451 --
13452 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
13453 p_header_num => 0); -- 4262811
13454 --
13455 -- set accounting line options
13456 --
13457 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
13458 p_natural_side_code => 'C'
13459 , p_gain_or_loss_flag => 'N'
13460 , p_gl_transfer_mode_code => 'S'
13461 , p_acct_entry_type_code => 'A'
13462 , p_switch_side_flag => 'Y'
13463 , p_merge_duplicate_code => 'A'
13464 );
13465 --
13466 l_acc_rev_natural_side_code := 'D'; -- 4262811
13467 --
13468 --
13469 -- set accounting line type info
13470 --
13471 xla_ae_lines_pkg.SetAcctLineType
13472 (p_component_type => l_component_type
13473 ,p_event_type_code => l_event_type_code
13474 ,p_line_definition_owner_code => l_line_definition_owner_code
13475 ,p_line_definition_code => l_line_definition_code
13476 ,p_accounting_line_code => l_component_code
13477 ,p_accounting_line_type_code => l_component_type_code
13478 ,p_accounting_line_appl_id => l_component_appl_id
13479 ,p_amb_context_code => l_amb_context_code
13480 ,p_entity_code => l_entity_code
13481 ,p_event_class_code => l_event_class_code);
13482 --
13483 -- set accounting class
13484 --
13485 xla_ae_lines_pkg.SetAcctClass(
13486 p_accounting_class_code => 'UNEARNED_REVENUE'
13487 , p_ae_header_id => l_ae_header_id
13488 );
13489
13490 --
13491 -- set rounding class
13492 --
13493 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
13494 'RECEIVABLE';
13495
13496 --
13497 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
13498 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
13499 --
13500 -- bulk performance
13501 --
13502 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
13503
13504 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
13505 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
13506
13507 -- 4955764
13508 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13509 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
13510
13511 -- 4458381 Public Sector Enh
13512
13513 --
13514 -- set accounting attributes for the line type
13515 --
13516 l_entered_amt_idx := 3;
13517 l_accted_amt_idx := 9;
13518 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13519 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
13520 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_44);
13521 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
13522 l_rec_acct_attrs.array_char_value(2) := p_source_45;
13523 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
13524 l_rec_acct_attrs.array_num_value(3) := p_source_56;
13525 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
13526 l_rec_acct_attrs.array_char_value(4) := p_source_46;
13527 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
13528 l_rec_acct_attrs.array_date_value(5) := p_source_47;
13529 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
13530 l_rec_acct_attrs.array_num_value(6) := p_source_48;
13531 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
13532 l_rec_acct_attrs.array_char_value(7) := p_source_49;
13533 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
13534 l_rec_acct_attrs.array_char_value(8) := p_source_50;
13535 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
13536 l_rec_acct_attrs.array_num_value(9) := p_source_51;
13537 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
13538 l_rec_acct_attrs.array_num_value(10) := p_source_52;
13539 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
13540 l_rec_acct_attrs.array_num_value(11) := p_source_53;
13541 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
13542 l_rec_acct_attrs.array_char_value(12) := p_source_34;
13543 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
13544 l_rec_acct_attrs.array_num_value(13) := p_source_54;
13545
13546 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
13547 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
13551 ---------------------------------------------------------------------------------------------------------------
13548
13549 ---------------------------------------------------------------------------------------------------------------
13550 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
13552 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
13553
13554 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13555 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13556
13557 IF xla_accounting_cache_pkg.GetValueChar
13558 (p_source_code => 'LEDGER_CATEGORY_CODE'
13559 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
13560 AND l_bflow_method_code = 'PRIOR_ENTRY'
13561 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
13562 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
13563 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
13564 )
13565 THEN
13566 xla_ae_lines_pkg.BflowUpgEntry
13567 (p_business_method_code => l_bflow_method_code
13568 ,p_business_class_code => l_bflow_class_code
13569 ,p_balance_type => l_balance_type_code);
13570 ELSE
13571 NULL;
13572 -- No business flow processing for business flow method of NONE.
13573 END IF;
13574
13575 --
13576 -- call analytical criteria
13577 --
13578
13579 --
13580 -- call description
13581 --
13582 -- No description or it is inherited.
13583 --
13584 -- call ADRs
13585 -- Bug 4922099
13586 --
13587 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13588 (NVL(l_actual_upg_option, 'N') = 'O') OR
13589 (NVL(l_enc_upg_option, 'N') = 'O')
13590 )
13591 THEN
13592 NULL;
13593 --
13594 --
13595
13596 l_ccid := AcctDerRule_10(
13597 p_application_id => p_application_id
13598 , p_ae_header_id => l_ae_header_id
13599 , p_source_9 => p_source_9
13600 , x_transaction_coa_id => l_adr_transaction_coa_id
13601 , x_accounting_coa_id => l_adr_accounting_coa_id
13602 , x_value_type_code => l_adr_value_type_code
13603 , p_side => 'NA'
13604 );
13605
13606 xla_ae_lines_pkg.set_ccid(
13607 p_code_combination_id => l_ccid
13608 , p_value_type_code => l_adr_value_type_code
13609 , p_transaction_coa_id => l_adr_transaction_coa_id
13610 , p_accounting_coa_id => l_adr_accounting_coa_id
13611 , p_adr_code => 'CM_DIST_CCID'
13612 , p_adr_type_code => 'S'
13613 , p_component_type => l_component_type
13614 , p_component_code => l_component_code
13615 , p_component_type_code => l_component_type_code
13616 , p_component_appl_id => l_component_appl_id
13617 , p_amb_context_code => l_amb_context_code
13618 , p_side => 'NA'
13619 );
13620
13621
13622 --
13623 --
13624 END IF;
13625 --
13626 -- Bug 4922099
13627 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
13628 (NVL(l_enc_upg_option, 'N') = 'O')
13629 ) AND
13630 (l_bflow_method_code = 'PRIOR_ENTRY')
13631 )
13632 THEN
13633 IF
13634 --
13635 1 = 2
13636 --
13637 THEN
13638 xla_accounting_err_pkg.build_message
13639 (p_appli_s_name => 'XLA'
13640 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13641 ,p_token_1 => 'LINE_NUMBER'
13642 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
13643 ,p_token_2 => 'LINE_TYPE_NAME'
13644 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
13645 l_component_type
13646 ,l_component_code
13647 ,l_component_type_code
13648 ,l_component_appl_id
13649 ,l_amb_context_code
13650 ,l_entity_code
13651 ,l_event_class_code
13652 )
13653 ,p_token_3 => 'OWNER'
13654 ,p_value_3 => xla_lookups_pkg.get_meaning(
13655 p_lookup_type => 'XLA_OWNER_TYPE'
13656 ,p_lookup_code => l_component_type_code
13660 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
13657 )
13658 ,p_token_4 => 'PRODUCT_NAME'
13659 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
13661 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
13662 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
13663 ,p_ae_header_id => NULL
13664 );
13665
13666 IF (C_LEVEL_ERROR>= g_log_level) THEN
13667 trace
13668 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13669 ,p_level => C_LEVEL_ERROR
13670 ,p_module => l_log_module);
13671 END IF;
13672 END IF;
13673 END IF;
13674 --
13675 --
13676 ------------------------------------------------------------------------------------------------
13677 -- 4219869 Business Flow
13678 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
13679 -- Prior Entry. Currently, the following code is always generated.
13680 ------------------------------------------------------------------------------------------------
13681 XLA_AE_LINES_PKG.ValidateCurrentLine;
13682
13683 ------------------------------------------------------------------------------------
13684 -- 4219869 Business Flow
13685 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
13686 ------------------------------------------------------------------------------------
13687 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13688
13689 ----------------------------------------------------------------------------------
13690 -- 4219869 Business Flow
13691 -- Update journal entry status -- Need to generate this within IF <condition>
13692 ----------------------------------------------------------------------------------
13693 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13694 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
13695 ,p_balance_type_code => l_balance_type_code
13696 );
13697
13698 -------------------------------------------------------------------------------------------
13699 -- 4262811 - Generate the Accrual Reversal lines
13700 -------------------------------------------------------------------------------------------
13701 BEGIN
13702 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
13703 (g_array_event(p_event_id).array_value_num('header_index'));
13704 IF l_acc_rev_flag IS NULL THEN
13705 l_acc_rev_flag := 'N';
13706 END IF;
13707 EXCEPTION
13708 WHEN OTHERS THEN
13709 l_acc_rev_flag := 'N';
13710 END;
13711 --
13712 IF (l_acc_rev_flag = 'Y') THEN
13713
13714 -- 4645092 ------------------------------------------------------------------------------
13715 -- To allow MPA report to determine if it should generate report process
13716 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
13717 ------------------------------------------------------------------------------------------
13718
13719 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
13720 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
13721 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
13722 -- call ADRs
13723 -- Bug 4922099
13724 --
13725 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13726 (NVL(l_actual_upg_option, 'N') = 'O') OR
13727 (NVL(l_enc_upg_option, 'N') = 'O')
13728 )
13729 THEN
13730 NULL;
13731 --
13732 --
13733
13734 l_ccid := AcctDerRule_10(
13735 p_application_id => p_application_id
13736 , p_ae_header_id => l_ae_header_id
13737 , p_source_9 => p_source_9
13738 , x_transaction_coa_id => l_adr_transaction_coa_id
13739 , x_accounting_coa_id => l_adr_accounting_coa_id
13740 , x_value_type_code => l_adr_value_type_code
13741 , p_side => 'NA'
13742 );
13743
13744 xla_ae_lines_pkg.set_ccid(
13745 p_code_combination_id => l_ccid
13746 , p_value_type_code => l_adr_value_type_code
13747 , p_transaction_coa_id => l_adr_transaction_coa_id
13748 , p_accounting_coa_id => l_adr_accounting_coa_id
13749 , p_adr_code => 'CM_DIST_CCID'
13750 , p_adr_type_code => 'S'
13751 , p_component_type => l_component_type
13752 , p_component_code => l_component_code
13753 , p_component_type_code => l_component_type_code
13754 , p_component_appl_id => l_component_appl_id
13755 , p_amb_context_code => l_amb_context_code
13756 , p_side => 'NA'
13757 );
13758
13759
13760 --
13761 --
13762 END IF;
13763
13764 --
13765 -- Update the line information that should be overwritten
13766 --
13770
13767 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
13768 p_header_num => 1);
13769 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
13771 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
13772
13773 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
13774 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
13775 END IF;
13776
13777 --
13778 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
13779 --
13780 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
13781 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
13782 ELSE
13783 ---------------------------------------------------------------------------------------------------
13784 -- 4262811a Switch Sign
13785 ---------------------------------------------------------------------------------------------------
13786 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
13787 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13788 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13789 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13790 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13791 -- 5132302
13792 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
13793 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13794
13795 END IF;
13796
13797 -- 4955764
13798 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13799 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
13800
13801
13802 XLA_AE_LINES_PKG.ValidateCurrentLine;
13803 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13804
13805 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13806 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
13807 ,p_balance_type_code => l_balance_type_code);
13808
13809 END IF;
13810
13811 -----------------------------------------------------------------------------------------
13812 -- 4262811 Multiperiod Accounting
13813 -----------------------------------------------------------------------------------------
13814 -- No MPA option is assigned.
13815
13816
13817 END IF;
13818 END IF;
13819 --
13820
13821 --
13822 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13823 trace
13824 (p_msg => 'END of AcctLineType_50'
13825 ,p_level => C_LEVEL_PROCEDURE
13826 ,p_module => l_log_module);
13827 END IF;
13828 --
13829 EXCEPTION
13830 WHEN xla_exceptions_pkg.application_exception THEN
13831 RAISE;
13832 WHEN OTHERS THEN
13833 xla_exceptions_pkg.raise_message
13834 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_50');
13835 END AcctLineType_50;
13836 --
13837
13838 ---------------------------------------
13839 --
13840 -- PRIVATE FUNCTION
13841 -- AcctLineType_51
13842 --
13843 ---------------------------------------
13844 PROCEDURE AcctLineType_51 (
13845 p_application_id IN NUMBER
13846 ,p_event_id IN NUMBER
13847 ,p_calculate_acctd_flag IN VARCHAR2
13848 ,p_calculate_g_l_flag IN VARCHAR2
13849 ,p_actual_flag IN OUT VARCHAR2
13850 ,p_balance_type_code OUT VARCHAR2
13851 ,p_gain_or_loss_ref OUT VARCHAR2
13852
13853 --Transaction Distribution GL Account
13854 , p_source_21 IN NUMBER
13855 --Bill To Customer Account Identifier
13856 , p_source_32 IN NUMBER
13857 --Bill To Customer Site Use Identifier
13858 , p_source_33 IN NUMBER
13859 --SLA Party Type
13860 , p_source_34 IN VARCHAR2
13861 --Transaction Distribution Account Class
13862 , p_source_35 IN VARCHAR2
13863 --Transaction Distribution Identifier
13864 , p_source_36 IN NUMBER
13865 --Transaction Distribution Type
13866 , p_source_37 IN VARCHAR2
13867 --Transaction Distribution Entered Amount
13868 , p_source_38 IN NUMBER
13869 --Transaction Currency Code
13870 , p_source_39 IN VARCHAR2
13871 --Transaction Exchange Date
13872 , p_source_40 IN DATE
13873 --Transaction Exchange Rate
13874 , p_source_41 IN NUMBER
13875 --Transaction Exchange Rate Type
13876 , p_source_42 IN VARCHAR2
13877 --Transaction Accounting Amount
13878 , p_source_43 IN NUMBER
13879 )
13880 IS
13881
13882 l_component_type VARCHAR2(80);
13883 l_component_code VARCHAR2(30);
13884 l_component_type_code VARCHAR2(1);
13885 l_component_appl_id INTEGER;
13886 l_amb_context_code VARCHAR2(30);
13887 l_entity_code VARCHAR2(30);
13888 l_event_class_code VARCHAR2(30);
13889 l_ae_header_id NUMBER;
13890 l_event_type_code VARCHAR2(30);
13894 -- adr variables
13891 l_line_definition_code VARCHAR2(30);
13892 l_line_definition_owner_code VARCHAR2(1);
13893 --
13895 l_segment VARCHAR2(30);
13896 l_ccid NUMBER;
13897 l_adr_transaction_coa_id NUMBER;
13898 l_adr_accounting_coa_id NUMBER;
13899 l_adr_flexfield_segment_code VARCHAR2(30);
13900 l_adr_flex_value_set_id NUMBER;
13901 l_adr_value_type_code VARCHAR2(30);
13902 l_adr_value_combination_id NUMBER;
13903 l_adr_value_segment_code VARCHAR2(30);
13904
13905 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
13906 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
13907 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
13908 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
13909
13910 -- 4262811 Variables ------------------------------------------------------------------------------------------
13911 l_entered_amt_idx NUMBER;
13912 l_accted_amt_idx NUMBER;
13913 l_acc_rev_flag VARCHAR2(1);
13914 l_accrual_line_num NUMBER;
13915 l_tmp_amt NUMBER;
13916 l_acc_rev_natural_side_code VARCHAR2(1);
13917
13918 l_num_entries NUMBER;
13919 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
13920 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
13921 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
13922 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
13923 l_recog_line_1 NUMBER;
13924 l_recog_line_2 NUMBER;
13925
13926 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
13927 l_bflow_applied_to_amt NUMBER; -- 5132302
13928 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
13929
13930 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
13931
13932 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
13933 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
13934
13935 ---------------------------------------------------------------------------------------------------------------
13936
13937
13938 --
13939 -- bulk performance
13940 --
13941 l_balance_type_code VARCHAR2(1);
13942 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
13943 l_log_module VARCHAR2(240);
13944
13945 --
13946 -- Upgrade strategy
13947 --
13948 l_actual_upg_option VARCHAR2(1);
13949 l_enc_upg_option VARCHAR2(1);
13950
13951 --
13952 BEGIN
13953 --
13954 IF g_log_enabled THEN
13955 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_51';
13956 END IF;
13957 --
13958 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13959
13960 trace
13961 (p_msg => 'BEGIN of AcctLineType_51'
13962 ,p_level => C_LEVEL_PROCEDURE
13963 ,p_module => l_log_module);
13964
13965 END IF;
13966 --
13967 l_component_type := 'AMB_JLT';
13968 l_component_code := 'DEP_DEFAULT_REC';
13969 l_component_type_code := 'S';
13970 l_component_appl_id := 222;
13971 l_amb_context_code := 'DEFAULT';
13972 l_entity_code := 'TRANSACTIONS';
13973 l_event_class_code := 'DEPOSIT';
13974 l_event_type_code := 'DEPOSIT_ALL';
13975 l_line_definition_owner_code := 'S';
13976 l_line_definition_code := 'AR_DEP_DEFAULT_ACCRUAL';
13977 --
13978 l_balance_type_code := 'A';
13979 l_segment := NULL;
13980 l_ccid := NULL;
13981 l_adr_transaction_coa_id := NULL;
13982 l_adr_accounting_coa_id := NULL;
13983 l_adr_flexfield_segment_code := NULL;
13984 l_adr_flex_value_set_id := NULL;
13985 l_adr_value_type_code := NULL;
13986 l_adr_value_combination_id := NULL;
13987 l_adr_value_segment_code := NULL;
13988
13989 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
13990 l_bflow_class_code := ''; -- 4219869 Business Flow
13991 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
13992 l_budgetary_control_flag := 'N';
13993
13994 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13995 l_bflow_applied_to_amt := NULL; -- 5132302
13996 l_entered_amt_idx := NULL; -- 4262811
13997 l_accted_amt_idx := NULL; -- 4262811
13998 l_acc_rev_flag := NULL; -- 4262811
13999 l_accrual_line_num := NULL; -- 4262811
14000 l_tmp_amt := NULL; -- 4262811
14001 --
14002
14003 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
14004 l_balance_type_code <> 'B' THEN
14005 IF NVL(p_source_35,'
14006 ') = 'REC'
14007 THEN
14008
14009 --
14010 XLA_AE_LINES_PKG.SetNewLine;
14011
14012 p_balance_type_code := l_balance_type_code;
14013 -- set the flag so later we will know whether the gain loss line needs to be created
14014
14015 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
14016 p_actual_flag :='A';
14017 END IF;
14018
14019 --
14020 -- bulk performance
14021 --
14025 -- set accounting line options
14022 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
14023 p_header_num => 0); -- 4262811
14024 --
14026 --
14027 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
14028 p_natural_side_code => 'D'
14029 , p_gain_or_loss_flag => 'N'
14030 , p_gl_transfer_mode_code => 'S'
14031 , p_acct_entry_type_code => 'A'
14032 , p_switch_side_flag => 'Y'
14033 , p_merge_duplicate_code => 'A'
14034 );
14035 --
14036 l_acc_rev_natural_side_code := 'C'; -- 4262811
14037 --
14038 --
14039 -- set accounting line type info
14040 --
14041 xla_ae_lines_pkg.SetAcctLineType
14042 (p_component_type => l_component_type
14043 ,p_event_type_code => l_event_type_code
14044 ,p_line_definition_owner_code => l_line_definition_owner_code
14045 ,p_line_definition_code => l_line_definition_code
14046 ,p_accounting_line_code => l_component_code
14047 ,p_accounting_line_type_code => l_component_type_code
14048 ,p_accounting_line_appl_id => l_component_appl_id
14049 ,p_amb_context_code => l_amb_context_code
14050 ,p_entity_code => l_entity_code
14051 ,p_event_class_code => l_event_class_code);
14052 --
14053 -- set accounting class
14054 --
14055 xla_ae_lines_pkg.SetAcctClass(
14056 p_accounting_class_code => 'RECEIVABLE'
14057 , p_ae_header_id => l_ae_header_id
14058 );
14059
14060 --
14061 -- set rounding class
14062 --
14063 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
14064 'RECEIVABLE';
14065
14066 --
14067 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
14068 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
14069 --
14070 -- bulk performance
14071 --
14072 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
14073
14074 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
14075 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
14076
14077 -- 4955764
14078 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14079 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
14080
14081 -- 4458381 Public Sector Enh
14082
14083 --
14084 -- set accounting attributes for the line type
14085 --
14086 l_entered_amt_idx := 3;
14087 l_accted_amt_idx := 8;
14088 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14089 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
14090 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
14091 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
14092 l_rec_acct_attrs.array_char_value(2) := p_source_37;
14093 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
14094 l_rec_acct_attrs.array_num_value(3) := p_source_38;
14095 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
14096 l_rec_acct_attrs.array_char_value(4) := p_source_39;
14097 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
14098 l_rec_acct_attrs.array_date_value(5) := p_source_40;
14099 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
14100 l_rec_acct_attrs.array_num_value(6) := p_source_41;
14101 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
14102 l_rec_acct_attrs.array_char_value(7) := p_source_42;
14103 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
14104 l_rec_acct_attrs.array_num_value(8) := p_source_43;
14105 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
14106 l_rec_acct_attrs.array_num_value(9) := p_source_32;
14107 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
14108 l_rec_acct_attrs.array_num_value(10) := p_source_33;
14109 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
14110 l_rec_acct_attrs.array_char_value(11) := p_source_34;
14111
14112 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
14113 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
14114
14115 ---------------------------------------------------------------------------------------------------------------
14116 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
14117 ---------------------------------------------------------------------------------------------------------------
14118 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
14119
14120 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
14121 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
14122
14123 IF xla_accounting_cache_pkg.GetValueChar
14124 (p_source_code => 'LEDGER_CATEGORY_CODE'
14125 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
14126 AND l_bflow_method_code = 'PRIOR_ENTRY'
14130 )
14127 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
14128 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
14129 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
14131 THEN
14132 xla_ae_lines_pkg.BflowUpgEntry
14133 (p_business_method_code => l_bflow_method_code
14134 ,p_business_class_code => l_bflow_class_code
14135 ,p_balance_type => l_balance_type_code);
14136 ELSE
14137 NULL;
14138 -- No business flow processing for business flow method of NONE.
14139 END IF;
14140
14141 --
14142 -- call analytical criteria
14143 --
14144
14145 --
14146 -- call description
14147 --
14148 -- No description or it is inherited.
14149 --
14150 -- call ADRs
14151 -- Bug 4922099
14152 --
14153 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14154 (NVL(l_actual_upg_option, 'N') = 'O') OR
14155 (NVL(l_enc_upg_option, 'N') = 'O')
14156 )
14157 THEN
14158 NULL;
14159 --
14160 --
14161
14162 l_ccid := AcctDerRule_34(
14163 p_application_id => p_application_id
14164 , p_ae_header_id => l_ae_header_id
14165 , p_source_21 => p_source_21
14166 , x_transaction_coa_id => l_adr_transaction_coa_id
14167 , x_accounting_coa_id => l_adr_accounting_coa_id
14168 , x_value_type_code => l_adr_value_type_code
14169 , p_side => 'NA'
14170 );
14171
14172 xla_ae_lines_pkg.set_ccid(
14173 p_code_combination_id => l_ccid
14174 , p_value_type_code => l_adr_value_type_code
14175 , p_transaction_coa_id => l_adr_transaction_coa_id
14176 , p_accounting_coa_id => l_adr_accounting_coa_id
14177 , p_adr_code => 'TRX_DIST_CCID'
14178 , p_adr_type_code => 'S'
14179 , p_component_type => l_component_type
14180 , p_component_code => l_component_code
14181 , p_component_type_code => l_component_type_code
14182 , p_component_appl_id => l_component_appl_id
14183 , p_amb_context_code => l_amb_context_code
14184 , p_side => 'NA'
14185 );
14186
14187
14188 --
14189 --
14190 END IF;
14191 --
14192 -- Bug 4922099
14193 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
14194 (NVL(l_enc_upg_option, 'N') = 'O')
14195 ) AND
14196 (l_bflow_method_code = 'PRIOR_ENTRY')
14197 )
14198 THEN
14199 IF
14200 --
14201 1 = 2
14202 --
14203 THEN
14204 xla_accounting_err_pkg.build_message
14205 (p_appli_s_name => 'XLA'
14206 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14207 ,p_token_1 => 'LINE_NUMBER'
14208 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
14209 ,p_token_2 => 'LINE_TYPE_NAME'
14210 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
14211 l_component_type
14212 ,l_component_code
14213 ,l_component_type_code
14214 ,l_component_appl_id
14215 ,l_amb_context_code
14216 ,l_entity_code
14217 ,l_event_class_code
14218 )
14219 ,p_token_3 => 'OWNER'
14220 ,p_value_3 => xla_lookups_pkg.get_meaning(
14221 p_lookup_type => 'XLA_OWNER_TYPE'
14222 ,p_lookup_code => l_component_type_code
14223 )
14224 ,p_token_4 => 'PRODUCT_NAME'
14225 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
14226 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
14227 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
14228 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
14229 ,p_ae_header_id => NULL
14230 );
14231
14232 IF (C_LEVEL_ERROR>= g_log_level) THEN
14233 trace
14234 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14235 ,p_level => C_LEVEL_ERROR
14239 END IF;
14236 ,p_module => l_log_module);
14237 END IF;
14238 END IF;
14240 --
14241 --
14242 ------------------------------------------------------------------------------------------------
14243 -- 4219869 Business Flow
14244 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
14245 -- Prior Entry. Currently, the following code is always generated.
14246 ------------------------------------------------------------------------------------------------
14247 XLA_AE_LINES_PKG.ValidateCurrentLine;
14248
14249 ------------------------------------------------------------------------------------
14250 -- 4219869 Business Flow
14251 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
14252 ------------------------------------------------------------------------------------
14253 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14254
14255 ----------------------------------------------------------------------------------
14256 -- 4219869 Business Flow
14257 -- Update journal entry status -- Need to generate this within IF <condition>
14258 ----------------------------------------------------------------------------------
14259 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14260 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
14261 ,p_balance_type_code => l_balance_type_code
14262 );
14263
14264 -------------------------------------------------------------------------------------------
14265 -- 4262811 - Generate the Accrual Reversal lines
14266 -------------------------------------------------------------------------------------------
14267 BEGIN
14268 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
14269 (g_array_event(p_event_id).array_value_num('header_index'));
14270 IF l_acc_rev_flag IS NULL THEN
14271 l_acc_rev_flag := 'N';
14272 END IF;
14273 EXCEPTION
14274 WHEN OTHERS THEN
14275 l_acc_rev_flag := 'N';
14276 END;
14277 --
14278 IF (l_acc_rev_flag = 'Y') THEN
14279
14280 -- 4645092 ------------------------------------------------------------------------------
14281 -- To allow MPA report to determine if it should generate report process
14282 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
14283 ------------------------------------------------------------------------------------------
14284
14285 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
14286 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
14287 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
14288 -- call ADRs
14289 -- Bug 4922099
14290 --
14291 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14292 (NVL(l_actual_upg_option, 'N') = 'O') OR
14293 (NVL(l_enc_upg_option, 'N') = 'O')
14294 )
14295 THEN
14296 NULL;
14297 --
14298 --
14299
14300 l_ccid := AcctDerRule_34(
14301 p_application_id => p_application_id
14302 , p_ae_header_id => l_ae_header_id
14303 , p_source_21 => p_source_21
14304 , x_transaction_coa_id => l_adr_transaction_coa_id
14305 , x_accounting_coa_id => l_adr_accounting_coa_id
14306 , x_value_type_code => l_adr_value_type_code
14307 , p_side => 'NA'
14308 );
14309
14310 xla_ae_lines_pkg.set_ccid(
14311 p_code_combination_id => l_ccid
14312 , p_value_type_code => l_adr_value_type_code
14313 , p_transaction_coa_id => l_adr_transaction_coa_id
14314 , p_accounting_coa_id => l_adr_accounting_coa_id
14315 , p_adr_code => 'TRX_DIST_CCID'
14316 , p_adr_type_code => 'S'
14317 , p_component_type => l_component_type
14318 , p_component_code => l_component_code
14319 , p_component_type_code => l_component_type_code
14320 , p_component_appl_id => l_component_appl_id
14321 , p_amb_context_code => l_amb_context_code
14322 , p_side => 'NA'
14323 );
14324
14325
14326 --
14327 --
14328 END IF;
14329
14330 --
14331 -- Update the line information that should be overwritten
14332 --
14333 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
14334 p_header_num => 1);
14335 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
14336
14337 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
14338
14339 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
14340 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
14341 END IF;
14342
14343 --
14344 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
14345 --
14346 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
14347 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
14348 ELSE
14349 ---------------------------------------------------------------------------------------------------
14353 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14350 -- 4262811a Switch Sign
14351 ---------------------------------------------------------------------------------------------------
14352 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
14354 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14355 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14356 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14357 -- 5132302
14358 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
14359 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14360
14361 END IF;
14362
14363 -- 4955764
14364 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14365 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
14366
14367
14368 XLA_AE_LINES_PKG.ValidateCurrentLine;
14369 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14370
14371 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14372 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
14373 ,p_balance_type_code => l_balance_type_code);
14374
14375 END IF;
14376
14377 -----------------------------------------------------------------------------------------
14378 -- 4262811 Multiperiod Accounting
14379 -----------------------------------------------------------------------------------------
14380 -- No MPA option is assigned.
14381
14382
14383 END IF;
14384 END IF;
14385 --
14386
14387 --
14388 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14389 trace
14390 (p_msg => 'END of AcctLineType_51'
14391 ,p_level => C_LEVEL_PROCEDURE
14392 ,p_module => l_log_module);
14393 END IF;
14394 --
14395 EXCEPTION
14396 WHEN xla_exceptions_pkg.application_exception THEN
14397 RAISE;
14398 WHEN OTHERS THEN
14399 xla_exceptions_pkg.raise_message
14400 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_51');
14401 END AcctLineType_51;
14402 --
14403
14404 ---------------------------------------
14405 --
14406 -- PRIVATE FUNCTION
14407 -- AcctLineType_52
14408 --
14409 ---------------------------------------
14410 PROCEDURE AcctLineType_52 (
14411 p_application_id IN NUMBER
14412 ,p_event_id IN NUMBER
14413 ,p_calculate_acctd_flag IN VARCHAR2
14414 ,p_calculate_g_l_flag IN VARCHAR2
14415 ,p_actual_flag IN OUT VARCHAR2
14416 ,p_balance_type_code OUT VARCHAR2
14417 ,p_gain_or_loss_ref OUT VARCHAR2
14418
14419 --Transaction Distribution GL Account
14420 , p_source_21 IN NUMBER
14421 --Bill To Customer Account Identifier
14422 , p_source_32 IN NUMBER
14423 --Bill To Customer Site Use Identifier
14424 , p_source_33 IN NUMBER
14425 --SLA Party Type
14426 , p_source_34 IN VARCHAR2
14427 --Transaction Distribution Account Class
14428 , p_source_35 IN VARCHAR2
14429 --Transaction Distribution Identifier
14430 , p_source_36 IN NUMBER
14431 --Transaction Distribution Type
14432 , p_source_37 IN VARCHAR2
14433 --Transaction Distribution Entered Amount
14434 , p_source_38 IN NUMBER
14435 --Transaction Currency Code
14436 , p_source_39 IN VARCHAR2
14437 --Transaction Exchange Date
14438 , p_source_40 IN DATE
14439 --Transaction Exchange Rate
14440 , p_source_41 IN NUMBER
14441 --Transaction Exchange Rate Type
14442 , p_source_42 IN VARCHAR2
14443 --Transaction Accounting Amount
14444 , p_source_43 IN NUMBER
14445 )
14446 IS
14447
14448 l_component_type VARCHAR2(80);
14449 l_component_code VARCHAR2(30);
14450 l_component_type_code VARCHAR2(1);
14451 l_component_appl_id INTEGER;
14452 l_amb_context_code VARCHAR2(30);
14453 l_entity_code VARCHAR2(30);
14454 l_event_class_code VARCHAR2(30);
14455 l_ae_header_id NUMBER;
14456 l_event_type_code VARCHAR2(30);
14457 l_line_definition_code VARCHAR2(30);
14458 l_line_definition_owner_code VARCHAR2(1);
14459 --
14460 -- adr variables
14461 l_segment VARCHAR2(30);
14462 l_ccid NUMBER;
14463 l_adr_transaction_coa_id NUMBER;
14464 l_adr_accounting_coa_id NUMBER;
14465 l_adr_flexfield_segment_code VARCHAR2(30);
14466 l_adr_flex_value_set_id NUMBER;
14467 l_adr_value_type_code VARCHAR2(30);
14468 l_adr_value_combination_id NUMBER;
14469 l_adr_value_segment_code VARCHAR2(30);
14470
14471 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
14472 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
14473 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
14474 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
14475
14476 -- 4262811 Variables ------------------------------------------------------------------------------------------
14477 l_entered_amt_idx NUMBER;
14481 l_tmp_amt NUMBER;
14478 l_accted_amt_idx NUMBER;
14479 l_acc_rev_flag VARCHAR2(1);
14480 l_accrual_line_num NUMBER;
14482 l_acc_rev_natural_side_code VARCHAR2(1);
14483
14484 l_num_entries NUMBER;
14485 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
14486 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
14487 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
14488 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
14489 l_recog_line_1 NUMBER;
14490 l_recog_line_2 NUMBER;
14491
14492 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
14493 l_bflow_applied_to_amt NUMBER; -- 5132302
14494 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
14495
14496 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
14497
14498 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
14499 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
14500
14501 ---------------------------------------------------------------------------------------------------------------
14502
14503
14504 --
14505 -- bulk performance
14506 --
14507 l_balance_type_code VARCHAR2(1);
14508 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
14509 l_log_module VARCHAR2(240);
14510
14511 --
14512 -- Upgrade strategy
14513 --
14514 l_actual_upg_option VARCHAR2(1);
14515 l_enc_upg_option VARCHAR2(1);
14516
14517 --
14518 BEGIN
14519 --
14520 IF g_log_enabled THEN
14521 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_52';
14522 END IF;
14523 --
14524 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14525
14526 trace
14527 (p_msg => 'BEGIN of AcctLineType_52'
14528 ,p_level => C_LEVEL_PROCEDURE
14529 ,p_module => l_log_module);
14530
14531 END IF;
14532 --
14533 l_component_type := 'AMB_JLT';
14534 l_component_code := 'DEP_OFFSET';
14535 l_component_type_code := 'S';
14536 l_component_appl_id := 222;
14537 l_amb_context_code := 'DEFAULT';
14538 l_entity_code := 'TRANSACTIONS';
14539 l_event_class_code := 'DEPOSIT';
14540 l_event_type_code := 'DEPOSIT_ALL';
14541 l_line_definition_owner_code := 'S';
14542 l_line_definition_code := 'AR_DEP_DEFAULT_ACCRUAL';
14543 --
14544 l_balance_type_code := 'A';
14545 l_segment := NULL;
14546 l_ccid := NULL;
14547 l_adr_transaction_coa_id := NULL;
14548 l_adr_accounting_coa_id := NULL;
14549 l_adr_flexfield_segment_code := NULL;
14550 l_adr_flex_value_set_id := NULL;
14551 l_adr_value_type_code := NULL;
14552 l_adr_value_combination_id := NULL;
14553 l_adr_value_segment_code := NULL;
14554
14555 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
14556 l_bflow_class_code := ''; -- 4219869 Business Flow
14557 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
14558 l_budgetary_control_flag := 'N';
14559
14560 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14561 l_bflow_applied_to_amt := NULL; -- 5132302
14562 l_entered_amt_idx := NULL; -- 4262811
14563 l_accted_amt_idx := NULL; -- 4262811
14564 l_acc_rev_flag := NULL; -- 4262811
14565 l_accrual_line_num := NULL; -- 4262811
14566 l_tmp_amt := NULL; -- 4262811
14567 --
14568
14569 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
14570 l_balance_type_code <> 'B' THEN
14571 IF NVL(p_source_35,'
14572 ') = 'REV'
14573 THEN
14574
14575 --
14576 XLA_AE_LINES_PKG.SetNewLine;
14577
14578 p_balance_type_code := l_balance_type_code;
14579 -- set the flag so later we will know whether the gain loss line needs to be created
14580
14581 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
14582 p_actual_flag :='A';
14583 END IF;
14584
14585 --
14586 -- bulk performance
14587 --
14588 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
14589 p_header_num => 0); -- 4262811
14590 --
14591 -- set accounting line options
14592 --
14593 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
14594 p_natural_side_code => 'C'
14595 , p_gain_or_loss_flag => 'N'
14596 , p_gl_transfer_mode_code => 'S'
14597 , p_acct_entry_type_code => 'A'
14598 , p_switch_side_flag => 'Y'
14599 , p_merge_duplicate_code => 'A'
14600 );
14601 --
14602 l_acc_rev_natural_side_code := 'D'; -- 4262811
14603 --
14604 --
14605 -- set accounting line type info
14606 --
14607 xla_ae_lines_pkg.SetAcctLineType
14608 (p_component_type => l_component_type
14609 ,p_event_type_code => l_event_type_code
14610 ,p_line_definition_owner_code => l_line_definition_owner_code
14611 ,p_line_definition_code => l_line_definition_code
14615 ,p_amb_context_code => l_amb_context_code
14612 ,p_accounting_line_code => l_component_code
14613 ,p_accounting_line_type_code => l_component_type_code
14614 ,p_accounting_line_appl_id => l_component_appl_id
14616 ,p_entity_code => l_entity_code
14617 ,p_event_class_code => l_event_class_code);
14618 --
14619 -- set accounting class
14620 --
14621 xla_ae_lines_pkg.SetAcctClass(
14622 p_accounting_class_code => 'ACCRUAL'
14623 , p_ae_header_id => l_ae_header_id
14624 );
14625
14626 --
14627 -- set rounding class
14628 --
14629 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
14630 'RECEIVABLE';
14631
14632 --
14633 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
14634 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
14635 --
14636 -- bulk performance
14637 --
14638 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
14639
14640 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
14641 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
14642
14643 -- 4955764
14644 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14645 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
14646
14647 -- 4458381 Public Sector Enh
14648
14649 --
14650 -- set accounting attributes for the line type
14651 --
14652 l_entered_amt_idx := 3;
14653 l_accted_amt_idx := 8;
14654 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14655 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
14656 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
14657 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
14658 l_rec_acct_attrs.array_char_value(2) := p_source_37;
14659 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
14660 l_rec_acct_attrs.array_num_value(3) := p_source_38;
14661 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
14662 l_rec_acct_attrs.array_char_value(4) := p_source_39;
14663 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
14664 l_rec_acct_attrs.array_date_value(5) := p_source_40;
14665 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
14666 l_rec_acct_attrs.array_num_value(6) := p_source_41;
14667 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
14668 l_rec_acct_attrs.array_char_value(7) := p_source_42;
14669 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
14670 l_rec_acct_attrs.array_num_value(8) := p_source_43;
14671 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
14672 l_rec_acct_attrs.array_num_value(9) := p_source_32;
14673 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
14674 l_rec_acct_attrs.array_num_value(10) := p_source_33;
14675 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
14676 l_rec_acct_attrs.array_char_value(11) := p_source_34;
14677
14678 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
14679 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
14680
14681 ---------------------------------------------------------------------------------------------------------------
14682 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
14683 ---------------------------------------------------------------------------------------------------------------
14684 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
14685
14686 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
14687 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
14688
14689 IF xla_accounting_cache_pkg.GetValueChar
14690 (p_source_code => 'LEDGER_CATEGORY_CODE'
14691 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
14692 AND l_bflow_method_code = 'PRIOR_ENTRY'
14693 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
14694 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
14695 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
14696 )
14697 THEN
14698 xla_ae_lines_pkg.BflowUpgEntry
14699 (p_business_method_code => l_bflow_method_code
14700 ,p_business_class_code => l_bflow_class_code
14701 ,p_balance_type => l_balance_type_code);
14702 ELSE
14703 NULL;
14704 -- No business flow processing for business flow method of NONE.
14705 END IF;
14706
14707 --
14708 -- call analytical criteria
14709 --
14710
14711 --
14712 -- call description
14713 --
14714 -- No description or it is inherited.
14715 --
14716 -- call ADRs
14717 -- Bug 4922099
14718 --
14719 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14720 (NVL(l_actual_upg_option, 'N') = 'O') OR
14721 (NVL(l_enc_upg_option, 'N') = 'O')
14725 --
14722 )
14723 THEN
14724 NULL;
14726 --
14727
14728 l_ccid := AcctDerRule_34(
14729 p_application_id => p_application_id
14730 , p_ae_header_id => l_ae_header_id
14731 , p_source_21 => p_source_21
14732 , x_transaction_coa_id => l_adr_transaction_coa_id
14733 , x_accounting_coa_id => l_adr_accounting_coa_id
14734 , x_value_type_code => l_adr_value_type_code
14735 , p_side => 'NA'
14736 );
14737
14738 xla_ae_lines_pkg.set_ccid(
14739 p_code_combination_id => l_ccid
14740 , p_value_type_code => l_adr_value_type_code
14741 , p_transaction_coa_id => l_adr_transaction_coa_id
14742 , p_accounting_coa_id => l_adr_accounting_coa_id
14743 , p_adr_code => 'TRX_DIST_CCID'
14744 , p_adr_type_code => 'S'
14745 , p_component_type => l_component_type
14746 , p_component_code => l_component_code
14747 , p_component_type_code => l_component_type_code
14748 , p_component_appl_id => l_component_appl_id
14749 , p_amb_context_code => l_amb_context_code
14750 , p_side => 'NA'
14751 );
14752
14753
14754 --
14755 --
14756 END IF;
14757 --
14758 -- Bug 4922099
14759 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
14760 (NVL(l_enc_upg_option, 'N') = 'O')
14761 ) AND
14762 (l_bflow_method_code = 'PRIOR_ENTRY')
14763 )
14764 THEN
14765 IF
14766 --
14767 1 = 2
14768 --
14769 THEN
14770 xla_accounting_err_pkg.build_message
14771 (p_appli_s_name => 'XLA'
14772 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14773 ,p_token_1 => 'LINE_NUMBER'
14774 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
14775 ,p_token_2 => 'LINE_TYPE_NAME'
14776 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
14777 l_component_type
14778 ,l_component_code
14779 ,l_component_type_code
14780 ,l_component_appl_id
14781 ,l_amb_context_code
14782 ,l_entity_code
14783 ,l_event_class_code
14784 )
14785 ,p_token_3 => 'OWNER'
14786 ,p_value_3 => xla_lookups_pkg.get_meaning(
14787 p_lookup_type => 'XLA_OWNER_TYPE'
14788 ,p_lookup_code => l_component_type_code
14789 )
14790 ,p_token_4 => 'PRODUCT_NAME'
14791 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
14792 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
14793 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
14794 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
14795 ,p_ae_header_id => NULL
14796 );
14797
14798 IF (C_LEVEL_ERROR>= g_log_level) THEN
14799 trace
14800 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14801 ,p_level => C_LEVEL_ERROR
14802 ,p_module => l_log_module);
14803 END IF;
14804 END IF;
14805 END IF;
14806 --
14807 --
14808 ------------------------------------------------------------------------------------------------
14809 -- 4219869 Business Flow
14810 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
14811 -- Prior Entry. Currently, the following code is always generated.
14812 ------------------------------------------------------------------------------------------------
14813 XLA_AE_LINES_PKG.ValidateCurrentLine;
14814
14815 ------------------------------------------------------------------------------------
14816 -- 4219869 Business Flow
14817 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
14818 ------------------------------------------------------------------------------------
14819 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14820
14821 ----------------------------------------------------------------------------------
14822 -- 4219869 Business Flow
14826 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
14823 -- Update journal entry status -- Need to generate this within IF <condition>
14824 ----------------------------------------------------------------------------------
14825 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14827 ,p_balance_type_code => l_balance_type_code
14828 );
14829
14830 -------------------------------------------------------------------------------------------
14831 -- 4262811 - Generate the Accrual Reversal lines
14832 -------------------------------------------------------------------------------------------
14833 BEGIN
14834 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
14835 (g_array_event(p_event_id).array_value_num('header_index'));
14836 IF l_acc_rev_flag IS NULL THEN
14837 l_acc_rev_flag := 'N';
14838 END IF;
14839 EXCEPTION
14840 WHEN OTHERS THEN
14841 l_acc_rev_flag := 'N';
14842 END;
14843 --
14844 IF (l_acc_rev_flag = 'Y') THEN
14845
14846 -- 4645092 ------------------------------------------------------------------------------
14847 -- To allow MPA report to determine if it should generate report process
14848 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
14849 ------------------------------------------------------------------------------------------
14850
14851 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
14852 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
14853 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
14854 -- call ADRs
14855 -- Bug 4922099
14856 --
14857 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14858 (NVL(l_actual_upg_option, 'N') = 'O') OR
14859 (NVL(l_enc_upg_option, 'N') = 'O')
14860 )
14861 THEN
14862 NULL;
14863 --
14864 --
14865
14866 l_ccid := AcctDerRule_34(
14867 p_application_id => p_application_id
14868 , p_ae_header_id => l_ae_header_id
14869 , p_source_21 => p_source_21
14870 , x_transaction_coa_id => l_adr_transaction_coa_id
14871 , x_accounting_coa_id => l_adr_accounting_coa_id
14872 , x_value_type_code => l_adr_value_type_code
14873 , p_side => 'NA'
14874 );
14875
14876 xla_ae_lines_pkg.set_ccid(
14877 p_code_combination_id => l_ccid
14878 , p_value_type_code => l_adr_value_type_code
14879 , p_transaction_coa_id => l_adr_transaction_coa_id
14880 , p_accounting_coa_id => l_adr_accounting_coa_id
14881 , p_adr_code => 'TRX_DIST_CCID'
14882 , p_adr_type_code => 'S'
14883 , p_component_type => l_component_type
14884 , p_component_code => l_component_code
14885 , p_component_type_code => l_component_type_code
14886 , p_component_appl_id => l_component_appl_id
14887 , p_amb_context_code => l_amb_context_code
14888 , p_side => 'NA'
14889 );
14890
14891
14892 --
14893 --
14894 END IF;
14895
14896 --
14897 -- Update the line information that should be overwritten
14898 --
14899 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
14900 p_header_num => 1);
14901 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
14902
14903 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
14904
14905 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
14906 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
14907 END IF;
14908
14909 --
14910 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
14911 --
14912 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
14913 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
14914 ELSE
14915 ---------------------------------------------------------------------------------------------------
14916 -- 4262811a Switch Sign
14917 ---------------------------------------------------------------------------------------------------
14918 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
14919 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14920 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14921 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14922 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14923 -- 5132302
14924 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
14925 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14926
14927 END IF;
14928
14929 -- 4955764
14930 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14931 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
14932
14933
14937 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14934 XLA_AE_LINES_PKG.ValidateCurrentLine;
14935 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14936
14938 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
14939 ,p_balance_type_code => l_balance_type_code);
14940
14941 END IF;
14942
14943 -----------------------------------------------------------------------------------------
14944 -- 4262811 Multiperiod Accounting
14945 -----------------------------------------------------------------------------------------
14946 -- No MPA option is assigned.
14947
14948
14949 END IF;
14950 END IF;
14951 --
14952
14953 --
14954 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14955 trace
14956 (p_msg => 'END of AcctLineType_52'
14957 ,p_level => C_LEVEL_PROCEDURE
14958 ,p_module => l_log_module);
14959 END IF;
14960 --
14961 EXCEPTION
14962 WHEN xla_exceptions_pkg.application_exception THEN
14963 RAISE;
14964 WHEN OTHERS THEN
14965 xla_exceptions_pkg.raise_message
14966 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_52');
14967 END AcctLineType_52;
14968 --
14969
14970 ---------------------------------------
14971 --
14972 -- PRIVATE FUNCTION
14973 -- AcctLineType_53
14974 --
14975 ---------------------------------------
14976 PROCEDURE AcctLineType_53 (
14977 p_application_id IN NUMBER
14978 ,p_event_id IN NUMBER
14979 ,p_calculate_acctd_flag IN VARCHAR2
14980 ,p_calculate_g_l_flag IN VARCHAR2
14981 ,p_actual_flag IN OUT VARCHAR2
14982 ,p_balance_type_code OUT VARCHAR2
14983 ,p_gain_or_loss_ref OUT VARCHAR2
14984
14985 --Transaction Distribution GL Account
14986 , p_source_21 IN NUMBER
14987 --Bill To Customer Account Identifier
14988 , p_source_32 IN NUMBER
14989 --Bill To Customer Site Use Identifier
14990 , p_source_33 IN NUMBER
14991 --SLA Party Type
14992 , p_source_34 IN VARCHAR2
14993 --Transaction Distribution Account Class
14994 , p_source_35 IN VARCHAR2
14995 --Transaction Distribution Identifier
14996 , p_source_36 IN NUMBER
14997 --Transaction Distribution Type
14998 , p_source_37 IN VARCHAR2
14999 --Transaction Distribution Entered Amount
15000 , p_source_38 IN NUMBER
15001 --Transaction Currency Code
15002 , p_source_39 IN VARCHAR2
15003 --Transaction Exchange Date
15004 , p_source_40 IN DATE
15005 --Transaction Exchange Rate
15006 , p_source_41 IN NUMBER
15007 --Transaction Exchange Rate Type
15008 , p_source_42 IN VARCHAR2
15009 --Transaction Accounting Amount
15010 , p_source_43 IN NUMBER
15011 --Transaction Tax Line Identifier
15012 , p_source_57 IN NUMBER
15013 )
15014 IS
15015
15016 l_component_type VARCHAR2(80);
15017 l_component_code VARCHAR2(30);
15018 l_component_type_code VARCHAR2(1);
15019 l_component_appl_id INTEGER;
15020 l_amb_context_code VARCHAR2(30);
15021 l_entity_code VARCHAR2(30);
15022 l_event_class_code VARCHAR2(30);
15023 l_ae_header_id NUMBER;
15024 l_event_type_code VARCHAR2(30);
15025 l_line_definition_code VARCHAR2(30);
15026 l_line_definition_owner_code VARCHAR2(1);
15027 --
15028 -- adr variables
15029 l_segment VARCHAR2(30);
15030 l_ccid NUMBER;
15031 l_adr_transaction_coa_id NUMBER;
15032 l_adr_accounting_coa_id NUMBER;
15033 l_adr_flexfield_segment_code VARCHAR2(30);
15034 l_adr_flex_value_set_id NUMBER;
15035 l_adr_value_type_code VARCHAR2(30);
15036 l_adr_value_combination_id NUMBER;
15037 l_adr_value_segment_code VARCHAR2(30);
15038
15039 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
15040 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
15041 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
15042 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
15043
15044 -- 4262811 Variables ------------------------------------------------------------------------------------------
15045 l_entered_amt_idx NUMBER;
15046 l_accted_amt_idx NUMBER;
15047 l_acc_rev_flag VARCHAR2(1);
15048 l_accrual_line_num NUMBER;
15049 l_tmp_amt NUMBER;
15050 l_acc_rev_natural_side_code VARCHAR2(1);
15051
15052 l_num_entries NUMBER;
15053 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
15054 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
15055 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
15056 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
15057 l_recog_line_1 NUMBER;
15058 l_recog_line_2 NUMBER;
15059
15060 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
15061 l_bflow_applied_to_amt NUMBER; -- 5132302
15062 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
15063
15064 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
15065
15069 ---------------------------------------------------------------------------------------------------------------
15066 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
15067 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
15068
15070
15071
15072 --
15073 -- bulk performance
15074 --
15075 l_balance_type_code VARCHAR2(1);
15076 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
15077 l_log_module VARCHAR2(240);
15078
15079 --
15080 -- Upgrade strategy
15081 --
15082 l_actual_upg_option VARCHAR2(1);
15083 l_enc_upg_option VARCHAR2(1);
15084
15085 --
15086 BEGIN
15087 --
15088 IF g_log_enabled THEN
15089 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_53';
15090 END IF;
15091 --
15092 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15093
15094 trace
15095 (p_msg => 'BEGIN of AcctLineType_53'
15096 ,p_level => C_LEVEL_PROCEDURE
15097 ,p_module => l_log_module);
15098
15099 END IF;
15100 --
15101 l_component_type := 'AMB_JLT';
15102 l_component_code := 'DM_CHARGES';
15103 l_component_type_code := 'S';
15104 l_component_appl_id := 222;
15105 l_amb_context_code := 'DEFAULT';
15106 l_entity_code := 'TRANSACTIONS';
15107 l_event_class_code := 'DEBIT_MEMO';
15108 l_event_type_code := 'DEBIT_MEMO_ALL';
15109 l_line_definition_owner_code := 'S';
15110 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
15111 --
15112 l_balance_type_code := 'A';
15113 l_segment := NULL;
15114 l_ccid := NULL;
15115 l_adr_transaction_coa_id := NULL;
15116 l_adr_accounting_coa_id := NULL;
15117 l_adr_flexfield_segment_code := NULL;
15118 l_adr_flex_value_set_id := NULL;
15119 l_adr_value_type_code := NULL;
15120 l_adr_value_combination_id := NULL;
15121 l_adr_value_segment_code := NULL;
15122
15123 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
15124 l_bflow_class_code := ''; -- 4219869 Business Flow
15125 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
15126 l_budgetary_control_flag := 'N';
15127
15128 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15129 l_bflow_applied_to_amt := NULL; -- 5132302
15130 l_entered_amt_idx := NULL; -- 4262811
15131 l_accted_amt_idx := NULL; -- 4262811
15132 l_acc_rev_flag := NULL; -- 4262811
15133 l_accrual_line_num := NULL; -- 4262811
15134 l_tmp_amt := NULL; -- 4262811
15135 --
15136
15137 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
15138 l_balance_type_code <> 'B' THEN
15139 IF NVL(p_source_35,'
15140 ') = 'CHARGES'
15141 THEN
15142
15143 --
15144 XLA_AE_LINES_PKG.SetNewLine;
15145
15146 p_balance_type_code := l_balance_type_code;
15147 -- set the flag so later we will know whether the gain loss line needs to be created
15148
15149 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
15150 p_actual_flag :='A';
15151 END IF;
15152
15153 --
15154 -- bulk performance
15155 --
15156 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
15157 p_header_num => 0); -- 4262811
15158 --
15159 -- set accounting line options
15160 --
15161 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
15162 p_natural_side_code => 'C'
15163 , p_gain_or_loss_flag => 'N'
15164 , p_gl_transfer_mode_code => 'S'
15165 , p_acct_entry_type_code => 'A'
15166 , p_switch_side_flag => 'Y'
15167 , p_merge_duplicate_code => 'A'
15168 );
15169 --
15170 l_acc_rev_natural_side_code := 'D'; -- 4262811
15171 --
15172 --
15173 -- set accounting line type info
15174 --
15175 xla_ae_lines_pkg.SetAcctLineType
15176 (p_component_type => l_component_type
15177 ,p_event_type_code => l_event_type_code
15178 ,p_line_definition_owner_code => l_line_definition_owner_code
15179 ,p_line_definition_code => l_line_definition_code
15180 ,p_accounting_line_code => l_component_code
15181 ,p_accounting_line_type_code => l_component_type_code
15182 ,p_accounting_line_appl_id => l_component_appl_id
15183 ,p_amb_context_code => l_amb_context_code
15184 ,p_entity_code => l_entity_code
15185 ,p_event_class_code => l_event_class_code);
15186 --
15187 -- set accounting class
15188 --
15189 xla_ae_lines_pkg.SetAcctClass(
15190 p_accounting_class_code => 'CHARGES'
15191 , p_ae_header_id => l_ae_header_id
15192 );
15193
15194 --
15195 -- set rounding class
15196 --
15197 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
15198 'RECEIVABLE';
15199
15200 --
15201 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
15205 --
15202 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
15203 --
15204 -- bulk performance
15206 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
15207
15208 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
15209 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
15210
15211 -- 4955764
15212 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15213 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
15214
15215 -- 4458381 Public Sector Enh
15216
15217 --
15218 -- set accounting attributes for the line type
15219 --
15220 l_entered_amt_idx := 3;
15221 l_accted_amt_idx := 8;
15222 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15223 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
15224 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
15225 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
15226 l_rec_acct_attrs.array_char_value(2) := p_source_37;
15227 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
15228 l_rec_acct_attrs.array_num_value(3) := p_source_38;
15229 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
15230 l_rec_acct_attrs.array_char_value(4) := p_source_39;
15231 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
15232 l_rec_acct_attrs.array_date_value(5) := p_source_40;
15233 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
15234 l_rec_acct_attrs.array_num_value(6) := p_source_41;
15235 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
15236 l_rec_acct_attrs.array_char_value(7) := p_source_42;
15237 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
15238 l_rec_acct_attrs.array_num_value(8) := p_source_43;
15239 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
15240 l_rec_acct_attrs.array_num_value(9) := p_source_32;
15241 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
15242 l_rec_acct_attrs.array_num_value(10) := p_source_33;
15243 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
15244 l_rec_acct_attrs.array_char_value(11) := p_source_34;
15245 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
15246 l_rec_acct_attrs.array_num_value(12) := p_source_57;
15247
15248 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
15249 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
15250
15251 ---------------------------------------------------------------------------------------------------------------
15252 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
15253 ---------------------------------------------------------------------------------------------------------------
15254 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
15255
15256 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15257 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15258
15259 IF xla_accounting_cache_pkg.GetValueChar
15260 (p_source_code => 'LEDGER_CATEGORY_CODE'
15261 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
15262 AND l_bflow_method_code = 'PRIOR_ENTRY'
15263 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
15264 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
15265 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
15266 )
15267 THEN
15268 xla_ae_lines_pkg.BflowUpgEntry
15269 (p_business_method_code => l_bflow_method_code
15270 ,p_business_class_code => l_bflow_class_code
15271 ,p_balance_type => l_balance_type_code);
15272 ELSE
15273 NULL;
15274 -- No business flow processing for business flow method of NONE.
15275 END IF;
15276
15277 --
15278 -- call analytical criteria
15279 --
15280
15281 --
15282 -- call description
15283 --
15284 -- No description or it is inherited.
15285 --
15286 -- call ADRs
15287 -- Bug 4922099
15288 --
15289 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15290 (NVL(l_actual_upg_option, 'N') = 'O') OR
15291 (NVL(l_enc_upg_option, 'N') = 'O')
15292 )
15293 THEN
15294 NULL;
15295 --
15296 --
15297
15298 l_ccid := AcctDerRule_34(
15299 p_application_id => p_application_id
15300 , p_ae_header_id => l_ae_header_id
15301 , p_source_21 => p_source_21
15302 , x_transaction_coa_id => l_adr_transaction_coa_id
15303 , x_accounting_coa_id => l_adr_accounting_coa_id
15304 , x_value_type_code => l_adr_value_type_code
15305 , p_side => 'NA'
15306 );
15307
15308 xla_ae_lines_pkg.set_ccid(
15309 p_code_combination_id => l_ccid
15310 , p_value_type_code => l_adr_value_type_code
15311 , p_transaction_coa_id => l_adr_transaction_coa_id
15315 , p_component_type => l_component_type
15312 , p_accounting_coa_id => l_adr_accounting_coa_id
15313 , p_adr_code => 'TRX_DIST_CCID'
15314 , p_adr_type_code => 'S'
15316 , p_component_code => l_component_code
15317 , p_component_type_code => l_component_type_code
15318 , p_component_appl_id => l_component_appl_id
15319 , p_amb_context_code => l_amb_context_code
15320 , p_side => 'NA'
15321 );
15322
15323
15324 --
15325 --
15326 END IF;
15327 --
15328 -- Bug 4922099
15329 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
15330 (NVL(l_enc_upg_option, 'N') = 'O')
15331 ) AND
15332 (l_bflow_method_code = 'PRIOR_ENTRY')
15333 )
15334 THEN
15335 IF
15336 --
15337 1 = 2
15338 --
15339 THEN
15340 xla_accounting_err_pkg.build_message
15341 (p_appli_s_name => 'XLA'
15342 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15343 ,p_token_1 => 'LINE_NUMBER'
15344 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
15345 ,p_token_2 => 'LINE_TYPE_NAME'
15346 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
15347 l_component_type
15348 ,l_component_code
15349 ,l_component_type_code
15350 ,l_component_appl_id
15351 ,l_amb_context_code
15352 ,l_entity_code
15353 ,l_event_class_code
15354 )
15355 ,p_token_3 => 'OWNER'
15356 ,p_value_3 => xla_lookups_pkg.get_meaning(
15357 p_lookup_type => 'XLA_OWNER_TYPE'
15358 ,p_lookup_code => l_component_type_code
15359 )
15360 ,p_token_4 => 'PRODUCT_NAME'
15361 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
15362 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
15363 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
15364 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
15365 ,p_ae_header_id => NULL
15366 );
15367
15368 IF (C_LEVEL_ERROR>= g_log_level) THEN
15369 trace
15370 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15371 ,p_level => C_LEVEL_ERROR
15372 ,p_module => l_log_module);
15373 END IF;
15374 END IF;
15375 END IF;
15376 --
15377 --
15378 ------------------------------------------------------------------------------------------------
15379 -- 4219869 Business Flow
15380 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
15381 -- Prior Entry. Currently, the following code is always generated.
15382 ------------------------------------------------------------------------------------------------
15383 XLA_AE_LINES_PKG.ValidateCurrentLine;
15384
15385 ------------------------------------------------------------------------------------
15386 -- 4219869 Business Flow
15387 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
15388 ------------------------------------------------------------------------------------
15389 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15390
15391 ----------------------------------------------------------------------------------
15392 -- 4219869 Business Flow
15393 -- Update journal entry status -- Need to generate this within IF <condition>
15394 ----------------------------------------------------------------------------------
15395 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15396 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
15397 ,p_balance_type_code => l_balance_type_code
15398 );
15399
15400 -------------------------------------------------------------------------------------------
15401 -- 4262811 - Generate the Accrual Reversal lines
15402 -------------------------------------------------------------------------------------------
15403 BEGIN
15404 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
15405 (g_array_event(p_event_id).array_value_num('header_index'));
15409 EXCEPTION
15406 IF l_acc_rev_flag IS NULL THEN
15407 l_acc_rev_flag := 'N';
15408 END IF;
15410 WHEN OTHERS THEN
15411 l_acc_rev_flag := 'N';
15412 END;
15413 --
15414 IF (l_acc_rev_flag = 'Y') THEN
15415
15416 -- 4645092 ------------------------------------------------------------------------------
15417 -- To allow MPA report to determine if it should generate report process
15418 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
15419 ------------------------------------------------------------------------------------------
15420
15421 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
15422 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
15423 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
15424 -- call ADRs
15425 -- Bug 4922099
15426 --
15427 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15428 (NVL(l_actual_upg_option, 'N') = 'O') OR
15429 (NVL(l_enc_upg_option, 'N') = 'O')
15430 )
15431 THEN
15432 NULL;
15433 --
15434 --
15435
15436 l_ccid := AcctDerRule_34(
15437 p_application_id => p_application_id
15438 , p_ae_header_id => l_ae_header_id
15439 , p_source_21 => p_source_21
15440 , x_transaction_coa_id => l_adr_transaction_coa_id
15441 , x_accounting_coa_id => l_adr_accounting_coa_id
15442 , x_value_type_code => l_adr_value_type_code
15443 , p_side => 'NA'
15444 );
15445
15446 xla_ae_lines_pkg.set_ccid(
15447 p_code_combination_id => l_ccid
15448 , p_value_type_code => l_adr_value_type_code
15449 , p_transaction_coa_id => l_adr_transaction_coa_id
15450 , p_accounting_coa_id => l_adr_accounting_coa_id
15451 , p_adr_code => 'TRX_DIST_CCID'
15452 , p_adr_type_code => 'S'
15453 , p_component_type => l_component_type
15454 , p_component_code => l_component_code
15455 , p_component_type_code => l_component_type_code
15456 , p_component_appl_id => l_component_appl_id
15457 , p_amb_context_code => l_amb_context_code
15458 , p_side => 'NA'
15459 );
15460
15461
15462 --
15463 --
15464 END IF;
15465
15466 --
15467 -- Update the line information that should be overwritten
15468 --
15469 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
15470 p_header_num => 1);
15471 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
15472
15473 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
15474
15475 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
15476 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
15477 END IF;
15478
15479 --
15480 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
15481 --
15482 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
15483 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
15484 ELSE
15485 ---------------------------------------------------------------------------------------------------
15486 -- 4262811a Switch Sign
15487 ---------------------------------------------------------------------------------------------------
15488 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
15489 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15490 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15491 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15492 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15493 -- 5132302
15494 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
15495 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15496
15497 END IF;
15498
15499 -- 4955764
15500 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15501 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
15502
15503
15504 XLA_AE_LINES_PKG.ValidateCurrentLine;
15505 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15506
15507 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15508 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
15509 ,p_balance_type_code => l_balance_type_code);
15510
15511 END IF;
15512
15513 -----------------------------------------------------------------------------------------
15514 -- 4262811 Multiperiod Accounting
15515 -----------------------------------------------------------------------------------------
15516 -- No MPA option is assigned.
15517
15518
15519 END IF;
15520 END IF;
15521 --
15522
15523 --
15527 ,p_level => C_LEVEL_PROCEDURE
15524 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15525 trace
15526 (p_msg => 'END of AcctLineType_53'
15528 ,p_module => l_log_module);
15529 END IF;
15530 --
15531 EXCEPTION
15532 WHEN xla_exceptions_pkg.application_exception THEN
15533 RAISE;
15534 WHEN OTHERS THEN
15535 xla_exceptions_pkg.raise_message
15536 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_53');
15537 END AcctLineType_53;
15538 --
15539
15540 ---------------------------------------
15541 --
15542 -- PRIVATE FUNCTION
15543 -- AcctLineType_54
15544 --
15545 ---------------------------------------
15546 PROCEDURE AcctLineType_54 (
15547 p_application_id IN NUMBER
15548 ,p_event_id IN NUMBER
15549 ,p_calculate_acctd_flag IN VARCHAR2
15550 ,p_calculate_g_l_flag IN VARCHAR2
15551 ,p_actual_flag IN OUT VARCHAR2
15552 ,p_balance_type_code OUT VARCHAR2
15553 ,p_gain_or_loss_ref OUT VARCHAR2
15554
15555 --Transaction Distribution GL Account
15556 , p_source_21 IN NUMBER
15557 --Bill To Customer Account Identifier
15558 , p_source_32 IN NUMBER
15559 --Bill To Customer Site Use Identifier
15560 , p_source_33 IN NUMBER
15561 --SLA Party Type
15562 , p_source_34 IN VARCHAR2
15563 --Transaction Distribution Account Class
15564 , p_source_35 IN VARCHAR2
15565 --Transaction Distribution Identifier
15566 , p_source_36 IN NUMBER
15567 --Transaction Distribution Type
15568 , p_source_37 IN VARCHAR2
15569 --Transaction Distribution Entered Amount
15570 , p_source_38 IN NUMBER
15571 --Transaction Currency Code
15572 , p_source_39 IN VARCHAR2
15573 --Transaction Exchange Date
15574 , p_source_40 IN DATE
15575 --Transaction Exchange Rate
15576 , p_source_41 IN NUMBER
15577 --Transaction Exchange Rate Type
15578 , p_source_42 IN VARCHAR2
15579 --Transaction Accounting Amount
15580 , p_source_43 IN NUMBER
15581 --Transaction Tax Line Identifier
15582 , p_source_57 IN NUMBER
15583 )
15584 IS
15585
15586 l_component_type VARCHAR2(80);
15587 l_component_code VARCHAR2(30);
15588 l_component_type_code VARCHAR2(1);
15589 l_component_appl_id INTEGER;
15590 l_amb_context_code VARCHAR2(30);
15591 l_entity_code VARCHAR2(30);
15592 l_event_class_code VARCHAR2(30);
15593 l_ae_header_id NUMBER;
15594 l_event_type_code VARCHAR2(30);
15595 l_line_definition_code VARCHAR2(30);
15596 l_line_definition_owner_code VARCHAR2(1);
15597 --
15598 -- adr variables
15599 l_segment VARCHAR2(30);
15600 l_ccid NUMBER;
15601 l_adr_transaction_coa_id NUMBER;
15602 l_adr_accounting_coa_id NUMBER;
15603 l_adr_flexfield_segment_code VARCHAR2(30);
15604 l_adr_flex_value_set_id NUMBER;
15605 l_adr_value_type_code VARCHAR2(30);
15606 l_adr_value_combination_id NUMBER;
15607 l_adr_value_segment_code VARCHAR2(30);
15608
15609 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
15610 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
15611 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
15612 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
15613
15614 -- 4262811 Variables ------------------------------------------------------------------------------------------
15615 l_entered_amt_idx NUMBER;
15616 l_accted_amt_idx NUMBER;
15617 l_acc_rev_flag VARCHAR2(1);
15618 l_accrual_line_num NUMBER;
15619 l_tmp_amt NUMBER;
15620 l_acc_rev_natural_side_code VARCHAR2(1);
15621
15622 l_num_entries NUMBER;
15623 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
15624 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
15625 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
15626 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
15627 l_recog_line_1 NUMBER;
15628 l_recog_line_2 NUMBER;
15629
15630 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
15631 l_bflow_applied_to_amt NUMBER; -- 5132302
15632 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
15633
15634 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
15635
15636 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
15637 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
15638
15639 ---------------------------------------------------------------------------------------------------------------
15640
15641
15642 --
15643 -- bulk performance
15644 --
15645 l_balance_type_code VARCHAR2(1);
15646 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
15647 l_log_module VARCHAR2(240);
15648
15649 --
15650 -- Upgrade strategy
15651 --
15652 l_actual_upg_option VARCHAR2(1);
15653 l_enc_upg_option VARCHAR2(1);
15654
15655 --
15656 BEGIN
15657 --
15658 IF g_log_enabled THEN
15662 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15659 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_54';
15660 END IF;
15661 --
15663
15664 trace
15665 (p_msg => 'BEGIN of AcctLineType_54'
15666 ,p_level => C_LEVEL_PROCEDURE
15667 ,p_module => l_log_module);
15668
15669 END IF;
15670 --
15671 l_component_type := 'AMB_JLT';
15672 l_component_code := 'DM_FREIGHT';
15673 l_component_type_code := 'S';
15674 l_component_appl_id := 222;
15675 l_amb_context_code := 'DEFAULT';
15676 l_entity_code := 'TRANSACTIONS';
15677 l_event_class_code := 'DEBIT_MEMO';
15678 l_event_type_code := 'DEBIT_MEMO_ALL';
15679 l_line_definition_owner_code := 'S';
15680 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
15681 --
15682 l_balance_type_code := 'A';
15683 l_segment := NULL;
15684 l_ccid := NULL;
15685 l_adr_transaction_coa_id := NULL;
15686 l_adr_accounting_coa_id := NULL;
15687 l_adr_flexfield_segment_code := NULL;
15688 l_adr_flex_value_set_id := NULL;
15689 l_adr_value_type_code := NULL;
15690 l_adr_value_combination_id := NULL;
15691 l_adr_value_segment_code := NULL;
15692
15693 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
15694 l_bflow_class_code := ''; -- 4219869 Business Flow
15695 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
15696 l_budgetary_control_flag := 'N';
15697
15698 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15699 l_bflow_applied_to_amt := NULL; -- 5132302
15700 l_entered_amt_idx := NULL; -- 4262811
15701 l_accted_amt_idx := NULL; -- 4262811
15702 l_acc_rev_flag := NULL; -- 4262811
15703 l_accrual_line_num := NULL; -- 4262811
15704 l_tmp_amt := NULL; -- 4262811
15705 --
15706
15707 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
15708 l_balance_type_code <> 'B' THEN
15709 IF NVL(p_source_35,'
15710 ') = 'FREIGHT'
15711 THEN
15712
15713 --
15714 XLA_AE_LINES_PKG.SetNewLine;
15715
15716 p_balance_type_code := l_balance_type_code;
15717 -- set the flag so later we will know whether the gain loss line needs to be created
15718
15719 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
15720 p_actual_flag :='A';
15721 END IF;
15722
15723 --
15724 -- bulk performance
15725 --
15726 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
15727 p_header_num => 0); -- 4262811
15728 --
15729 -- set accounting line options
15730 --
15731 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
15732 p_natural_side_code => 'C'
15733 , p_gain_or_loss_flag => 'N'
15734 , p_gl_transfer_mode_code => 'S'
15735 , p_acct_entry_type_code => 'A'
15736 , p_switch_side_flag => 'Y'
15737 , p_merge_duplicate_code => 'A'
15738 );
15739 --
15740 l_acc_rev_natural_side_code := 'D'; -- 4262811
15741 --
15742 --
15743 -- set accounting line type info
15744 --
15745 xla_ae_lines_pkg.SetAcctLineType
15746 (p_component_type => l_component_type
15747 ,p_event_type_code => l_event_type_code
15748 ,p_line_definition_owner_code => l_line_definition_owner_code
15749 ,p_line_definition_code => l_line_definition_code
15750 ,p_accounting_line_code => l_component_code
15751 ,p_accounting_line_type_code => l_component_type_code
15752 ,p_accounting_line_appl_id => l_component_appl_id
15753 ,p_amb_context_code => l_amb_context_code
15754 ,p_entity_code => l_entity_code
15755 ,p_event_class_code => l_event_class_code);
15756 --
15757 -- set accounting class
15758 --
15759 xla_ae_lines_pkg.SetAcctClass(
15760 p_accounting_class_code => 'FREIGHT'
15761 , p_ae_header_id => l_ae_header_id
15762 );
15763
15764 --
15765 -- set rounding class
15766 --
15767 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
15768 'RECEIVABLE';
15769
15770 --
15771 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
15772 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
15773 --
15774 -- bulk performance
15775 --
15776 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
15777
15778 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
15779 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
15780
15781 -- 4955764
15782 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15783 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
15784
15785 -- 4458381 Public Sector Enh
15786
15787 --
15788 -- set accounting attributes for the line type
15789 --
15790 l_entered_amt_idx := 3;
15794 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
15791 l_accted_amt_idx := 8;
15792 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15793 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
15795 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
15796 l_rec_acct_attrs.array_char_value(2) := p_source_37;
15797 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
15798 l_rec_acct_attrs.array_num_value(3) := p_source_38;
15799 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
15800 l_rec_acct_attrs.array_char_value(4) := p_source_39;
15801 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
15802 l_rec_acct_attrs.array_date_value(5) := p_source_40;
15803 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
15804 l_rec_acct_attrs.array_num_value(6) := p_source_41;
15805 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
15806 l_rec_acct_attrs.array_char_value(7) := p_source_42;
15807 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
15808 l_rec_acct_attrs.array_num_value(8) := p_source_43;
15809 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
15810 l_rec_acct_attrs.array_num_value(9) := p_source_32;
15811 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
15812 l_rec_acct_attrs.array_num_value(10) := p_source_33;
15813 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
15814 l_rec_acct_attrs.array_char_value(11) := p_source_34;
15815 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
15816 l_rec_acct_attrs.array_num_value(12) := p_source_57;
15817
15818 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
15819 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
15820
15821 ---------------------------------------------------------------------------------------------------------------
15822 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
15823 ---------------------------------------------------------------------------------------------------------------
15824 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
15825
15826 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15827 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15828
15829 IF xla_accounting_cache_pkg.GetValueChar
15830 (p_source_code => 'LEDGER_CATEGORY_CODE'
15831 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
15832 AND l_bflow_method_code = 'PRIOR_ENTRY'
15833 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
15834 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
15835 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
15836 )
15837 THEN
15838 xla_ae_lines_pkg.BflowUpgEntry
15839 (p_business_method_code => l_bflow_method_code
15840 ,p_business_class_code => l_bflow_class_code
15841 ,p_balance_type => l_balance_type_code);
15842 ELSE
15843 NULL;
15844 -- No business flow processing for business flow method of NONE.
15845 END IF;
15846
15847 --
15848 -- call analytical criteria
15849 --
15850
15851 --
15852 -- call description
15853 --
15854 -- No description or it is inherited.
15855 --
15856 -- call ADRs
15857 -- Bug 4922099
15858 --
15859 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15860 (NVL(l_actual_upg_option, 'N') = 'O') OR
15861 (NVL(l_enc_upg_option, 'N') = 'O')
15862 )
15863 THEN
15864 NULL;
15865 --
15866 --
15867
15868 l_ccid := AcctDerRule_34(
15869 p_application_id => p_application_id
15870 , p_ae_header_id => l_ae_header_id
15871 , p_source_21 => p_source_21
15872 , x_transaction_coa_id => l_adr_transaction_coa_id
15873 , x_accounting_coa_id => l_adr_accounting_coa_id
15874 , x_value_type_code => l_adr_value_type_code
15875 , p_side => 'NA'
15876 );
15877
15878 xla_ae_lines_pkg.set_ccid(
15879 p_code_combination_id => l_ccid
15880 , p_value_type_code => l_adr_value_type_code
15881 , p_transaction_coa_id => l_adr_transaction_coa_id
15882 , p_accounting_coa_id => l_adr_accounting_coa_id
15883 , p_adr_code => 'TRX_DIST_CCID'
15884 , p_adr_type_code => 'S'
15885 , p_component_type => l_component_type
15886 , p_component_code => l_component_code
15887 , p_component_type_code => l_component_type_code
15888 , p_component_appl_id => l_component_appl_id
15889 , p_amb_context_code => l_amb_context_code
15890 , p_side => 'NA'
15891 );
15892
15893
15894 --
15895 --
15896 END IF;
15897 --
15898 -- Bug 4922099
15899 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
15900 (NVL(l_enc_upg_option, 'N') = 'O')
15901 ) AND
15902 (l_bflow_method_code = 'PRIOR_ENTRY')
15903 )
15904 THEN
15905 IF
15906 --
15910 xla_accounting_err_pkg.build_message
15907 1 = 2
15908 --
15909 THEN
15911 (p_appli_s_name => 'XLA'
15912 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15913 ,p_token_1 => 'LINE_NUMBER'
15914 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
15915 ,p_token_2 => 'LINE_TYPE_NAME'
15916 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
15917 l_component_type
15918 ,l_component_code
15919 ,l_component_type_code
15920 ,l_component_appl_id
15921 ,l_amb_context_code
15922 ,l_entity_code
15923 ,l_event_class_code
15924 )
15925 ,p_token_3 => 'OWNER'
15926 ,p_value_3 => xla_lookups_pkg.get_meaning(
15927 p_lookup_type => 'XLA_OWNER_TYPE'
15928 ,p_lookup_code => l_component_type_code
15929 )
15930 ,p_token_4 => 'PRODUCT_NAME'
15931 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
15932 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
15933 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
15934 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
15935 ,p_ae_header_id => NULL
15936 );
15937
15938 IF (C_LEVEL_ERROR>= g_log_level) THEN
15939 trace
15940 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15941 ,p_level => C_LEVEL_ERROR
15942 ,p_module => l_log_module);
15943 END IF;
15944 END IF;
15945 END IF;
15946 --
15947 --
15948 ------------------------------------------------------------------------------------------------
15949 -- 4219869 Business Flow
15950 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
15951 -- Prior Entry. Currently, the following code is always generated.
15952 ------------------------------------------------------------------------------------------------
15953 XLA_AE_LINES_PKG.ValidateCurrentLine;
15954
15955 ------------------------------------------------------------------------------------
15956 -- 4219869 Business Flow
15957 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
15958 ------------------------------------------------------------------------------------
15959 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15960
15961 ----------------------------------------------------------------------------------
15962 -- 4219869 Business Flow
15963 -- Update journal entry status -- Need to generate this within IF <condition>
15964 ----------------------------------------------------------------------------------
15965 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15966 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
15967 ,p_balance_type_code => l_balance_type_code
15968 );
15969
15970 -------------------------------------------------------------------------------------------
15971 -- 4262811 - Generate the Accrual Reversal lines
15972 -------------------------------------------------------------------------------------------
15973 BEGIN
15974 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
15975 (g_array_event(p_event_id).array_value_num('header_index'));
15976 IF l_acc_rev_flag IS NULL THEN
15977 l_acc_rev_flag := 'N';
15978 END IF;
15979 EXCEPTION
15980 WHEN OTHERS THEN
15981 l_acc_rev_flag := 'N';
15982 END;
15983 --
15984 IF (l_acc_rev_flag = 'Y') THEN
15985
15986 -- 4645092 ------------------------------------------------------------------------------
15987 -- To allow MPA report to determine if it should generate report process
15988 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
15989 ------------------------------------------------------------------------------------------
15990
15991 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
15992 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
15993 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
15994 -- call ADRs
15995 -- Bug 4922099
15996 --
16000 )
15997 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15998 (NVL(l_actual_upg_option, 'N') = 'O') OR
15999 (NVL(l_enc_upg_option, 'N') = 'O')
16001 THEN
16002 NULL;
16003 --
16004 --
16005
16006 l_ccid := AcctDerRule_34(
16007 p_application_id => p_application_id
16008 , p_ae_header_id => l_ae_header_id
16009 , p_source_21 => p_source_21
16010 , x_transaction_coa_id => l_adr_transaction_coa_id
16011 , x_accounting_coa_id => l_adr_accounting_coa_id
16012 , x_value_type_code => l_adr_value_type_code
16013 , p_side => 'NA'
16014 );
16015
16016 xla_ae_lines_pkg.set_ccid(
16017 p_code_combination_id => l_ccid
16018 , p_value_type_code => l_adr_value_type_code
16019 , p_transaction_coa_id => l_adr_transaction_coa_id
16020 , p_accounting_coa_id => l_adr_accounting_coa_id
16021 , p_adr_code => 'TRX_DIST_CCID'
16022 , p_adr_type_code => 'S'
16023 , p_component_type => l_component_type
16024 , p_component_code => l_component_code
16025 , p_component_type_code => l_component_type_code
16026 , p_component_appl_id => l_component_appl_id
16027 , p_amb_context_code => l_amb_context_code
16028 , p_side => 'NA'
16029 );
16030
16031
16032 --
16033 --
16034 END IF;
16035
16036 --
16037 -- Update the line information that should be overwritten
16038 --
16039 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
16040 p_header_num => 1);
16041 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
16042
16043 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
16044
16045 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
16046 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
16047 END IF;
16048
16049 --
16050 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
16051 --
16052 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
16053 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
16054 ELSE
16055 ---------------------------------------------------------------------------------------------------
16056 -- 4262811a Switch Sign
16057 ---------------------------------------------------------------------------------------------------
16058 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
16059 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
16060 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16061 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
16062 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16063 -- 5132302
16064 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
16065 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16066
16067 END IF;
16068
16069 -- 4955764
16070 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16071 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
16072
16073
16074 XLA_AE_LINES_PKG.ValidateCurrentLine;
16075 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
16076
16077 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
16078 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
16079 ,p_balance_type_code => l_balance_type_code);
16080
16081 END IF;
16082
16083 -----------------------------------------------------------------------------------------
16084 -- 4262811 Multiperiod Accounting
16085 -----------------------------------------------------------------------------------------
16086 -- No MPA option is assigned.
16087
16088
16089 END IF;
16090 END IF;
16091 --
16092
16093 --
16094 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16095 trace
16096 (p_msg => 'END of AcctLineType_54'
16097 ,p_level => C_LEVEL_PROCEDURE
16098 ,p_module => l_log_module);
16099 END IF;
16100 --
16101 EXCEPTION
16102 WHEN xla_exceptions_pkg.application_exception THEN
16103 RAISE;
16104 WHEN OTHERS THEN
16105 xla_exceptions_pkg.raise_message
16106 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_54');
16107 END AcctLineType_54;
16108 --
16109
16110 ---------------------------------------
16111 --
16112 -- PRIVATE FUNCTION
16113 -- AcctLineType_55
16114 --
16115 ---------------------------------------
16116 PROCEDURE AcctLineType_55 (
16117 p_application_id IN NUMBER
16118 ,p_event_id IN NUMBER
16119 ,p_calculate_acctd_flag IN VARCHAR2
16120 ,p_calculate_g_l_flag IN VARCHAR2
16124
16121 ,p_actual_flag IN OUT VARCHAR2
16122 ,p_balance_type_code OUT VARCHAR2
16123 ,p_gain_or_loss_ref OUT VARCHAR2
16125 --Transaction Distribution GL Account
16126 , p_source_21 IN NUMBER
16127 --Bill To Customer Account Identifier
16128 , p_source_32 IN NUMBER
16129 --Bill To Customer Site Use Identifier
16130 , p_source_33 IN NUMBER
16131 --SLA Party Type
16132 , p_source_34 IN VARCHAR2
16133 --Transaction Distribution Account Class
16134 , p_source_35 IN VARCHAR2
16135 --Transaction Distribution Identifier
16136 , p_source_36 IN NUMBER
16137 --Transaction Distribution Type
16138 , p_source_37 IN VARCHAR2
16139 --Transaction Distribution Entered Amount
16140 , p_source_38 IN NUMBER
16141 --Transaction Currency Code
16142 , p_source_39 IN VARCHAR2
16143 --Transaction Exchange Date
16144 , p_source_40 IN DATE
16145 --Transaction Exchange Rate
16146 , p_source_41 IN NUMBER
16147 --Transaction Exchange Rate Type
16148 , p_source_42 IN VARCHAR2
16149 --Transaction Accounting Amount
16150 , p_source_43 IN NUMBER
16151 --Transaction Tax Line Identifier
16152 , p_source_57 IN NUMBER
16153 )
16154 IS
16155
16156 l_component_type VARCHAR2(80);
16157 l_component_code VARCHAR2(30);
16158 l_component_type_code VARCHAR2(1);
16159 l_component_appl_id INTEGER;
16160 l_amb_context_code VARCHAR2(30);
16161 l_entity_code VARCHAR2(30);
16162 l_event_class_code VARCHAR2(30);
16163 l_ae_header_id NUMBER;
16164 l_event_type_code VARCHAR2(30);
16165 l_line_definition_code VARCHAR2(30);
16166 l_line_definition_owner_code VARCHAR2(1);
16167 --
16168 -- adr variables
16169 l_segment VARCHAR2(30);
16170 l_ccid NUMBER;
16171 l_adr_transaction_coa_id NUMBER;
16172 l_adr_accounting_coa_id NUMBER;
16173 l_adr_flexfield_segment_code VARCHAR2(30);
16174 l_adr_flex_value_set_id NUMBER;
16175 l_adr_value_type_code VARCHAR2(30);
16176 l_adr_value_combination_id NUMBER;
16177 l_adr_value_segment_code VARCHAR2(30);
16178
16179 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
16180 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
16181 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
16182 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
16183
16184 -- 4262811 Variables ------------------------------------------------------------------------------------------
16185 l_entered_amt_idx NUMBER;
16186 l_accted_amt_idx NUMBER;
16187 l_acc_rev_flag VARCHAR2(1);
16188 l_accrual_line_num NUMBER;
16189 l_tmp_amt NUMBER;
16190 l_acc_rev_natural_side_code VARCHAR2(1);
16191
16192 l_num_entries NUMBER;
16193 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
16194 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
16195 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
16196 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
16197 l_recog_line_1 NUMBER;
16198 l_recog_line_2 NUMBER;
16199
16200 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
16201 l_bflow_applied_to_amt NUMBER; -- 5132302
16202 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
16203
16204 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
16205
16206 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
16207 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
16208
16209 ---------------------------------------------------------------------------------------------------------------
16210
16211
16212 --
16213 -- bulk performance
16214 --
16215 l_balance_type_code VARCHAR2(1);
16216 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
16217 l_log_module VARCHAR2(240);
16218
16219 --
16220 -- Upgrade strategy
16221 --
16222 l_actual_upg_option VARCHAR2(1);
16223 l_enc_upg_option VARCHAR2(1);
16224
16225 --
16226 BEGIN
16227 --
16228 IF g_log_enabled THEN
16229 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_55';
16230 END IF;
16231 --
16232 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16233
16234 trace
16235 (p_msg => 'BEGIN of AcctLineType_55'
16236 ,p_level => C_LEVEL_PROCEDURE
16237 ,p_module => l_log_module);
16238
16239 END IF;
16240 --
16241 l_component_type := 'AMB_JLT';
16242 l_component_code := 'DM_REV';
16243 l_component_type_code := 'S';
16244 l_component_appl_id := 222;
16245 l_amb_context_code := 'DEFAULT';
16246 l_entity_code := 'TRANSACTIONS';
16247 l_event_class_code := 'DEBIT_MEMO';
16248 l_event_type_code := 'DEBIT_MEMO_ALL';
16249 l_line_definition_owner_code := 'S';
16250 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
16251 --
16252 l_balance_type_code := 'A';
16256 l_adr_accounting_coa_id := NULL;
16253 l_segment := NULL;
16254 l_ccid := NULL;
16255 l_adr_transaction_coa_id := NULL;
16257 l_adr_flexfield_segment_code := NULL;
16258 l_adr_flex_value_set_id := NULL;
16259 l_adr_value_type_code := NULL;
16260 l_adr_value_combination_id := NULL;
16261 l_adr_value_segment_code := NULL;
16262
16263 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
16264 l_bflow_class_code := ''; -- 4219869 Business Flow
16265 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
16266 l_budgetary_control_flag := 'N';
16267
16268 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16269 l_bflow_applied_to_amt := NULL; -- 5132302
16270 l_entered_amt_idx := NULL; -- 4262811
16271 l_accted_amt_idx := NULL; -- 4262811
16272 l_acc_rev_flag := NULL; -- 4262811
16273 l_accrual_line_num := NULL; -- 4262811
16274 l_tmp_amt := NULL; -- 4262811
16275 --
16276
16277 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
16278 l_balance_type_code <> 'B' THEN
16279 IF NVL(p_source_35,'
16280 ') = 'REV'
16281 THEN
16282
16283 --
16284 XLA_AE_LINES_PKG.SetNewLine;
16285
16286 p_balance_type_code := l_balance_type_code;
16287 -- set the flag so later we will know whether the gain loss line needs to be created
16288
16289 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
16290 p_actual_flag :='A';
16291 END IF;
16292
16293 --
16294 -- bulk performance
16295 --
16296 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
16297 p_header_num => 0); -- 4262811
16298 --
16299 -- set accounting line options
16300 --
16301 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
16302 p_natural_side_code => 'C'
16303 , p_gain_or_loss_flag => 'N'
16304 , p_gl_transfer_mode_code => 'S'
16305 , p_acct_entry_type_code => 'A'
16306 , p_switch_side_flag => 'Y'
16307 , p_merge_duplicate_code => 'A'
16308 );
16309 --
16310 l_acc_rev_natural_side_code := 'D'; -- 4262811
16311 --
16312 --
16313 -- set accounting line type info
16314 --
16315 xla_ae_lines_pkg.SetAcctLineType
16316 (p_component_type => l_component_type
16317 ,p_event_type_code => l_event_type_code
16318 ,p_line_definition_owner_code => l_line_definition_owner_code
16319 ,p_line_definition_code => l_line_definition_code
16320 ,p_accounting_line_code => l_component_code
16321 ,p_accounting_line_type_code => l_component_type_code
16322 ,p_accounting_line_appl_id => l_component_appl_id
16323 ,p_amb_context_code => l_amb_context_code
16324 ,p_entity_code => l_entity_code
16325 ,p_event_class_code => l_event_class_code);
16326 --
16327 -- set accounting class
16328 --
16329 xla_ae_lines_pkg.SetAcctClass(
16330 p_accounting_class_code => 'REVENUE'
16331 , p_ae_header_id => l_ae_header_id
16332 );
16333
16334 --
16335 -- set rounding class
16336 --
16337 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
16338 'RECEIVABLE';
16339
16340 --
16341 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
16342 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
16343 --
16344 -- bulk performance
16345 --
16346 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
16347
16348 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
16349 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
16350
16351 -- 4955764
16352 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16353 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
16354
16355 -- 4458381 Public Sector Enh
16356
16357 --
16358 -- set accounting attributes for the line type
16359 --
16360 l_entered_amt_idx := 3;
16361 l_accted_amt_idx := 8;
16362 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16363 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
16364 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
16365 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
16366 l_rec_acct_attrs.array_char_value(2) := p_source_37;
16367 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
16368 l_rec_acct_attrs.array_num_value(3) := p_source_38;
16369 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
16370 l_rec_acct_attrs.array_char_value(4) := p_source_39;
16371 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
16372 l_rec_acct_attrs.array_date_value(5) := p_source_40;
16373 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
16374 l_rec_acct_attrs.array_num_value(6) := p_source_41;
16378 l_rec_acct_attrs.array_num_value(8) := p_source_43;
16375 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
16376 l_rec_acct_attrs.array_char_value(7) := p_source_42;
16377 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
16379 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
16380 l_rec_acct_attrs.array_num_value(9) := p_source_32;
16381 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
16382 l_rec_acct_attrs.array_num_value(10) := p_source_33;
16383 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
16384 l_rec_acct_attrs.array_char_value(11) := p_source_34;
16385 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
16386 l_rec_acct_attrs.array_num_value(12) := p_source_57;
16387
16388 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
16389 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
16390
16391 ---------------------------------------------------------------------------------------------------------------
16392 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
16393 ---------------------------------------------------------------------------------------------------------------
16394 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
16395
16396 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16397 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16398
16399 IF xla_accounting_cache_pkg.GetValueChar
16400 (p_source_code => 'LEDGER_CATEGORY_CODE'
16401 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
16402 AND l_bflow_method_code = 'PRIOR_ENTRY'
16403 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
16404 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
16405 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
16406 )
16407 THEN
16408 xla_ae_lines_pkg.BflowUpgEntry
16409 (p_business_method_code => l_bflow_method_code
16410 ,p_business_class_code => l_bflow_class_code
16411 ,p_balance_type => l_balance_type_code);
16412 ELSE
16413 NULL;
16414 -- No business flow processing for business flow method of NONE.
16415 END IF;
16416
16417 --
16418 -- call analytical criteria
16419 --
16420
16421 --
16422 -- call description
16423 --
16424 -- No description or it is inherited.
16425 --
16426 -- call ADRs
16427 -- Bug 4922099
16428 --
16429 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
16430 (NVL(l_actual_upg_option, 'N') = 'O') OR
16431 (NVL(l_enc_upg_option, 'N') = 'O')
16432 )
16433 THEN
16434 NULL;
16435 --
16436 --
16437
16438 l_ccid := AcctDerRule_34(
16439 p_application_id => p_application_id
16440 , p_ae_header_id => l_ae_header_id
16441 , p_source_21 => p_source_21
16442 , x_transaction_coa_id => l_adr_transaction_coa_id
16443 , x_accounting_coa_id => l_adr_accounting_coa_id
16444 , x_value_type_code => l_adr_value_type_code
16445 , p_side => 'NA'
16446 );
16447
16448 xla_ae_lines_pkg.set_ccid(
16449 p_code_combination_id => l_ccid
16450 , p_value_type_code => l_adr_value_type_code
16451 , p_transaction_coa_id => l_adr_transaction_coa_id
16452 , p_accounting_coa_id => l_adr_accounting_coa_id
16453 , p_adr_code => 'TRX_DIST_CCID'
16454 , p_adr_type_code => 'S'
16455 , p_component_type => l_component_type
16456 , p_component_code => l_component_code
16457 , p_component_type_code => l_component_type_code
16458 , p_component_appl_id => l_component_appl_id
16459 , p_amb_context_code => l_amb_context_code
16460 , p_side => 'NA'
16461 );
16462
16463
16464 --
16465 --
16466 END IF;
16467 --
16468 -- Bug 4922099
16469 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
16470 (NVL(l_enc_upg_option, 'N') = 'O')
16471 ) AND
16472 (l_bflow_method_code = 'PRIOR_ENTRY')
16473 )
16474 THEN
16475 IF
16476 --
16477 1 = 2
16478 --
16479 THEN
16480 xla_accounting_err_pkg.build_message
16481 (p_appli_s_name => 'XLA'
16482 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16483 ,p_token_1 => 'LINE_NUMBER'
16484 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
16485 ,p_token_2 => 'LINE_TYPE_NAME'
16486 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
16487 l_component_type
16488 ,l_component_code
16492 ,l_entity_code
16489 ,l_component_type_code
16490 ,l_component_appl_id
16491 ,l_amb_context_code
16493 ,l_event_class_code
16494 )
16495 ,p_token_3 => 'OWNER'
16496 ,p_value_3 => xla_lookups_pkg.get_meaning(
16497 p_lookup_type => 'XLA_OWNER_TYPE'
16498 ,p_lookup_code => l_component_type_code
16499 )
16500 ,p_token_4 => 'PRODUCT_NAME'
16501 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
16502 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
16503 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
16504 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
16505 ,p_ae_header_id => NULL
16506 );
16507
16508 IF (C_LEVEL_ERROR>= g_log_level) THEN
16509 trace
16510 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16511 ,p_level => C_LEVEL_ERROR
16512 ,p_module => l_log_module);
16513 END IF;
16514 END IF;
16515 END IF;
16516 --
16517 --
16518 ------------------------------------------------------------------------------------------------
16519 -- 4219869 Business Flow
16520 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
16521 -- Prior Entry. Currently, the following code is always generated.
16522 ------------------------------------------------------------------------------------------------
16523 XLA_AE_LINES_PKG.ValidateCurrentLine;
16524
16525 ------------------------------------------------------------------------------------
16526 -- 4219869 Business Flow
16527 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
16528 ------------------------------------------------------------------------------------
16529 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
16530
16531 ----------------------------------------------------------------------------------
16532 -- 4219869 Business Flow
16533 -- Update journal entry status -- Need to generate this within IF <condition>
16534 ----------------------------------------------------------------------------------
16535 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
16536 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
16537 ,p_balance_type_code => l_balance_type_code
16538 );
16539
16540 -------------------------------------------------------------------------------------------
16541 -- 4262811 - Generate the Accrual Reversal lines
16542 -------------------------------------------------------------------------------------------
16543 BEGIN
16544 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
16545 (g_array_event(p_event_id).array_value_num('header_index'));
16546 IF l_acc_rev_flag IS NULL THEN
16547 l_acc_rev_flag := 'N';
16548 END IF;
16549 EXCEPTION
16550 WHEN OTHERS THEN
16551 l_acc_rev_flag := 'N';
16552 END;
16553 --
16554 IF (l_acc_rev_flag = 'Y') THEN
16555
16556 -- 4645092 ------------------------------------------------------------------------------
16557 -- To allow MPA report to determine if it should generate report process
16558 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
16559 ------------------------------------------------------------------------------------------
16560
16561 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
16562 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
16563 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
16564 -- call ADRs
16565 -- Bug 4922099
16566 --
16567 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
16568 (NVL(l_actual_upg_option, 'N') = 'O') OR
16569 (NVL(l_enc_upg_option, 'N') = 'O')
16570 )
16571 THEN
16572 NULL;
16573 --
16574 --
16575
16576 l_ccid := AcctDerRule_34(
16577 p_application_id => p_application_id
16578 , p_ae_header_id => l_ae_header_id
16579 , p_source_21 => p_source_21
16580 , x_transaction_coa_id => l_adr_transaction_coa_id
16581 , x_accounting_coa_id => l_adr_accounting_coa_id
16582 , x_value_type_code => l_adr_value_type_code
16583 , p_side => 'NA'
16584 );
16585
16586 xla_ae_lines_pkg.set_ccid(
16590 , p_accounting_coa_id => l_adr_accounting_coa_id
16587 p_code_combination_id => l_ccid
16588 , p_value_type_code => l_adr_value_type_code
16589 , p_transaction_coa_id => l_adr_transaction_coa_id
16591 , p_adr_code => 'TRX_DIST_CCID'
16592 , p_adr_type_code => 'S'
16593 , p_component_type => l_component_type
16594 , p_component_code => l_component_code
16595 , p_component_type_code => l_component_type_code
16596 , p_component_appl_id => l_component_appl_id
16597 , p_amb_context_code => l_amb_context_code
16598 , p_side => 'NA'
16599 );
16600
16601
16602 --
16603 --
16604 END IF;
16605
16606 --
16607 -- Update the line information that should be overwritten
16608 --
16609 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
16610 p_header_num => 1);
16611 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
16612
16613 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
16614
16615 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
16616 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
16617 END IF;
16618
16619 --
16620 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
16621 --
16622 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
16623 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
16624 ELSE
16625 ---------------------------------------------------------------------------------------------------
16626 -- 4262811a Switch Sign
16627 ---------------------------------------------------------------------------------------------------
16628 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
16629 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
16630 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16631 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
16632 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16633 -- 5132302
16634 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
16635 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16636
16637 END IF;
16638
16639 -- 4955764
16640 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16641 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
16642
16643
16644 XLA_AE_LINES_PKG.ValidateCurrentLine;
16645 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
16646
16647 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
16648 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
16649 ,p_balance_type_code => l_balance_type_code);
16650
16651 END IF;
16652
16653 -----------------------------------------------------------------------------------------
16654 -- 4262811 Multiperiod Accounting
16655 -----------------------------------------------------------------------------------------
16656 -- No MPA option is assigned.
16657
16658
16659 END IF;
16660 END IF;
16661 --
16662
16663 --
16664 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16665 trace
16666 (p_msg => 'END of AcctLineType_55'
16667 ,p_level => C_LEVEL_PROCEDURE
16668 ,p_module => l_log_module);
16669 END IF;
16670 --
16671 EXCEPTION
16672 WHEN xla_exceptions_pkg.application_exception THEN
16673 RAISE;
16674 WHEN OTHERS THEN
16675 xla_exceptions_pkg.raise_message
16676 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_55');
16677 END AcctLineType_55;
16678 --
16679
16680 ---------------------------------------
16681 --
16682 -- PRIVATE FUNCTION
16683 -- AcctLineType_56
16684 --
16685 ---------------------------------------
16686 PROCEDURE AcctLineType_56 (
16687 p_application_id IN NUMBER
16688 ,p_event_id IN NUMBER
16689 ,p_calculate_acctd_flag IN VARCHAR2
16690 ,p_calculate_g_l_flag IN VARCHAR2
16691 ,p_actual_flag IN OUT VARCHAR2
16692 ,p_balance_type_code OUT VARCHAR2
16693 ,p_gain_or_loss_ref OUT VARCHAR2
16694
16695 --Transaction Distribution GL Account
16696 , p_source_21 IN NUMBER
16697 --Bill To Customer Account Identifier
16698 , p_source_32 IN NUMBER
16699 --Bill To Customer Site Use Identifier
16700 , p_source_33 IN NUMBER
16701 --SLA Party Type
16702 , p_source_34 IN VARCHAR2
16703 --Transaction Distribution Account Class
16704 , p_source_35 IN VARCHAR2
16705 --Transaction Distribution Identifier
16706 , p_source_36 IN NUMBER
16707 --Transaction Distribution Type
16708 , p_source_37 IN VARCHAR2
16709 --Transaction Distribution Entered Amount
16713 --Transaction Exchange Date
16710 , p_source_38 IN NUMBER
16711 --Transaction Currency Code
16712 , p_source_39 IN VARCHAR2
16714 , p_source_40 IN DATE
16715 --Transaction Exchange Rate
16716 , p_source_41 IN NUMBER
16717 --Transaction Exchange Rate Type
16718 , p_source_42 IN VARCHAR2
16719 --Transaction Accounting Amount
16720 , p_source_43 IN NUMBER
16721 --Transaction Tax Line Identifier
16722 , p_source_57 IN NUMBER
16723 )
16724 IS
16725
16726 l_component_type VARCHAR2(80);
16727 l_component_code VARCHAR2(30);
16728 l_component_type_code VARCHAR2(1);
16729 l_component_appl_id INTEGER;
16730 l_amb_context_code VARCHAR2(30);
16731 l_entity_code VARCHAR2(30);
16732 l_event_class_code VARCHAR2(30);
16733 l_ae_header_id NUMBER;
16734 l_event_type_code VARCHAR2(30);
16735 l_line_definition_code VARCHAR2(30);
16736 l_line_definition_owner_code VARCHAR2(1);
16737 --
16738 -- adr variables
16739 l_segment VARCHAR2(30);
16740 l_ccid NUMBER;
16741 l_adr_transaction_coa_id NUMBER;
16742 l_adr_accounting_coa_id NUMBER;
16743 l_adr_flexfield_segment_code VARCHAR2(30);
16744 l_adr_flex_value_set_id NUMBER;
16745 l_adr_value_type_code VARCHAR2(30);
16746 l_adr_value_combination_id NUMBER;
16747 l_adr_value_segment_code VARCHAR2(30);
16748
16749 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
16750 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
16751 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
16752 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
16753
16754 -- 4262811 Variables ------------------------------------------------------------------------------------------
16755 l_entered_amt_idx NUMBER;
16756 l_accted_amt_idx NUMBER;
16757 l_acc_rev_flag VARCHAR2(1);
16758 l_accrual_line_num NUMBER;
16759 l_tmp_amt NUMBER;
16760 l_acc_rev_natural_side_code VARCHAR2(1);
16761
16762 l_num_entries NUMBER;
16763 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
16764 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
16765 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
16766 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
16767 l_recog_line_1 NUMBER;
16768 l_recog_line_2 NUMBER;
16769
16770 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
16771 l_bflow_applied_to_amt NUMBER; -- 5132302
16772 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
16773
16774 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
16775
16776 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
16777 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
16778
16779 ---------------------------------------------------------------------------------------------------------------
16780
16781
16782 --
16783 -- bulk performance
16784 --
16785 l_balance_type_code VARCHAR2(1);
16786 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
16787 l_log_module VARCHAR2(240);
16788
16789 --
16790 -- Upgrade strategy
16791 --
16792 l_actual_upg_option VARCHAR2(1);
16793 l_enc_upg_option VARCHAR2(1);
16794
16795 --
16796 BEGIN
16797 --
16798 IF g_log_enabled THEN
16799 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_56';
16800 END IF;
16801 --
16802 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16803
16804 trace
16805 (p_msg => 'BEGIN of AcctLineType_56'
16806 ,p_level => C_LEVEL_PROCEDURE
16807 ,p_module => l_log_module);
16808
16809 END IF;
16810 --
16811 l_component_type := 'AMB_JLT';
16812 l_component_code := 'DM_ROUND';
16813 l_component_type_code := 'S';
16814 l_component_appl_id := 222;
16815 l_amb_context_code := 'DEFAULT';
16816 l_entity_code := 'TRANSACTIONS';
16817 l_event_class_code := 'DEBIT_MEMO';
16818 l_event_type_code := 'DEBIT_MEMO_ALL';
16819 l_line_definition_owner_code := 'S';
16820 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
16821 --
16822 l_balance_type_code := 'A';
16823 l_segment := NULL;
16824 l_ccid := NULL;
16825 l_adr_transaction_coa_id := NULL;
16826 l_adr_accounting_coa_id := NULL;
16827 l_adr_flexfield_segment_code := NULL;
16828 l_adr_flex_value_set_id := NULL;
16829 l_adr_value_type_code := NULL;
16830 l_adr_value_combination_id := NULL;
16831 l_adr_value_segment_code := NULL;
16832
16833 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
16834 l_bflow_class_code := ''; -- 4219869 Business Flow
16835 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
16836 l_budgetary_control_flag := 'N';
16837
16838 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16839 l_bflow_applied_to_amt := NULL; -- 5132302
16843 l_accrual_line_num := NULL; -- 4262811
16840 l_entered_amt_idx := NULL; -- 4262811
16841 l_accted_amt_idx := NULL; -- 4262811
16842 l_acc_rev_flag := NULL; -- 4262811
16844 l_tmp_amt := NULL; -- 4262811
16845 --
16846
16847 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
16848 l_balance_type_code <> 'B' THEN
16849 IF NVL(p_source_35,'
16850 ') = 'ROUND'
16851 THEN
16852
16853 --
16854 XLA_AE_LINES_PKG.SetNewLine;
16855
16856 p_balance_type_code := l_balance_type_code;
16857 -- set the flag so later we will know whether the gain loss line needs to be created
16858
16859 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
16860 p_actual_flag :='A';
16861 END IF;
16862
16863 --
16864 -- bulk performance
16865 --
16866 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
16867 p_header_num => 0); -- 4262811
16868 --
16869 -- set accounting line options
16870 --
16871 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
16872 p_natural_side_code => 'C'
16873 , p_gain_or_loss_flag => 'N'
16874 , p_gl_transfer_mode_code => 'S'
16875 , p_acct_entry_type_code => 'A'
16876 , p_switch_side_flag => 'Y'
16877 , p_merge_duplicate_code => 'A'
16878 );
16879 --
16880 l_acc_rev_natural_side_code := 'D'; -- 4262811
16881 --
16882 --
16883 -- set accounting line type info
16884 --
16885 xla_ae_lines_pkg.SetAcctLineType
16886 (p_component_type => l_component_type
16887 ,p_event_type_code => l_event_type_code
16888 ,p_line_definition_owner_code => l_line_definition_owner_code
16889 ,p_line_definition_code => l_line_definition_code
16890 ,p_accounting_line_code => l_component_code
16891 ,p_accounting_line_type_code => l_component_type_code
16892 ,p_accounting_line_appl_id => l_component_appl_id
16893 ,p_amb_context_code => l_amb_context_code
16894 ,p_entity_code => l_entity_code
16895 ,p_event_class_code => l_event_class_code);
16896 --
16897 -- set accounting class
16898 --
16899 xla_ae_lines_pkg.SetAcctClass(
16900 p_accounting_class_code => 'ROUNDING'
16901 , p_ae_header_id => l_ae_header_id
16902 );
16903
16904 --
16905 -- set rounding class
16906 --
16907 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
16908 'RECEIVABLE';
16909
16910 --
16911 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
16912 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
16913 --
16914 -- bulk performance
16915 --
16916 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
16917
16918 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
16919 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
16920
16921 -- 4955764
16922 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16923 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
16924
16925 -- 4458381 Public Sector Enh
16926
16927 --
16928 -- set accounting attributes for the line type
16929 --
16930 l_entered_amt_idx := 3;
16931 l_accted_amt_idx := 8;
16932 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16933 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
16934 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
16935 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
16936 l_rec_acct_attrs.array_char_value(2) := p_source_37;
16937 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
16938 l_rec_acct_attrs.array_num_value(3) := p_source_38;
16939 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
16940 l_rec_acct_attrs.array_char_value(4) := p_source_39;
16941 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
16942 l_rec_acct_attrs.array_date_value(5) := p_source_40;
16943 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
16944 l_rec_acct_attrs.array_num_value(6) := p_source_41;
16945 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
16946 l_rec_acct_attrs.array_char_value(7) := p_source_42;
16947 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
16948 l_rec_acct_attrs.array_num_value(8) := p_source_43;
16949 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
16950 l_rec_acct_attrs.array_num_value(9) := p_source_32;
16951 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
16952 l_rec_acct_attrs.array_num_value(10) := p_source_33;
16953 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
16954 l_rec_acct_attrs.array_char_value(11) := p_source_34;
16955 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
16956 l_rec_acct_attrs.array_num_value(12) := p_source_57;
16957
16961 ---------------------------------------------------------------------------------------------------------------
16958 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
16959 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
16960
16962 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
16963 ---------------------------------------------------------------------------------------------------------------
16964 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
16965
16966 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16967 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16968
16969 IF xla_accounting_cache_pkg.GetValueChar
16970 (p_source_code => 'LEDGER_CATEGORY_CODE'
16971 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
16972 AND l_bflow_method_code = 'PRIOR_ENTRY'
16973 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
16974 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
16975 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
16976 )
16977 THEN
16978 xla_ae_lines_pkg.BflowUpgEntry
16979 (p_business_method_code => l_bflow_method_code
16980 ,p_business_class_code => l_bflow_class_code
16981 ,p_balance_type => l_balance_type_code);
16982 ELSE
16983 NULL;
16984 -- No business flow processing for business flow method of NONE.
16985 END IF;
16986
16987 --
16988 -- call analytical criteria
16989 --
16990
16991 --
16992 -- call description
16993 --
16994 -- No description or it is inherited.
16995 --
16996 -- call ADRs
16997 -- Bug 4922099
16998 --
16999 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17000 (NVL(l_actual_upg_option, 'N') = 'O') OR
17001 (NVL(l_enc_upg_option, 'N') = 'O')
17002 )
17003 THEN
17004 NULL;
17005 --
17006 --
17007
17008 l_ccid := AcctDerRule_34(
17009 p_application_id => p_application_id
17010 , p_ae_header_id => l_ae_header_id
17011 , p_source_21 => p_source_21
17012 , x_transaction_coa_id => l_adr_transaction_coa_id
17013 , x_accounting_coa_id => l_adr_accounting_coa_id
17014 , x_value_type_code => l_adr_value_type_code
17015 , p_side => 'NA'
17016 );
17017
17018 xla_ae_lines_pkg.set_ccid(
17019 p_code_combination_id => l_ccid
17020 , p_value_type_code => l_adr_value_type_code
17021 , p_transaction_coa_id => l_adr_transaction_coa_id
17022 , p_accounting_coa_id => l_adr_accounting_coa_id
17023 , p_adr_code => 'TRX_DIST_CCID'
17024 , p_adr_type_code => 'S'
17025 , p_component_type => l_component_type
17026 , p_component_code => l_component_code
17027 , p_component_type_code => l_component_type_code
17028 , p_component_appl_id => l_component_appl_id
17029 , p_amb_context_code => l_amb_context_code
17030 , p_side => 'NA'
17031 );
17032
17033
17034 --
17035 --
17036 END IF;
17037 --
17038 -- Bug 4922099
17039 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
17040 (NVL(l_enc_upg_option, 'N') = 'O')
17041 ) AND
17042 (l_bflow_method_code = 'PRIOR_ENTRY')
17043 )
17044 THEN
17045 IF
17046 --
17047 1 = 2
17048 --
17049 THEN
17050 xla_accounting_err_pkg.build_message
17051 (p_appli_s_name => 'XLA'
17052 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
17053 ,p_token_1 => 'LINE_NUMBER'
17054 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
17055 ,p_token_2 => 'LINE_TYPE_NAME'
17056 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
17057 l_component_type
17058 ,l_component_code
17059 ,l_component_type_code
17060 ,l_component_appl_id
17061 ,l_amb_context_code
17062 ,l_entity_code
17063 ,l_event_class_code
17064 )
17065 ,p_token_3 => 'OWNER'
17066 ,p_value_3 => xla_lookups_pkg.get_meaning(
17070 ,p_token_4 => 'PRODUCT_NAME'
17067 p_lookup_type => 'XLA_OWNER_TYPE'
17068 ,p_lookup_code => l_component_type_code
17069 )
17071 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
17072 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
17073 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
17074 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
17075 ,p_ae_header_id => NULL
17076 );
17077
17078 IF (C_LEVEL_ERROR>= g_log_level) THEN
17079 trace
17080 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
17081 ,p_level => C_LEVEL_ERROR
17082 ,p_module => l_log_module);
17083 END IF;
17084 END IF;
17085 END IF;
17086 --
17087 --
17088 ------------------------------------------------------------------------------------------------
17089 -- 4219869 Business Flow
17090 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
17091 -- Prior Entry. Currently, the following code is always generated.
17092 ------------------------------------------------------------------------------------------------
17093 XLA_AE_LINES_PKG.ValidateCurrentLine;
17094
17095 ------------------------------------------------------------------------------------
17096 -- 4219869 Business Flow
17097 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
17098 ------------------------------------------------------------------------------------
17099 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17100
17101 ----------------------------------------------------------------------------------
17102 -- 4219869 Business Flow
17103 -- Update journal entry status -- Need to generate this within IF <condition>
17104 ----------------------------------------------------------------------------------
17105 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17106 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
17107 ,p_balance_type_code => l_balance_type_code
17108 );
17109
17110 -------------------------------------------------------------------------------------------
17111 -- 4262811 - Generate the Accrual Reversal lines
17112 -------------------------------------------------------------------------------------------
17113 BEGIN
17114 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
17115 (g_array_event(p_event_id).array_value_num('header_index'));
17116 IF l_acc_rev_flag IS NULL THEN
17117 l_acc_rev_flag := 'N';
17118 END IF;
17119 EXCEPTION
17120 WHEN OTHERS THEN
17121 l_acc_rev_flag := 'N';
17122 END;
17123 --
17124 IF (l_acc_rev_flag = 'Y') THEN
17125
17126 -- 4645092 ------------------------------------------------------------------------------
17127 -- To allow MPA report to determine if it should generate report process
17128 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
17129 ------------------------------------------------------------------------------------------
17130
17131 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
17132 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
17133 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
17134 -- call ADRs
17135 -- Bug 4922099
17136 --
17137 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17138 (NVL(l_actual_upg_option, 'N') = 'O') OR
17139 (NVL(l_enc_upg_option, 'N') = 'O')
17140 )
17141 THEN
17142 NULL;
17143 --
17144 --
17145
17146 l_ccid := AcctDerRule_34(
17147 p_application_id => p_application_id
17148 , p_ae_header_id => l_ae_header_id
17149 , p_source_21 => p_source_21
17150 , x_transaction_coa_id => l_adr_transaction_coa_id
17151 , x_accounting_coa_id => l_adr_accounting_coa_id
17152 , x_value_type_code => l_adr_value_type_code
17153 , p_side => 'NA'
17154 );
17155
17156 xla_ae_lines_pkg.set_ccid(
17157 p_code_combination_id => l_ccid
17158 , p_value_type_code => l_adr_value_type_code
17159 , p_transaction_coa_id => l_adr_transaction_coa_id
17160 , p_accounting_coa_id => l_adr_accounting_coa_id
17161 , p_adr_code => 'TRX_DIST_CCID'
17162 , p_adr_type_code => 'S'
17163 , p_component_type => l_component_type
17164 , p_component_code => l_component_code
17165 , p_component_type_code => l_component_type_code
17166 , p_component_appl_id => l_component_appl_id
17167 , p_amb_context_code => l_amb_context_code
17168 , p_side => 'NA'
17172 --
17169 );
17170
17171
17173 --
17174 END IF;
17175
17176 --
17177 -- Update the line information that should be overwritten
17178 --
17179 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
17180 p_header_num => 1);
17181 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
17182
17183 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
17184
17185 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
17186 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
17187 END IF;
17188
17189 --
17190 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
17191 --
17192 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
17193 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
17194 ELSE
17195 ---------------------------------------------------------------------------------------------------
17196 -- 4262811a Switch Sign
17197 ---------------------------------------------------------------------------------------------------
17198 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
17199 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17200 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17201 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17202 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17203 -- 5132302
17204 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
17205 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17206
17207 END IF;
17208
17209 -- 4955764
17210 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17211 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
17212
17213
17214 XLA_AE_LINES_PKG.ValidateCurrentLine;
17215 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17216
17217 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17218 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
17219 ,p_balance_type_code => l_balance_type_code);
17220
17221 END IF;
17222
17223 -----------------------------------------------------------------------------------------
17224 -- 4262811 Multiperiod Accounting
17225 -----------------------------------------------------------------------------------------
17226 -- No MPA option is assigned.
17227
17228
17229 END IF;
17230 END IF;
17231 --
17232
17233 --
17234 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17235 trace
17236 (p_msg => 'END of AcctLineType_56'
17237 ,p_level => C_LEVEL_PROCEDURE
17238 ,p_module => l_log_module);
17239 END IF;
17240 --
17241 EXCEPTION
17242 WHEN xla_exceptions_pkg.application_exception THEN
17243 RAISE;
17244 WHEN OTHERS THEN
17245 xla_exceptions_pkg.raise_message
17246 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_56');
17247 END AcctLineType_56;
17248 --
17249
17250 ---------------------------------------
17251 --
17252 -- PRIVATE FUNCTION
17253 -- AcctLineType_57
17254 --
17255 ---------------------------------------
17256 PROCEDURE AcctLineType_57 (
17257 p_application_id IN NUMBER
17258 ,p_event_id IN NUMBER
17259 ,p_calculate_acctd_flag IN VARCHAR2
17260 ,p_calculate_g_l_flag IN VARCHAR2
17261 ,p_actual_flag IN OUT VARCHAR2
17262 ,p_balance_type_code OUT VARCHAR2
17263 ,p_gain_or_loss_ref OUT VARCHAR2
17264
17265 --Transaction Distribution GL Account
17266 , p_source_21 IN NUMBER
17267 --Bill To Customer Account Identifier
17268 , p_source_32 IN NUMBER
17269 --Bill To Customer Site Use Identifier
17270 , p_source_33 IN NUMBER
17271 --SLA Party Type
17272 , p_source_34 IN VARCHAR2
17273 --Transaction Distribution Account Class
17274 , p_source_35 IN VARCHAR2
17275 --Transaction Distribution Identifier
17276 , p_source_36 IN NUMBER
17277 --Transaction Distribution Type
17278 , p_source_37 IN VARCHAR2
17279 --Transaction Distribution Entered Amount
17280 , p_source_38 IN NUMBER
17281 --Transaction Currency Code
17282 , p_source_39 IN VARCHAR2
17283 --Transaction Exchange Date
17284 , p_source_40 IN DATE
17285 --Transaction Exchange Rate
17286 , p_source_41 IN NUMBER
17287 --Transaction Exchange Rate Type
17288 , p_source_42 IN VARCHAR2
17289 --Transaction Accounting Amount
17290 , p_source_43 IN NUMBER
17291 --Transaction Tax Line Identifier
17292 , p_source_57 IN NUMBER
17293 )
17294 IS
17295
17296 l_component_type VARCHAR2(80);
17297 l_component_code VARCHAR2(30);
17298 l_component_type_code VARCHAR2(1);
17302 l_event_class_code VARCHAR2(30);
17299 l_component_appl_id INTEGER;
17300 l_amb_context_code VARCHAR2(30);
17301 l_entity_code VARCHAR2(30);
17303 l_ae_header_id NUMBER;
17304 l_event_type_code VARCHAR2(30);
17305 l_line_definition_code VARCHAR2(30);
17306 l_line_definition_owner_code VARCHAR2(1);
17307 --
17308 -- adr variables
17309 l_segment VARCHAR2(30);
17310 l_ccid NUMBER;
17311 l_adr_transaction_coa_id NUMBER;
17312 l_adr_accounting_coa_id NUMBER;
17313 l_adr_flexfield_segment_code VARCHAR2(30);
17314 l_adr_flex_value_set_id NUMBER;
17315 l_adr_value_type_code VARCHAR2(30);
17316 l_adr_value_combination_id NUMBER;
17317 l_adr_value_segment_code VARCHAR2(30);
17318
17319 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
17320 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
17321 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
17322 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
17323
17324 -- 4262811 Variables ------------------------------------------------------------------------------------------
17325 l_entered_amt_idx NUMBER;
17326 l_accted_amt_idx NUMBER;
17327 l_acc_rev_flag VARCHAR2(1);
17328 l_accrual_line_num NUMBER;
17329 l_tmp_amt NUMBER;
17330 l_acc_rev_natural_side_code VARCHAR2(1);
17331
17332 l_num_entries NUMBER;
17333 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
17334 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
17335 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
17336 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
17337 l_recog_line_1 NUMBER;
17338 l_recog_line_2 NUMBER;
17339
17340 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
17341 l_bflow_applied_to_amt NUMBER; -- 5132302
17342 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
17343
17344 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
17345
17346 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
17347 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
17348
17349 ---------------------------------------------------------------------------------------------------------------
17350
17351
17352 --
17353 -- bulk performance
17354 --
17355 l_balance_type_code VARCHAR2(1);
17356 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
17357 l_log_module VARCHAR2(240);
17358
17359 --
17360 -- Upgrade strategy
17361 --
17362 l_actual_upg_option VARCHAR2(1);
17363 l_enc_upg_option VARCHAR2(1);
17364
17365 --
17366 BEGIN
17367 --
17368 IF g_log_enabled THEN
17369 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_57';
17370 END IF;
17371 --
17372 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17373
17374 trace
17375 (p_msg => 'BEGIN of AcctLineType_57'
17376 ,p_level => C_LEVEL_PROCEDURE
17377 ,p_module => l_log_module);
17378
17379 END IF;
17380 --
17381 l_component_type := 'AMB_JLT';
17382 l_component_code := 'DM_TAX';
17383 l_component_type_code := 'S';
17384 l_component_appl_id := 222;
17385 l_amb_context_code := 'DEFAULT';
17386 l_entity_code := 'TRANSACTIONS';
17387 l_event_class_code := 'DEBIT_MEMO';
17388 l_event_type_code := 'DEBIT_MEMO_ALL';
17389 l_line_definition_owner_code := 'S';
17390 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
17391 --
17392 l_balance_type_code := 'A';
17393 l_segment := NULL;
17394 l_ccid := NULL;
17395 l_adr_transaction_coa_id := NULL;
17396 l_adr_accounting_coa_id := NULL;
17397 l_adr_flexfield_segment_code := NULL;
17398 l_adr_flex_value_set_id := NULL;
17399 l_adr_value_type_code := NULL;
17400 l_adr_value_combination_id := NULL;
17401 l_adr_value_segment_code := NULL;
17402
17403 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
17404 l_bflow_class_code := ''; -- 4219869 Business Flow
17405 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
17406 l_budgetary_control_flag := 'N';
17407
17408 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17409 l_bflow_applied_to_amt := NULL; -- 5132302
17410 l_entered_amt_idx := NULL; -- 4262811
17411 l_accted_amt_idx := NULL; -- 4262811
17412 l_acc_rev_flag := NULL; -- 4262811
17413 l_accrual_line_num := NULL; -- 4262811
17414 l_tmp_amt := NULL; -- 4262811
17415 --
17416
17417 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
17418 l_balance_type_code <> 'B' THEN
17419 IF NVL(p_source_35,'
17420 ') = 'TAX'
17421 THEN
17422
17423 --
17424 XLA_AE_LINES_PKG.SetNewLine;
17425
17426 p_balance_type_code := l_balance_type_code;
17430 p_actual_flag :='A';
17427 -- set the flag so later we will know whether the gain loss line needs to be created
17428
17429 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
17431 END IF;
17432
17433 --
17434 -- bulk performance
17435 --
17436 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
17437 p_header_num => 0); -- 4262811
17438 --
17439 -- set accounting line options
17440 --
17441 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
17442 p_natural_side_code => 'C'
17443 , p_gain_or_loss_flag => 'N'
17444 , p_gl_transfer_mode_code => 'S'
17445 , p_acct_entry_type_code => 'A'
17446 , p_switch_side_flag => 'Y'
17447 , p_merge_duplicate_code => 'A'
17448 );
17449 --
17450 l_acc_rev_natural_side_code := 'D'; -- 4262811
17451 --
17452 --
17453 -- set accounting line type info
17454 --
17455 xla_ae_lines_pkg.SetAcctLineType
17456 (p_component_type => l_component_type
17457 ,p_event_type_code => l_event_type_code
17458 ,p_line_definition_owner_code => l_line_definition_owner_code
17459 ,p_line_definition_code => l_line_definition_code
17460 ,p_accounting_line_code => l_component_code
17461 ,p_accounting_line_type_code => l_component_type_code
17462 ,p_accounting_line_appl_id => l_component_appl_id
17463 ,p_amb_context_code => l_amb_context_code
17464 ,p_entity_code => l_entity_code
17465 ,p_event_class_code => l_event_class_code);
17466 --
17467 -- set accounting class
17468 --
17469 xla_ae_lines_pkg.SetAcctClass(
17470 p_accounting_class_code => 'TAX'
17471 , p_ae_header_id => l_ae_header_id
17472 );
17473
17474 --
17475 -- set rounding class
17476 --
17477 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
17478 'RECEIVABLE';
17479
17480 --
17481 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
17482 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
17483 --
17484 -- bulk performance
17485 --
17486 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
17487
17488 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
17489 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
17490
17491 -- 4955764
17492 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17493 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
17494
17495 -- 4458381 Public Sector Enh
17496
17497 --
17498 -- set accounting attributes for the line type
17499 --
17500 l_entered_amt_idx := 3;
17501 l_accted_amt_idx := 8;
17502 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17503 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
17504 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
17505 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
17506 l_rec_acct_attrs.array_char_value(2) := p_source_37;
17507 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
17508 l_rec_acct_attrs.array_num_value(3) := p_source_38;
17509 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
17510 l_rec_acct_attrs.array_char_value(4) := p_source_39;
17511 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
17512 l_rec_acct_attrs.array_date_value(5) := p_source_40;
17513 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
17514 l_rec_acct_attrs.array_num_value(6) := p_source_41;
17515 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
17516 l_rec_acct_attrs.array_char_value(7) := p_source_42;
17517 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
17518 l_rec_acct_attrs.array_num_value(8) := p_source_43;
17519 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
17520 l_rec_acct_attrs.array_num_value(9) := p_source_32;
17521 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
17522 l_rec_acct_attrs.array_num_value(10) := p_source_33;
17523 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
17524 l_rec_acct_attrs.array_char_value(11) := p_source_34;
17525 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
17526 l_rec_acct_attrs.array_num_value(12) := p_source_57;
17527
17528 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
17529 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
17530
17531 ---------------------------------------------------------------------------------------------------------------
17532 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
17533 ---------------------------------------------------------------------------------------------------------------
17534 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
17535
17536 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17540 (p_source_code => 'LEDGER_CATEGORY_CODE'
17537 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17538
17539 IF xla_accounting_cache_pkg.GetValueChar
17541 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
17542 AND l_bflow_method_code = 'PRIOR_ENTRY'
17543 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
17544 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
17545 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
17546 )
17547 THEN
17548 xla_ae_lines_pkg.BflowUpgEntry
17549 (p_business_method_code => l_bflow_method_code
17550 ,p_business_class_code => l_bflow_class_code
17551 ,p_balance_type => l_balance_type_code);
17552 ELSE
17553 NULL;
17554 -- No business flow processing for business flow method of NONE.
17555 END IF;
17556
17557 --
17558 -- call analytical criteria
17559 --
17560
17561 --
17562 -- call description
17563 --
17564 -- No description or it is inherited.
17565 --
17566 -- call ADRs
17567 -- Bug 4922099
17568 --
17569 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17570 (NVL(l_actual_upg_option, 'N') = 'O') OR
17571 (NVL(l_enc_upg_option, 'N') = 'O')
17572 )
17573 THEN
17574 NULL;
17575 --
17576 --
17577
17578 l_ccid := AcctDerRule_34(
17579 p_application_id => p_application_id
17580 , p_ae_header_id => l_ae_header_id
17581 , p_source_21 => p_source_21
17582 , x_transaction_coa_id => l_adr_transaction_coa_id
17583 , x_accounting_coa_id => l_adr_accounting_coa_id
17584 , x_value_type_code => l_adr_value_type_code
17585 , p_side => 'NA'
17586 );
17587
17588 xla_ae_lines_pkg.set_ccid(
17589 p_code_combination_id => l_ccid
17590 , p_value_type_code => l_adr_value_type_code
17591 , p_transaction_coa_id => l_adr_transaction_coa_id
17592 , p_accounting_coa_id => l_adr_accounting_coa_id
17593 , p_adr_code => 'TRX_DIST_CCID'
17594 , p_adr_type_code => 'S'
17595 , p_component_type => l_component_type
17596 , p_component_code => l_component_code
17597 , p_component_type_code => l_component_type_code
17598 , p_component_appl_id => l_component_appl_id
17599 , p_amb_context_code => l_amb_context_code
17600 , p_side => 'NA'
17601 );
17602
17603
17604 --
17605 --
17606 END IF;
17607 --
17608 -- Bug 4922099
17609 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
17610 (NVL(l_enc_upg_option, 'N') = 'O')
17611 ) AND
17612 (l_bflow_method_code = 'PRIOR_ENTRY')
17613 )
17614 THEN
17615 IF
17616 --
17617 1 = 2
17618 --
17619 THEN
17620 xla_accounting_err_pkg.build_message
17621 (p_appli_s_name => 'XLA'
17622 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
17623 ,p_token_1 => 'LINE_NUMBER'
17624 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
17625 ,p_token_2 => 'LINE_TYPE_NAME'
17626 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
17627 l_component_type
17628 ,l_component_code
17629 ,l_component_type_code
17630 ,l_component_appl_id
17631 ,l_amb_context_code
17632 ,l_entity_code
17633 ,l_event_class_code
17634 )
17635 ,p_token_3 => 'OWNER'
17636 ,p_value_3 => xla_lookups_pkg.get_meaning(
17637 p_lookup_type => 'XLA_OWNER_TYPE'
17638 ,p_lookup_code => l_component_type_code
17639 )
17640 ,p_token_4 => 'PRODUCT_NAME'
17641 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
17642 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
17643 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
17644 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
17648 IF (C_LEVEL_ERROR>= g_log_level) THEN
17645 ,p_ae_header_id => NULL
17646 );
17647
17649 trace
17650 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
17651 ,p_level => C_LEVEL_ERROR
17652 ,p_module => l_log_module);
17653 END IF;
17654 END IF;
17655 END IF;
17656 --
17657 --
17658 ------------------------------------------------------------------------------------------------
17659 -- 4219869 Business Flow
17660 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
17661 -- Prior Entry. Currently, the following code is always generated.
17662 ------------------------------------------------------------------------------------------------
17663 XLA_AE_LINES_PKG.ValidateCurrentLine;
17664
17665 ------------------------------------------------------------------------------------
17666 -- 4219869 Business Flow
17667 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
17668 ------------------------------------------------------------------------------------
17669 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17670
17671 ----------------------------------------------------------------------------------
17672 -- 4219869 Business Flow
17673 -- Update journal entry status -- Need to generate this within IF <condition>
17674 ----------------------------------------------------------------------------------
17675 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17676 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
17677 ,p_balance_type_code => l_balance_type_code
17678 );
17679
17680 -------------------------------------------------------------------------------------------
17681 -- 4262811 - Generate the Accrual Reversal lines
17682 -------------------------------------------------------------------------------------------
17683 BEGIN
17684 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
17685 (g_array_event(p_event_id).array_value_num('header_index'));
17686 IF l_acc_rev_flag IS NULL THEN
17687 l_acc_rev_flag := 'N';
17688 END IF;
17689 EXCEPTION
17690 WHEN OTHERS THEN
17691 l_acc_rev_flag := 'N';
17692 END;
17693 --
17694 IF (l_acc_rev_flag = 'Y') THEN
17695
17696 -- 4645092 ------------------------------------------------------------------------------
17697 -- To allow MPA report to determine if it should generate report process
17698 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
17699 ------------------------------------------------------------------------------------------
17700
17701 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
17702 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
17703 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
17704 -- call ADRs
17705 -- Bug 4922099
17706 --
17707 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17708 (NVL(l_actual_upg_option, 'N') = 'O') OR
17709 (NVL(l_enc_upg_option, 'N') = 'O')
17710 )
17711 THEN
17712 NULL;
17713 --
17714 --
17715
17716 l_ccid := AcctDerRule_34(
17717 p_application_id => p_application_id
17718 , p_ae_header_id => l_ae_header_id
17719 , p_source_21 => p_source_21
17720 , x_transaction_coa_id => l_adr_transaction_coa_id
17721 , x_accounting_coa_id => l_adr_accounting_coa_id
17722 , x_value_type_code => l_adr_value_type_code
17723 , p_side => 'NA'
17724 );
17725
17726 xla_ae_lines_pkg.set_ccid(
17727 p_code_combination_id => l_ccid
17728 , p_value_type_code => l_adr_value_type_code
17729 , p_transaction_coa_id => l_adr_transaction_coa_id
17730 , p_accounting_coa_id => l_adr_accounting_coa_id
17731 , p_adr_code => 'TRX_DIST_CCID'
17732 , p_adr_type_code => 'S'
17733 , p_component_type => l_component_type
17734 , p_component_code => l_component_code
17735 , p_component_type_code => l_component_type_code
17736 , p_component_appl_id => l_component_appl_id
17737 , p_amb_context_code => l_amb_context_code
17738 , p_side => 'NA'
17739 );
17740
17741
17742 --
17743 --
17744 END IF;
17745
17746 --
17747 -- Update the line information that should be overwritten
17748 --
17749 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
17750 p_header_num => 1);
17751 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
17752
17753 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
17754
17755 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
17756 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
17757 END IF;
17758
17759 --
17763 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
17760 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
17761 --
17762 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
17764 ELSE
17765 ---------------------------------------------------------------------------------------------------
17766 -- 4262811a Switch Sign
17767 ---------------------------------------------------------------------------------------------------
17768 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
17769 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17770 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17771 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17772 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17773 -- 5132302
17774 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
17775 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17776
17777 END IF;
17778
17779 -- 4955764
17780 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17781 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
17782
17783
17784 XLA_AE_LINES_PKG.ValidateCurrentLine;
17785 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17786
17787 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17788 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
17789 ,p_balance_type_code => l_balance_type_code);
17790
17791 END IF;
17792
17793 -----------------------------------------------------------------------------------------
17794 -- 4262811 Multiperiod Accounting
17795 -----------------------------------------------------------------------------------------
17796 -- No MPA option is assigned.
17797
17798
17799 END IF;
17800 END IF;
17801 --
17802
17803 --
17804 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17805 trace
17806 (p_msg => 'END of AcctLineType_57'
17807 ,p_level => C_LEVEL_PROCEDURE
17808 ,p_module => l_log_module);
17809 END IF;
17810 --
17811 EXCEPTION
17812 WHEN xla_exceptions_pkg.application_exception THEN
17813 RAISE;
17814 WHEN OTHERS THEN
17815 xla_exceptions_pkg.raise_message
17816 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_57');
17817 END AcctLineType_57;
17818 --
17819
17820 ---------------------------------------
17821 --
17822 -- PRIVATE FUNCTION
17823 -- AcctLineType_58
17824 --
17825 ---------------------------------------
17826 PROCEDURE AcctLineType_58 (
17827 p_application_id IN NUMBER
17828 ,p_event_id IN NUMBER
17829 ,p_calculate_acctd_flag IN VARCHAR2
17830 ,p_calculate_g_l_flag IN VARCHAR2
17831 ,p_actual_flag IN OUT VARCHAR2
17832 ,p_balance_type_code OUT VARCHAR2
17833 ,p_gain_or_loss_ref OUT VARCHAR2
17834
17835 --Transaction Distribution GL Account
17836 , p_source_21 IN NUMBER
17837 --Bill To Customer Account Identifier
17838 , p_source_32 IN NUMBER
17839 --Bill To Customer Site Use Identifier
17840 , p_source_33 IN NUMBER
17841 --SLA Party Type
17842 , p_source_34 IN VARCHAR2
17843 --Transaction Distribution Account Class
17844 , p_source_35 IN VARCHAR2
17845 --Transaction Distribution Identifier
17846 , p_source_36 IN NUMBER
17847 --Transaction Distribution Type
17848 , p_source_37 IN VARCHAR2
17849 --Transaction Distribution Entered Amount
17850 , p_source_38 IN NUMBER
17851 --Transaction Currency Code
17852 , p_source_39 IN VARCHAR2
17853 --Transaction Exchange Date
17854 , p_source_40 IN DATE
17855 --Transaction Exchange Rate
17856 , p_source_41 IN NUMBER
17857 --Transaction Exchange Rate Type
17858 , p_source_42 IN VARCHAR2
17859 --Transaction Accounting Amount
17860 , p_source_43 IN NUMBER
17861 --Transaction Tax Line Identifier
17862 , p_source_57 IN NUMBER
17863 )
17864 IS
17865
17866 l_component_type VARCHAR2(80);
17867 l_component_code VARCHAR2(30);
17868 l_component_type_code VARCHAR2(1);
17869 l_component_appl_id INTEGER;
17870 l_amb_context_code VARCHAR2(30);
17871 l_entity_code VARCHAR2(30);
17872 l_event_class_code VARCHAR2(30);
17873 l_ae_header_id NUMBER;
17874 l_event_type_code VARCHAR2(30);
17875 l_line_definition_code VARCHAR2(30);
17876 l_line_definition_owner_code VARCHAR2(1);
17877 --
17878 -- adr variables
17879 l_segment VARCHAR2(30);
17880 l_ccid NUMBER;
17881 l_adr_transaction_coa_id NUMBER;
17882 l_adr_accounting_coa_id NUMBER;
17883 l_adr_flexfield_segment_code VARCHAR2(30);
17884 l_adr_flex_value_set_id NUMBER;
17885 l_adr_value_type_code VARCHAR2(30);
17886 l_adr_value_combination_id NUMBER;
17890 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
17887 l_adr_value_segment_code VARCHAR2(30);
17888
17889 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
17891 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
17892 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
17893
17894 -- 4262811 Variables ------------------------------------------------------------------------------------------
17895 l_entered_amt_idx NUMBER;
17896 l_accted_amt_idx NUMBER;
17897 l_acc_rev_flag VARCHAR2(1);
17898 l_accrual_line_num NUMBER;
17899 l_tmp_amt NUMBER;
17900 l_acc_rev_natural_side_code VARCHAR2(1);
17901
17902 l_num_entries NUMBER;
17903 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
17904 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
17905 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
17906 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
17907 l_recog_line_1 NUMBER;
17908 l_recog_line_2 NUMBER;
17909
17910 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
17911 l_bflow_applied_to_amt NUMBER; -- 5132302
17912 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
17913
17914 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
17915
17916 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
17917 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
17918
17919 ---------------------------------------------------------------------------------------------------------------
17920
17921
17922 --
17923 -- bulk performance
17924 --
17925 l_balance_type_code VARCHAR2(1);
17926 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
17927 l_log_module VARCHAR2(240);
17928
17929 --
17930 -- Upgrade strategy
17931 --
17932 l_actual_upg_option VARCHAR2(1);
17933 l_enc_upg_option VARCHAR2(1);
17934
17935 --
17936 BEGIN
17937 --
17938 IF g_log_enabled THEN
17939 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_58';
17940 END IF;
17941 --
17942 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17943
17944 trace
17945 (p_msg => 'BEGIN of AcctLineType_58'
17946 ,p_level => C_LEVEL_PROCEDURE
17947 ,p_module => l_log_module);
17948
17949 END IF;
17950 --
17951 l_component_type := 'AMB_JLT';
17952 l_component_code := 'DM_UNBILL';
17953 l_component_type_code := 'S';
17954 l_component_appl_id := 222;
17955 l_amb_context_code := 'DEFAULT';
17956 l_entity_code := 'TRANSACTIONS';
17957 l_event_class_code := 'DEBIT_MEMO';
17958 l_event_type_code := 'DEBIT_MEMO_ALL';
17959 l_line_definition_owner_code := 'S';
17960 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
17961 --
17962 l_balance_type_code := 'A';
17963 l_segment := NULL;
17964 l_ccid := NULL;
17965 l_adr_transaction_coa_id := NULL;
17966 l_adr_accounting_coa_id := NULL;
17967 l_adr_flexfield_segment_code := NULL;
17968 l_adr_flex_value_set_id := NULL;
17969 l_adr_value_type_code := NULL;
17970 l_adr_value_combination_id := NULL;
17971 l_adr_value_segment_code := NULL;
17972
17973 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
17974 l_bflow_class_code := ''; -- 4219869 Business Flow
17975 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
17976 l_budgetary_control_flag := 'N';
17977
17978 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17979 l_bflow_applied_to_amt := NULL; -- 5132302
17980 l_entered_amt_idx := NULL; -- 4262811
17981 l_accted_amt_idx := NULL; -- 4262811
17982 l_acc_rev_flag := NULL; -- 4262811
17983 l_accrual_line_num := NULL; -- 4262811
17984 l_tmp_amt := NULL; -- 4262811
17985 --
17986
17987 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
17988 l_balance_type_code <> 'B' THEN
17989 IF NVL(p_source_35,'
17990 ') = 'UNBILL'
17991 THEN
17992
17993 --
17994 XLA_AE_LINES_PKG.SetNewLine;
17995
17996 p_balance_type_code := l_balance_type_code;
17997 -- set the flag so later we will know whether the gain loss line needs to be created
17998
17999 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
18000 p_actual_flag :='A';
18001 END IF;
18002
18003 --
18004 -- bulk performance
18005 --
18006 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
18007 p_header_num => 0); -- 4262811
18008 --
18009 -- set accounting line options
18010 --
18011 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
18012 p_natural_side_code => 'D'
18013 , p_gain_or_loss_flag => 'N'
18014 , p_gl_transfer_mode_code => 'S'
18015 , p_acct_entry_type_code => 'A'
18019 --
18016 , p_switch_side_flag => 'Y'
18017 , p_merge_duplicate_code => 'A'
18018 );
18020 l_acc_rev_natural_side_code := 'C'; -- 4262811
18021 --
18022 --
18023 -- set accounting line type info
18024 --
18025 xla_ae_lines_pkg.SetAcctLineType
18026 (p_component_type => l_component_type
18027 ,p_event_type_code => l_event_type_code
18028 ,p_line_definition_owner_code => l_line_definition_owner_code
18029 ,p_line_definition_code => l_line_definition_code
18030 ,p_accounting_line_code => l_component_code
18031 ,p_accounting_line_type_code => l_component_type_code
18032 ,p_accounting_line_appl_id => l_component_appl_id
18033 ,p_amb_context_code => l_amb_context_code
18034 ,p_entity_code => l_entity_code
18035 ,p_event_class_code => l_event_class_code);
18036 --
18037 -- set accounting class
18038 --
18039 xla_ae_lines_pkg.SetAcctClass(
18040 p_accounting_class_code => 'UNBILL'
18041 , p_ae_header_id => l_ae_header_id
18042 );
18043
18044 --
18045 -- set rounding class
18046 --
18047 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
18048 'RECEIVABLE';
18049
18050 --
18051 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
18052 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
18053 --
18054 -- bulk performance
18055 --
18056 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
18057
18058 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
18059 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
18060
18061 -- 4955764
18062 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18063 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
18064
18065 -- 4458381 Public Sector Enh
18066
18067 --
18068 -- set accounting attributes for the line type
18069 --
18070 l_entered_amt_idx := 3;
18071 l_accted_amt_idx := 8;
18072 l_bflow_applied_to_amt_idx := NULL; -- 5132302
18073 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
18074 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
18075 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
18076 l_rec_acct_attrs.array_char_value(2) := p_source_37;
18077 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
18078 l_rec_acct_attrs.array_num_value(3) := p_source_38;
18079 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
18080 l_rec_acct_attrs.array_char_value(4) := p_source_39;
18081 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
18082 l_rec_acct_attrs.array_date_value(5) := p_source_40;
18083 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
18084 l_rec_acct_attrs.array_num_value(6) := p_source_41;
18085 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
18086 l_rec_acct_attrs.array_char_value(7) := p_source_42;
18087 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
18088 l_rec_acct_attrs.array_num_value(8) := p_source_43;
18089 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
18090 l_rec_acct_attrs.array_num_value(9) := p_source_32;
18091 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
18092 l_rec_acct_attrs.array_num_value(10) := p_source_33;
18093 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
18094 l_rec_acct_attrs.array_char_value(11) := p_source_34;
18095 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
18096 l_rec_acct_attrs.array_num_value(12) := p_source_57;
18097
18098 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
18099 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
18100
18101 ---------------------------------------------------------------------------------------------------------------
18102 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
18103 ---------------------------------------------------------------------------------------------------------------
18104 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
18105
18106 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18107 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18108
18109 IF xla_accounting_cache_pkg.GetValueChar
18110 (p_source_code => 'LEDGER_CATEGORY_CODE'
18111 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
18112 AND l_bflow_method_code = 'PRIOR_ENTRY'
18113 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
18114 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
18115 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
18116 )
18117 THEN
18118 xla_ae_lines_pkg.BflowUpgEntry
18119 (p_business_method_code => l_bflow_method_code
18123 NULL;
18120 ,p_business_class_code => l_bflow_class_code
18121 ,p_balance_type => l_balance_type_code);
18122 ELSE
18124 -- No business flow processing for business flow method of NONE.
18125 END IF;
18126
18127 --
18128 -- call analytical criteria
18129 --
18130
18131 --
18132 -- call description
18133 --
18134 -- No description or it is inherited.
18135 --
18136 -- call ADRs
18137 -- Bug 4922099
18138 --
18139 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18140 (NVL(l_actual_upg_option, 'N') = 'O') OR
18141 (NVL(l_enc_upg_option, 'N') = 'O')
18142 )
18143 THEN
18144 NULL;
18145 --
18146 --
18147
18148 l_ccid := AcctDerRule_34(
18149 p_application_id => p_application_id
18150 , p_ae_header_id => l_ae_header_id
18151 , p_source_21 => p_source_21
18152 , x_transaction_coa_id => l_adr_transaction_coa_id
18153 , x_accounting_coa_id => l_adr_accounting_coa_id
18154 , x_value_type_code => l_adr_value_type_code
18155 , p_side => 'NA'
18156 );
18157
18158 xla_ae_lines_pkg.set_ccid(
18159 p_code_combination_id => l_ccid
18160 , p_value_type_code => l_adr_value_type_code
18161 , p_transaction_coa_id => l_adr_transaction_coa_id
18162 , p_accounting_coa_id => l_adr_accounting_coa_id
18163 , p_adr_code => 'TRX_DIST_CCID'
18164 , p_adr_type_code => 'S'
18165 , p_component_type => l_component_type
18166 , p_component_code => l_component_code
18167 , p_component_type_code => l_component_type_code
18168 , p_component_appl_id => l_component_appl_id
18169 , p_amb_context_code => l_amb_context_code
18170 , p_side => 'NA'
18171 );
18172
18173
18174 --
18175 --
18176 END IF;
18177 --
18178 -- Bug 4922099
18179 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
18180 (NVL(l_enc_upg_option, 'N') = 'O')
18181 ) AND
18182 (l_bflow_method_code = 'PRIOR_ENTRY')
18183 )
18184 THEN
18185 IF
18186 --
18187 1 = 2
18188 --
18189 THEN
18190 xla_accounting_err_pkg.build_message
18191 (p_appli_s_name => 'XLA'
18192 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18193 ,p_token_1 => 'LINE_NUMBER'
18194 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
18195 ,p_token_2 => 'LINE_TYPE_NAME'
18196 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
18197 l_component_type
18198 ,l_component_code
18199 ,l_component_type_code
18200 ,l_component_appl_id
18201 ,l_amb_context_code
18202 ,l_entity_code
18203 ,l_event_class_code
18204 )
18205 ,p_token_3 => 'OWNER'
18206 ,p_value_3 => xla_lookups_pkg.get_meaning(
18207 p_lookup_type => 'XLA_OWNER_TYPE'
18208 ,p_lookup_code => l_component_type_code
18209 )
18210 ,p_token_4 => 'PRODUCT_NAME'
18211 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
18212 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
18213 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
18214 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
18215 ,p_ae_header_id => NULL
18216 );
18217
18218 IF (C_LEVEL_ERROR>= g_log_level) THEN
18219 trace
18220 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18221 ,p_level => C_LEVEL_ERROR
18222 ,p_module => l_log_module);
18223 END IF;
18224 END IF;
18225 END IF;
18226 --
18227 --
18228 ------------------------------------------------------------------------------------------------
18229 -- 4219869 Business Flow
18233 XLA_AE_LINES_PKG.ValidateCurrentLine;
18230 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
18231 -- Prior Entry. Currently, the following code is always generated.
18232 ------------------------------------------------------------------------------------------------
18234
18235 ------------------------------------------------------------------------------------
18236 -- 4219869 Business Flow
18237 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
18238 ------------------------------------------------------------------------------------
18239 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18240
18241 ----------------------------------------------------------------------------------
18242 -- 4219869 Business Flow
18243 -- Update journal entry status -- Need to generate this within IF <condition>
18244 ----------------------------------------------------------------------------------
18245 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18246 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
18247 ,p_balance_type_code => l_balance_type_code
18248 );
18249
18250 -------------------------------------------------------------------------------------------
18251 -- 4262811 - Generate the Accrual Reversal lines
18252 -------------------------------------------------------------------------------------------
18253 BEGIN
18254 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
18255 (g_array_event(p_event_id).array_value_num('header_index'));
18256 IF l_acc_rev_flag IS NULL THEN
18257 l_acc_rev_flag := 'N';
18258 END IF;
18259 EXCEPTION
18260 WHEN OTHERS THEN
18261 l_acc_rev_flag := 'N';
18262 END;
18263 --
18264 IF (l_acc_rev_flag = 'Y') THEN
18265
18266 -- 4645092 ------------------------------------------------------------------------------
18267 -- To allow MPA report to determine if it should generate report process
18268 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
18269 ------------------------------------------------------------------------------------------
18270
18271 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
18272 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
18273 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
18274 -- call ADRs
18275 -- Bug 4922099
18276 --
18277 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18278 (NVL(l_actual_upg_option, 'N') = 'O') OR
18279 (NVL(l_enc_upg_option, 'N') = 'O')
18280 )
18281 THEN
18282 NULL;
18283 --
18284 --
18285
18286 l_ccid := AcctDerRule_34(
18287 p_application_id => p_application_id
18288 , p_ae_header_id => l_ae_header_id
18289 , p_source_21 => p_source_21
18290 , x_transaction_coa_id => l_adr_transaction_coa_id
18291 , x_accounting_coa_id => l_adr_accounting_coa_id
18292 , x_value_type_code => l_adr_value_type_code
18293 , p_side => 'NA'
18294 );
18295
18296 xla_ae_lines_pkg.set_ccid(
18297 p_code_combination_id => l_ccid
18298 , p_value_type_code => l_adr_value_type_code
18299 , p_transaction_coa_id => l_adr_transaction_coa_id
18300 , p_accounting_coa_id => l_adr_accounting_coa_id
18301 , p_adr_code => 'TRX_DIST_CCID'
18302 , p_adr_type_code => 'S'
18303 , p_component_type => l_component_type
18304 , p_component_code => l_component_code
18305 , p_component_type_code => l_component_type_code
18306 , p_component_appl_id => l_component_appl_id
18307 , p_amb_context_code => l_amb_context_code
18308 , p_side => 'NA'
18309 );
18310
18311
18312 --
18313 --
18314 END IF;
18315
18316 --
18317 -- Update the line information that should be overwritten
18318 --
18319 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
18320 p_header_num => 1);
18321 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
18322
18323 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
18324
18325 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
18326 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
18327 END IF;
18328
18329 --
18330 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
18331 --
18332 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
18333 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
18334 ELSE
18335 ---------------------------------------------------------------------------------------------------
18336 -- 4262811a Switch Sign
18337 ---------------------------------------------------------------------------------------------------
18338 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
18342 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18339 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18340 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18341 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18343 -- 5132302
18344 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
18345 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18346
18347 END IF;
18348
18349 -- 4955764
18350 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18351 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
18352
18353
18354 XLA_AE_LINES_PKG.ValidateCurrentLine;
18355 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18356
18357 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18358 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
18359 ,p_balance_type_code => l_balance_type_code);
18360
18361 END IF;
18362
18363 -----------------------------------------------------------------------------------------
18364 -- 4262811 Multiperiod Accounting
18365 -----------------------------------------------------------------------------------------
18366 -- No MPA option is assigned.
18367
18368
18369 END IF;
18370 END IF;
18371 --
18372
18373 --
18374 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18375 trace
18376 (p_msg => 'END of AcctLineType_58'
18377 ,p_level => C_LEVEL_PROCEDURE
18378 ,p_module => l_log_module);
18379 END IF;
18380 --
18381 EXCEPTION
18382 WHEN xla_exceptions_pkg.application_exception THEN
18383 RAISE;
18384 WHEN OTHERS THEN
18385 xla_exceptions_pkg.raise_message
18386 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_58');
18387 END AcctLineType_58;
18388 --
18389
18390 ---------------------------------------
18391 --
18392 -- PRIVATE FUNCTION
18393 -- AcctLineType_59
18394 --
18395 ---------------------------------------
18396 PROCEDURE AcctLineType_59 (
18397 p_application_id IN NUMBER
18398 ,p_event_id IN NUMBER
18399 ,p_calculate_acctd_flag IN VARCHAR2
18400 ,p_calculate_g_l_flag IN VARCHAR2
18401 ,p_actual_flag IN OUT VARCHAR2
18402 ,p_balance_type_code OUT VARCHAR2
18403 ,p_gain_or_loss_ref OUT VARCHAR2
18404
18405 --Transaction Distribution GL Account
18406 , p_source_21 IN NUMBER
18407 --Bill To Customer Account Identifier
18408 , p_source_32 IN NUMBER
18409 --Bill To Customer Site Use Identifier
18410 , p_source_33 IN NUMBER
18411 --SLA Party Type
18412 , p_source_34 IN VARCHAR2
18413 --Transaction Distribution Account Class
18414 , p_source_35 IN VARCHAR2
18415 --Transaction Distribution Identifier
18416 , p_source_36 IN NUMBER
18417 --Transaction Distribution Type
18418 , p_source_37 IN VARCHAR2
18419 --Transaction Distribution Entered Amount
18420 , p_source_38 IN NUMBER
18421 --Transaction Currency Code
18422 , p_source_39 IN VARCHAR2
18423 --Transaction Exchange Date
18424 , p_source_40 IN DATE
18425 --Transaction Exchange Rate
18426 , p_source_41 IN NUMBER
18427 --Transaction Exchange Rate Type
18428 , p_source_42 IN VARCHAR2
18429 --Transaction Accounting Amount
18430 , p_source_43 IN NUMBER
18431 --Transaction Tax Line Identifier
18432 , p_source_57 IN NUMBER
18433 )
18434 IS
18435
18436 l_component_type VARCHAR2(80);
18437 l_component_code VARCHAR2(30);
18438 l_component_type_code VARCHAR2(1);
18439 l_component_appl_id INTEGER;
18440 l_amb_context_code VARCHAR2(30);
18441 l_entity_code VARCHAR2(30);
18442 l_event_class_code VARCHAR2(30);
18443 l_ae_header_id NUMBER;
18444 l_event_type_code VARCHAR2(30);
18445 l_line_definition_code VARCHAR2(30);
18446 l_line_definition_owner_code VARCHAR2(1);
18447 --
18448 -- adr variables
18449 l_segment VARCHAR2(30);
18450 l_ccid NUMBER;
18451 l_adr_transaction_coa_id NUMBER;
18452 l_adr_accounting_coa_id NUMBER;
18453 l_adr_flexfield_segment_code VARCHAR2(30);
18454 l_adr_flex_value_set_id NUMBER;
18455 l_adr_value_type_code VARCHAR2(30);
18456 l_adr_value_combination_id NUMBER;
18457 l_adr_value_segment_code VARCHAR2(30);
18458
18459 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
18460 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
18461 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
18462 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
18463
18464 -- 4262811 Variables ------------------------------------------------------------------------------------------
18465 l_entered_amt_idx NUMBER;
18466 l_accted_amt_idx NUMBER;
18467 l_acc_rev_flag VARCHAR2(1);
18468 l_accrual_line_num NUMBER;
18469 l_tmp_amt NUMBER;
18473 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
18470 l_acc_rev_natural_side_code VARCHAR2(1);
18471
18472 l_num_entries NUMBER;
18474 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
18475 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
18476 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
18477 l_recog_line_1 NUMBER;
18478 l_recog_line_2 NUMBER;
18479
18480 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
18481 l_bflow_applied_to_amt NUMBER; -- 5132302
18482 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
18483
18484 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
18485
18486 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
18487 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
18488
18489 ---------------------------------------------------------------------------------------------------------------
18490
18491
18492 --
18493 -- bulk performance
18494 --
18495 l_balance_type_code VARCHAR2(1);
18496 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
18497 l_log_module VARCHAR2(240);
18498
18499 --
18500 -- Upgrade strategy
18501 --
18502 l_actual_upg_option VARCHAR2(1);
18503 l_enc_upg_option VARCHAR2(1);
18504
18505 --
18506 BEGIN
18507 --
18508 IF g_log_enabled THEN
18509 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_59';
18510 END IF;
18511 --
18512 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18513
18514 trace
18515 (p_msg => 'BEGIN of AcctLineType_59'
18516 ,p_level => C_LEVEL_PROCEDURE
18517 ,p_module => l_log_module);
18518
18519 END IF;
18520 --
18521 l_component_type := 'AMB_JLT';
18522 l_component_code := 'DM_UNEARN';
18523 l_component_type_code := 'S';
18524 l_component_appl_id := 222;
18525 l_amb_context_code := 'DEFAULT';
18526 l_entity_code := 'TRANSACTIONS';
18527 l_event_class_code := 'DEBIT_MEMO';
18528 l_event_type_code := 'DEBIT_MEMO_ALL';
18529 l_line_definition_owner_code := 'S';
18530 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
18531 --
18532 l_balance_type_code := 'A';
18533 l_segment := NULL;
18534 l_ccid := NULL;
18535 l_adr_transaction_coa_id := NULL;
18536 l_adr_accounting_coa_id := NULL;
18537 l_adr_flexfield_segment_code := NULL;
18538 l_adr_flex_value_set_id := NULL;
18539 l_adr_value_type_code := NULL;
18540 l_adr_value_combination_id := NULL;
18541 l_adr_value_segment_code := NULL;
18542
18543 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
18544 l_bflow_class_code := ''; -- 4219869 Business Flow
18545 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
18546 l_budgetary_control_flag := 'N';
18547
18548 l_bflow_applied_to_amt_idx := NULL; -- 5132302
18549 l_bflow_applied_to_amt := NULL; -- 5132302
18550 l_entered_amt_idx := NULL; -- 4262811
18551 l_accted_amt_idx := NULL; -- 4262811
18552 l_acc_rev_flag := NULL; -- 4262811
18553 l_accrual_line_num := NULL; -- 4262811
18554 l_tmp_amt := NULL; -- 4262811
18555 --
18556
18557 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
18558 l_balance_type_code <> 'B' THEN
18559 IF NVL(p_source_35,'
18560 ') = 'UNEARN'
18561 THEN
18562
18563 --
18564 XLA_AE_LINES_PKG.SetNewLine;
18565
18566 p_balance_type_code := l_balance_type_code;
18567 -- set the flag so later we will know whether the gain loss line needs to be created
18568
18569 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
18570 p_actual_flag :='A';
18571 END IF;
18572
18573 --
18574 -- bulk performance
18575 --
18576 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
18577 p_header_num => 0); -- 4262811
18578 --
18579 -- set accounting line options
18580 --
18581 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
18582 p_natural_side_code => 'C'
18583 , p_gain_or_loss_flag => 'N'
18584 , p_gl_transfer_mode_code => 'S'
18585 , p_acct_entry_type_code => 'A'
18586 , p_switch_side_flag => 'Y'
18587 , p_merge_duplicate_code => 'A'
18588 );
18589 --
18590 l_acc_rev_natural_side_code := 'D'; -- 4262811
18591 --
18592 --
18593 -- set accounting line type info
18594 --
18595 xla_ae_lines_pkg.SetAcctLineType
18596 (p_component_type => l_component_type
18597 ,p_event_type_code => l_event_type_code
18598 ,p_line_definition_owner_code => l_line_definition_owner_code
18599 ,p_line_definition_code => l_line_definition_code
18600 ,p_accounting_line_code => l_component_code
18601 ,p_accounting_line_type_code => l_component_type_code
18605 ,p_event_class_code => l_event_class_code);
18602 ,p_accounting_line_appl_id => l_component_appl_id
18603 ,p_amb_context_code => l_amb_context_code
18604 ,p_entity_code => l_entity_code
18606 --
18607 -- set accounting class
18608 --
18609 xla_ae_lines_pkg.SetAcctClass(
18610 p_accounting_class_code => 'UNEARNED_REVENUE'
18611 , p_ae_header_id => l_ae_header_id
18612 );
18613
18614 --
18615 -- set rounding class
18616 --
18617 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
18618 'RECEIVABLE';
18619
18620 --
18621 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
18622 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
18623 --
18624 -- bulk performance
18625 --
18626 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
18627
18628 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
18629 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
18630
18631 -- 4955764
18632 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18633 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
18634
18635 -- 4458381 Public Sector Enh
18636
18637 --
18638 -- set accounting attributes for the line type
18639 --
18640 l_entered_amt_idx := 3;
18641 l_accted_amt_idx := 8;
18642 l_bflow_applied_to_amt_idx := NULL; -- 5132302
18643 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
18644 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
18645 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
18646 l_rec_acct_attrs.array_char_value(2) := p_source_37;
18647 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
18648 l_rec_acct_attrs.array_num_value(3) := p_source_38;
18649 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
18650 l_rec_acct_attrs.array_char_value(4) := p_source_39;
18651 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
18652 l_rec_acct_attrs.array_date_value(5) := p_source_40;
18653 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
18654 l_rec_acct_attrs.array_num_value(6) := p_source_41;
18655 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
18656 l_rec_acct_attrs.array_char_value(7) := p_source_42;
18657 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
18658 l_rec_acct_attrs.array_num_value(8) := p_source_43;
18659 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
18660 l_rec_acct_attrs.array_num_value(9) := p_source_32;
18661 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
18662 l_rec_acct_attrs.array_num_value(10) := p_source_33;
18663 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
18664 l_rec_acct_attrs.array_char_value(11) := p_source_34;
18665 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
18666 l_rec_acct_attrs.array_num_value(12) := p_source_57;
18667
18668 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
18669 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
18670
18671 ---------------------------------------------------------------------------------------------------------------
18672 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
18673 ---------------------------------------------------------------------------------------------------------------
18674 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
18675
18676 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18677 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18678
18679 IF xla_accounting_cache_pkg.GetValueChar
18680 (p_source_code => 'LEDGER_CATEGORY_CODE'
18681 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
18682 AND l_bflow_method_code = 'PRIOR_ENTRY'
18683 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
18684 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
18685 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
18686 )
18687 THEN
18688 xla_ae_lines_pkg.BflowUpgEntry
18689 (p_business_method_code => l_bflow_method_code
18690 ,p_business_class_code => l_bflow_class_code
18691 ,p_balance_type => l_balance_type_code);
18692 ELSE
18693 NULL;
18694 -- No business flow processing for business flow method of NONE.
18695 END IF;
18696
18697 --
18698 -- call analytical criteria
18699 --
18700
18701 --
18702 -- call description
18703 --
18704 -- No description or it is inherited.
18705 --
18706 -- call ADRs
18707 -- Bug 4922099
18708 --
18709 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18710 (NVL(l_actual_upg_option, 'N') = 'O') OR
18714 NULL;
18711 (NVL(l_enc_upg_option, 'N') = 'O')
18712 )
18713 THEN
18715 --
18716 --
18717
18718 l_ccid := AcctDerRule_34(
18719 p_application_id => p_application_id
18720 , p_ae_header_id => l_ae_header_id
18721 , p_source_21 => p_source_21
18722 , x_transaction_coa_id => l_adr_transaction_coa_id
18723 , x_accounting_coa_id => l_adr_accounting_coa_id
18724 , x_value_type_code => l_adr_value_type_code
18725 , p_side => 'NA'
18726 );
18727
18728 xla_ae_lines_pkg.set_ccid(
18729 p_code_combination_id => l_ccid
18730 , p_value_type_code => l_adr_value_type_code
18731 , p_transaction_coa_id => l_adr_transaction_coa_id
18732 , p_accounting_coa_id => l_adr_accounting_coa_id
18733 , p_adr_code => 'TRX_DIST_CCID'
18734 , p_adr_type_code => 'S'
18735 , p_component_type => l_component_type
18736 , p_component_code => l_component_code
18737 , p_component_type_code => l_component_type_code
18738 , p_component_appl_id => l_component_appl_id
18739 , p_amb_context_code => l_amb_context_code
18740 , p_side => 'NA'
18741 );
18742
18743
18744 --
18745 --
18746 END IF;
18747 --
18748 -- Bug 4922099
18749 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
18750 (NVL(l_enc_upg_option, 'N') = 'O')
18751 ) AND
18752 (l_bflow_method_code = 'PRIOR_ENTRY')
18753 )
18754 THEN
18755 IF
18756 --
18757 1 = 2
18758 --
18759 THEN
18760 xla_accounting_err_pkg.build_message
18761 (p_appli_s_name => 'XLA'
18762 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18763 ,p_token_1 => 'LINE_NUMBER'
18764 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
18765 ,p_token_2 => 'LINE_TYPE_NAME'
18766 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
18767 l_component_type
18768 ,l_component_code
18769 ,l_component_type_code
18770 ,l_component_appl_id
18771 ,l_amb_context_code
18772 ,l_entity_code
18773 ,l_event_class_code
18774 )
18775 ,p_token_3 => 'OWNER'
18776 ,p_value_3 => xla_lookups_pkg.get_meaning(
18777 p_lookup_type => 'XLA_OWNER_TYPE'
18778 ,p_lookup_code => l_component_type_code
18779 )
18780 ,p_token_4 => 'PRODUCT_NAME'
18781 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
18782 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
18783 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
18784 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
18785 ,p_ae_header_id => NULL
18786 );
18787
18788 IF (C_LEVEL_ERROR>= g_log_level) THEN
18789 trace
18790 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18791 ,p_level => C_LEVEL_ERROR
18792 ,p_module => l_log_module);
18793 END IF;
18794 END IF;
18795 END IF;
18796 --
18797 --
18798 ------------------------------------------------------------------------------------------------
18799 -- 4219869 Business Flow
18800 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
18801 -- Prior Entry. Currently, the following code is always generated.
18802 ------------------------------------------------------------------------------------------------
18803 XLA_AE_LINES_PKG.ValidateCurrentLine;
18804
18805 ------------------------------------------------------------------------------------
18806 -- 4219869 Business Flow
18807 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
18808 ------------------------------------------------------------------------------------
18809 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18810
18811 ----------------------------------------------------------------------------------
18815 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18812 -- 4219869 Business Flow
18813 -- Update journal entry status -- Need to generate this within IF <condition>
18814 ----------------------------------------------------------------------------------
18816 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
18817 ,p_balance_type_code => l_balance_type_code
18818 );
18819
18820 -------------------------------------------------------------------------------------------
18821 -- 4262811 - Generate the Accrual Reversal lines
18822 -------------------------------------------------------------------------------------------
18823 BEGIN
18824 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
18825 (g_array_event(p_event_id).array_value_num('header_index'));
18826 IF l_acc_rev_flag IS NULL THEN
18827 l_acc_rev_flag := 'N';
18828 END IF;
18829 EXCEPTION
18830 WHEN OTHERS THEN
18831 l_acc_rev_flag := 'N';
18832 END;
18833 --
18834 IF (l_acc_rev_flag = 'Y') THEN
18835
18836 -- 4645092 ------------------------------------------------------------------------------
18837 -- To allow MPA report to determine if it should generate report process
18838 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
18839 ------------------------------------------------------------------------------------------
18840
18841 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
18842 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
18843 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
18844 -- call ADRs
18845 -- Bug 4922099
18846 --
18847 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18848 (NVL(l_actual_upg_option, 'N') = 'O') OR
18849 (NVL(l_enc_upg_option, 'N') = 'O')
18850 )
18851 THEN
18852 NULL;
18853 --
18854 --
18855
18856 l_ccid := AcctDerRule_34(
18857 p_application_id => p_application_id
18858 , p_ae_header_id => l_ae_header_id
18859 , p_source_21 => p_source_21
18860 , x_transaction_coa_id => l_adr_transaction_coa_id
18861 , x_accounting_coa_id => l_adr_accounting_coa_id
18862 , x_value_type_code => l_adr_value_type_code
18863 , p_side => 'NA'
18864 );
18865
18866 xla_ae_lines_pkg.set_ccid(
18867 p_code_combination_id => l_ccid
18868 , p_value_type_code => l_adr_value_type_code
18869 , p_transaction_coa_id => l_adr_transaction_coa_id
18870 , p_accounting_coa_id => l_adr_accounting_coa_id
18871 , p_adr_code => 'TRX_DIST_CCID'
18872 , p_adr_type_code => 'S'
18873 , p_component_type => l_component_type
18874 , p_component_code => l_component_code
18875 , p_component_type_code => l_component_type_code
18876 , p_component_appl_id => l_component_appl_id
18877 , p_amb_context_code => l_amb_context_code
18878 , p_side => 'NA'
18879 );
18880
18881
18882 --
18883 --
18884 END IF;
18885
18886 --
18887 -- Update the line information that should be overwritten
18888 --
18889 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
18890 p_header_num => 1);
18891 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
18892
18893 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
18894
18895 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
18896 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
18897 END IF;
18898
18899 --
18900 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
18901 --
18902 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
18903 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
18904 ELSE
18905 ---------------------------------------------------------------------------------------------------
18906 -- 4262811a Switch Sign
18907 ---------------------------------------------------------------------------------------------------
18908 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
18909 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18910 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18911 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18912 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18913 -- 5132302
18914 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
18915 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18916
18917 END IF;
18918
18919 -- 4955764
18920 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18924 XLA_AE_LINES_PKG.ValidateCurrentLine;
18921 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
18922
18923
18925 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18926
18927 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18928 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
18929 ,p_balance_type_code => l_balance_type_code);
18930
18931 END IF;
18932
18933 -----------------------------------------------------------------------------------------
18934 -- 4262811 Multiperiod Accounting
18935 -----------------------------------------------------------------------------------------
18936 -- No MPA option is assigned.
18937
18938
18939 END IF;
18940 END IF;
18941 --
18942
18943 --
18944 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18945 trace
18946 (p_msg => 'END of AcctLineType_59'
18947 ,p_level => C_LEVEL_PROCEDURE
18948 ,p_module => l_log_module);
18949 END IF;
18950 --
18951 EXCEPTION
18952 WHEN xla_exceptions_pkg.application_exception THEN
18953 RAISE;
18954 WHEN OTHERS THEN
18955 xla_exceptions_pkg.raise_message
18956 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_59');
18957 END AcctLineType_59;
18958 --
18959
18960 ---------------------------------------
18961 --
18962 -- PRIVATE FUNCTION
18963 -- AcctLineType_60
18964 --
18965 ---------------------------------------
18966 PROCEDURE AcctLineType_60 (
18967 p_application_id IN NUMBER
18968 ,p_event_id IN NUMBER
18969 ,p_calculate_acctd_flag IN VARCHAR2
18970 ,p_calculate_g_l_flag IN VARCHAR2
18971 ,p_actual_flag IN OUT VARCHAR2
18972 ,p_balance_type_code OUT VARCHAR2
18973 ,p_gain_or_loss_ref OUT VARCHAR2
18974
18975 --Federal Fund Category
18976 , p_source_11 IN VARCHAR2
18977 --Bill To Customer Classification
18978 , p_source_12 IN VARCHAR2
18979 --Transaction Distribution GL Account
18980 , p_source_21 IN NUMBER
18981 --Bill To Customer Account Identifier
18982 , p_source_32 IN NUMBER
18983 --Bill To Customer Site Use Identifier
18984 , p_source_33 IN NUMBER
18985 --SLA Party Type
18986 , p_source_34 IN VARCHAR2
18987 --Transaction Distribution Account Class
18988 , p_source_35 IN VARCHAR2
18989 --Transaction Distribution Identifier
18990 , p_source_36 IN NUMBER
18991 --Transaction Distribution Type
18992 , p_source_37 IN VARCHAR2
18993 --Transaction Distribution Entered Amount
18994 , p_source_38 IN NUMBER
18995 --Transaction Currency Code
18996 , p_source_39 IN VARCHAR2
18997 --Transaction Exchange Date
18998 , p_source_40 IN DATE
18999 --Transaction Exchange Rate
19000 , p_source_41 IN NUMBER
19001 --Transaction Exchange Rate Type
19002 , p_source_42 IN VARCHAR2
19003 --Transaction Accounting Amount
19004 , p_source_43 IN NUMBER
19005 --Transaction Tax Line Identifier
19006 , p_source_57 IN NUMBER
19007 --Federal Account Valid Flag
19008 , p_source_58 IN VARCHAR2
19009 )
19010 IS
19011
19012 l_component_type VARCHAR2(80);
19013 l_component_code VARCHAR2(30);
19014 l_component_type_code VARCHAR2(1);
19015 l_component_appl_id INTEGER;
19016 l_amb_context_code VARCHAR2(30);
19017 l_entity_code VARCHAR2(30);
19018 l_event_class_code VARCHAR2(30);
19019 l_ae_header_id NUMBER;
19020 l_event_type_code VARCHAR2(30);
19021 l_line_definition_code VARCHAR2(30);
19022 l_line_definition_owner_code VARCHAR2(1);
19023 --
19024 -- adr variables
19025 l_segment VARCHAR2(30);
19026 l_ccid NUMBER;
19027 l_adr_transaction_coa_id NUMBER;
19028 l_adr_accounting_coa_id NUMBER;
19029 l_adr_flexfield_segment_code VARCHAR2(30);
19030 l_adr_flex_value_set_id NUMBER;
19031 l_adr_value_type_code VARCHAR2(30);
19032 l_adr_value_combination_id NUMBER;
19033 l_adr_value_segment_code VARCHAR2(30);
19034
19035 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
19036 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
19037 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
19038 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
19039
19040 -- 4262811 Variables ------------------------------------------------------------------------------------------
19041 l_entered_amt_idx NUMBER;
19042 l_accted_amt_idx NUMBER;
19043 l_acc_rev_flag VARCHAR2(1);
19044 l_accrual_line_num NUMBER;
19045 l_tmp_amt NUMBER;
19046 l_acc_rev_natural_side_code VARCHAR2(1);
19047
19048 l_num_entries NUMBER;
19049 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
19050 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
19051 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
19052 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
19053 l_recog_line_1 NUMBER;
19054 l_recog_line_2 NUMBER;
19055
19059
19056 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
19057 l_bflow_applied_to_amt NUMBER; -- 5132302
19058 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
19060 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
19061
19062 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
19063 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
19064
19065 ---------------------------------------------------------------------------------------------------------------
19066
19067
19068 --
19069 -- bulk performance
19070 --
19071 l_balance_type_code VARCHAR2(1);
19072 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
19073 l_log_module VARCHAR2(240);
19074
19075 --
19076 -- Upgrade strategy
19077 --
19078 l_actual_upg_option VARCHAR2(1);
19079 l_enc_upg_option VARCHAR2(1);
19080
19081 --
19082 BEGIN
19083 --
19084 IF g_log_enabled THEN
19085 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_60';
19086 END IF;
19087 --
19088 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19089
19090 trace
19091 (p_msg => 'BEGIN of AcctLineType_60'
19092 ,p_level => C_LEVEL_PROCEDURE
19093 ,p_module => l_log_module);
19094
19095 END IF;
19096 --
19097 l_component_type := 'AMB_JLT';
19098 l_component_code := 'FV_INV_REIM_ADV_CR';
19099 l_component_type_code := 'S';
19100 l_component_appl_id := 222;
19101 l_amb_context_code := 'DEFAULT';
19102 l_entity_code := 'TRANSACTIONS';
19103 l_event_class_code := 'INVOICE';
19104 l_event_type_code := 'INVOICE_ALL';
19105 l_line_definition_owner_code := 'S';
19106 l_line_definition_code := 'MFAR_FED_AR_ACCR_INV_ACCOUNT';
19107 --
19108 l_balance_type_code := 'A';
19109 l_segment := NULL;
19110 l_ccid := NULL;
19111 l_adr_transaction_coa_id := NULL;
19112 l_adr_accounting_coa_id := NULL;
19113 l_adr_flexfield_segment_code := NULL;
19114 l_adr_flex_value_set_id := NULL;
19115 l_adr_value_type_code := NULL;
19116 l_adr_value_combination_id := NULL;
19117 l_adr_value_segment_code := NULL;
19118
19119 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
19120 l_bflow_class_code := 'FV_INVOICE_REV_CR'; -- 4219869 Business Flow
19121 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
19122 l_budgetary_control_flag := 'N';
19123
19124 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19125 l_bflow_applied_to_amt := NULL; -- 5132302
19126 l_entered_amt_idx := NULL; -- 4262811
19127 l_accted_amt_idx := NULL; -- 4262811
19128 l_acc_rev_flag := NULL; -- 4262811
19129 l_accrual_line_num := NULL; -- 4262811
19130 l_tmp_amt := NULL; -- 4262811
19131 --
19132
19133 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
19134 l_balance_type_code <> 'B' THEN
19135 IF NVL(p_source_35,'
19136 ') = 'REV' AND
19137 NVL(p_source_11,'
19138 ') = 'Reimbursable' AND
19139 NVL(p_source_58,'
19140 ') = 'Y'
19141 THEN
19142
19143 --
19144 XLA_AE_LINES_PKG.SetNewLine;
19145
19146 p_balance_type_code := l_balance_type_code;
19147 -- set the flag so later we will know whether the gain loss line needs to be created
19148
19149 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
19150 p_actual_flag :='A';
19151 END IF;
19152
19153 --
19154 -- bulk performance
19155 --
19156 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
19157 p_header_num => 0); -- 4262811
19158 --
19159 -- set accounting line options
19160 --
19161 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
19162 p_natural_side_code => 'C'
19163 , p_gain_or_loss_flag => 'N'
19164 , p_gl_transfer_mode_code => 'S'
19165 , p_acct_entry_type_code => 'A'
19166 , p_switch_side_flag => 'Y'
19167 , p_merge_duplicate_code => 'A'
19168 );
19169 --
19170 l_acc_rev_natural_side_code := 'D'; -- 4262811
19171 --
19172 --
19173 -- set accounting line type info
19174 --
19175 xla_ae_lines_pkg.SetAcctLineType
19176 (p_component_type => l_component_type
19177 ,p_event_type_code => l_event_type_code
19178 ,p_line_definition_owner_code => l_line_definition_owner_code
19179 ,p_line_definition_code => l_line_definition_code
19180 ,p_accounting_line_code => l_component_code
19181 ,p_accounting_line_type_code => l_component_type_code
19182 ,p_accounting_line_appl_id => l_component_appl_id
19183 ,p_amb_context_code => l_amb_context_code
19184 ,p_entity_code => l_entity_code
19185 ,p_event_class_code => l_event_class_code);
19186 --
19187 -- set accounting class
19188 --
19189 xla_ae_lines_pkg.SetAcctClass(
19190 p_accounting_class_code => 'FV_REC_CR'
19194 --
19191 , p_ae_header_id => l_ae_header_id
19192 );
19193
19195 -- set rounding class
19196 --
19197 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
19198 'RECEIVABLE';
19199
19200 --
19201 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
19202 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
19203 --
19204 -- bulk performance
19205 --
19206 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
19207
19208 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
19209 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
19210
19211 -- 4955764
19212 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19213 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
19214
19215 -- 4458381 Public Sector Enh
19216
19217 --
19218 -- set accounting attributes for the line type
19219 --
19220 l_entered_amt_idx := 3;
19221 l_accted_amt_idx := 8;
19222 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19223 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
19224 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
19225 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
19226 l_rec_acct_attrs.array_char_value(2) := p_source_37;
19227 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
19228 l_rec_acct_attrs.array_num_value(3) := p_source_38;
19229 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
19230 l_rec_acct_attrs.array_char_value(4) := p_source_39;
19231 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
19232 l_rec_acct_attrs.array_date_value(5) := p_source_40;
19233 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
19234 l_rec_acct_attrs.array_num_value(6) := p_source_41;
19235 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
19236 l_rec_acct_attrs.array_char_value(7) := p_source_42;
19237 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
19238 l_rec_acct_attrs.array_num_value(8) := p_source_43;
19239 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
19240 l_rec_acct_attrs.array_num_value(9) := p_source_32;
19241 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
19242 l_rec_acct_attrs.array_num_value(10) := p_source_33;
19243 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
19244 l_rec_acct_attrs.array_char_value(11) := p_source_34;
19245 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
19246 l_rec_acct_attrs.array_num_value(12) := p_source_57;
19247
19248 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
19249 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
19250
19251 ---------------------------------------------------------------------------------------------------------------
19252 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
19253 ---------------------------------------------------------------------------------------------------------------
19254 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
19255
19256 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19257 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19258
19259 IF xla_accounting_cache_pkg.GetValueChar
19260 (p_source_code => 'LEDGER_CATEGORY_CODE'
19261 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
19262 AND l_bflow_method_code = 'PRIOR_ENTRY'
19263 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
19264 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
19265 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
19266 )
19267 THEN
19268 xla_ae_lines_pkg.BflowUpgEntry
19269 (p_business_method_code => l_bflow_method_code
19270 ,p_business_class_code => l_bflow_class_code
19271 ,p_balance_type => l_balance_type_code);
19272 ELSE
19273 NULL;
19274 -- No business flow processing for business flow method of NONE.
19275 END IF;
19276
19277 --
19278 -- call analytical criteria
19279 --
19280
19281 --
19282 -- call description
19283 --
19284 -- No description or it is inherited.
19285 --
19286 -- call ADRs
19287 -- Bug 4922099
19288 --
19289 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19290 (NVL(l_actual_upg_option, 'N') = 'O') OR
19291 (NVL(l_enc_upg_option, 'N') = 'O')
19292 )
19293 THEN
19294 NULL;
19295 --
19296 --
19297
19298 l_ccid := AcctDerRule_34(
19299 p_application_id => p_application_id
19300 , p_ae_header_id => l_ae_header_id
19301 , p_source_21 => p_source_21
19302 , x_transaction_coa_id => l_adr_transaction_coa_id
19306 );
19303 , x_accounting_coa_id => l_adr_accounting_coa_id
19304 , x_value_type_code => l_adr_value_type_code
19305 , p_side => 'NA'
19307
19308 xla_ae_lines_pkg.set_ccid(
19309 p_code_combination_id => l_ccid
19310 , p_value_type_code => l_adr_value_type_code
19311 , p_transaction_coa_id => l_adr_transaction_coa_id
19312 , p_accounting_coa_id => l_adr_accounting_coa_id
19313 , p_adr_code => 'TRX_DIST_CCID'
19314 , p_adr_type_code => 'S'
19315 , p_component_type => l_component_type
19316 , p_component_code => l_component_code
19317 , p_component_type_code => l_component_type_code
19318 , p_component_appl_id => l_component_appl_id
19319 , p_amb_context_code => l_amb_context_code
19320 , p_side => 'NA'
19321 );
19322
19323
19324 l_segment := AcctDerRule_13(
19325 p_application_id => p_application_id
19326 , p_ae_header_id => l_ae_header_id
19327 , p_source_11 => p_source_11
19328 , p_source_12 => p_source_12
19329 , x_transaction_coa_id => l_adr_transaction_coa_id
19330 , x_accounting_coa_id => l_adr_accounting_coa_id
19331 , x_flexfield_segment_code => l_adr_flexfield_segment_code
19332 , x_flex_value_set_id => l_adr_flex_value_set_id
19333 , x_value_type_code => l_adr_value_type_code
19334 , x_value_combination_id => l_adr_value_combination_id
19335 , x_value_segment_code => l_adr_value_segment_code
19336 , p_side => 'NA'
19337 , p_override_seg_flag => 'Y'
19338 );
19339
19340 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
19341
19342 xla_ae_lines_pkg.set_segment(
19343 p_to_segment_code => 'GL_ACCOUNT'
19344 , p_segment_value => l_segment
19345 , p_from_segment_code => l_adr_value_segment_code
19346 , p_from_combination_id => l_adr_value_combination_id
19347 , p_value_type_code => l_adr_value_type_code
19348 , p_transaction_coa_id => l_adr_transaction_coa_id
19349 , p_accounting_coa_id => l_adr_accounting_coa_id
19350 , p_flexfield_segment_code => l_adr_flexfield_segment_code
19351 , p_flex_value_set_id => l_adr_flex_value_set_id
19352 , p_adr_code => 'FV_AR_422X0X_INV_REIM_CR'
19353 , p_adr_type_code => 'S'
19354 , p_component_type => l_component_type
19355 , p_component_code => l_component_code
19356 , p_component_type_code => l_component_type_code
19357 , p_component_appl_id => l_component_appl_id
19358 , p_amb_context_code => l_amb_context_code
19359 , p_entity_code => 'TRANSACTIONS'
19360 , p_event_class_code => 'INVOICE'
19361 , p_side => 'NA'
19362 );
19363
19364 END IF;
19365
19366 --
19367 --
19368 END IF;
19369 --
19370 -- Bug 4922099
19371 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
19372 (NVL(l_enc_upg_option, 'N') = 'O')
19373 ) AND
19374 (l_bflow_method_code = 'PRIOR_ENTRY')
19375 )
19376 THEN
19377 IF
19378 --
19379 1 = 2
19380 --
19381 THEN
19382 xla_accounting_err_pkg.build_message
19383 (p_appli_s_name => 'XLA'
19384 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19385 ,p_token_1 => 'LINE_NUMBER'
19386 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
19387 ,p_token_2 => 'LINE_TYPE_NAME'
19388 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
19389 l_component_type
19390 ,l_component_code
19391 ,l_component_type_code
19392 ,l_component_appl_id
19393 ,l_amb_context_code
19394 ,l_entity_code
19395 ,l_event_class_code
19396 )
19397 ,p_token_3 => 'OWNER'
19398 ,p_value_3 => xla_lookups_pkg.get_meaning(
19399 p_lookup_type => 'XLA_OWNER_TYPE'
19400 ,p_lookup_code => l_component_type_code
19401 )
19402 ,p_token_4 => 'PRODUCT_NAME'
19406 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
19403 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
19404 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
19405 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
19407 ,p_ae_header_id => NULL
19408 );
19409
19410 IF (C_LEVEL_ERROR>= g_log_level) THEN
19411 trace
19412 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19413 ,p_level => C_LEVEL_ERROR
19414 ,p_module => l_log_module);
19415 END IF;
19416 END IF;
19417 END IF;
19418 --
19419 --
19420 ------------------------------------------------------------------------------------------------
19421 -- 4219869 Business Flow
19422 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
19423 -- Prior Entry. Currently, the following code is always generated.
19424 ------------------------------------------------------------------------------------------------
19425 XLA_AE_LINES_PKG.ValidateCurrentLine;
19426
19427 ------------------------------------------------------------------------------------
19428 -- 4219869 Business Flow
19429 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
19430 ------------------------------------------------------------------------------------
19431 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19432
19433 ----------------------------------------------------------------------------------
19434 -- 4219869 Business Flow
19435 -- Update journal entry status -- Need to generate this within IF <condition>
19436 ----------------------------------------------------------------------------------
19437 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19438 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
19439 ,p_balance_type_code => l_balance_type_code
19440 );
19441
19442 -------------------------------------------------------------------------------------------
19443 -- 4262811 - Generate the Accrual Reversal lines
19444 -------------------------------------------------------------------------------------------
19445 BEGIN
19446 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
19447 (g_array_event(p_event_id).array_value_num('header_index'));
19448 IF l_acc_rev_flag IS NULL THEN
19449 l_acc_rev_flag := 'N';
19450 END IF;
19451 EXCEPTION
19452 WHEN OTHERS THEN
19453 l_acc_rev_flag := 'N';
19454 END;
19455 --
19456 IF (l_acc_rev_flag = 'Y') THEN
19457
19458 -- 4645092 ------------------------------------------------------------------------------
19459 -- To allow MPA report to determine if it should generate report process
19460 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
19461 ------------------------------------------------------------------------------------------
19462
19463 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
19464 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
19465 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
19466 -- call ADRs
19467 -- Bug 4922099
19468 --
19469 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19470 (NVL(l_actual_upg_option, 'N') = 'O') OR
19471 (NVL(l_enc_upg_option, 'N') = 'O')
19472 )
19473 THEN
19474 NULL;
19475 --
19476 --
19477
19478 l_ccid := AcctDerRule_34(
19479 p_application_id => p_application_id
19480 , p_ae_header_id => l_ae_header_id
19481 , p_source_21 => p_source_21
19482 , x_transaction_coa_id => l_adr_transaction_coa_id
19483 , x_accounting_coa_id => l_adr_accounting_coa_id
19484 , x_value_type_code => l_adr_value_type_code
19485 , p_side => 'NA'
19486 );
19487
19488 xla_ae_lines_pkg.set_ccid(
19489 p_code_combination_id => l_ccid
19490 , p_value_type_code => l_adr_value_type_code
19491 , p_transaction_coa_id => l_adr_transaction_coa_id
19492 , p_accounting_coa_id => l_adr_accounting_coa_id
19493 , p_adr_code => 'TRX_DIST_CCID'
19494 , p_adr_type_code => 'S'
19495 , p_component_type => l_component_type
19496 , p_component_code => l_component_code
19497 , p_component_type_code => l_component_type_code
19498 , p_component_appl_id => l_component_appl_id
19499 , p_amb_context_code => l_amb_context_code
19500 , p_side => 'NA'
19501 );
19502
19503
19504 l_segment := AcctDerRule_13(
19505 p_application_id => p_application_id
19506 , p_ae_header_id => l_ae_header_id
19507 , p_source_11 => p_source_11
19508 , p_source_12 => p_source_12
19509 , x_transaction_coa_id => l_adr_transaction_coa_id
19510 , x_accounting_coa_id => l_adr_accounting_coa_id
19511 , x_flexfield_segment_code => l_adr_flexfield_segment_code
19512 , x_flex_value_set_id => l_adr_flex_value_set_id
19516 , p_side => 'NA'
19513 , x_value_type_code => l_adr_value_type_code
19514 , x_value_combination_id => l_adr_value_combination_id
19515 , x_value_segment_code => l_adr_value_segment_code
19517 , p_override_seg_flag => 'Y'
19518 );
19519
19520 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
19521
19522 xla_ae_lines_pkg.set_segment(
19523 p_to_segment_code => 'GL_ACCOUNT'
19524 , p_segment_value => l_segment
19525 , p_from_segment_code => l_adr_value_segment_code
19526 , p_from_combination_id => l_adr_value_combination_id
19527 , p_value_type_code => l_adr_value_type_code
19528 , p_transaction_coa_id => l_adr_transaction_coa_id
19529 , p_accounting_coa_id => l_adr_accounting_coa_id
19530 , p_flexfield_segment_code => l_adr_flexfield_segment_code
19531 , p_flex_value_set_id => l_adr_flex_value_set_id
19532 , p_adr_code => 'FV_AR_422X0X_INV_REIM_CR'
19533 , p_adr_type_code => 'S'
19534 , p_component_type => l_component_type
19535 , p_component_code => l_component_code
19536 , p_component_type_code => l_component_type_code
19537 , p_component_appl_id => l_component_appl_id
19538 , p_amb_context_code => l_amb_context_code
19539 , p_entity_code => 'TRANSACTIONS'
19540 , p_event_class_code => 'INVOICE'
19541 , p_side => 'NA'
19542 );
19543
19544 END IF;
19545
19546 --
19547 --
19548 END IF;
19549
19550 --
19551 -- Update the line information that should be overwritten
19552 --
19553 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
19554 p_header_num => 1);
19555 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
19556
19557 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
19558
19559 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
19560 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
19561 END IF;
19562
19563 --
19564 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
19565 --
19566 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
19567 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
19568 ELSE
19569 ---------------------------------------------------------------------------------------------------
19570 -- 4262811a Switch Sign
19571 ---------------------------------------------------------------------------------------------------
19572 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
19573 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19574 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19575 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19576 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19577 -- 5132302
19578 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
19579 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19580
19581 END IF;
19582
19583 -- 4955764
19584 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19585 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
19586
19587
19588 XLA_AE_LINES_PKG.ValidateCurrentLine;
19589 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19590
19591 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19592 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
19593 ,p_balance_type_code => l_balance_type_code);
19594
19595 END IF;
19596
19597 -----------------------------------------------------------------------------------------
19598 -- 4262811 Multiperiod Accounting
19599 -----------------------------------------------------------------------------------------
19600 -- No MPA option is assigned.
19601
19602
19603 END IF;
19604 END IF;
19605 --
19606
19607 --
19608 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19609 trace
19610 (p_msg => 'END of AcctLineType_60'
19611 ,p_level => C_LEVEL_PROCEDURE
19612 ,p_module => l_log_module);
19613 END IF;
19614 --
19615 EXCEPTION
19616 WHEN xla_exceptions_pkg.application_exception THEN
19617 RAISE;
19618 WHEN OTHERS THEN
19619 xla_exceptions_pkg.raise_message
19620 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_60');
19621 END AcctLineType_60;
19622 --
19623
19624 ---------------------------------------
19625 --
19626 -- PRIVATE FUNCTION
19627 -- AcctLineType_61
19628 --
19632 ,p_event_id IN NUMBER
19629 ---------------------------------------
19630 PROCEDURE AcctLineType_61 (
19631 p_application_id IN NUMBER
19633 ,p_calculate_acctd_flag IN VARCHAR2
19634 ,p_calculate_g_l_flag IN VARCHAR2
19635 ,p_actual_flag IN OUT VARCHAR2
19636 ,p_balance_type_code OUT VARCHAR2
19637 ,p_gain_or_loss_ref OUT VARCHAR2
19638
19639 --Federal Fund Category
19640 , p_source_11 IN VARCHAR2
19641 --Bill To Customer Classification
19642 , p_source_12 IN VARCHAR2
19643 --Transaction Distribution GL Account
19644 , p_source_21 IN NUMBER
19645 --Bill To Customer Account Identifier
19646 , p_source_32 IN NUMBER
19647 --Bill To Customer Site Use Identifier
19648 , p_source_33 IN NUMBER
19649 --SLA Party Type
19650 , p_source_34 IN VARCHAR2
19651 --Transaction Distribution Account Class
19652 , p_source_35 IN VARCHAR2
19653 --Transaction Distribution Identifier
19654 , p_source_36 IN NUMBER
19655 --Transaction Distribution Type
19656 , p_source_37 IN VARCHAR2
19657 --Transaction Distribution Entered Amount
19658 , p_source_38 IN NUMBER
19659 --Transaction Currency Code
19660 , p_source_39 IN VARCHAR2
19661 --Transaction Exchange Date
19662 , p_source_40 IN DATE
19663 --Transaction Exchange Rate
19664 , p_source_41 IN NUMBER
19665 --Transaction Exchange Rate Type
19666 , p_source_42 IN VARCHAR2
19667 --Transaction Accounting Amount
19668 , p_source_43 IN NUMBER
19669 --Transaction Tax Line Identifier
19670 , p_source_57 IN NUMBER
19671 --Federal Account Valid Flag
19672 , p_source_58 IN VARCHAR2
19673 )
19674 IS
19675
19676 l_component_type VARCHAR2(80);
19677 l_component_code VARCHAR2(30);
19678 l_component_type_code VARCHAR2(1);
19679 l_component_appl_id INTEGER;
19680 l_amb_context_code VARCHAR2(30);
19681 l_entity_code VARCHAR2(30);
19682 l_event_class_code VARCHAR2(30);
19683 l_ae_header_id NUMBER;
19684 l_event_type_code VARCHAR2(30);
19685 l_line_definition_code VARCHAR2(30);
19686 l_line_definition_owner_code VARCHAR2(1);
19687 --
19688 -- adr variables
19689 l_segment VARCHAR2(30);
19690 l_ccid NUMBER;
19691 l_adr_transaction_coa_id NUMBER;
19692 l_adr_accounting_coa_id NUMBER;
19693 l_adr_flexfield_segment_code VARCHAR2(30);
19694 l_adr_flex_value_set_id NUMBER;
19695 l_adr_value_type_code VARCHAR2(30);
19696 l_adr_value_combination_id NUMBER;
19697 l_adr_value_segment_code VARCHAR2(30);
19698
19699 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
19700 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
19701 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
19702 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
19703
19704 -- 4262811 Variables ------------------------------------------------------------------------------------------
19705 l_entered_amt_idx NUMBER;
19706 l_accted_amt_idx NUMBER;
19707 l_acc_rev_flag VARCHAR2(1);
19708 l_accrual_line_num NUMBER;
19709 l_tmp_amt NUMBER;
19710 l_acc_rev_natural_side_code VARCHAR2(1);
19711
19712 l_num_entries NUMBER;
19713 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
19714 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
19715 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
19716 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
19717 l_recog_line_1 NUMBER;
19718 l_recog_line_2 NUMBER;
19719
19720 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
19721 l_bflow_applied_to_amt NUMBER; -- 5132302
19722 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
19723
19724 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
19725
19726 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
19727 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
19728
19729 ---------------------------------------------------------------------------------------------------------------
19730
19731
19732 --
19733 -- bulk performance
19734 --
19735 l_balance_type_code VARCHAR2(1);
19736 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
19737 l_log_module VARCHAR2(240);
19738
19739 --
19740 -- Upgrade strategy
19741 --
19742 l_actual_upg_option VARCHAR2(1);
19743 l_enc_upg_option VARCHAR2(1);
19744
19745 --
19746 BEGIN
19747 --
19748 IF g_log_enabled THEN
19749 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_61';
19750 END IF;
19751 --
19752 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19753
19754 trace
19755 (p_msg => 'BEGIN of AcctLineType_61'
19756 ,p_level => C_LEVEL_PROCEDURE
19757 ,p_module => l_log_module);
19758
19759 END IF;
19760 --
19761 l_component_type := 'AMB_JLT';
19765 l_amb_context_code := 'DEFAULT';
19762 l_component_code := 'FV_INV_REIM_ADV_DR';
19763 l_component_type_code := 'S';
19764 l_component_appl_id := 222;
19766 l_entity_code := 'TRANSACTIONS';
19767 l_event_class_code := 'INVOICE';
19768 l_event_type_code := 'INVOICE_ALL';
19769 l_line_definition_owner_code := 'S';
19770 l_line_definition_code := 'MFAR_FED_AR_ACCR_INV_ACCOUNT';
19771 --
19772 l_balance_type_code := 'A';
19773 l_segment := NULL;
19774 l_ccid := NULL;
19775 l_adr_transaction_coa_id := NULL;
19776 l_adr_accounting_coa_id := NULL;
19777 l_adr_flexfield_segment_code := NULL;
19778 l_adr_flex_value_set_id := NULL;
19779 l_adr_value_type_code := NULL;
19780 l_adr_value_combination_id := NULL;
19781 l_adr_value_segment_code := NULL;
19782
19783 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
19784 l_bflow_class_code := 'FV_INVOICE_REC_DR'; -- 4219869 Business Flow
19785 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
19786 l_budgetary_control_flag := 'N';
19787
19788 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19789 l_bflow_applied_to_amt := NULL; -- 5132302
19790 l_entered_amt_idx := NULL; -- 4262811
19791 l_accted_amt_idx := NULL; -- 4262811
19792 l_acc_rev_flag := NULL; -- 4262811
19793 l_accrual_line_num := NULL; -- 4262811
19794 l_tmp_amt := NULL; -- 4262811
19795 --
19796
19797 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
19798 l_balance_type_code <> 'B' THEN
19799 IF NVL(p_source_35,'
19800 ') = 'REV' AND
19801 NVL(p_source_11,'
19802 ') = 'Reimbursable' AND
19803 NVL(p_source_58,'
19804 ') = 'Y'
19805 THEN
19806
19807 --
19808 XLA_AE_LINES_PKG.SetNewLine;
19809
19810 p_balance_type_code := l_balance_type_code;
19811 -- set the flag so later we will know whether the gain loss line needs to be created
19812
19813 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
19814 p_actual_flag :='A';
19815 END IF;
19816
19817 --
19818 -- bulk performance
19819 --
19820 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
19821 p_header_num => 0); -- 4262811
19822 --
19823 -- set accounting line options
19824 --
19825 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
19826 p_natural_side_code => 'D'
19827 , p_gain_or_loss_flag => 'N'
19828 , p_gl_transfer_mode_code => 'S'
19829 , p_acct_entry_type_code => 'A'
19830 , p_switch_side_flag => 'Y'
19831 , p_merge_duplicate_code => 'A'
19832 );
19833 --
19834 l_acc_rev_natural_side_code := 'C'; -- 4262811
19835 --
19836 --
19837 -- set accounting line type info
19838 --
19839 xla_ae_lines_pkg.SetAcctLineType
19840 (p_component_type => l_component_type
19841 ,p_event_type_code => l_event_type_code
19842 ,p_line_definition_owner_code => l_line_definition_owner_code
19843 ,p_line_definition_code => l_line_definition_code
19844 ,p_accounting_line_code => l_component_code
19845 ,p_accounting_line_type_code => l_component_type_code
19846 ,p_accounting_line_appl_id => l_component_appl_id
19847 ,p_amb_context_code => l_amb_context_code
19848 ,p_entity_code => l_entity_code
19849 ,p_event_class_code => l_event_class_code);
19850 --
19851 -- set accounting class
19852 --
19853 xla_ae_lines_pkg.SetAcctClass(
19854 p_accounting_class_code => 'FV_REC_DR'
19855 , p_ae_header_id => l_ae_header_id
19856 );
19857
19858 --
19859 -- set rounding class
19860 --
19861 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
19862 'RECEIVABLE';
19863
19864 --
19865 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
19866 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
19867 --
19868 -- bulk performance
19869 --
19870 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
19871
19872 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
19873 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
19874
19875 -- 4955764
19876 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19877 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
19878
19879 -- 4458381 Public Sector Enh
19880
19881 --
19882 -- set accounting attributes for the line type
19883 --
19884 l_entered_amt_idx := 3;
19885 l_accted_amt_idx := 8;
19886 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19887 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
19891 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
19888 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
19889 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
19890 l_rec_acct_attrs.array_char_value(2) := p_source_37;
19892 l_rec_acct_attrs.array_num_value(3) := p_source_38;
19893 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
19894 l_rec_acct_attrs.array_char_value(4) := p_source_39;
19895 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
19896 l_rec_acct_attrs.array_date_value(5) := p_source_40;
19897 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
19898 l_rec_acct_attrs.array_num_value(6) := p_source_41;
19899 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
19900 l_rec_acct_attrs.array_char_value(7) := p_source_42;
19901 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
19902 l_rec_acct_attrs.array_num_value(8) := p_source_43;
19903 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
19904 l_rec_acct_attrs.array_num_value(9) := p_source_32;
19905 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
19906 l_rec_acct_attrs.array_num_value(10) := p_source_33;
19907 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
19908 l_rec_acct_attrs.array_char_value(11) := p_source_34;
19909 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
19910 l_rec_acct_attrs.array_num_value(12) := p_source_57;
19911
19912 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
19913 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
19914
19915 ---------------------------------------------------------------------------------------------------------------
19916 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
19917 ---------------------------------------------------------------------------------------------------------------
19918 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
19919
19920 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19921 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19922
19923 IF xla_accounting_cache_pkg.GetValueChar
19924 (p_source_code => 'LEDGER_CATEGORY_CODE'
19925 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
19926 AND l_bflow_method_code = 'PRIOR_ENTRY'
19927 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
19928 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
19929 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
19930 )
19931 THEN
19932 xla_ae_lines_pkg.BflowUpgEntry
19933 (p_business_method_code => l_bflow_method_code
19934 ,p_business_class_code => l_bflow_class_code
19935 ,p_balance_type => l_balance_type_code);
19936 ELSE
19937 NULL;
19938 -- No business flow processing for business flow method of NONE.
19939 END IF;
19940
19941 --
19942 -- call analytical criteria
19943 --
19944
19945 --
19946 -- call description
19947 --
19948 -- No description or it is inherited.
19949 --
19950 -- call ADRs
19951 -- Bug 4922099
19952 --
19953 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19954 (NVL(l_actual_upg_option, 'N') = 'O') OR
19955 (NVL(l_enc_upg_option, 'N') = 'O')
19956 )
19957 THEN
19958 NULL;
19959 --
19960 --
19961
19962 l_ccid := AcctDerRule_34(
19963 p_application_id => p_application_id
19964 , p_ae_header_id => l_ae_header_id
19965 , p_source_21 => p_source_21
19966 , x_transaction_coa_id => l_adr_transaction_coa_id
19967 , x_accounting_coa_id => l_adr_accounting_coa_id
19968 , x_value_type_code => l_adr_value_type_code
19969 , p_side => 'NA'
19970 );
19971
19972 xla_ae_lines_pkg.set_ccid(
19973 p_code_combination_id => l_ccid
19974 , p_value_type_code => l_adr_value_type_code
19975 , p_transaction_coa_id => l_adr_transaction_coa_id
19976 , p_accounting_coa_id => l_adr_accounting_coa_id
19977 , p_adr_code => 'TRX_DIST_CCID'
19978 , p_adr_type_code => 'S'
19979 , p_component_type => l_component_type
19980 , p_component_code => l_component_code
19981 , p_component_type_code => l_component_type_code
19982 , p_component_appl_id => l_component_appl_id
19983 , p_amb_context_code => l_amb_context_code
19984 , p_side => 'NA'
19985 );
19986
19987
19988 l_segment := AcctDerRule_17(
19989 p_application_id => p_application_id
19990 , p_ae_header_id => l_ae_header_id
19991 , p_source_11 => p_source_11
19992 , p_source_12 => p_source_12
19993 , x_transaction_coa_id => l_adr_transaction_coa_id
19994 , x_accounting_coa_id => l_adr_accounting_coa_id
19995 , x_flexfield_segment_code => l_adr_flexfield_segment_code
19996 , x_flex_value_set_id => l_adr_flex_value_set_id
20000 , p_side => 'NA'
19997 , x_value_type_code => l_adr_value_type_code
19998 , x_value_combination_id => l_adr_value_combination_id
19999 , x_value_segment_code => l_adr_value_segment_code
20001 , p_override_seg_flag => 'Y'
20002 );
20003
20004 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
20005
20006 xla_ae_lines_pkg.set_segment(
20007 p_to_segment_code => 'GL_ACCOUNT'
20008 , p_segment_value => l_segment
20009 , p_from_segment_code => l_adr_value_segment_code
20010 , p_from_combination_id => l_adr_value_combination_id
20011 , p_value_type_code => l_adr_value_type_code
20012 , p_transaction_coa_id => l_adr_transaction_coa_id
20013 , p_accounting_coa_id => l_adr_accounting_coa_id
20014 , p_flexfield_segment_code => l_adr_flexfield_segment_code
20015 , p_flex_value_set_id => l_adr_flex_value_set_id
20016 , p_adr_code => 'FV_AR_425X0X_INV_REIM_DR'
20017 , p_adr_type_code => 'S'
20018 , p_component_type => l_component_type
20019 , p_component_code => l_component_code
20020 , p_component_type_code => l_component_type_code
20021 , p_component_appl_id => l_component_appl_id
20022 , p_amb_context_code => l_amb_context_code
20023 , p_entity_code => 'TRANSACTIONS'
20024 , p_event_class_code => 'INVOICE'
20025 , p_side => 'NA'
20026 );
20027
20028 END IF;
20029
20030 --
20031 --
20032 END IF;
20033 --
20034 -- Bug 4922099
20035 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
20036 (NVL(l_enc_upg_option, 'N') = 'O')
20037 ) AND
20038 (l_bflow_method_code = 'PRIOR_ENTRY')
20039 )
20040 THEN
20041 IF
20042 --
20043 1 = 2
20044 --
20045 THEN
20046 xla_accounting_err_pkg.build_message
20047 (p_appli_s_name => 'XLA'
20048 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20049 ,p_token_1 => 'LINE_NUMBER'
20050 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
20051 ,p_token_2 => 'LINE_TYPE_NAME'
20052 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
20053 l_component_type
20054 ,l_component_code
20055 ,l_component_type_code
20056 ,l_component_appl_id
20057 ,l_amb_context_code
20058 ,l_entity_code
20059 ,l_event_class_code
20060 )
20061 ,p_token_3 => 'OWNER'
20062 ,p_value_3 => xla_lookups_pkg.get_meaning(
20063 p_lookup_type => 'XLA_OWNER_TYPE'
20064 ,p_lookup_code => l_component_type_code
20065 )
20066 ,p_token_4 => 'PRODUCT_NAME'
20067 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
20068 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
20069 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
20070 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
20071 ,p_ae_header_id => NULL
20072 );
20073
20074 IF (C_LEVEL_ERROR>= g_log_level) THEN
20075 trace
20076 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20077 ,p_level => C_LEVEL_ERROR
20078 ,p_module => l_log_module);
20079 END IF;
20080 END IF;
20081 END IF;
20082 --
20083 --
20084 ------------------------------------------------------------------------------------------------
20085 -- 4219869 Business Flow
20086 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
20087 -- Prior Entry. Currently, the following code is always generated.
20088 ------------------------------------------------------------------------------------------------
20089 XLA_AE_LINES_PKG.ValidateCurrentLine;
20090
20091 ------------------------------------------------------------------------------------
20092 -- 4219869 Business Flow
20093 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
20094 ------------------------------------------------------------------------------------
20098 -- 4219869 Business Flow
20095 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20096
20097 ----------------------------------------------------------------------------------
20099 -- Update journal entry status -- Need to generate this within IF <condition>
20100 ----------------------------------------------------------------------------------
20101 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20102 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
20103 ,p_balance_type_code => l_balance_type_code
20104 );
20105
20106 -------------------------------------------------------------------------------------------
20107 -- 4262811 - Generate the Accrual Reversal lines
20108 -------------------------------------------------------------------------------------------
20109 BEGIN
20110 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
20111 (g_array_event(p_event_id).array_value_num('header_index'));
20112 IF l_acc_rev_flag IS NULL THEN
20113 l_acc_rev_flag := 'N';
20114 END IF;
20115 EXCEPTION
20116 WHEN OTHERS THEN
20117 l_acc_rev_flag := 'N';
20118 END;
20119 --
20120 IF (l_acc_rev_flag = 'Y') THEN
20121
20122 -- 4645092 ------------------------------------------------------------------------------
20123 -- To allow MPA report to determine if it should generate report process
20124 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
20125 ------------------------------------------------------------------------------------------
20126
20127 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
20128 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
20129 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
20130 -- call ADRs
20131 -- Bug 4922099
20132 --
20133 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20134 (NVL(l_actual_upg_option, 'N') = 'O') OR
20135 (NVL(l_enc_upg_option, 'N') = 'O')
20136 )
20137 THEN
20138 NULL;
20139 --
20140 --
20141
20142 l_ccid := AcctDerRule_34(
20143 p_application_id => p_application_id
20144 , p_ae_header_id => l_ae_header_id
20145 , p_source_21 => p_source_21
20146 , x_transaction_coa_id => l_adr_transaction_coa_id
20147 , x_accounting_coa_id => l_adr_accounting_coa_id
20148 , x_value_type_code => l_adr_value_type_code
20149 , p_side => 'NA'
20150 );
20151
20152 xla_ae_lines_pkg.set_ccid(
20153 p_code_combination_id => l_ccid
20154 , p_value_type_code => l_adr_value_type_code
20155 , p_transaction_coa_id => l_adr_transaction_coa_id
20156 , p_accounting_coa_id => l_adr_accounting_coa_id
20157 , p_adr_code => 'TRX_DIST_CCID'
20158 , p_adr_type_code => 'S'
20159 , p_component_type => l_component_type
20160 , p_component_code => l_component_code
20161 , p_component_type_code => l_component_type_code
20162 , p_component_appl_id => l_component_appl_id
20163 , p_amb_context_code => l_amb_context_code
20164 , p_side => 'NA'
20165 );
20166
20167
20168 l_segment := AcctDerRule_17(
20169 p_application_id => p_application_id
20170 , p_ae_header_id => l_ae_header_id
20171 , p_source_11 => p_source_11
20172 , p_source_12 => p_source_12
20173 , x_transaction_coa_id => l_adr_transaction_coa_id
20174 , x_accounting_coa_id => l_adr_accounting_coa_id
20175 , x_flexfield_segment_code => l_adr_flexfield_segment_code
20176 , x_flex_value_set_id => l_adr_flex_value_set_id
20177 , x_value_type_code => l_adr_value_type_code
20178 , x_value_combination_id => l_adr_value_combination_id
20179 , x_value_segment_code => l_adr_value_segment_code
20180 , p_side => 'NA'
20181 , p_override_seg_flag => 'Y'
20182 );
20183
20184 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
20185
20186 xla_ae_lines_pkg.set_segment(
20187 p_to_segment_code => 'GL_ACCOUNT'
20188 , p_segment_value => l_segment
20189 , p_from_segment_code => l_adr_value_segment_code
20190 , p_from_combination_id => l_adr_value_combination_id
20191 , p_value_type_code => l_adr_value_type_code
20192 , p_transaction_coa_id => l_adr_transaction_coa_id
20193 , p_accounting_coa_id => l_adr_accounting_coa_id
20194 , p_flexfield_segment_code => l_adr_flexfield_segment_code
20195 , p_flex_value_set_id => l_adr_flex_value_set_id
20196 , p_adr_code => 'FV_AR_425X0X_INV_REIM_DR'
20197 , p_adr_type_code => 'S'
20198 , p_component_type => l_component_type
20199 , p_component_code => l_component_code
20200 , p_component_type_code => l_component_type_code
20201 , p_component_appl_id => l_component_appl_id
20202 , p_amb_context_code => l_amb_context_code
20203 , p_entity_code => 'TRANSACTIONS'
20204 , p_event_class_code => 'INVOICE'
20208 END IF;
20205 , p_side => 'NA'
20206 );
20207
20209
20210 --
20211 --
20212 END IF;
20213
20214 --
20215 -- Update the line information that should be overwritten
20216 --
20217 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
20218 p_header_num => 1);
20219 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
20220
20221 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
20222
20223 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
20224 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
20225 END IF;
20226
20227 --
20228 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
20229 --
20230 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
20231 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
20232 ELSE
20233 ---------------------------------------------------------------------------------------------------
20234 -- 4262811a Switch Sign
20235 ---------------------------------------------------------------------------------------------------
20236 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
20237 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
20238 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20239 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
20240 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20241 -- 5132302
20242 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
20243 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20244
20245 END IF;
20246
20247 -- 4955764
20248 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20249 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
20250
20251
20252 XLA_AE_LINES_PKG.ValidateCurrentLine;
20253 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20254
20255 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20256 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
20257 ,p_balance_type_code => l_balance_type_code);
20258
20259 END IF;
20260
20261 -----------------------------------------------------------------------------------------
20262 -- 4262811 Multiperiod Accounting
20263 -----------------------------------------------------------------------------------------
20264 -- No MPA option is assigned.
20265
20266
20267 END IF;
20268 END IF;
20269 --
20270
20271 --
20272 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20273 trace
20274 (p_msg => 'END of AcctLineType_61'
20275 ,p_level => C_LEVEL_PROCEDURE
20276 ,p_module => l_log_module);
20277 END IF;
20278 --
20279 EXCEPTION
20280 WHEN xla_exceptions_pkg.application_exception THEN
20281 RAISE;
20282 WHEN OTHERS THEN
20283 xla_exceptions_pkg.raise_message
20284 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_61');
20285 END AcctLineType_61;
20286 --
20287
20288 ---------------------------------------
20289 --
20290 -- PRIVATE FUNCTION
20291 -- AcctLineType_62
20292 --
20293 ---------------------------------------
20294 PROCEDURE AcctLineType_62 (
20295 p_application_id IN NUMBER
20296 ,p_event_id IN NUMBER
20297 ,p_calculate_acctd_flag IN VARCHAR2
20298 ,p_calculate_g_l_flag IN VARCHAR2
20299 ,p_actual_flag IN OUT VARCHAR2
20300 ,p_balance_type_code OUT VARCHAR2
20301 ,p_gain_or_loss_ref OUT VARCHAR2
20302
20303 --Distribution GL Account
20304 , p_source_10 IN NUMBER
20305 --Federal Fund Expired Status
20306 , p_source_14 IN VARCHAR2
20307 --Federal Prior Year Flag
20308 , p_source_15 IN VARCHAR2
20309 --Federal Fund Time Frame
20310 , p_source_16 IN VARCHAR2
20311 --Distribution Source Type
20312 , p_source_22 IN VARCHAR2
20313 --Distribution Line Identifier
20314 , p_source_24 IN NUMBER
20315 --Distribution Type
20316 , p_source_25 IN VARCHAR2
20317 --Entered Amount
20318 , p_source_26 IN NUMBER
20319 --Currency Code
20320 , p_source_27 IN VARCHAR2
20321 --Exchange Rate
20322 , p_source_29 IN NUMBER
20323 --Exchange Rate Type
20324 , p_source_30 IN VARCHAR2
20325 --Applied To Document Accounting Amount
20326 , p_source_31 IN NUMBER
20327 --Federal Account Valid Flag
20328 , p_source_58 IN VARCHAR2
20329 --Applied To Document Exchange Date
20330 , p_source_59 IN DATE
20331 )
20332 IS
20333
20334 l_component_type VARCHAR2(80);
20338 l_amb_context_code VARCHAR2(30);
20335 l_component_code VARCHAR2(30);
20336 l_component_type_code VARCHAR2(1);
20337 l_component_appl_id INTEGER;
20339 l_entity_code VARCHAR2(30);
20340 l_event_class_code VARCHAR2(30);
20341 l_ae_header_id NUMBER;
20342 l_event_type_code VARCHAR2(30);
20343 l_line_definition_code VARCHAR2(30);
20344 l_line_definition_owner_code VARCHAR2(1);
20345 --
20346 -- adr variables
20347 l_segment VARCHAR2(30);
20348 l_ccid NUMBER;
20349 l_adr_transaction_coa_id NUMBER;
20350 l_adr_accounting_coa_id NUMBER;
20351 l_adr_flexfield_segment_code VARCHAR2(30);
20352 l_adr_flex_value_set_id NUMBER;
20353 l_adr_value_type_code VARCHAR2(30);
20354 l_adr_value_combination_id NUMBER;
20355 l_adr_value_segment_code VARCHAR2(30);
20356
20357 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
20358 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
20359 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
20360 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
20361
20362 -- 4262811 Variables ------------------------------------------------------------------------------------------
20363 l_entered_amt_idx NUMBER;
20364 l_accted_amt_idx NUMBER;
20365 l_acc_rev_flag VARCHAR2(1);
20366 l_accrual_line_num NUMBER;
20367 l_tmp_amt NUMBER;
20368 l_acc_rev_natural_side_code VARCHAR2(1);
20369
20370 l_num_entries NUMBER;
20371 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
20372 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
20373 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
20374 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
20375 l_recog_line_1 NUMBER;
20376 l_recog_line_2 NUMBER;
20377
20378 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
20379 l_bflow_applied_to_amt NUMBER; -- 5132302
20380 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
20381
20382 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
20383
20384 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
20385 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
20386
20387 ---------------------------------------------------------------------------------------------------------------
20388
20389
20390 --
20391 -- bulk performance
20392 --
20393 l_balance_type_code VARCHAR2(1);
20394 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
20395 l_log_module VARCHAR2(240);
20396
20397 --
20398 -- Upgrade strategy
20399 --
20400 l_actual_upg_option VARCHAR2(1);
20401 l_enc_upg_option VARCHAR2(1);
20402
20403 --
20404 BEGIN
20405 --
20406 IF g_log_enabled THEN
20407 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_62';
20408 END IF;
20409 --
20410 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20411
20412 trace
20413 (p_msg => 'BEGIN of AcctLineType_62'
20414 ,p_level => C_LEVEL_PROCEDURE
20415 ,p_module => l_log_module);
20416
20417 END IF;
20418 --
20419 l_component_type := 'AMB_JLT';
20420 l_component_code := 'FV_MISC_RCT_REF_OEF_CR';
20421 l_component_type_code := 'S';
20422 l_component_appl_id := 222;
20423 l_amb_context_code := 'DEFAULT';
20424 l_entity_code := 'RECEIPTS';
20425 l_event_class_code := 'MISC_RECEIPT';
20426 l_event_type_code := 'MISC_RECEIPT_ALL';
20427 l_line_definition_owner_code := 'S';
20428 l_line_definition_code := 'MFAR_FED_AR_MISC_REC_ACCOUNT';
20429 --
20430 l_balance_type_code := 'A';
20431 l_segment := NULL;
20432 l_ccid := NULL;
20433 l_adr_transaction_coa_id := NULL;
20434 l_adr_accounting_coa_id := NULL;
20435 l_adr_flexfield_segment_code := NULL;
20436 l_adr_flex_value_set_id := NULL;
20437 l_adr_value_type_code := NULL;
20438 l_adr_value_combination_id := NULL;
20439 l_adr_value_segment_code := NULL;
20440
20441 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
20442 l_bflow_class_code := ''; -- 4219869 Business Flow
20443 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
20444 l_budgetary_control_flag := 'N';
20445
20446 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20447 l_bflow_applied_to_amt := NULL; -- 5132302
20448 l_entered_amt_idx := NULL; -- 4262811
20449 l_accted_amt_idx := NULL; -- 4262811
20450 l_acc_rev_flag := NULL; -- 4262811
20451 l_accrual_line_num := NULL; -- 4262811
20452 l_tmp_amt := NULL; -- 4262811
20453 --
20454
20455 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
20456 l_balance_type_code <> 'B' THEN
20457 IF NVL(p_source_22,'
20458 ') = 'MISCCASH' AND
20459 NVL(p_source_14,'
20463 (NVL(p_source_16,'
20460 ') = 'Expired' AND
20461 NVL(p_source_15,'
20462 ') = 'Y' AND
20464 ') = 'SINGLE' OR
20465 NVL(p_source_16,'
20466 ') = 'MULTIPLE' OR
20467 NVL(p_source_16,'
20468 ') = 'NO_YEAR') AND
20469 NVL(p_source_58,'
20470 ') = 'Y'
20471 THEN
20472
20473 --
20474 XLA_AE_LINES_PKG.SetNewLine;
20475
20476 p_balance_type_code := l_balance_type_code;
20477 -- set the flag so later we will know whether the gain loss line needs to be created
20478
20479 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
20480 p_actual_flag :='A';
20481 END IF;
20482
20483 --
20484 -- bulk performance
20485 --
20486 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
20487 p_header_num => 0); -- 4262811
20488 --
20489 -- set accounting line options
20490 --
20491 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
20492 p_natural_side_code => 'C'
20493 , p_gain_or_loss_flag => 'N'
20494 , p_gl_transfer_mode_code => 'S'
20495 , p_acct_entry_type_code => 'A'
20496 , p_switch_side_flag => 'Y'
20497 , p_merge_duplicate_code => 'A'
20498 );
20499 --
20500 l_acc_rev_natural_side_code := 'D'; -- 4262811
20501 --
20502 --
20503 -- set accounting line type info
20504 --
20505 xla_ae_lines_pkg.SetAcctLineType
20506 (p_component_type => l_component_type
20507 ,p_event_type_code => l_event_type_code
20508 ,p_line_definition_owner_code => l_line_definition_owner_code
20509 ,p_line_definition_code => l_line_definition_code
20510 ,p_accounting_line_code => l_component_code
20511 ,p_accounting_line_type_code => l_component_type_code
20512 ,p_accounting_line_appl_id => l_component_appl_id
20513 ,p_amb_context_code => l_amb_context_code
20514 ,p_entity_code => l_entity_code
20515 ,p_event_class_code => l_event_class_code);
20516 --
20517 -- set accounting class
20518 --
20519 xla_ae_lines_pkg.SetAcctClass(
20520 p_accounting_class_code => 'FV_MISCCASH_CR'
20521 , p_ae_header_id => l_ae_header_id
20522 );
20523
20524 --
20525 -- set rounding class
20526 --
20527 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
20528 'RECEIVABLE';
20529
20530 --
20531 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
20532 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
20533 --
20534 -- bulk performance
20535 --
20536 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
20537
20538 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
20539 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
20540
20541 -- 4955764
20542 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20543 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
20544
20545 -- 4458381 Public Sector Enh
20546
20547 --
20548 -- set accounting attributes for the line type
20549 --
20550 l_entered_amt_idx := 3;
20551 l_accted_amt_idx := 8;
20552 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20553 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
20554 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
20555 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
20556 l_rec_acct_attrs.array_char_value(2) := p_source_25;
20557 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
20558 l_rec_acct_attrs.array_num_value(3) := p_source_26;
20559 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
20560 l_rec_acct_attrs.array_char_value(4) := p_source_27;
20561 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
20562 l_rec_acct_attrs.array_date_value(5) := p_source_59;
20563 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
20564 l_rec_acct_attrs.array_num_value(6) := p_source_29;
20565 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
20566 l_rec_acct_attrs.array_char_value(7) := p_source_30;
20567 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
20568 l_rec_acct_attrs.array_num_value(8) := p_source_31;
20569
20570 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
20571 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
20572
20573 ---------------------------------------------------------------------------------------------------------------
20574 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
20575 ---------------------------------------------------------------------------------------------------------------
20576 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
20577
20578 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20582 (p_source_code => 'LEDGER_CATEGORY_CODE'
20579 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20580
20581 IF xla_accounting_cache_pkg.GetValueChar
20583 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
20584 AND l_bflow_method_code = 'PRIOR_ENTRY'
20585 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
20586 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
20587 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
20588 )
20589 THEN
20590 xla_ae_lines_pkg.BflowUpgEntry
20591 (p_business_method_code => l_bflow_method_code
20592 ,p_business_class_code => l_bflow_class_code
20593 ,p_balance_type => l_balance_type_code);
20594 ELSE
20595 NULL;
20596 -- No business flow processing for business flow method of NONE.
20597 END IF;
20598
20599 --
20600 -- call analytical criteria
20601 --
20602
20603 --
20604 -- call description
20605 --
20606 -- No description or it is inherited.
20607 --
20608 -- call ADRs
20609 -- Bug 4922099
20610 --
20611 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20612 (NVL(l_actual_upg_option, 'N') = 'O') OR
20613 (NVL(l_enc_upg_option, 'N') = 'O')
20614 )
20615 THEN
20616 NULL;
20617 --
20618 --
20619
20620 l_ccid := AcctDerRule_11(
20621 p_application_id => p_application_id
20622 , p_ae_header_id => l_ae_header_id
20623 , p_source_10 => p_source_10
20624 , x_transaction_coa_id => l_adr_transaction_coa_id
20625 , x_accounting_coa_id => l_adr_accounting_coa_id
20626 , x_value_type_code => l_adr_value_type_code
20627 , p_side => 'NA'
20628 );
20629
20630 xla_ae_lines_pkg.set_ccid(
20631 p_code_combination_id => l_ccid
20632 , p_value_type_code => l_adr_value_type_code
20633 , p_transaction_coa_id => l_adr_transaction_coa_id
20634 , p_accounting_coa_id => l_adr_accounting_coa_id
20635 , p_adr_code => 'DIST_CCID'
20636 , p_adr_type_code => 'S'
20637 , p_component_type => l_component_type
20638 , p_component_code => l_component_code
20639 , p_component_type_code => l_component_type_code
20640 , p_component_appl_id => l_component_appl_id
20641 , p_amb_context_code => l_amb_context_code
20642 , p_side => 'NA'
20643 );
20644
20645
20646 l_segment := AcctDerRule_20(
20647 p_application_id => p_application_id
20648 , p_ae_header_id => l_ae_header_id
20649 , p_source_14 => p_source_14
20650 , p_source_15 => p_source_15
20651 , p_source_16 => p_source_16
20652 , x_transaction_coa_id => l_adr_transaction_coa_id
20653 , x_accounting_coa_id => l_adr_accounting_coa_id
20654 , x_flexfield_segment_code => l_adr_flexfield_segment_code
20655 , x_flex_value_set_id => l_adr_flex_value_set_id
20656 , x_value_type_code => l_adr_value_type_code
20657 , x_value_combination_id => l_adr_value_combination_id
20658 , x_value_segment_code => l_adr_value_segment_code
20659 , p_side => 'NA'
20660 , p_override_seg_flag => 'Y'
20661 );
20662
20663 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
20664
20665 xla_ae_lines_pkg.set_segment(
20666 p_to_segment_code => 'GL_ACCOUNT'
20667 , p_segment_value => l_segment
20668 , p_from_segment_code => l_adr_value_segment_code
20669 , p_from_combination_id => l_adr_value_combination_id
20670 , p_value_type_code => l_adr_value_type_code
20671 , p_transaction_coa_id => l_adr_transaction_coa_id
20672 , p_accounting_coa_id => l_adr_accounting_coa_id
20673 , p_flexfield_segment_code => l_adr_flexfield_segment_code
20674 , p_flex_value_set_id => l_adr_flex_value_set_id
20675 , p_adr_code => 'FV_AR_465002_MISC_RCT_CR'
20676 , p_adr_type_code => 'S'
20677 , p_component_type => l_component_type
20678 , p_component_code => l_component_code
20679 , p_component_type_code => l_component_type_code
20680 , p_component_appl_id => l_component_appl_id
20681 , p_amb_context_code => l_amb_context_code
20682 , p_entity_code => 'RECEIPTS'
20683 , p_event_class_code => 'MISC_RECEIPT'
20684 , p_side => 'NA'
20685 );
20686
20687 END IF;
20688
20689 --
20690 --
20691 END IF;
20692 --
20693 -- Bug 4922099
20694 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
20695 (NVL(l_enc_upg_option, 'N') = 'O')
20696 ) AND
20697 (l_bflow_method_code = 'PRIOR_ENTRY')
20698 )
20699 THEN
20700 IF
20701 --
20702 1 = 2
20703 --
20704 THEN
20705 xla_accounting_err_pkg.build_message
20706 (p_appli_s_name => 'XLA'
20710 ,p_token_2 => 'LINE_TYPE_NAME'
20707 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20708 ,p_token_1 => 'LINE_NUMBER'
20709 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
20711 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
20712 l_component_type
20713 ,l_component_code
20714 ,l_component_type_code
20715 ,l_component_appl_id
20716 ,l_amb_context_code
20717 ,l_entity_code
20718 ,l_event_class_code
20719 )
20720 ,p_token_3 => 'OWNER'
20721 ,p_value_3 => xla_lookups_pkg.get_meaning(
20722 p_lookup_type => 'XLA_OWNER_TYPE'
20723 ,p_lookup_code => l_component_type_code
20724 )
20725 ,p_token_4 => 'PRODUCT_NAME'
20726 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
20727 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
20728 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
20729 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
20730 ,p_ae_header_id => NULL
20731 );
20732
20733 IF (C_LEVEL_ERROR>= g_log_level) THEN
20734 trace
20735 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20736 ,p_level => C_LEVEL_ERROR
20737 ,p_module => l_log_module);
20738 END IF;
20739 END IF;
20740 END IF;
20741 --
20742 --
20743 ------------------------------------------------------------------------------------------------
20744 -- 4219869 Business Flow
20745 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
20746 -- Prior Entry. Currently, the following code is always generated.
20747 ------------------------------------------------------------------------------------------------
20748 XLA_AE_LINES_PKG.ValidateCurrentLine;
20749
20750 ------------------------------------------------------------------------------------
20751 -- 4219869 Business Flow
20752 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
20753 ------------------------------------------------------------------------------------
20754 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20755
20756 ----------------------------------------------------------------------------------
20757 -- 4219869 Business Flow
20758 -- Update journal entry status -- Need to generate this within IF <condition>
20759 ----------------------------------------------------------------------------------
20760 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20761 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
20762 ,p_balance_type_code => l_balance_type_code
20763 );
20764
20765 -------------------------------------------------------------------------------------------
20766 -- 4262811 - Generate the Accrual Reversal lines
20767 -------------------------------------------------------------------------------------------
20768 BEGIN
20769 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
20770 (g_array_event(p_event_id).array_value_num('header_index'));
20771 IF l_acc_rev_flag IS NULL THEN
20772 l_acc_rev_flag := 'N';
20773 END IF;
20774 EXCEPTION
20775 WHEN OTHERS THEN
20776 l_acc_rev_flag := 'N';
20777 END;
20778 --
20779 IF (l_acc_rev_flag = 'Y') THEN
20780
20781 -- 4645092 ------------------------------------------------------------------------------
20782 -- To allow MPA report to determine if it should generate report process
20783 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
20784 ------------------------------------------------------------------------------------------
20785
20786 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
20787 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
20788 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
20789 -- call ADRs
20790 -- Bug 4922099
20791 --
20792 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20793 (NVL(l_actual_upg_option, 'N') = 'O') OR
20794 (NVL(l_enc_upg_option, 'N') = 'O')
20795 )
20796 THEN
20797 NULL;
20798 --
20802 p_application_id => p_application_id
20799 --
20800
20801 l_ccid := AcctDerRule_11(
20803 , p_ae_header_id => l_ae_header_id
20804 , p_source_10 => p_source_10
20805 , x_transaction_coa_id => l_adr_transaction_coa_id
20806 , x_accounting_coa_id => l_adr_accounting_coa_id
20807 , x_value_type_code => l_adr_value_type_code
20808 , p_side => 'NA'
20809 );
20810
20811 xla_ae_lines_pkg.set_ccid(
20812 p_code_combination_id => l_ccid
20813 , p_value_type_code => l_adr_value_type_code
20814 , p_transaction_coa_id => l_adr_transaction_coa_id
20815 , p_accounting_coa_id => l_adr_accounting_coa_id
20816 , p_adr_code => 'DIST_CCID'
20817 , p_adr_type_code => 'S'
20818 , p_component_type => l_component_type
20819 , p_component_code => l_component_code
20820 , p_component_type_code => l_component_type_code
20821 , p_component_appl_id => l_component_appl_id
20822 , p_amb_context_code => l_amb_context_code
20823 , p_side => 'NA'
20824 );
20825
20826
20827 l_segment := AcctDerRule_20(
20828 p_application_id => p_application_id
20829 , p_ae_header_id => l_ae_header_id
20830 , p_source_14 => p_source_14
20831 , p_source_15 => p_source_15
20832 , p_source_16 => p_source_16
20833 , x_transaction_coa_id => l_adr_transaction_coa_id
20834 , x_accounting_coa_id => l_adr_accounting_coa_id
20835 , x_flexfield_segment_code => l_adr_flexfield_segment_code
20836 , x_flex_value_set_id => l_adr_flex_value_set_id
20837 , x_value_type_code => l_adr_value_type_code
20838 , x_value_combination_id => l_adr_value_combination_id
20839 , x_value_segment_code => l_adr_value_segment_code
20840 , p_side => 'NA'
20841 , p_override_seg_flag => 'Y'
20842 );
20843
20844 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
20845
20846 xla_ae_lines_pkg.set_segment(
20847 p_to_segment_code => 'GL_ACCOUNT'
20848 , p_segment_value => l_segment
20849 , p_from_segment_code => l_adr_value_segment_code
20850 , p_from_combination_id => l_adr_value_combination_id
20851 , p_value_type_code => l_adr_value_type_code
20852 , p_transaction_coa_id => l_adr_transaction_coa_id
20853 , p_accounting_coa_id => l_adr_accounting_coa_id
20854 , p_flexfield_segment_code => l_adr_flexfield_segment_code
20855 , p_flex_value_set_id => l_adr_flex_value_set_id
20856 , p_adr_code => 'FV_AR_465002_MISC_RCT_CR'
20857 , p_adr_type_code => 'S'
20858 , p_component_type => l_component_type
20859 , p_component_code => l_component_code
20860 , p_component_type_code => l_component_type_code
20861 , p_component_appl_id => l_component_appl_id
20862 , p_amb_context_code => l_amb_context_code
20863 , p_entity_code => 'RECEIPTS'
20864 , p_event_class_code => 'MISC_RECEIPT'
20865 , p_side => 'NA'
20866 );
20867
20868 END IF;
20869
20870 --
20871 --
20872 END IF;
20873
20874 --
20875 -- Update the line information that should be overwritten
20876 --
20877 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
20878 p_header_num => 1);
20879 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
20880
20881 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
20882
20883 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
20884 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
20885 END IF;
20886
20887 --
20888 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
20889 --
20890 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
20891 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
20892 ELSE
20893 ---------------------------------------------------------------------------------------------------
20894 -- 4262811a Switch Sign
20895 ---------------------------------------------------------------------------------------------------
20896 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
20897 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
20898 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20899 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
20900 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20901 -- 5132302
20902 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
20906
20903 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20904
20905 END IF;
20907 -- 4955764
20908 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20909 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
20910
20911
20912 XLA_AE_LINES_PKG.ValidateCurrentLine;
20913 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20914
20915 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20916 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
20917 ,p_balance_type_code => l_balance_type_code);
20918
20919 END IF;
20920
20921 -----------------------------------------------------------------------------------------
20922 -- 4262811 Multiperiod Accounting
20923 -----------------------------------------------------------------------------------------
20924 -- No MPA option is assigned.
20925
20926
20927 END IF;
20928 END IF;
20929 --
20930
20931 --
20932 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20933 trace
20934 (p_msg => 'END of AcctLineType_62'
20935 ,p_level => C_LEVEL_PROCEDURE
20936 ,p_module => l_log_module);
20937 END IF;
20938 --
20939 EXCEPTION
20940 WHEN xla_exceptions_pkg.application_exception THEN
20941 RAISE;
20942 WHEN OTHERS THEN
20943 xla_exceptions_pkg.raise_message
20944 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_62');
20945 END AcctLineType_62;
20946 --
20947
20948 ---------------------------------------
20949 --
20950 -- PRIVATE FUNCTION
20951 -- AcctLineType_63
20952 --
20953 ---------------------------------------
20954 PROCEDURE AcctLineType_63 (
20955 p_application_id IN NUMBER
20956 ,p_event_id IN NUMBER
20957 ,p_calculate_acctd_flag IN VARCHAR2
20958 ,p_calculate_g_l_flag IN VARCHAR2
20959 ,p_actual_flag IN OUT VARCHAR2
20960 ,p_balance_type_code OUT VARCHAR2
20961 ,p_gain_or_loss_ref OUT VARCHAR2
20962
20963 --Distribution GL Account
20964 , p_source_10 IN NUMBER
20965 --Federal Fund Expired Status
20966 , p_source_14 IN VARCHAR2
20967 --Federal Prior Year Flag
20968 , p_source_15 IN VARCHAR2
20969 --Federal Fund Time Frame
20970 , p_source_16 IN VARCHAR2
20971 --Distribution Source Type
20972 , p_source_22 IN VARCHAR2
20973 --Distribution Line Identifier
20974 , p_source_24 IN NUMBER
20975 --Distribution Type
20976 , p_source_25 IN VARCHAR2
20977 --Entered Amount
20978 , p_source_26 IN NUMBER
20979 --Currency Code
20980 , p_source_27 IN VARCHAR2
20981 --Exchange Rate
20982 , p_source_29 IN NUMBER
20983 --Exchange Rate Type
20984 , p_source_30 IN VARCHAR2
20985 --Applied To Document Accounting Amount
20986 , p_source_31 IN NUMBER
20987 --Federal Account Valid Flag
20988 , p_source_58 IN VARCHAR2
20989 --Applied To Document Exchange Date
20990 , p_source_59 IN DATE
20991 )
20992 IS
20993
20994 l_component_type VARCHAR2(80);
20995 l_component_code VARCHAR2(30);
20996 l_component_type_code VARCHAR2(1);
20997 l_component_appl_id INTEGER;
20998 l_amb_context_code VARCHAR2(30);
20999 l_entity_code VARCHAR2(30);
21000 l_event_class_code VARCHAR2(30);
21001 l_ae_header_id NUMBER;
21002 l_event_type_code VARCHAR2(30);
21003 l_line_definition_code VARCHAR2(30);
21004 l_line_definition_owner_code VARCHAR2(1);
21005 --
21006 -- adr variables
21007 l_segment VARCHAR2(30);
21008 l_ccid NUMBER;
21009 l_adr_transaction_coa_id NUMBER;
21010 l_adr_accounting_coa_id NUMBER;
21011 l_adr_flexfield_segment_code VARCHAR2(30);
21012 l_adr_flex_value_set_id NUMBER;
21013 l_adr_value_type_code VARCHAR2(30);
21014 l_adr_value_combination_id NUMBER;
21015 l_adr_value_segment_code VARCHAR2(30);
21016
21017 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
21018 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
21019 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
21020 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
21021
21022 -- 4262811 Variables ------------------------------------------------------------------------------------------
21023 l_entered_amt_idx NUMBER;
21024 l_accted_amt_idx NUMBER;
21025 l_acc_rev_flag VARCHAR2(1);
21026 l_accrual_line_num NUMBER;
21027 l_tmp_amt NUMBER;
21028 l_acc_rev_natural_side_code VARCHAR2(1);
21029
21030 l_num_entries NUMBER;
21031 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
21032 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
21033 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
21034 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
21035 l_recog_line_1 NUMBER;
21036 l_recog_line_2 NUMBER;
21037
21041
21038 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
21039 l_bflow_applied_to_amt NUMBER; -- 5132302
21040 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
21042 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
21043
21044 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
21045 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
21046
21047 ---------------------------------------------------------------------------------------------------------------
21048
21049
21050 --
21051 -- bulk performance
21052 --
21053 l_balance_type_code VARCHAR2(1);
21054 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
21055 l_log_module VARCHAR2(240);
21056
21057 --
21058 -- Upgrade strategy
21059 --
21060 l_actual_upg_option VARCHAR2(1);
21061 l_enc_upg_option VARCHAR2(1);
21062
21063 --
21064 BEGIN
21065 --
21066 IF g_log_enabled THEN
21067 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_63';
21068 END IF;
21069 --
21070 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21071
21072 trace
21073 (p_msg => 'BEGIN of AcctLineType_63'
21074 ,p_level => C_LEVEL_PROCEDURE
21075 ,p_module => l_log_module);
21076
21077 END IF;
21078 --
21079 l_component_type := 'AMB_JLT';
21080 l_component_code := 'FV_MISC_RCT_REF_OEF_DR';
21081 l_component_type_code := 'S';
21082 l_component_appl_id := 222;
21083 l_amb_context_code := 'DEFAULT';
21084 l_entity_code := 'RECEIPTS';
21085 l_event_class_code := 'MISC_RECEIPT';
21086 l_event_type_code := 'MISC_RECEIPT_ALL';
21087 l_line_definition_owner_code := 'S';
21088 l_line_definition_code := 'MFAR_FED_AR_MISC_REC_ACCOUNT';
21089 --
21090 l_balance_type_code := 'A';
21091 l_segment := NULL;
21092 l_ccid := NULL;
21093 l_adr_transaction_coa_id := NULL;
21094 l_adr_accounting_coa_id := NULL;
21095 l_adr_flexfield_segment_code := NULL;
21096 l_adr_flex_value_set_id := NULL;
21097 l_adr_value_type_code := NULL;
21098 l_adr_value_combination_id := NULL;
21099 l_adr_value_segment_code := NULL;
21100
21101 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
21102 l_bflow_class_code := ''; -- 4219869 Business Flow
21103 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
21104 l_budgetary_control_flag := 'N';
21105
21106 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21107 l_bflow_applied_to_amt := NULL; -- 5132302
21108 l_entered_amt_idx := NULL; -- 4262811
21109 l_accted_amt_idx := NULL; -- 4262811
21110 l_acc_rev_flag := NULL; -- 4262811
21111 l_accrual_line_num := NULL; -- 4262811
21112 l_tmp_amt := NULL; -- 4262811
21113 --
21114
21115 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
21116 l_balance_type_code <> 'B' THEN
21117 IF NVL(p_source_22,'
21118 ') = 'MISCCASH' AND
21119 NVL(p_source_14,'
21120 ') = 'Expired' AND
21121 NVL(p_source_15,'
21122 ') = 'Y' AND
21123 (NVL(p_source_16,'
21124 ') = 'SINGLE' OR
21125 NVL(p_source_16,'
21126 ') = 'MULTIPLE' OR
21127 NVL(p_source_16,'
21128 ') = 'NO_YEAR') AND
21129 NVL(p_source_58,'
21130 ') = 'Y'
21131 THEN
21132
21133 --
21134 XLA_AE_LINES_PKG.SetNewLine;
21135
21136 p_balance_type_code := l_balance_type_code;
21137 -- set the flag so later we will know whether the gain loss line needs to be created
21138
21139 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
21140 p_actual_flag :='A';
21141 END IF;
21142
21143 --
21144 -- bulk performance
21145 --
21146 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
21147 p_header_num => 0); -- 4262811
21148 --
21149 -- set accounting line options
21150 --
21151 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
21152 p_natural_side_code => 'D'
21153 , p_gain_or_loss_flag => 'N'
21154 , p_gl_transfer_mode_code => 'S'
21155 , p_acct_entry_type_code => 'A'
21156 , p_switch_side_flag => 'Y'
21157 , p_merge_duplicate_code => 'A'
21158 );
21159 --
21160 l_acc_rev_natural_side_code := 'C'; -- 4262811
21161 --
21162 --
21163 -- set accounting line type info
21164 --
21165 xla_ae_lines_pkg.SetAcctLineType
21166 (p_component_type => l_component_type
21167 ,p_event_type_code => l_event_type_code
21168 ,p_line_definition_owner_code => l_line_definition_owner_code
21169 ,p_line_definition_code => l_line_definition_code
21170 ,p_accounting_line_code => l_component_code
21171 ,p_accounting_line_type_code => l_component_type_code
21172 ,p_accounting_line_appl_id => l_component_appl_id
21173 ,p_amb_context_code => l_amb_context_code
21174 ,p_entity_code => l_entity_code
21178 --
21175 ,p_event_class_code => l_event_class_code);
21176 --
21177 -- set accounting class
21179 xla_ae_lines_pkg.SetAcctClass(
21180 p_accounting_class_code => 'FV_MISCCASH_DR'
21181 , p_ae_header_id => l_ae_header_id
21182 );
21183
21184 --
21185 -- set rounding class
21186 --
21187 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
21188 'RECEIVABLE';
21189
21190 --
21191 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
21192 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
21193 --
21194 -- bulk performance
21195 --
21196 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
21197
21198 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
21199 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
21200
21201 -- 4955764
21202 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21203 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
21204
21205 -- 4458381 Public Sector Enh
21206
21207 --
21208 -- set accounting attributes for the line type
21209 --
21210 l_entered_amt_idx := 3;
21211 l_accted_amt_idx := 8;
21212 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21213 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
21214 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
21215 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
21216 l_rec_acct_attrs.array_char_value(2) := p_source_25;
21217 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
21218 l_rec_acct_attrs.array_num_value(3) := p_source_26;
21219 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
21220 l_rec_acct_attrs.array_char_value(4) := p_source_27;
21221 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
21222 l_rec_acct_attrs.array_date_value(5) := p_source_59;
21223 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
21224 l_rec_acct_attrs.array_num_value(6) := p_source_29;
21225 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
21226 l_rec_acct_attrs.array_char_value(7) := p_source_30;
21227 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
21228 l_rec_acct_attrs.array_num_value(8) := p_source_31;
21229
21230 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
21231 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
21232
21233 ---------------------------------------------------------------------------------------------------------------
21234 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
21235 ---------------------------------------------------------------------------------------------------------------
21236 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
21237
21238 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21239 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21240
21241 IF xla_accounting_cache_pkg.GetValueChar
21242 (p_source_code => 'LEDGER_CATEGORY_CODE'
21243 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
21244 AND l_bflow_method_code = 'PRIOR_ENTRY'
21245 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
21246 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
21247 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
21248 )
21249 THEN
21250 xla_ae_lines_pkg.BflowUpgEntry
21251 (p_business_method_code => l_bflow_method_code
21252 ,p_business_class_code => l_bflow_class_code
21253 ,p_balance_type => l_balance_type_code);
21254 ELSE
21255 NULL;
21256 -- No business flow processing for business flow method of NONE.
21257 END IF;
21258
21259 --
21260 -- call analytical criteria
21261 --
21262
21263 --
21264 -- call description
21265 --
21266 -- No description or it is inherited.
21267 --
21268 -- call ADRs
21269 -- Bug 4922099
21270 --
21271 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21272 (NVL(l_actual_upg_option, 'N') = 'O') OR
21273 (NVL(l_enc_upg_option, 'N') = 'O')
21274 )
21275 THEN
21276 NULL;
21277 --
21278 --
21279
21280 l_ccid := AcctDerRule_11(
21281 p_application_id => p_application_id
21282 , p_ae_header_id => l_ae_header_id
21283 , p_source_10 => p_source_10
21284 , x_transaction_coa_id => l_adr_transaction_coa_id
21285 , x_accounting_coa_id => l_adr_accounting_coa_id
21286 , x_value_type_code => l_adr_value_type_code
21287 , p_side => 'NA'
21288 );
21289
21290 xla_ae_lines_pkg.set_ccid(
21291 p_code_combination_id => l_ccid
21292 , p_value_type_code => l_adr_value_type_code
21296 , p_adr_type_code => 'S'
21293 , p_transaction_coa_id => l_adr_transaction_coa_id
21294 , p_accounting_coa_id => l_adr_accounting_coa_id
21295 , p_adr_code => 'DIST_CCID'
21297 , p_component_type => l_component_type
21298 , p_component_code => l_component_code
21299 , p_component_type_code => l_component_type_code
21300 , p_component_appl_id => l_component_appl_id
21301 , p_amb_context_code => l_amb_context_code
21302 , p_side => 'NA'
21303 );
21304
21305
21306 l_segment := AcctDerRule_25(
21307 p_application_id => p_application_id
21308 , p_ae_header_id => l_ae_header_id
21309 , p_source_14 => p_source_14
21310 , p_source_15 => p_source_15
21311 , p_source_16 => p_source_16
21312 , x_transaction_coa_id => l_adr_transaction_coa_id
21313 , x_accounting_coa_id => l_adr_accounting_coa_id
21314 , x_flexfield_segment_code => l_adr_flexfield_segment_code
21315 , x_flex_value_set_id => l_adr_flex_value_set_id
21316 , x_value_type_code => l_adr_value_type_code
21317 , x_value_combination_id => l_adr_value_combination_id
21318 , x_value_segment_code => l_adr_value_segment_code
21319 , p_side => 'NA'
21320 , p_override_seg_flag => 'Y'
21321 );
21322
21323 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
21324
21325 xla_ae_lines_pkg.set_segment(
21326 p_to_segment_code => 'GL_ACCOUNT'
21327 , p_segment_value => l_segment
21328 , p_from_segment_code => l_adr_value_segment_code
21329 , p_from_combination_id => l_adr_value_combination_id
21330 , p_value_type_code => l_adr_value_type_code
21331 , p_transaction_coa_id => l_adr_transaction_coa_id
21332 , p_accounting_coa_id => l_adr_accounting_coa_id
21333 , p_flexfield_segment_code => l_adr_flexfield_segment_code
21334 , p_flex_value_set_id => l_adr_flex_value_set_id
21335 , p_adr_code => 'FV_AR_497201_MISC_RCT_DR'
21336 , p_adr_type_code => 'S'
21337 , p_component_type => l_component_type
21338 , p_component_code => l_component_code
21339 , p_component_type_code => l_component_type_code
21340 , p_component_appl_id => l_component_appl_id
21341 , p_amb_context_code => l_amb_context_code
21342 , p_entity_code => 'RECEIPTS'
21343 , p_event_class_code => 'MISC_RECEIPT'
21344 , p_side => 'NA'
21345 );
21346
21347 END IF;
21348
21349 --
21350 --
21351 END IF;
21352 --
21353 -- Bug 4922099
21354 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
21355 (NVL(l_enc_upg_option, 'N') = 'O')
21356 ) AND
21357 (l_bflow_method_code = 'PRIOR_ENTRY')
21358 )
21359 THEN
21360 IF
21361 --
21362 1 = 2
21363 --
21364 THEN
21365 xla_accounting_err_pkg.build_message
21366 (p_appli_s_name => 'XLA'
21367 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
21368 ,p_token_1 => 'LINE_NUMBER'
21369 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
21370 ,p_token_2 => 'LINE_TYPE_NAME'
21371 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
21372 l_component_type
21373 ,l_component_code
21374 ,l_component_type_code
21375 ,l_component_appl_id
21376 ,l_amb_context_code
21377 ,l_entity_code
21378 ,l_event_class_code
21379 )
21380 ,p_token_3 => 'OWNER'
21381 ,p_value_3 => xla_lookups_pkg.get_meaning(
21382 p_lookup_type => 'XLA_OWNER_TYPE'
21383 ,p_lookup_code => l_component_type_code
21384 )
21385 ,p_token_4 => 'PRODUCT_NAME'
21386 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
21387 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
21388 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
21389 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
21390 ,p_ae_header_id => NULL
21394 trace
21391 );
21392
21393 IF (C_LEVEL_ERROR>= g_log_level) THEN
21395 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
21396 ,p_level => C_LEVEL_ERROR
21397 ,p_module => l_log_module);
21398 END IF;
21399 END IF;
21400 END IF;
21401 --
21402 --
21403 ------------------------------------------------------------------------------------------------
21404 -- 4219869 Business Flow
21405 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
21406 -- Prior Entry. Currently, the following code is always generated.
21407 ------------------------------------------------------------------------------------------------
21408 XLA_AE_LINES_PKG.ValidateCurrentLine;
21409
21410 ------------------------------------------------------------------------------------
21411 -- 4219869 Business Flow
21412 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
21413 ------------------------------------------------------------------------------------
21414 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21415
21416 ----------------------------------------------------------------------------------
21417 -- 4219869 Business Flow
21418 -- Update journal entry status -- Need to generate this within IF <condition>
21419 ----------------------------------------------------------------------------------
21420 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21421 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
21422 ,p_balance_type_code => l_balance_type_code
21423 );
21424
21425 -------------------------------------------------------------------------------------------
21426 -- 4262811 - Generate the Accrual Reversal lines
21427 -------------------------------------------------------------------------------------------
21428 BEGIN
21429 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
21430 (g_array_event(p_event_id).array_value_num('header_index'));
21431 IF l_acc_rev_flag IS NULL THEN
21432 l_acc_rev_flag := 'N';
21433 END IF;
21434 EXCEPTION
21435 WHEN OTHERS THEN
21436 l_acc_rev_flag := 'N';
21437 END;
21438 --
21439 IF (l_acc_rev_flag = 'Y') THEN
21440
21441 -- 4645092 ------------------------------------------------------------------------------
21442 -- To allow MPA report to determine if it should generate report process
21443 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
21444 ------------------------------------------------------------------------------------------
21445
21446 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
21447 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
21448 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
21449 -- call ADRs
21450 -- Bug 4922099
21451 --
21452 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21453 (NVL(l_actual_upg_option, 'N') = 'O') OR
21454 (NVL(l_enc_upg_option, 'N') = 'O')
21455 )
21456 THEN
21457 NULL;
21458 --
21459 --
21460
21461 l_ccid := AcctDerRule_11(
21462 p_application_id => p_application_id
21463 , p_ae_header_id => l_ae_header_id
21464 , p_source_10 => p_source_10
21465 , x_transaction_coa_id => l_adr_transaction_coa_id
21466 , x_accounting_coa_id => l_adr_accounting_coa_id
21467 , x_value_type_code => l_adr_value_type_code
21468 , p_side => 'NA'
21469 );
21470
21471 xla_ae_lines_pkg.set_ccid(
21472 p_code_combination_id => l_ccid
21473 , p_value_type_code => l_adr_value_type_code
21474 , p_transaction_coa_id => l_adr_transaction_coa_id
21475 , p_accounting_coa_id => l_adr_accounting_coa_id
21476 , p_adr_code => 'DIST_CCID'
21477 , p_adr_type_code => 'S'
21478 , p_component_type => l_component_type
21479 , p_component_code => l_component_code
21480 , p_component_type_code => l_component_type_code
21481 , p_component_appl_id => l_component_appl_id
21482 , p_amb_context_code => l_amb_context_code
21483 , p_side => 'NA'
21484 );
21485
21486
21487 l_segment := AcctDerRule_25(
21488 p_application_id => p_application_id
21489 , p_ae_header_id => l_ae_header_id
21490 , p_source_14 => p_source_14
21491 , p_source_15 => p_source_15
21492 , p_source_16 => p_source_16
21493 , x_transaction_coa_id => l_adr_transaction_coa_id
21494 , x_accounting_coa_id => l_adr_accounting_coa_id
21495 , x_flexfield_segment_code => l_adr_flexfield_segment_code
21496 , x_flex_value_set_id => l_adr_flex_value_set_id
21497 , x_value_type_code => l_adr_value_type_code
21498 , x_value_combination_id => l_adr_value_combination_id
21499 , x_value_segment_code => l_adr_value_segment_code
21500 , p_side => 'NA'
21501 , p_override_seg_flag => 'Y'
21502 );
21503
21507 p_to_segment_code => 'GL_ACCOUNT'
21504 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
21505
21506 xla_ae_lines_pkg.set_segment(
21508 , p_segment_value => l_segment
21509 , p_from_segment_code => l_adr_value_segment_code
21510 , p_from_combination_id => l_adr_value_combination_id
21511 , p_value_type_code => l_adr_value_type_code
21512 , p_transaction_coa_id => l_adr_transaction_coa_id
21513 , p_accounting_coa_id => l_adr_accounting_coa_id
21514 , p_flexfield_segment_code => l_adr_flexfield_segment_code
21515 , p_flex_value_set_id => l_adr_flex_value_set_id
21516 , p_adr_code => 'FV_AR_497201_MISC_RCT_DR'
21517 , p_adr_type_code => 'S'
21518 , p_component_type => l_component_type
21519 , p_component_code => l_component_code
21520 , p_component_type_code => l_component_type_code
21521 , p_component_appl_id => l_component_appl_id
21522 , p_amb_context_code => l_amb_context_code
21523 , p_entity_code => 'RECEIPTS'
21524 , p_event_class_code => 'MISC_RECEIPT'
21525 , p_side => 'NA'
21526 );
21527
21528 END IF;
21529
21530 --
21531 --
21532 END IF;
21533
21534 --
21535 -- Update the line information that should be overwritten
21536 --
21537 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
21538 p_header_num => 1);
21539 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
21540
21541 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
21542
21543 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
21544 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
21545 END IF;
21546
21547 --
21548 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
21549 --
21550 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
21551 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
21552 ELSE
21553 ---------------------------------------------------------------------------------------------------
21554 -- 4262811a Switch Sign
21555 ---------------------------------------------------------------------------------------------------
21556 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
21557 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21558 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21559 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21560 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21561 -- 5132302
21562 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
21563 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21564
21565 END IF;
21566
21567 -- 4955764
21568 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21569 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
21570
21571
21572 XLA_AE_LINES_PKG.ValidateCurrentLine;
21573 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21574
21575 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21576 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
21577 ,p_balance_type_code => l_balance_type_code);
21578
21579 END IF;
21580
21581 -----------------------------------------------------------------------------------------
21582 -- 4262811 Multiperiod Accounting
21583 -----------------------------------------------------------------------------------------
21584 -- No MPA option is assigned.
21585
21586
21587 END IF;
21588 END IF;
21589 --
21590
21591 --
21592 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21593 trace
21594 (p_msg => 'END of AcctLineType_63'
21595 ,p_level => C_LEVEL_PROCEDURE
21596 ,p_module => l_log_module);
21597 END IF;
21598 --
21599 EXCEPTION
21600 WHEN xla_exceptions_pkg.application_exception THEN
21601 RAISE;
21602 WHEN OTHERS THEN
21603 xla_exceptions_pkg.raise_message
21604 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_63');
21605 END AcctLineType_63;
21606 --
21607
21608 ---------------------------------------
21609 --
21610 -- PRIVATE FUNCTION
21611 -- AcctLineType_64
21612 --
21613 ---------------------------------------
21614 PROCEDURE AcctLineType_64 (
21615 p_application_id IN NUMBER
21616 ,p_event_id IN NUMBER
21617 ,p_calculate_acctd_flag IN VARCHAR2
21618 ,p_calculate_g_l_flag IN VARCHAR2
21619 ,p_actual_flag IN OUT VARCHAR2
21623 --Distribution GL Account
21620 ,p_balance_type_code OUT VARCHAR2
21621 ,p_gain_or_loss_ref OUT VARCHAR2
21622
21624 , p_source_10 IN NUMBER
21625 --Federal Fund Expired Status
21626 , p_source_14 IN VARCHAR2
21627 --Federal Prior Year Flag
21628 , p_source_15 IN VARCHAR2
21629 --Federal Fund Time Frame
21630 , p_source_16 IN VARCHAR2
21631 --Federal Apportionment Category
21632 , p_source_17 IN VARCHAR2
21633 --Distribution Source Type
21634 , p_source_22 IN VARCHAR2
21635 --Distribution Line Identifier
21636 , p_source_24 IN NUMBER
21637 --Distribution Type
21638 , p_source_25 IN VARCHAR2
21639 --Entered Amount
21640 , p_source_26 IN NUMBER
21641 --Currency Code
21642 , p_source_27 IN VARCHAR2
21643 --Exchange Rate
21644 , p_source_29 IN NUMBER
21645 --Exchange Rate Type
21646 , p_source_30 IN VARCHAR2
21647 --Applied To Document Accounting Amount
21648 , p_source_31 IN NUMBER
21649 --Federal Account Valid Flag
21650 , p_source_58 IN VARCHAR2
21651 --Applied To Document Exchange Date
21652 , p_source_59 IN DATE
21653 )
21654 IS
21655
21656 l_component_type VARCHAR2(80);
21657 l_component_code VARCHAR2(30);
21658 l_component_type_code VARCHAR2(1);
21659 l_component_appl_id INTEGER;
21660 l_amb_context_code VARCHAR2(30);
21661 l_entity_code VARCHAR2(30);
21662 l_event_class_code VARCHAR2(30);
21663 l_ae_header_id NUMBER;
21664 l_event_type_code VARCHAR2(30);
21665 l_line_definition_code VARCHAR2(30);
21666 l_line_definition_owner_code VARCHAR2(1);
21667 --
21668 -- adr variables
21669 l_segment VARCHAR2(30);
21670 l_ccid NUMBER;
21671 l_adr_transaction_coa_id NUMBER;
21672 l_adr_accounting_coa_id NUMBER;
21673 l_adr_flexfield_segment_code VARCHAR2(30);
21674 l_adr_flex_value_set_id NUMBER;
21675 l_adr_value_type_code VARCHAR2(30);
21676 l_adr_value_combination_id NUMBER;
21677 l_adr_value_segment_code VARCHAR2(30);
21678
21679 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
21680 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
21681 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
21682 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
21683
21684 -- 4262811 Variables ------------------------------------------------------------------------------------------
21685 l_entered_amt_idx NUMBER;
21686 l_accted_amt_idx NUMBER;
21687 l_acc_rev_flag VARCHAR2(1);
21688 l_accrual_line_num NUMBER;
21689 l_tmp_amt NUMBER;
21690 l_acc_rev_natural_side_code VARCHAR2(1);
21691
21692 l_num_entries NUMBER;
21693 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
21694 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
21695 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
21696 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
21697 l_recog_line_1 NUMBER;
21698 l_recog_line_2 NUMBER;
21699
21700 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
21701 l_bflow_applied_to_amt NUMBER; -- 5132302
21702 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
21703
21704 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
21705
21706 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
21707 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
21708
21709 ---------------------------------------------------------------------------------------------------------------
21710
21711
21712 --
21713 -- bulk performance
21714 --
21715 l_balance_type_code VARCHAR2(1);
21716 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
21717 l_log_module VARCHAR2(240);
21718
21719 --
21720 -- Upgrade strategy
21721 --
21722 l_actual_upg_option VARCHAR2(1);
21723 l_enc_upg_option VARCHAR2(1);
21724
21725 --
21726 BEGIN
21727 --
21728 IF g_log_enabled THEN
21729 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_64';
21730 END IF;
21731 --
21732 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21733
21734 trace
21735 (p_msg => 'BEGIN of AcctLineType_64'
21736 ,p_level => C_LEVEL_PROCEDURE
21737 ,p_module => l_log_module);
21738
21739 END IF;
21740 --
21741 l_component_type := 'AMB_JLT';
21742 l_component_code := 'FV_MISC_RCT_REF_OUFC_CR';
21743 l_component_type_code := 'S';
21744 l_component_appl_id := 222;
21745 l_amb_context_code := 'DEFAULT';
21746 l_entity_code := 'RECEIPTS';
21747 l_event_class_code := 'MISC_RECEIPT';
21748 l_event_type_code := 'MISC_RECEIPT_ALL';
21749 l_line_definition_owner_code := 'S';
21750 l_line_definition_code := 'MFAR_FED_AR_MISC_REC_ACCOUNT';
21751 --
21752 l_balance_type_code := 'A';
21753 l_segment := NULL;
21754 l_ccid := NULL;
21758 l_adr_flex_value_set_id := NULL;
21755 l_adr_transaction_coa_id := NULL;
21756 l_adr_accounting_coa_id := NULL;
21757 l_adr_flexfield_segment_code := NULL;
21759 l_adr_value_type_code := NULL;
21760 l_adr_value_combination_id := NULL;
21761 l_adr_value_segment_code := NULL;
21762
21763 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
21764 l_bflow_class_code := ''; -- 4219869 Business Flow
21765 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
21766 l_budgetary_control_flag := 'N';
21767
21768 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21769 l_bflow_applied_to_amt := NULL; -- 5132302
21770 l_entered_amt_idx := NULL; -- 4262811
21771 l_accted_amt_idx := NULL; -- 4262811
21772 l_acc_rev_flag := NULL; -- 4262811
21773 l_accrual_line_num := NULL; -- 4262811
21774 l_tmp_amt := NULL; -- 4262811
21775 --
21776
21777 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
21778 l_balance_type_code <> 'B' THEN
21779 IF NVL(p_source_22,'
21780 ') = 'MISCCASH' AND
21781 NVL(p_source_14,'
21782 ') = 'Unexpired' AND
21783 NVL(p_source_15,'
21784 ') = 'N' AND
21785 (NVL(p_source_17,'
21786 ') = 'A' OR
21787 NVL(p_source_17,'
21788 ') = 'B' OR
21789 NVL(p_source_17,'
21790 ') = 'C') AND
21791 (NVL(p_source_16,'
21792 ') = 'SINGLE' OR
21793 NVL(p_source_16,'
21794 ') = 'MULTIPLE' OR
21795 NVL(p_source_16,'
21796 ') = 'NO_YEAR') AND
21797 NVL(p_source_58,'
21798 ') = 'Y'
21799 THEN
21800
21801 --
21802 XLA_AE_LINES_PKG.SetNewLine;
21803
21804 p_balance_type_code := l_balance_type_code;
21805 -- set the flag so later we will know whether the gain loss line needs to be created
21806
21807 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
21808 p_actual_flag :='A';
21809 END IF;
21810
21811 --
21812 -- bulk performance
21813 --
21814 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
21815 p_header_num => 0); -- 4262811
21816 --
21817 -- set accounting line options
21818 --
21819 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
21820 p_natural_side_code => 'C'
21821 , p_gain_or_loss_flag => 'N'
21822 , p_gl_transfer_mode_code => 'S'
21823 , p_acct_entry_type_code => 'A'
21824 , p_switch_side_flag => 'Y'
21825 , p_merge_duplicate_code => 'A'
21826 );
21827 --
21828 l_acc_rev_natural_side_code := 'D'; -- 4262811
21829 --
21830 --
21831 -- set accounting line type info
21832 --
21833 xla_ae_lines_pkg.SetAcctLineType
21834 (p_component_type => l_component_type
21835 ,p_event_type_code => l_event_type_code
21836 ,p_line_definition_owner_code => l_line_definition_owner_code
21837 ,p_line_definition_code => l_line_definition_code
21838 ,p_accounting_line_code => l_component_code
21839 ,p_accounting_line_type_code => l_component_type_code
21840 ,p_accounting_line_appl_id => l_component_appl_id
21841 ,p_amb_context_code => l_amb_context_code
21842 ,p_entity_code => l_entity_code
21843 ,p_event_class_code => l_event_class_code);
21844 --
21845 -- set accounting class
21846 --
21847 xla_ae_lines_pkg.SetAcctClass(
21848 p_accounting_class_code => 'FV_MISCCASH_CR'
21849 , p_ae_header_id => l_ae_header_id
21850 );
21851
21852 --
21853 -- set rounding class
21854 --
21855 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
21856 'RECEIVABLE';
21857
21858 --
21859 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
21860 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
21861 --
21862 -- bulk performance
21863 --
21864 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
21865
21866 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
21867 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
21868
21869 -- 4955764
21870 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21871 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
21872
21873 -- 4458381 Public Sector Enh
21874
21875 --
21876 -- set accounting attributes for the line type
21877 --
21878 l_entered_amt_idx := 3;
21879 l_accted_amt_idx := 8;
21880 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21881 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
21882 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
21883 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
21884 l_rec_acct_attrs.array_char_value(2) := p_source_25;
21885 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
21886 l_rec_acct_attrs.array_num_value(3) := p_source_26;
21890 l_rec_acct_attrs.array_date_value(5) := p_source_59;
21887 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
21888 l_rec_acct_attrs.array_char_value(4) := p_source_27;
21889 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
21891 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
21892 l_rec_acct_attrs.array_num_value(6) := p_source_29;
21893 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
21894 l_rec_acct_attrs.array_char_value(7) := p_source_30;
21895 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
21896 l_rec_acct_attrs.array_num_value(8) := p_source_31;
21897
21898 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
21899 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
21900
21901 ---------------------------------------------------------------------------------------------------------------
21902 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
21903 ---------------------------------------------------------------------------------------------------------------
21904 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
21905
21906 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21907 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21908
21909 IF xla_accounting_cache_pkg.GetValueChar
21910 (p_source_code => 'LEDGER_CATEGORY_CODE'
21911 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
21912 AND l_bflow_method_code = 'PRIOR_ENTRY'
21913 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
21914 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
21915 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
21916 )
21917 THEN
21918 xla_ae_lines_pkg.BflowUpgEntry
21919 (p_business_method_code => l_bflow_method_code
21920 ,p_business_class_code => l_bflow_class_code
21921 ,p_balance_type => l_balance_type_code);
21922 ELSE
21923 NULL;
21924 -- No business flow processing for business flow method of NONE.
21925 END IF;
21926
21927 --
21928 -- call analytical criteria
21929 --
21930
21931 --
21932 -- call description
21933 --
21934 -- No description or it is inherited.
21935 --
21936 -- call ADRs
21937 -- Bug 4922099
21938 --
21939 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21940 (NVL(l_actual_upg_option, 'N') = 'O') OR
21941 (NVL(l_enc_upg_option, 'N') = 'O')
21942 )
21943 THEN
21944 NULL;
21945 --
21946 --
21947
21948 l_ccid := AcctDerRule_11(
21949 p_application_id => p_application_id
21950 , p_ae_header_id => l_ae_header_id
21951 , p_source_10 => p_source_10
21952 , x_transaction_coa_id => l_adr_transaction_coa_id
21953 , x_accounting_coa_id => l_adr_accounting_coa_id
21954 , x_value_type_code => l_adr_value_type_code
21955 , p_side => 'NA'
21956 );
21957
21958 xla_ae_lines_pkg.set_ccid(
21959 p_code_combination_id => l_ccid
21960 , p_value_type_code => l_adr_value_type_code
21961 , p_transaction_coa_id => l_adr_transaction_coa_id
21962 , p_accounting_coa_id => l_adr_accounting_coa_id
21963 , p_adr_code => 'DIST_CCID'
21964 , p_adr_type_code => 'S'
21965 , p_component_type => l_component_type
21966 , p_component_code => l_component_code
21967 , p_component_type_code => l_component_type_code
21968 , p_component_appl_id => l_component_appl_id
21969 , p_amb_context_code => l_amb_context_code
21970 , p_side => 'NA'
21971 );
21972
21973
21974 l_segment := AcctDerRule_22(
21975 p_application_id => p_application_id
21976 , p_ae_header_id => l_ae_header_id
21977 , p_source_14 => p_source_14
21978 , p_source_15 => p_source_15
21979 , p_source_16 => p_source_16
21980 , p_source_17 => p_source_17
21981 , x_transaction_coa_id => l_adr_transaction_coa_id
21982 , x_accounting_coa_id => l_adr_accounting_coa_id
21983 , x_flexfield_segment_code => l_adr_flexfield_segment_code
21984 , x_flex_value_set_id => l_adr_flex_value_set_id
21985 , x_value_type_code => l_adr_value_type_code
21986 , x_value_combination_id => l_adr_value_combination_id
21987 , x_value_segment_code => l_adr_value_segment_code
21988 , p_side => 'NA'
21989 , p_override_seg_flag => 'Y'
21990 );
21991
21992 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
21993
21994 xla_ae_lines_pkg.set_segment(
21995 p_to_segment_code => 'GL_ACCOUNT'
21996 , p_segment_value => l_segment
21997 , p_from_segment_code => l_adr_value_segment_code
21998 , p_from_combination_id => l_adr_value_combination_id
21999 , p_value_type_code => l_adr_value_type_code
22000 , p_transaction_coa_id => l_adr_transaction_coa_id
22004 , p_adr_code => 'FV_AR_46X002_MISC_RCT_CR'
22001 , p_accounting_coa_id => l_adr_accounting_coa_id
22002 , p_flexfield_segment_code => l_adr_flexfield_segment_code
22003 , p_flex_value_set_id => l_adr_flex_value_set_id
22005 , p_adr_type_code => 'S'
22006 , p_component_type => l_component_type
22007 , p_component_code => l_component_code
22008 , p_component_type_code => l_component_type_code
22009 , p_component_appl_id => l_component_appl_id
22010 , p_amb_context_code => l_amb_context_code
22011 , p_entity_code => 'RECEIPTS'
22012 , p_event_class_code => 'MISC_RECEIPT'
22013 , p_side => 'NA'
22014 );
22015
22016 END IF;
22017
22018 --
22019 --
22020 END IF;
22021 --
22022 -- Bug 4922099
22023 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
22024 (NVL(l_enc_upg_option, 'N') = 'O')
22025 ) AND
22026 (l_bflow_method_code = 'PRIOR_ENTRY')
22027 )
22028 THEN
22029 IF
22030 --
22031 1 = 2
22032 --
22033 THEN
22034 xla_accounting_err_pkg.build_message
22035 (p_appli_s_name => 'XLA'
22036 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22037 ,p_token_1 => 'LINE_NUMBER'
22038 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
22039 ,p_token_2 => 'LINE_TYPE_NAME'
22040 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
22041 l_component_type
22042 ,l_component_code
22043 ,l_component_type_code
22044 ,l_component_appl_id
22045 ,l_amb_context_code
22046 ,l_entity_code
22047 ,l_event_class_code
22048 )
22049 ,p_token_3 => 'OWNER'
22050 ,p_value_3 => xla_lookups_pkg.get_meaning(
22051 p_lookup_type => 'XLA_OWNER_TYPE'
22052 ,p_lookup_code => l_component_type_code
22053 )
22054 ,p_token_4 => 'PRODUCT_NAME'
22055 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
22056 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
22057 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
22058 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
22059 ,p_ae_header_id => NULL
22060 );
22061
22062 IF (C_LEVEL_ERROR>= g_log_level) THEN
22063 trace
22064 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22065 ,p_level => C_LEVEL_ERROR
22066 ,p_module => l_log_module);
22067 END IF;
22068 END IF;
22069 END IF;
22070 --
22071 --
22072 ------------------------------------------------------------------------------------------------
22073 -- 4219869 Business Flow
22074 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
22075 -- Prior Entry. Currently, the following code is always generated.
22076 ------------------------------------------------------------------------------------------------
22077 XLA_AE_LINES_PKG.ValidateCurrentLine;
22078
22079 ------------------------------------------------------------------------------------
22080 -- 4219869 Business Flow
22081 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
22082 ------------------------------------------------------------------------------------
22083 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22084
22085 ----------------------------------------------------------------------------------
22086 -- 4219869 Business Flow
22087 -- Update journal entry status -- Need to generate this within IF <condition>
22088 ----------------------------------------------------------------------------------
22089 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22090 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
22091 ,p_balance_type_code => l_balance_type_code
22092 );
22093
22094 -------------------------------------------------------------------------------------------
22095 -- 4262811 - Generate the Accrual Reversal lines
22099 (g_array_event(p_event_id).array_value_num('header_index'));
22096 -------------------------------------------------------------------------------------------
22097 BEGIN
22098 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
22100 IF l_acc_rev_flag IS NULL THEN
22101 l_acc_rev_flag := 'N';
22102 END IF;
22103 EXCEPTION
22104 WHEN OTHERS THEN
22105 l_acc_rev_flag := 'N';
22106 END;
22107 --
22108 IF (l_acc_rev_flag = 'Y') THEN
22109
22110 -- 4645092 ------------------------------------------------------------------------------
22111 -- To allow MPA report to determine if it should generate report process
22112 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
22113 ------------------------------------------------------------------------------------------
22114
22115 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
22116 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
22117 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
22118 -- call ADRs
22119 -- Bug 4922099
22120 --
22121 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22122 (NVL(l_actual_upg_option, 'N') = 'O') OR
22123 (NVL(l_enc_upg_option, 'N') = 'O')
22124 )
22125 THEN
22126 NULL;
22127 --
22128 --
22129
22130 l_ccid := AcctDerRule_11(
22131 p_application_id => p_application_id
22132 , p_ae_header_id => l_ae_header_id
22133 , p_source_10 => p_source_10
22134 , x_transaction_coa_id => l_adr_transaction_coa_id
22135 , x_accounting_coa_id => l_adr_accounting_coa_id
22136 , x_value_type_code => l_adr_value_type_code
22137 , p_side => 'NA'
22138 );
22139
22140 xla_ae_lines_pkg.set_ccid(
22141 p_code_combination_id => l_ccid
22142 , p_value_type_code => l_adr_value_type_code
22143 , p_transaction_coa_id => l_adr_transaction_coa_id
22144 , p_accounting_coa_id => l_adr_accounting_coa_id
22145 , p_adr_code => 'DIST_CCID'
22146 , p_adr_type_code => 'S'
22147 , p_component_type => l_component_type
22148 , p_component_code => l_component_code
22149 , p_component_type_code => l_component_type_code
22150 , p_component_appl_id => l_component_appl_id
22151 , p_amb_context_code => l_amb_context_code
22152 , p_side => 'NA'
22153 );
22154
22155
22156 l_segment := AcctDerRule_22(
22157 p_application_id => p_application_id
22158 , p_ae_header_id => l_ae_header_id
22159 , p_source_14 => p_source_14
22160 , p_source_15 => p_source_15
22161 , p_source_16 => p_source_16
22162 , p_source_17 => p_source_17
22163 , x_transaction_coa_id => l_adr_transaction_coa_id
22164 , x_accounting_coa_id => l_adr_accounting_coa_id
22165 , x_flexfield_segment_code => l_adr_flexfield_segment_code
22166 , x_flex_value_set_id => l_adr_flex_value_set_id
22167 , x_value_type_code => l_adr_value_type_code
22168 , x_value_combination_id => l_adr_value_combination_id
22169 , x_value_segment_code => l_adr_value_segment_code
22170 , p_side => 'NA'
22171 , p_override_seg_flag => 'Y'
22172 );
22173
22174 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
22175
22176 xla_ae_lines_pkg.set_segment(
22177 p_to_segment_code => 'GL_ACCOUNT'
22178 , p_segment_value => l_segment
22179 , p_from_segment_code => l_adr_value_segment_code
22180 , p_from_combination_id => l_adr_value_combination_id
22181 , p_value_type_code => l_adr_value_type_code
22182 , p_transaction_coa_id => l_adr_transaction_coa_id
22183 , p_accounting_coa_id => l_adr_accounting_coa_id
22184 , p_flexfield_segment_code => l_adr_flexfield_segment_code
22185 , p_flex_value_set_id => l_adr_flex_value_set_id
22186 , p_adr_code => 'FV_AR_46X002_MISC_RCT_CR'
22187 , p_adr_type_code => 'S'
22188 , p_component_type => l_component_type
22189 , p_component_code => l_component_code
22190 , p_component_type_code => l_component_type_code
22191 , p_component_appl_id => l_component_appl_id
22192 , p_amb_context_code => l_amb_context_code
22193 , p_entity_code => 'RECEIPTS'
22194 , p_event_class_code => 'MISC_RECEIPT'
22195 , p_side => 'NA'
22196 );
22197
22198 END IF;
22199
22200 --
22201 --
22202 END IF;
22203
22204 --
22205 -- Update the line information that should be overwritten
22206 --
22207 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
22208 p_header_num => 1);
22209 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
22210
22211 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
22212
22216
22213 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
22214 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
22215 END IF;
22217 --
22218 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
22219 --
22220 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
22221 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
22222 ELSE
22223 ---------------------------------------------------------------------------------------------------
22224 -- 4262811a Switch Sign
22225 ---------------------------------------------------------------------------------------------------
22226 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
22227 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22228 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22229 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22230 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22231 -- 5132302
22232 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
22233 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22234
22235 END IF;
22236
22237 -- 4955764
22238 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22239 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
22240
22241
22242 XLA_AE_LINES_PKG.ValidateCurrentLine;
22243 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22244
22245 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22246 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
22247 ,p_balance_type_code => l_balance_type_code);
22248
22249 END IF;
22250
22251 -----------------------------------------------------------------------------------------
22252 -- 4262811 Multiperiod Accounting
22253 -----------------------------------------------------------------------------------------
22254 -- No MPA option is assigned.
22255
22256
22257 END IF;
22258 END IF;
22259 --
22260
22261 --
22262 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22263 trace
22264 (p_msg => 'END of AcctLineType_64'
22265 ,p_level => C_LEVEL_PROCEDURE
22266 ,p_module => l_log_module);
22267 END IF;
22268 --
22269 EXCEPTION
22270 WHEN xla_exceptions_pkg.application_exception THEN
22271 RAISE;
22272 WHEN OTHERS THEN
22273 xla_exceptions_pkg.raise_message
22274 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_64');
22275 END AcctLineType_64;
22276 --
22277
22278 ---------------------------------------
22279 --
22280 -- PRIVATE FUNCTION
22281 -- AcctLineType_65
22282 --
22283 ---------------------------------------
22284 PROCEDURE AcctLineType_65 (
22285 p_application_id IN NUMBER
22286 ,p_event_id IN NUMBER
22287 ,p_calculate_acctd_flag IN VARCHAR2
22288 ,p_calculate_g_l_flag IN VARCHAR2
22289 ,p_actual_flag IN OUT VARCHAR2
22290 ,p_balance_type_code OUT VARCHAR2
22291 ,p_gain_or_loss_ref OUT VARCHAR2
22292
22293 --Distribution GL Account
22294 , p_source_10 IN NUMBER
22295 --Federal Fund Expired Status
22296 , p_source_14 IN VARCHAR2
22297 --Federal Prior Year Flag
22298 , p_source_15 IN VARCHAR2
22299 --Federal Fund Time Frame
22300 , p_source_16 IN VARCHAR2
22301 --Federal Apportionment Category
22302 , p_source_17 IN VARCHAR2
22303 --Distribution Source Type
22304 , p_source_22 IN VARCHAR2
22305 --Distribution Line Identifier
22306 , p_source_24 IN NUMBER
22307 --Distribution Type
22308 , p_source_25 IN VARCHAR2
22309 --Entered Amount
22310 , p_source_26 IN NUMBER
22311 --Currency Code
22312 , p_source_27 IN VARCHAR2
22313 --Exchange Rate
22314 , p_source_29 IN NUMBER
22315 --Exchange Rate Type
22316 , p_source_30 IN VARCHAR2
22317 --Applied To Document Accounting Amount
22318 , p_source_31 IN NUMBER
22319 --Federal Account Valid Flag
22320 , p_source_58 IN VARCHAR2
22321 --Applied To Document Exchange Date
22322 , p_source_59 IN DATE
22323 )
22324 IS
22325
22326 l_component_type VARCHAR2(80);
22327 l_component_code VARCHAR2(30);
22328 l_component_type_code VARCHAR2(1);
22329 l_component_appl_id INTEGER;
22330 l_amb_context_code VARCHAR2(30);
22331 l_entity_code VARCHAR2(30);
22332 l_event_class_code VARCHAR2(30);
22333 l_ae_header_id NUMBER;
22334 l_event_type_code VARCHAR2(30);
22335 l_line_definition_code VARCHAR2(30);
22336 l_line_definition_owner_code VARCHAR2(1);
22337 --
22338 -- adr variables
22339 l_segment VARCHAR2(30);
22340 l_ccid NUMBER;
22341 l_adr_transaction_coa_id NUMBER;
22345 l_adr_value_type_code VARCHAR2(30);
22342 l_adr_accounting_coa_id NUMBER;
22343 l_adr_flexfield_segment_code VARCHAR2(30);
22344 l_adr_flex_value_set_id NUMBER;
22346 l_adr_value_combination_id NUMBER;
22347 l_adr_value_segment_code VARCHAR2(30);
22348
22349 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
22350 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
22351 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
22352 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
22353
22354 -- 4262811 Variables ------------------------------------------------------------------------------------------
22355 l_entered_amt_idx NUMBER;
22356 l_accted_amt_idx NUMBER;
22357 l_acc_rev_flag VARCHAR2(1);
22358 l_accrual_line_num NUMBER;
22359 l_tmp_amt NUMBER;
22360 l_acc_rev_natural_side_code VARCHAR2(1);
22361
22362 l_num_entries NUMBER;
22363 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
22364 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
22365 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
22366 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
22367 l_recog_line_1 NUMBER;
22368 l_recog_line_2 NUMBER;
22369
22370 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
22371 l_bflow_applied_to_amt NUMBER; -- 5132302
22372 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
22373
22374 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
22375
22376 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
22377 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
22378
22379 ---------------------------------------------------------------------------------------------------------------
22380
22381
22382 --
22383 -- bulk performance
22384 --
22385 l_balance_type_code VARCHAR2(1);
22386 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
22387 l_log_module VARCHAR2(240);
22388
22389 --
22390 -- Upgrade strategy
22391 --
22392 l_actual_upg_option VARCHAR2(1);
22393 l_enc_upg_option VARCHAR2(1);
22394
22395 --
22396 BEGIN
22397 --
22398 IF g_log_enabled THEN
22399 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_65';
22400 END IF;
22401 --
22402 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22403
22404 trace
22405 (p_msg => 'BEGIN of AcctLineType_65'
22406 ,p_level => C_LEVEL_PROCEDURE
22407 ,p_module => l_log_module);
22408
22409 END IF;
22410 --
22411 l_component_type := 'AMB_JLT';
22412 l_component_code := 'FV_MISC_RCT_REF_OUFC_DR';
22413 l_component_type_code := 'S';
22414 l_component_appl_id := 222;
22415 l_amb_context_code := 'DEFAULT';
22416 l_entity_code := 'RECEIPTS';
22417 l_event_class_code := 'MISC_RECEIPT';
22418 l_event_type_code := 'MISC_RECEIPT_ALL';
22419 l_line_definition_owner_code := 'S';
22420 l_line_definition_code := 'MFAR_FED_AR_MISC_REC_ACCOUNT';
22421 --
22422 l_balance_type_code := 'A';
22423 l_segment := NULL;
22424 l_ccid := NULL;
22425 l_adr_transaction_coa_id := NULL;
22426 l_adr_accounting_coa_id := NULL;
22427 l_adr_flexfield_segment_code := NULL;
22428 l_adr_flex_value_set_id := NULL;
22429 l_adr_value_type_code := NULL;
22430 l_adr_value_combination_id := NULL;
22431 l_adr_value_segment_code := NULL;
22432
22433 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
22434 l_bflow_class_code := ''; -- 4219869 Business Flow
22435 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
22436 l_budgetary_control_flag := 'N';
22437
22438 l_bflow_applied_to_amt_idx := NULL; -- 5132302
22439 l_bflow_applied_to_amt := NULL; -- 5132302
22440 l_entered_amt_idx := NULL; -- 4262811
22441 l_accted_amt_idx := NULL; -- 4262811
22442 l_acc_rev_flag := NULL; -- 4262811
22443 l_accrual_line_num := NULL; -- 4262811
22444 l_tmp_amt := NULL; -- 4262811
22445 --
22446
22447 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
22448 l_balance_type_code <> 'B' THEN
22449 IF NVL(p_source_22,'
22450 ') = 'MISCCASH' AND
22451 NVL(p_source_14,'
22452 ') = 'Unexpired' AND
22453 NVL(p_source_15,'
22454 ') = 'N' AND
22455 (NVL(p_source_17,'
22456 ') = 'A' OR
22457 NVL(p_source_17,'
22458 ') = 'B' OR
22459 NVL(p_source_17,'
22460 ') = 'C') AND
22461 (NVL(p_source_16,'
22462 ') = 'SINGLE' OR
22463 NVL(p_source_16,'
22464 ') = 'MULTIPLE' OR
22465 NVL(p_source_16,'
22466 ') = 'NO_YEAR') AND
22467 NVL(p_source_58,'
22468 ') = 'Y'
22469 THEN
22470
22471 --
22472 XLA_AE_LINES_PKG.SetNewLine;
22473
22474 p_balance_type_code := l_balance_type_code;
22478 p_actual_flag :='A';
22475 -- set the flag so later we will know whether the gain loss line needs to be created
22476
22477 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
22479 END IF;
22480
22481 --
22482 -- bulk performance
22483 --
22484 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
22485 p_header_num => 0); -- 4262811
22486 --
22487 -- set accounting line options
22488 --
22489 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
22490 p_natural_side_code => 'D'
22491 , p_gain_or_loss_flag => 'N'
22492 , p_gl_transfer_mode_code => 'S'
22493 , p_acct_entry_type_code => 'A'
22494 , p_switch_side_flag => 'Y'
22495 , p_merge_duplicate_code => 'A'
22496 );
22497 --
22498 l_acc_rev_natural_side_code := 'C'; -- 4262811
22499 --
22500 --
22501 -- set accounting line type info
22502 --
22503 xla_ae_lines_pkg.SetAcctLineType
22504 (p_component_type => l_component_type
22505 ,p_event_type_code => l_event_type_code
22506 ,p_line_definition_owner_code => l_line_definition_owner_code
22507 ,p_line_definition_code => l_line_definition_code
22508 ,p_accounting_line_code => l_component_code
22509 ,p_accounting_line_type_code => l_component_type_code
22510 ,p_accounting_line_appl_id => l_component_appl_id
22511 ,p_amb_context_code => l_amb_context_code
22512 ,p_entity_code => l_entity_code
22513 ,p_event_class_code => l_event_class_code);
22514 --
22515 -- set accounting class
22516 --
22517 xla_ae_lines_pkg.SetAcctClass(
22518 p_accounting_class_code => 'FV_MISCCASH_DR'
22519 , p_ae_header_id => l_ae_header_id
22520 );
22521
22522 --
22523 -- set rounding class
22524 --
22525 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
22526 'RECEIVABLE';
22527
22528 --
22529 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
22530 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
22531 --
22532 -- bulk performance
22533 --
22534 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
22535
22536 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
22537 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
22538
22539 -- 4955764
22540 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22541 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
22542
22543 -- 4458381 Public Sector Enh
22544
22545 --
22546 -- set accounting attributes for the line type
22547 --
22548 l_entered_amt_idx := 3;
22549 l_accted_amt_idx := 8;
22550 l_bflow_applied_to_amt_idx := NULL; -- 5132302
22551 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
22552 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
22553 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
22554 l_rec_acct_attrs.array_char_value(2) := p_source_25;
22555 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
22556 l_rec_acct_attrs.array_num_value(3) := p_source_26;
22557 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
22558 l_rec_acct_attrs.array_char_value(4) := p_source_27;
22559 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
22560 l_rec_acct_attrs.array_date_value(5) := p_source_59;
22561 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
22562 l_rec_acct_attrs.array_num_value(6) := p_source_29;
22563 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
22564 l_rec_acct_attrs.array_char_value(7) := p_source_30;
22565 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
22566 l_rec_acct_attrs.array_num_value(8) := p_source_31;
22567
22568 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
22569 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
22570
22571 ---------------------------------------------------------------------------------------------------------------
22572 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
22573 ---------------------------------------------------------------------------------------------------------------
22574 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
22575
22576 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22577 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22578
22579 IF xla_accounting_cache_pkg.GetValueChar
22580 (p_source_code => 'LEDGER_CATEGORY_CODE'
22581 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
22582 AND l_bflow_method_code = 'PRIOR_ENTRY'
22583 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
22587 THEN
22584 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
22585 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
22586 )
22588 xla_ae_lines_pkg.BflowUpgEntry
22589 (p_business_method_code => l_bflow_method_code
22590 ,p_business_class_code => l_bflow_class_code
22591 ,p_balance_type => l_balance_type_code);
22592 ELSE
22593 NULL;
22594 -- No business flow processing for business flow method of NONE.
22595 END IF;
22596
22597 --
22598 -- call analytical criteria
22599 --
22600
22601 --
22602 -- call description
22603 --
22604 -- No description or it is inherited.
22605 --
22606 -- call ADRs
22607 -- Bug 4922099
22608 --
22609 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22610 (NVL(l_actual_upg_option, 'N') = 'O') OR
22611 (NVL(l_enc_upg_option, 'N') = 'O')
22612 )
22613 THEN
22614 NULL;
22615 --
22616 --
22617
22618 l_ccid := AcctDerRule_11(
22619 p_application_id => p_application_id
22620 , p_ae_header_id => l_ae_header_id
22621 , p_source_10 => p_source_10
22622 , x_transaction_coa_id => l_adr_transaction_coa_id
22623 , x_accounting_coa_id => l_adr_accounting_coa_id
22624 , x_value_type_code => l_adr_value_type_code
22625 , p_side => 'NA'
22626 );
22627
22628 xla_ae_lines_pkg.set_ccid(
22629 p_code_combination_id => l_ccid
22630 , p_value_type_code => l_adr_value_type_code
22631 , p_transaction_coa_id => l_adr_transaction_coa_id
22632 , p_accounting_coa_id => l_adr_accounting_coa_id
22633 , p_adr_code => 'DIST_CCID'
22634 , p_adr_type_code => 'S'
22635 , p_component_type => l_component_type
22636 , p_component_code => l_component_code
22637 , p_component_type_code => l_component_type_code
22638 , p_component_appl_id => l_component_appl_id
22639 , p_amb_context_code => l_amb_context_code
22640 , p_side => 'NA'
22641 );
22642
22643
22644 l_segment := AcctDerRule_24(
22645 p_application_id => p_application_id
22646 , p_ae_header_id => l_ae_header_id
22647 , p_source_14 => p_source_14
22648 , p_source_15 => p_source_15
22649 , p_source_16 => p_source_16
22650 , p_source_17 => p_source_17
22651 , x_transaction_coa_id => l_adr_transaction_coa_id
22652 , x_accounting_coa_id => l_adr_accounting_coa_id
22653 , x_flexfield_segment_code => l_adr_flexfield_segment_code
22654 , x_flex_value_set_id => l_adr_flex_value_set_id
22655 , x_value_type_code => l_adr_value_type_code
22656 , x_value_combination_id => l_adr_value_combination_id
22657 , x_value_segment_code => l_adr_value_segment_code
22658 , p_side => 'NA'
22659 , p_override_seg_flag => 'Y'
22660 );
22661
22662 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
22663
22664 xla_ae_lines_pkg.set_segment(
22665 p_to_segment_code => 'GL_ACCOUNT'
22666 , p_segment_value => l_segment
22667 , p_from_segment_code => l_adr_value_segment_code
22668 , p_from_combination_id => l_adr_value_combination_id
22669 , p_value_type_code => l_adr_value_type_code
22670 , p_transaction_coa_id => l_adr_transaction_coa_id
22671 , p_accounting_coa_id => l_adr_accounting_coa_id
22672 , p_flexfield_segment_code => l_adr_flexfield_segment_code
22673 , p_flex_value_set_id => l_adr_flex_value_set_id
22674 , p_adr_code => 'FV_AR_490201_MISC_RCT_DR'
22675 , p_adr_type_code => 'S'
22676 , p_component_type => l_component_type
22677 , p_component_code => l_component_code
22678 , p_component_type_code => l_component_type_code
22679 , p_component_appl_id => l_component_appl_id
22680 , p_amb_context_code => l_amb_context_code
22681 , p_entity_code => 'RECEIPTS'
22682 , p_event_class_code => 'MISC_RECEIPT'
22683 , p_side => 'NA'
22684 );
22685
22686 END IF;
22687
22688 --
22689 --
22690 END IF;
22691 --
22692 -- Bug 4922099
22693 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
22694 (NVL(l_enc_upg_option, 'N') = 'O')
22695 ) AND
22696 (l_bflow_method_code = 'PRIOR_ENTRY')
22697 )
22698 THEN
22699 IF
22700 --
22701 1 = 2
22702 --
22703 THEN
22704 xla_accounting_err_pkg.build_message
22705 (p_appli_s_name => 'XLA'
22706 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22707 ,p_token_1 => 'LINE_NUMBER'
22708 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
22709 ,p_token_2 => 'LINE_TYPE_NAME'
22713 ,l_component_type_code
22710 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
22711 l_component_type
22712 ,l_component_code
22714 ,l_component_appl_id
22715 ,l_amb_context_code
22716 ,l_entity_code
22717 ,l_event_class_code
22718 )
22719 ,p_token_3 => 'OWNER'
22720 ,p_value_3 => xla_lookups_pkg.get_meaning(
22721 p_lookup_type => 'XLA_OWNER_TYPE'
22722 ,p_lookup_code => l_component_type_code
22723 )
22724 ,p_token_4 => 'PRODUCT_NAME'
22725 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
22726 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
22727 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
22728 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
22729 ,p_ae_header_id => NULL
22730 );
22731
22732 IF (C_LEVEL_ERROR>= g_log_level) THEN
22733 trace
22734 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22735 ,p_level => C_LEVEL_ERROR
22736 ,p_module => l_log_module);
22737 END IF;
22738 END IF;
22739 END IF;
22740 --
22741 --
22742 ------------------------------------------------------------------------------------------------
22743 -- 4219869 Business Flow
22744 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
22745 -- Prior Entry. Currently, the following code is always generated.
22746 ------------------------------------------------------------------------------------------------
22747 XLA_AE_LINES_PKG.ValidateCurrentLine;
22748
22749 ------------------------------------------------------------------------------------
22750 -- 4219869 Business Flow
22751 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
22752 ------------------------------------------------------------------------------------
22753 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22754
22755 ----------------------------------------------------------------------------------
22756 -- 4219869 Business Flow
22757 -- Update journal entry status -- Need to generate this within IF <condition>
22758 ----------------------------------------------------------------------------------
22759 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22760 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
22761 ,p_balance_type_code => l_balance_type_code
22762 );
22763
22764 -------------------------------------------------------------------------------------------
22765 -- 4262811 - Generate the Accrual Reversal lines
22766 -------------------------------------------------------------------------------------------
22767 BEGIN
22768 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
22769 (g_array_event(p_event_id).array_value_num('header_index'));
22770 IF l_acc_rev_flag IS NULL THEN
22771 l_acc_rev_flag := 'N';
22772 END IF;
22773 EXCEPTION
22774 WHEN OTHERS THEN
22775 l_acc_rev_flag := 'N';
22776 END;
22777 --
22778 IF (l_acc_rev_flag = 'Y') THEN
22779
22780 -- 4645092 ------------------------------------------------------------------------------
22781 -- To allow MPA report to determine if it should generate report process
22782 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
22783 ------------------------------------------------------------------------------------------
22784
22785 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
22786 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
22787 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
22788 -- call ADRs
22789 -- Bug 4922099
22790 --
22791 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22792 (NVL(l_actual_upg_option, 'N') = 'O') OR
22793 (NVL(l_enc_upg_option, 'N') = 'O')
22794 )
22795 THEN
22796 NULL;
22797 --
22798 --
22799
22800 l_ccid := AcctDerRule_11(
22801 p_application_id => p_application_id
22802 , p_ae_header_id => l_ae_header_id
22803 , p_source_10 => p_source_10
22804 , x_transaction_coa_id => l_adr_transaction_coa_id
22808 );
22805 , x_accounting_coa_id => l_adr_accounting_coa_id
22806 , x_value_type_code => l_adr_value_type_code
22807 , p_side => 'NA'
22809
22810 xla_ae_lines_pkg.set_ccid(
22811 p_code_combination_id => l_ccid
22812 , p_value_type_code => l_adr_value_type_code
22813 , p_transaction_coa_id => l_adr_transaction_coa_id
22814 , p_accounting_coa_id => l_adr_accounting_coa_id
22815 , p_adr_code => 'DIST_CCID'
22816 , p_adr_type_code => 'S'
22817 , p_component_type => l_component_type
22818 , p_component_code => l_component_code
22819 , p_component_type_code => l_component_type_code
22820 , p_component_appl_id => l_component_appl_id
22821 , p_amb_context_code => l_amb_context_code
22822 , p_side => 'NA'
22823 );
22824
22825
22826 l_segment := AcctDerRule_24(
22827 p_application_id => p_application_id
22828 , p_ae_header_id => l_ae_header_id
22829 , p_source_14 => p_source_14
22830 , p_source_15 => p_source_15
22831 , p_source_16 => p_source_16
22832 , p_source_17 => p_source_17
22833 , x_transaction_coa_id => l_adr_transaction_coa_id
22834 , x_accounting_coa_id => l_adr_accounting_coa_id
22835 , x_flexfield_segment_code => l_adr_flexfield_segment_code
22836 , x_flex_value_set_id => l_adr_flex_value_set_id
22837 , x_value_type_code => l_adr_value_type_code
22838 , x_value_combination_id => l_adr_value_combination_id
22839 , x_value_segment_code => l_adr_value_segment_code
22840 , p_side => 'NA'
22841 , p_override_seg_flag => 'Y'
22842 );
22843
22844 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
22845
22846 xla_ae_lines_pkg.set_segment(
22847 p_to_segment_code => 'GL_ACCOUNT'
22848 , p_segment_value => l_segment
22849 , p_from_segment_code => l_adr_value_segment_code
22850 , p_from_combination_id => l_adr_value_combination_id
22851 , p_value_type_code => l_adr_value_type_code
22852 , p_transaction_coa_id => l_adr_transaction_coa_id
22853 , p_accounting_coa_id => l_adr_accounting_coa_id
22854 , p_flexfield_segment_code => l_adr_flexfield_segment_code
22855 , p_flex_value_set_id => l_adr_flex_value_set_id
22856 , p_adr_code => 'FV_AR_490201_MISC_RCT_DR'
22857 , p_adr_type_code => 'S'
22858 , p_component_type => l_component_type
22859 , p_component_code => l_component_code
22860 , p_component_type_code => l_component_type_code
22861 , p_component_appl_id => l_component_appl_id
22862 , p_amb_context_code => l_amb_context_code
22863 , p_entity_code => 'RECEIPTS'
22864 , p_event_class_code => 'MISC_RECEIPT'
22865 , p_side => 'NA'
22866 );
22867
22868 END IF;
22869
22870 --
22871 --
22872 END IF;
22873
22874 --
22875 -- Update the line information that should be overwritten
22876 --
22877 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
22878 p_header_num => 1);
22879 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
22880
22881 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
22882
22883 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
22884 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
22885 END IF;
22886
22887 --
22888 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
22889 --
22890 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
22891 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
22892 ELSE
22893 ---------------------------------------------------------------------------------------------------
22894 -- 4262811a Switch Sign
22895 ---------------------------------------------------------------------------------------------------
22896 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
22897 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22898 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22899 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22900 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22901 -- 5132302
22902 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
22903 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22904
22905 END IF;
22906
22907 -- 4955764
22908 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22912 XLA_AE_LINES_PKG.ValidateCurrentLine;
22909 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
22910
22911
22913 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22914
22915 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22916 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
22917 ,p_balance_type_code => l_balance_type_code);
22918
22919 END IF;
22920
22921 -----------------------------------------------------------------------------------------
22922 -- 4262811 Multiperiod Accounting
22923 -----------------------------------------------------------------------------------------
22924 -- No MPA option is assigned.
22925
22926
22927 END IF;
22928 END IF;
22929 --
22930
22931 --
22932 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22933 trace
22934 (p_msg => 'END of AcctLineType_65'
22935 ,p_level => C_LEVEL_PROCEDURE
22936 ,p_module => l_log_module);
22937 END IF;
22938 --
22939 EXCEPTION
22940 WHEN xla_exceptions_pkg.application_exception THEN
22941 RAISE;
22942 WHEN OTHERS THEN
22943 xla_exceptions_pkg.raise_message
22944 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_65');
22945 END AcctLineType_65;
22946 --
22947
22948 ---------------------------------------
22949 --
22950 -- PRIVATE FUNCTION
22951 -- AcctLineType_66
22952 --
22953 ---------------------------------------
22954 PROCEDURE AcctLineType_66 (
22955 p_application_id IN NUMBER
22956 ,p_event_id IN NUMBER
22957 ,p_calculate_acctd_flag IN VARCHAR2
22958 ,p_calculate_g_l_flag IN VARCHAR2
22959 ,p_actual_flag IN OUT VARCHAR2
22960 ,p_balance_type_code OUT VARCHAR2
22961 ,p_gain_or_loss_ref OUT VARCHAR2
22962
22963 --Distribution GL Account
22964 , p_source_10 IN NUMBER
22965 --Federal Fund Expired Status
22966 , p_source_14 IN VARCHAR2
22967 --Federal Prior Year Flag
22968 , p_source_15 IN VARCHAR2
22969 --Federal Fund Time Frame
22970 , p_source_16 IN VARCHAR2
22971 --Distribution Source Type
22972 , p_source_22 IN VARCHAR2
22973 --Distribution Line Identifier
22974 , p_source_24 IN NUMBER
22975 --Distribution Type
22976 , p_source_25 IN VARCHAR2
22977 --Entered Amount
22978 , p_source_26 IN NUMBER
22979 --Currency Code
22980 , p_source_27 IN VARCHAR2
22981 --Exchange Rate
22982 , p_source_29 IN NUMBER
22983 --Exchange Rate Type
22984 , p_source_30 IN VARCHAR2
22985 --Applied To Document Accounting Amount
22986 , p_source_31 IN NUMBER
22987 --Federal Account Valid Flag
22988 , p_source_58 IN VARCHAR2
22989 --Applied To Document Exchange Date
22990 , p_source_59 IN DATE
22991 )
22992 IS
22993
22994 l_component_type VARCHAR2(80);
22995 l_component_code VARCHAR2(30);
22996 l_component_type_code VARCHAR2(1);
22997 l_component_appl_id INTEGER;
22998 l_amb_context_code VARCHAR2(30);
22999 l_entity_code VARCHAR2(30);
23000 l_event_class_code VARCHAR2(30);
23001 l_ae_header_id NUMBER;
23002 l_event_type_code VARCHAR2(30);
23003 l_line_definition_code VARCHAR2(30);
23004 l_line_definition_owner_code VARCHAR2(1);
23005 --
23006 -- adr variables
23007 l_segment VARCHAR2(30);
23008 l_ccid NUMBER;
23009 l_adr_transaction_coa_id NUMBER;
23010 l_adr_accounting_coa_id NUMBER;
23011 l_adr_flexfield_segment_code VARCHAR2(30);
23012 l_adr_flex_value_set_id NUMBER;
23013 l_adr_value_type_code VARCHAR2(30);
23014 l_adr_value_combination_id NUMBER;
23015 l_adr_value_segment_code VARCHAR2(30);
23016
23017 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
23018 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
23019 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
23020 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
23021
23022 -- 4262811 Variables ------------------------------------------------------------------------------------------
23023 l_entered_amt_idx NUMBER;
23024 l_accted_amt_idx NUMBER;
23025 l_acc_rev_flag VARCHAR2(1);
23026 l_accrual_line_num NUMBER;
23027 l_tmp_amt NUMBER;
23028 l_acc_rev_natural_side_code VARCHAR2(1);
23029
23030 l_num_entries NUMBER;
23031 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
23032 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
23033 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
23034 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
23035 l_recog_line_1 NUMBER;
23036 l_recog_line_2 NUMBER;
23037
23038 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
23039 l_bflow_applied_to_amt NUMBER; -- 5132302
23040 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
23041
23045 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
23042 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
23043
23044 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
23046
23047 ---------------------------------------------------------------------------------------------------------------
23048
23049
23050 --
23051 -- bulk performance
23052 --
23053 l_balance_type_code VARCHAR2(1);
23054 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
23055 l_log_module VARCHAR2(240);
23056
23057 --
23058 -- Upgrade strategy
23059 --
23060 l_actual_upg_option VARCHAR2(1);
23061 l_enc_upg_option VARCHAR2(1);
23062
23063 --
23064 BEGIN
23065 --
23066 IF g_log_enabled THEN
23067 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_66';
23068 END IF;
23069 --
23070 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23071
23072 trace
23073 (p_msg => 'BEGIN of AcctLineType_66'
23074 ,p_level => C_LEVEL_PROCEDURE
23075 ,p_module => l_log_module);
23076
23077 END IF;
23078 --
23079 l_component_type := 'AMB_JLT';
23080 l_component_code := 'FV_MISC_RCT_REF_OUFP_CR';
23081 l_component_type_code := 'S';
23082 l_component_appl_id := 222;
23083 l_amb_context_code := 'DEFAULT';
23084 l_entity_code := 'RECEIPTS';
23085 l_event_class_code := 'MISC_RECEIPT';
23086 l_event_type_code := 'MISC_RECEIPT_ALL';
23087 l_line_definition_owner_code := 'S';
23088 l_line_definition_code := 'MFAR_FED_AR_MISC_REC_ACCOUNT';
23089 --
23090 l_balance_type_code := 'A';
23091 l_segment := NULL;
23092 l_ccid := NULL;
23093 l_adr_transaction_coa_id := NULL;
23094 l_adr_accounting_coa_id := NULL;
23095 l_adr_flexfield_segment_code := NULL;
23096 l_adr_flex_value_set_id := NULL;
23097 l_adr_value_type_code := NULL;
23098 l_adr_value_combination_id := NULL;
23099 l_adr_value_segment_code := NULL;
23100
23101 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
23102 l_bflow_class_code := ''; -- 4219869 Business Flow
23103 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
23104 l_budgetary_control_flag := 'N';
23105
23106 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23107 l_bflow_applied_to_amt := NULL; -- 5132302
23108 l_entered_amt_idx := NULL; -- 4262811
23109 l_accted_amt_idx := NULL; -- 4262811
23110 l_acc_rev_flag := NULL; -- 4262811
23111 l_accrual_line_num := NULL; -- 4262811
23112 l_tmp_amt := NULL; -- 4262811
23113 --
23114
23115 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
23116 l_balance_type_code <> 'B' THEN
23117 IF NVL(p_source_22,'
23118 ') = 'MISCCASH' AND
23119 NVL(p_source_14,'
23120 ') = 'Unexpired' AND
23121 NVL(p_source_15,'
23122 ') = 'Y' AND
23123 (NVL(p_source_16,'
23124 ') = 'MULTIPLE' OR
23125 NVL(p_source_16,'
23126 ') = 'NO_YEAR') AND
23127 NVL(p_source_58,'
23128 ') = 'Y'
23129 THEN
23130
23131 --
23132 XLA_AE_LINES_PKG.SetNewLine;
23133
23134 p_balance_type_code := l_balance_type_code;
23135 -- set the flag so later we will know whether the gain loss line needs to be created
23136
23137 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
23138 p_actual_flag :='A';
23139 END IF;
23140
23141 --
23142 -- bulk performance
23143 --
23144 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
23145 p_header_num => 0); -- 4262811
23146 --
23147 -- set accounting line options
23148 --
23149 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
23150 p_natural_side_code => 'C'
23151 , p_gain_or_loss_flag => 'N'
23152 , p_gl_transfer_mode_code => 'S'
23153 , p_acct_entry_type_code => 'A'
23154 , p_switch_side_flag => 'Y'
23155 , p_merge_duplicate_code => 'A'
23156 );
23157 --
23158 l_acc_rev_natural_side_code := 'D'; -- 4262811
23159 --
23160 --
23161 -- set accounting line type info
23162 --
23163 xla_ae_lines_pkg.SetAcctLineType
23164 (p_component_type => l_component_type
23165 ,p_event_type_code => l_event_type_code
23166 ,p_line_definition_owner_code => l_line_definition_owner_code
23167 ,p_line_definition_code => l_line_definition_code
23168 ,p_accounting_line_code => l_component_code
23169 ,p_accounting_line_type_code => l_component_type_code
23170 ,p_accounting_line_appl_id => l_component_appl_id
23171 ,p_amb_context_code => l_amb_context_code
23172 ,p_entity_code => l_entity_code
23173 ,p_event_class_code => l_event_class_code);
23174 --
23175 -- set accounting class
23176 --
23177 xla_ae_lines_pkg.SetAcctClass(
23178 p_accounting_class_code => 'FV_MISCCASH_CR'
23182 --
23179 , p_ae_header_id => l_ae_header_id
23180 );
23181
23183 -- set rounding class
23184 --
23185 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
23186 'RECEIVABLE';
23187
23188 --
23189 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
23190 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
23191 --
23192 -- bulk performance
23193 --
23194 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
23195
23196 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
23197 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
23198
23199 -- 4955764
23200 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23201 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
23202
23203 -- 4458381 Public Sector Enh
23204
23205 --
23206 -- set accounting attributes for the line type
23207 --
23208 l_entered_amt_idx := 3;
23209 l_accted_amt_idx := 8;
23210 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23211 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
23212 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
23213 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
23214 l_rec_acct_attrs.array_char_value(2) := p_source_25;
23215 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
23216 l_rec_acct_attrs.array_num_value(3) := p_source_26;
23217 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
23218 l_rec_acct_attrs.array_char_value(4) := p_source_27;
23219 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
23220 l_rec_acct_attrs.array_date_value(5) := p_source_59;
23221 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
23222 l_rec_acct_attrs.array_num_value(6) := p_source_29;
23223 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
23224 l_rec_acct_attrs.array_char_value(7) := p_source_30;
23225 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
23226 l_rec_acct_attrs.array_num_value(8) := p_source_31;
23227
23228 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
23229 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
23230
23231 ---------------------------------------------------------------------------------------------------------------
23232 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
23233 ---------------------------------------------------------------------------------------------------------------
23234 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
23235
23236 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23237 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23238
23239 IF xla_accounting_cache_pkg.GetValueChar
23240 (p_source_code => 'LEDGER_CATEGORY_CODE'
23241 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
23242 AND l_bflow_method_code = 'PRIOR_ENTRY'
23243 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
23244 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
23245 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
23246 )
23247 THEN
23248 xla_ae_lines_pkg.BflowUpgEntry
23249 (p_business_method_code => l_bflow_method_code
23250 ,p_business_class_code => l_bflow_class_code
23251 ,p_balance_type => l_balance_type_code);
23252 ELSE
23253 NULL;
23254 -- No business flow processing for business flow method of NONE.
23255 END IF;
23256
23257 --
23258 -- call analytical criteria
23259 --
23260
23261 --
23262 -- call description
23263 --
23264 -- No description or it is inherited.
23265 --
23266 -- call ADRs
23267 -- Bug 4922099
23268 --
23269 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23270 (NVL(l_actual_upg_option, 'N') = 'O') OR
23271 (NVL(l_enc_upg_option, 'N') = 'O')
23272 )
23273 THEN
23274 NULL;
23275 --
23276 --
23277
23278 l_ccid := AcctDerRule_11(
23279 p_application_id => p_application_id
23280 , p_ae_header_id => l_ae_header_id
23281 , p_source_10 => p_source_10
23282 , x_transaction_coa_id => l_adr_transaction_coa_id
23283 , x_accounting_coa_id => l_adr_accounting_coa_id
23284 , x_value_type_code => l_adr_value_type_code
23285 , p_side => 'NA'
23286 );
23287
23288 xla_ae_lines_pkg.set_ccid(
23289 p_code_combination_id => l_ccid
23290 , p_value_type_code => l_adr_value_type_code
23291 , p_transaction_coa_id => l_adr_transaction_coa_id
23292 , p_accounting_coa_id => l_adr_accounting_coa_id
23293 , p_adr_code => 'DIST_CCID'
23297 , p_component_type_code => l_component_type_code
23294 , p_adr_type_code => 'S'
23295 , p_component_type => l_component_type
23296 , p_component_code => l_component_code
23298 , p_component_appl_id => l_component_appl_id
23299 , p_amb_context_code => l_amb_context_code
23300 , p_side => 'NA'
23301 );
23302
23303
23304 l_segment := AcctDerRule_18(
23305 p_application_id => p_application_id
23306 , p_ae_header_id => l_ae_header_id
23307 , p_source_14 => p_source_14
23308 , p_source_15 => p_source_15
23309 , p_source_16 => p_source_16
23310 , x_transaction_coa_id => l_adr_transaction_coa_id
23311 , x_accounting_coa_id => l_adr_accounting_coa_id
23312 , x_flexfield_segment_code => l_adr_flexfield_segment_code
23313 , x_flex_value_set_id => l_adr_flex_value_set_id
23314 , x_value_type_code => l_adr_value_type_code
23315 , x_value_combination_id => l_adr_value_combination_id
23316 , x_value_segment_code => l_adr_value_segment_code
23317 , p_side => 'NA'
23318 , p_override_seg_flag => 'Y'
23319 );
23320
23321 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
23322
23323 xla_ae_lines_pkg.set_segment(
23324 p_to_segment_code => 'GL_ACCOUNT'
23325 , p_segment_value => l_segment
23326 , p_from_segment_code => l_adr_value_segment_code
23327 , p_from_combination_id => l_adr_value_combination_id
23328 , p_value_type_code => l_adr_value_type_code
23329 , p_transaction_coa_id => l_adr_transaction_coa_id
23330 , p_accounting_coa_id => l_adr_accounting_coa_id
23331 , p_flexfield_segment_code => l_adr_flexfield_segment_code
23332 , p_flex_value_set_id => l_adr_flex_value_set_id
23333 , p_adr_code => 'FV_AR_445001_MISC_RCT_CR'
23334 , p_adr_type_code => 'S'
23335 , p_component_type => l_component_type
23336 , p_component_code => l_component_code
23337 , p_component_type_code => l_component_type_code
23338 , p_component_appl_id => l_component_appl_id
23339 , p_amb_context_code => l_amb_context_code
23340 , p_entity_code => 'RECEIPTS'
23341 , p_event_class_code => 'MISC_RECEIPT'
23342 , p_side => 'NA'
23343 );
23344
23345 END IF;
23346
23347 --
23348 --
23349 END IF;
23350 --
23351 -- Bug 4922099
23352 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
23353 (NVL(l_enc_upg_option, 'N') = 'O')
23354 ) AND
23355 (l_bflow_method_code = 'PRIOR_ENTRY')
23356 )
23357 THEN
23358 IF
23359 --
23360 1 = 2
23361 --
23362 THEN
23363 xla_accounting_err_pkg.build_message
23364 (p_appli_s_name => 'XLA'
23365 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23366 ,p_token_1 => 'LINE_NUMBER'
23367 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
23368 ,p_token_2 => 'LINE_TYPE_NAME'
23369 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
23370 l_component_type
23371 ,l_component_code
23372 ,l_component_type_code
23373 ,l_component_appl_id
23374 ,l_amb_context_code
23375 ,l_entity_code
23376 ,l_event_class_code
23377 )
23378 ,p_token_3 => 'OWNER'
23379 ,p_value_3 => xla_lookups_pkg.get_meaning(
23380 p_lookup_type => 'XLA_OWNER_TYPE'
23381 ,p_lookup_code => l_component_type_code
23382 )
23383 ,p_token_4 => 'PRODUCT_NAME'
23384 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
23385 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
23386 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
23387 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
23388 ,p_ae_header_id => NULL
23389 );
23390
23394 ,p_level => C_LEVEL_ERROR
23391 IF (C_LEVEL_ERROR>= g_log_level) THEN
23392 trace
23393 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23395 ,p_module => l_log_module);
23396 END IF;
23397 END IF;
23398 END IF;
23399 --
23400 --
23401 ------------------------------------------------------------------------------------------------
23402 -- 4219869 Business Flow
23403 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
23404 -- Prior Entry. Currently, the following code is always generated.
23405 ------------------------------------------------------------------------------------------------
23406 XLA_AE_LINES_PKG.ValidateCurrentLine;
23407
23408 ------------------------------------------------------------------------------------
23409 -- 4219869 Business Flow
23410 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
23411 ------------------------------------------------------------------------------------
23412 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23413
23414 ----------------------------------------------------------------------------------
23415 -- 4219869 Business Flow
23416 -- Update journal entry status -- Need to generate this within IF <condition>
23417 ----------------------------------------------------------------------------------
23418 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23419 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
23420 ,p_balance_type_code => l_balance_type_code
23421 );
23422
23423 -------------------------------------------------------------------------------------------
23424 -- 4262811 - Generate the Accrual Reversal lines
23425 -------------------------------------------------------------------------------------------
23426 BEGIN
23427 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
23428 (g_array_event(p_event_id).array_value_num('header_index'));
23429 IF l_acc_rev_flag IS NULL THEN
23430 l_acc_rev_flag := 'N';
23431 END IF;
23432 EXCEPTION
23433 WHEN OTHERS THEN
23434 l_acc_rev_flag := 'N';
23435 END;
23436 --
23437 IF (l_acc_rev_flag = 'Y') THEN
23438
23439 -- 4645092 ------------------------------------------------------------------------------
23440 -- To allow MPA report to determine if it should generate report process
23441 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
23442 ------------------------------------------------------------------------------------------
23443
23444 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
23445 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
23446 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
23447 -- call ADRs
23448 -- Bug 4922099
23449 --
23450 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23451 (NVL(l_actual_upg_option, 'N') = 'O') OR
23452 (NVL(l_enc_upg_option, 'N') = 'O')
23453 )
23454 THEN
23455 NULL;
23456 --
23457 --
23458
23459 l_ccid := AcctDerRule_11(
23460 p_application_id => p_application_id
23461 , p_ae_header_id => l_ae_header_id
23462 , p_source_10 => p_source_10
23463 , x_transaction_coa_id => l_adr_transaction_coa_id
23464 , x_accounting_coa_id => l_adr_accounting_coa_id
23465 , x_value_type_code => l_adr_value_type_code
23466 , p_side => 'NA'
23467 );
23468
23469 xla_ae_lines_pkg.set_ccid(
23470 p_code_combination_id => l_ccid
23471 , p_value_type_code => l_adr_value_type_code
23472 , p_transaction_coa_id => l_adr_transaction_coa_id
23473 , p_accounting_coa_id => l_adr_accounting_coa_id
23474 , p_adr_code => 'DIST_CCID'
23475 , p_adr_type_code => 'S'
23476 , p_component_type => l_component_type
23477 , p_component_code => l_component_code
23478 , p_component_type_code => l_component_type_code
23479 , p_component_appl_id => l_component_appl_id
23480 , p_amb_context_code => l_amb_context_code
23481 , p_side => 'NA'
23482 );
23483
23484
23485 l_segment := AcctDerRule_18(
23486 p_application_id => p_application_id
23487 , p_ae_header_id => l_ae_header_id
23488 , p_source_14 => p_source_14
23489 , p_source_15 => p_source_15
23490 , p_source_16 => p_source_16
23491 , x_transaction_coa_id => l_adr_transaction_coa_id
23492 , x_accounting_coa_id => l_adr_accounting_coa_id
23493 , x_flexfield_segment_code => l_adr_flexfield_segment_code
23494 , x_flex_value_set_id => l_adr_flex_value_set_id
23495 , x_value_type_code => l_adr_value_type_code
23496 , x_value_combination_id => l_adr_value_combination_id
23497 , x_value_segment_code => l_adr_value_segment_code
23498 , p_side => 'NA'
23499 , p_override_seg_flag => 'Y'
23500 );
23501
23502 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
23503
23504 xla_ae_lines_pkg.set_segment(
23505 p_to_segment_code => 'GL_ACCOUNT'
23509 , p_value_type_code => l_adr_value_type_code
23506 , p_segment_value => l_segment
23507 , p_from_segment_code => l_adr_value_segment_code
23508 , p_from_combination_id => l_adr_value_combination_id
23510 , p_transaction_coa_id => l_adr_transaction_coa_id
23511 , p_accounting_coa_id => l_adr_accounting_coa_id
23512 , p_flexfield_segment_code => l_adr_flexfield_segment_code
23513 , p_flex_value_set_id => l_adr_flex_value_set_id
23514 , p_adr_code => 'FV_AR_445001_MISC_RCT_CR'
23515 , p_adr_type_code => 'S'
23516 , p_component_type => l_component_type
23517 , p_component_code => l_component_code
23518 , p_component_type_code => l_component_type_code
23519 , p_component_appl_id => l_component_appl_id
23520 , p_amb_context_code => l_amb_context_code
23521 , p_entity_code => 'RECEIPTS'
23522 , p_event_class_code => 'MISC_RECEIPT'
23523 , p_side => 'NA'
23524 );
23525
23526 END IF;
23527
23528 --
23529 --
23530 END IF;
23531
23532 --
23533 -- Update the line information that should be overwritten
23534 --
23535 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
23536 p_header_num => 1);
23537 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
23538
23539 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
23540
23541 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
23542 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
23543 END IF;
23544
23545 --
23546 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
23547 --
23548 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
23549 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
23550 ELSE
23551 ---------------------------------------------------------------------------------------------------
23552 -- 4262811a Switch Sign
23553 ---------------------------------------------------------------------------------------------------
23554 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
23555 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23556 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23557 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23558 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23559 -- 5132302
23560 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
23561 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23562
23563 END IF;
23564
23565 -- 4955764
23566 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23567 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
23568
23569
23570 XLA_AE_LINES_PKG.ValidateCurrentLine;
23571 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23572
23573 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23574 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
23575 ,p_balance_type_code => l_balance_type_code);
23576
23577 END IF;
23578
23579 -----------------------------------------------------------------------------------------
23580 -- 4262811 Multiperiod Accounting
23581 -----------------------------------------------------------------------------------------
23582 -- No MPA option is assigned.
23583
23584
23585 END IF;
23586 END IF;
23587 --
23588
23589 --
23590 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23591 trace
23592 (p_msg => 'END of AcctLineType_66'
23593 ,p_level => C_LEVEL_PROCEDURE
23594 ,p_module => l_log_module);
23595 END IF;
23596 --
23597 EXCEPTION
23598 WHEN xla_exceptions_pkg.application_exception THEN
23599 RAISE;
23600 WHEN OTHERS THEN
23601 xla_exceptions_pkg.raise_message
23602 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_66');
23603 END AcctLineType_66;
23604 --
23605
23606 ---------------------------------------
23607 --
23608 -- PRIVATE FUNCTION
23609 -- AcctLineType_67
23610 --
23611 ---------------------------------------
23612 PROCEDURE AcctLineType_67 (
23613 p_application_id IN NUMBER
23614 ,p_event_id IN NUMBER
23615 ,p_calculate_acctd_flag IN VARCHAR2
23616 ,p_calculate_g_l_flag IN VARCHAR2
23617 ,p_actual_flag IN OUT VARCHAR2
23618 ,p_balance_type_code OUT VARCHAR2
23619 ,p_gain_or_loss_ref OUT VARCHAR2
23620
23621 --Distribution GL Account
23622 , p_source_10 IN NUMBER
23623 --Federal Fund Expired Status
23627 --Federal Fund Time Frame
23624 , p_source_14 IN VARCHAR2
23625 --Federal Prior Year Flag
23626 , p_source_15 IN VARCHAR2
23628 , p_source_16 IN VARCHAR2
23629 --Distribution Source Type
23630 , p_source_22 IN VARCHAR2
23631 --Distribution Line Identifier
23632 , p_source_24 IN NUMBER
23633 --Distribution Type
23634 , p_source_25 IN VARCHAR2
23635 --Entered Amount
23636 , p_source_26 IN NUMBER
23637 --Currency Code
23638 , p_source_27 IN VARCHAR2
23639 --Exchange Rate
23640 , p_source_29 IN NUMBER
23641 --Exchange Rate Type
23642 , p_source_30 IN VARCHAR2
23643 --Applied To Document Accounting Amount
23644 , p_source_31 IN NUMBER
23645 --Federal Account Valid Flag
23646 , p_source_58 IN VARCHAR2
23647 --Applied To Document Exchange Date
23648 , p_source_59 IN DATE
23649 )
23650 IS
23651
23652 l_component_type VARCHAR2(80);
23653 l_component_code VARCHAR2(30);
23654 l_component_type_code VARCHAR2(1);
23655 l_component_appl_id INTEGER;
23656 l_amb_context_code VARCHAR2(30);
23657 l_entity_code VARCHAR2(30);
23658 l_event_class_code VARCHAR2(30);
23659 l_ae_header_id NUMBER;
23660 l_event_type_code VARCHAR2(30);
23661 l_line_definition_code VARCHAR2(30);
23662 l_line_definition_owner_code VARCHAR2(1);
23663 --
23664 -- adr variables
23665 l_segment VARCHAR2(30);
23666 l_ccid NUMBER;
23667 l_adr_transaction_coa_id NUMBER;
23668 l_adr_accounting_coa_id NUMBER;
23669 l_adr_flexfield_segment_code VARCHAR2(30);
23670 l_adr_flex_value_set_id NUMBER;
23671 l_adr_value_type_code VARCHAR2(30);
23672 l_adr_value_combination_id NUMBER;
23673 l_adr_value_segment_code VARCHAR2(30);
23674
23675 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
23676 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
23677 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
23678 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
23679
23680 -- 4262811 Variables ------------------------------------------------------------------------------------------
23681 l_entered_amt_idx NUMBER;
23682 l_accted_amt_idx NUMBER;
23683 l_acc_rev_flag VARCHAR2(1);
23684 l_accrual_line_num NUMBER;
23685 l_tmp_amt NUMBER;
23686 l_acc_rev_natural_side_code VARCHAR2(1);
23687
23688 l_num_entries NUMBER;
23689 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
23690 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
23691 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
23692 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
23693 l_recog_line_1 NUMBER;
23694 l_recog_line_2 NUMBER;
23695
23696 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
23697 l_bflow_applied_to_amt NUMBER; -- 5132302
23698 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
23699
23700 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
23701
23702 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
23703 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
23704
23705 ---------------------------------------------------------------------------------------------------------------
23706
23707
23708 --
23709 -- bulk performance
23710 --
23711 l_balance_type_code VARCHAR2(1);
23712 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
23713 l_log_module VARCHAR2(240);
23714
23715 --
23716 -- Upgrade strategy
23717 --
23718 l_actual_upg_option VARCHAR2(1);
23719 l_enc_upg_option VARCHAR2(1);
23720
23721 --
23722 BEGIN
23723 --
23724 IF g_log_enabled THEN
23725 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_67';
23726 END IF;
23727 --
23728 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23729
23730 trace
23731 (p_msg => 'BEGIN of AcctLineType_67'
23732 ,p_level => C_LEVEL_PROCEDURE
23733 ,p_module => l_log_module);
23734
23735 END IF;
23736 --
23737 l_component_type := 'AMB_JLT';
23738 l_component_code := 'FV_MISC_RCT_REF_OUFP_DR';
23739 l_component_type_code := 'S';
23740 l_component_appl_id := 222;
23741 l_amb_context_code := 'DEFAULT';
23742 l_entity_code := 'RECEIPTS';
23743 l_event_class_code := 'MISC_RECEIPT';
23744 l_event_type_code := 'MISC_RECEIPT_ALL';
23745 l_line_definition_owner_code := 'S';
23746 l_line_definition_code := 'MFAR_FED_AR_MISC_REC_ACCOUNT';
23747 --
23748 l_balance_type_code := 'A';
23749 l_segment := NULL;
23750 l_ccid := NULL;
23751 l_adr_transaction_coa_id := NULL;
23752 l_adr_accounting_coa_id := NULL;
23753 l_adr_flexfield_segment_code := NULL;
23754 l_adr_flex_value_set_id := NULL;
23758
23755 l_adr_value_type_code := NULL;
23756 l_adr_value_combination_id := NULL;
23757 l_adr_value_segment_code := NULL;
23759 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
23760 l_bflow_class_code := ''; -- 4219869 Business Flow
23761 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
23762 l_budgetary_control_flag := 'N';
23763
23764 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23765 l_bflow_applied_to_amt := NULL; -- 5132302
23766 l_entered_amt_idx := NULL; -- 4262811
23767 l_accted_amt_idx := NULL; -- 4262811
23768 l_acc_rev_flag := NULL; -- 4262811
23769 l_accrual_line_num := NULL; -- 4262811
23770 l_tmp_amt := NULL; -- 4262811
23771 --
23772
23773 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
23774 l_balance_type_code <> 'B' THEN
23775 IF NVL(p_source_22,'
23776 ') = 'MISCCASH' AND
23777 NVL(p_source_14,'
23778 ') = 'Unexpired' AND
23779 NVL(p_source_15,'
23780 ') = 'Y' AND
23781 (NVL(p_source_16,'
23782 ') = 'MULTIPLE' OR
23783 NVL(p_source_16,'
23784 ') = 'NO_YEAR') AND
23785 NVL(p_source_58,'
23786 ') = 'Y'
23787 THEN
23788
23789 --
23790 XLA_AE_LINES_PKG.SetNewLine;
23791
23792 p_balance_type_code := l_balance_type_code;
23793 -- set the flag so later we will know whether the gain loss line needs to be created
23794
23795 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
23796 p_actual_flag :='A';
23797 END IF;
23798
23799 --
23800 -- bulk performance
23801 --
23802 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
23803 p_header_num => 0); -- 4262811
23804 --
23805 -- set accounting line options
23806 --
23807 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
23808 p_natural_side_code => 'D'
23809 , p_gain_or_loss_flag => 'N'
23810 , p_gl_transfer_mode_code => 'S'
23811 , p_acct_entry_type_code => 'A'
23812 , p_switch_side_flag => 'Y'
23813 , p_merge_duplicate_code => 'A'
23814 );
23815 --
23816 l_acc_rev_natural_side_code := 'C'; -- 4262811
23817 --
23818 --
23819 -- set accounting line type info
23820 --
23821 xla_ae_lines_pkg.SetAcctLineType
23822 (p_component_type => l_component_type
23823 ,p_event_type_code => l_event_type_code
23824 ,p_line_definition_owner_code => l_line_definition_owner_code
23825 ,p_line_definition_code => l_line_definition_code
23826 ,p_accounting_line_code => l_component_code
23827 ,p_accounting_line_type_code => l_component_type_code
23828 ,p_accounting_line_appl_id => l_component_appl_id
23829 ,p_amb_context_code => l_amb_context_code
23830 ,p_entity_code => l_entity_code
23831 ,p_event_class_code => l_event_class_code);
23832 --
23833 -- set accounting class
23834 --
23835 xla_ae_lines_pkg.SetAcctClass(
23836 p_accounting_class_code => 'FV_MISCCASH_DR'
23837 , p_ae_header_id => l_ae_header_id
23838 );
23839
23840 --
23841 -- set rounding class
23842 --
23843 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
23844 'RECEIVABLE';
23845
23846 --
23847 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
23848 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
23849 --
23850 -- bulk performance
23851 --
23852 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
23853
23854 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
23855 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
23856
23857 -- 4955764
23858 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23859 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
23860
23861 -- 4458381 Public Sector Enh
23862
23863 --
23864 -- set accounting attributes for the line type
23865 --
23866 l_entered_amt_idx := 3;
23867 l_accted_amt_idx := 8;
23868 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23869 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
23870 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
23871 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
23872 l_rec_acct_attrs.array_char_value(2) := p_source_25;
23873 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
23874 l_rec_acct_attrs.array_num_value(3) := p_source_26;
23875 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
23876 l_rec_acct_attrs.array_char_value(4) := p_source_27;
23877 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
23878 l_rec_acct_attrs.array_date_value(5) := p_source_59;
23879 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
23883 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
23880 l_rec_acct_attrs.array_num_value(6) := p_source_29;
23881 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
23882 l_rec_acct_attrs.array_char_value(7) := p_source_30;
23884 l_rec_acct_attrs.array_num_value(8) := p_source_31;
23885
23886 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
23887 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
23888
23889 ---------------------------------------------------------------------------------------------------------------
23890 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
23891 ---------------------------------------------------------------------------------------------------------------
23892 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
23893
23894 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23895 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23896
23897 IF xla_accounting_cache_pkg.GetValueChar
23898 (p_source_code => 'LEDGER_CATEGORY_CODE'
23899 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
23900 AND l_bflow_method_code = 'PRIOR_ENTRY'
23901 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
23902 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
23903 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
23904 )
23905 THEN
23906 xla_ae_lines_pkg.BflowUpgEntry
23907 (p_business_method_code => l_bflow_method_code
23908 ,p_business_class_code => l_bflow_class_code
23909 ,p_balance_type => l_balance_type_code);
23910 ELSE
23911 NULL;
23912 -- No business flow processing for business flow method of NONE.
23913 END IF;
23914
23915 --
23916 -- call analytical criteria
23917 --
23918
23919 --
23920 -- call description
23921 --
23922 -- No description or it is inherited.
23923 --
23924 -- call ADRs
23925 -- Bug 4922099
23926 --
23927 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23928 (NVL(l_actual_upg_option, 'N') = 'O') OR
23929 (NVL(l_enc_upg_option, 'N') = 'O')
23930 )
23931 THEN
23932 NULL;
23933 --
23934 --
23935
23936 l_ccid := AcctDerRule_11(
23937 p_application_id => p_application_id
23938 , p_ae_header_id => l_ae_header_id
23939 , p_source_10 => p_source_10
23940 , x_transaction_coa_id => l_adr_transaction_coa_id
23941 , x_accounting_coa_id => l_adr_accounting_coa_id
23942 , x_value_type_code => l_adr_value_type_code
23943 , p_side => 'NA'
23944 );
23945
23946 xla_ae_lines_pkg.set_ccid(
23947 p_code_combination_id => l_ccid
23948 , p_value_type_code => l_adr_value_type_code
23949 , p_transaction_coa_id => l_adr_transaction_coa_id
23950 , p_accounting_coa_id => l_adr_accounting_coa_id
23951 , p_adr_code => 'DIST_CCID'
23952 , p_adr_type_code => 'S'
23953 , p_component_type => l_component_type
23954 , p_component_code => l_component_code
23955 , p_component_type_code => l_component_type_code
23956 , p_component_appl_id => l_component_appl_id
23957 , p_amb_context_code => l_amb_context_code
23958 , p_side => 'NA'
23959 );
23960
23961
23962 l_segment := AcctDerRule_25(
23963 p_application_id => p_application_id
23964 , p_ae_header_id => l_ae_header_id
23965 , p_source_14 => p_source_14
23966 , p_source_15 => p_source_15
23967 , p_source_16 => p_source_16
23968 , x_transaction_coa_id => l_adr_transaction_coa_id
23969 , x_accounting_coa_id => l_adr_accounting_coa_id
23970 , x_flexfield_segment_code => l_adr_flexfield_segment_code
23971 , x_flex_value_set_id => l_adr_flex_value_set_id
23972 , x_value_type_code => l_adr_value_type_code
23973 , x_value_combination_id => l_adr_value_combination_id
23974 , x_value_segment_code => l_adr_value_segment_code
23975 , p_side => 'NA'
23976 , p_override_seg_flag => 'Y'
23977 );
23978
23979 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
23980
23981 xla_ae_lines_pkg.set_segment(
23982 p_to_segment_code => 'GL_ACCOUNT'
23983 , p_segment_value => l_segment
23984 , p_from_segment_code => l_adr_value_segment_code
23985 , p_from_combination_id => l_adr_value_combination_id
23986 , p_value_type_code => l_adr_value_type_code
23987 , p_transaction_coa_id => l_adr_transaction_coa_id
23988 , p_accounting_coa_id => l_adr_accounting_coa_id
23989 , p_flexfield_segment_code => l_adr_flexfield_segment_code
23990 , p_flex_value_set_id => l_adr_flex_value_set_id
23991 , p_adr_code => 'FV_AR_497201_MISC_RCT_DR'
23992 , p_adr_type_code => 'S'
23996 , p_component_appl_id => l_component_appl_id
23993 , p_component_type => l_component_type
23994 , p_component_code => l_component_code
23995 , p_component_type_code => l_component_type_code
23997 , p_amb_context_code => l_amb_context_code
23998 , p_entity_code => 'RECEIPTS'
23999 , p_event_class_code => 'MISC_RECEIPT'
24000 , p_side => 'NA'
24001 );
24002
24003 END IF;
24004
24005 --
24006 --
24007 END IF;
24008 --
24009 -- Bug 4922099
24010 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
24011 (NVL(l_enc_upg_option, 'N') = 'O')
24012 ) AND
24013 (l_bflow_method_code = 'PRIOR_ENTRY')
24014 )
24015 THEN
24016 IF
24017 --
24018 1 = 2
24019 --
24020 THEN
24021 xla_accounting_err_pkg.build_message
24022 (p_appli_s_name => 'XLA'
24023 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24024 ,p_token_1 => 'LINE_NUMBER'
24025 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
24026 ,p_token_2 => 'LINE_TYPE_NAME'
24027 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
24028 l_component_type
24029 ,l_component_code
24030 ,l_component_type_code
24031 ,l_component_appl_id
24032 ,l_amb_context_code
24033 ,l_entity_code
24034 ,l_event_class_code
24035 )
24036 ,p_token_3 => 'OWNER'
24037 ,p_value_3 => xla_lookups_pkg.get_meaning(
24038 p_lookup_type => 'XLA_OWNER_TYPE'
24039 ,p_lookup_code => l_component_type_code
24040 )
24041 ,p_token_4 => 'PRODUCT_NAME'
24042 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
24043 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
24044 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
24045 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
24046 ,p_ae_header_id => NULL
24047 );
24048
24049 IF (C_LEVEL_ERROR>= g_log_level) THEN
24050 trace
24051 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24052 ,p_level => C_LEVEL_ERROR
24053 ,p_module => l_log_module);
24054 END IF;
24055 END IF;
24056 END IF;
24057 --
24058 --
24059 ------------------------------------------------------------------------------------------------
24060 -- 4219869 Business Flow
24061 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
24062 -- Prior Entry. Currently, the following code is always generated.
24063 ------------------------------------------------------------------------------------------------
24064 XLA_AE_LINES_PKG.ValidateCurrentLine;
24065
24066 ------------------------------------------------------------------------------------
24067 -- 4219869 Business Flow
24068 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
24069 ------------------------------------------------------------------------------------
24070 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24071
24072 ----------------------------------------------------------------------------------
24073 -- 4219869 Business Flow
24074 -- Update journal entry status -- Need to generate this within IF <condition>
24075 ----------------------------------------------------------------------------------
24076 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24077 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
24078 ,p_balance_type_code => l_balance_type_code
24079 );
24080
24081 -------------------------------------------------------------------------------------------
24082 -- 4262811 - Generate the Accrual Reversal lines
24083 -------------------------------------------------------------------------------------------
24084 BEGIN
24085 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
24086 (g_array_event(p_event_id).array_value_num('header_index'));
24087 IF l_acc_rev_flag IS NULL THEN
24088 l_acc_rev_flag := 'N';
24089 END IF;
24090 EXCEPTION
24094 --
24091 WHEN OTHERS THEN
24092 l_acc_rev_flag := 'N';
24093 END;
24095 IF (l_acc_rev_flag = 'Y') THEN
24096
24097 -- 4645092 ------------------------------------------------------------------------------
24098 -- To allow MPA report to determine if it should generate report process
24099 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
24100 ------------------------------------------------------------------------------------------
24101
24102 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
24103 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
24104 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
24105 -- call ADRs
24106 -- Bug 4922099
24107 --
24108 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24109 (NVL(l_actual_upg_option, 'N') = 'O') OR
24110 (NVL(l_enc_upg_option, 'N') = 'O')
24111 )
24112 THEN
24113 NULL;
24114 --
24115 --
24116
24117 l_ccid := AcctDerRule_11(
24118 p_application_id => p_application_id
24119 , p_ae_header_id => l_ae_header_id
24120 , p_source_10 => p_source_10
24121 , x_transaction_coa_id => l_adr_transaction_coa_id
24122 , x_accounting_coa_id => l_adr_accounting_coa_id
24123 , x_value_type_code => l_adr_value_type_code
24124 , p_side => 'NA'
24125 );
24126
24127 xla_ae_lines_pkg.set_ccid(
24128 p_code_combination_id => l_ccid
24129 , p_value_type_code => l_adr_value_type_code
24130 , p_transaction_coa_id => l_adr_transaction_coa_id
24131 , p_accounting_coa_id => l_adr_accounting_coa_id
24132 , p_adr_code => 'DIST_CCID'
24133 , p_adr_type_code => 'S'
24134 , p_component_type => l_component_type
24135 , p_component_code => l_component_code
24136 , p_component_type_code => l_component_type_code
24137 , p_component_appl_id => l_component_appl_id
24138 , p_amb_context_code => l_amb_context_code
24139 , p_side => 'NA'
24140 );
24141
24142
24143 l_segment := AcctDerRule_25(
24144 p_application_id => p_application_id
24145 , p_ae_header_id => l_ae_header_id
24146 , p_source_14 => p_source_14
24147 , p_source_15 => p_source_15
24148 , p_source_16 => p_source_16
24149 , x_transaction_coa_id => l_adr_transaction_coa_id
24150 , x_accounting_coa_id => l_adr_accounting_coa_id
24151 , x_flexfield_segment_code => l_adr_flexfield_segment_code
24152 , x_flex_value_set_id => l_adr_flex_value_set_id
24153 , x_value_type_code => l_adr_value_type_code
24154 , x_value_combination_id => l_adr_value_combination_id
24155 , x_value_segment_code => l_adr_value_segment_code
24156 , p_side => 'NA'
24157 , p_override_seg_flag => 'Y'
24158 );
24159
24160 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
24161
24162 xla_ae_lines_pkg.set_segment(
24163 p_to_segment_code => 'GL_ACCOUNT'
24164 , p_segment_value => l_segment
24165 , p_from_segment_code => l_adr_value_segment_code
24166 , p_from_combination_id => l_adr_value_combination_id
24167 , p_value_type_code => l_adr_value_type_code
24168 , p_transaction_coa_id => l_adr_transaction_coa_id
24169 , p_accounting_coa_id => l_adr_accounting_coa_id
24170 , p_flexfield_segment_code => l_adr_flexfield_segment_code
24171 , p_flex_value_set_id => l_adr_flex_value_set_id
24172 , p_adr_code => 'FV_AR_497201_MISC_RCT_DR'
24173 , p_adr_type_code => 'S'
24174 , p_component_type => l_component_type
24175 , p_component_code => l_component_code
24176 , p_component_type_code => l_component_type_code
24177 , p_component_appl_id => l_component_appl_id
24178 , p_amb_context_code => l_amb_context_code
24179 , p_entity_code => 'RECEIPTS'
24180 , p_event_class_code => 'MISC_RECEIPT'
24181 , p_side => 'NA'
24182 );
24183
24184 END IF;
24185
24186 --
24187 --
24188 END IF;
24189
24190 --
24191 -- Update the line information that should be overwritten
24192 --
24193 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
24194 p_header_num => 1);
24195 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
24196
24197 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
24198
24199 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
24200 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
24201 END IF;
24202
24203 --
24204 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
24205 --
24206 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
24207 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
24211 ---------------------------------------------------------------------------------------------------
24208 ELSE
24209 ---------------------------------------------------------------------------------------------------
24210 -- 4262811a Switch Sign
24212 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
24213 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24214 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24215 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24216 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24217 -- 5132302
24218 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
24219 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24220
24221 END IF;
24222
24223 -- 4955764
24224 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24225 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
24226
24227
24228 XLA_AE_LINES_PKG.ValidateCurrentLine;
24229 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24230
24231 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24232 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
24233 ,p_balance_type_code => l_balance_type_code);
24234
24235 END IF;
24236
24237 -----------------------------------------------------------------------------------------
24238 -- 4262811 Multiperiod Accounting
24239 -----------------------------------------------------------------------------------------
24240 -- No MPA option is assigned.
24241
24242
24243 END IF;
24244 END IF;
24245 --
24246
24247 --
24248 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24249 trace
24250 (p_msg => 'END of AcctLineType_67'
24251 ,p_level => C_LEVEL_PROCEDURE
24252 ,p_module => l_log_module);
24253 END IF;
24254 --
24255 EXCEPTION
24256 WHEN xla_exceptions_pkg.application_exception THEN
24257 RAISE;
24258 WHEN OTHERS THEN
24259 xla_exceptions_pkg.raise_message
24260 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_67');
24261 END AcctLineType_67;
24262 --
24263
24264 ---------------------------------------
24265 --
24266 -- PRIVATE FUNCTION
24267 -- AcctLineType_68
24268 --
24269 ---------------------------------------
24270 PROCEDURE AcctLineType_68 (
24271 p_application_id IN NUMBER
24272 ,p_event_id IN NUMBER
24273 ,p_calculate_acctd_flag IN VARCHAR2
24274 ,p_calculate_g_l_flag IN VARCHAR2
24275 ,p_actual_flag IN OUT VARCHAR2
24276 ,p_balance_type_code OUT VARCHAR2
24277 ,p_gain_or_loss_ref OUT VARCHAR2
24278
24279 --Distribution GL Account
24280 , p_source_10 IN NUMBER
24281 --Federal Fund Category
24282 , p_source_11 IN VARCHAR2
24283 --Distribution Source Type
24284 , p_source_22 IN VARCHAR2
24285 --Distribution Line Identifier
24286 , p_source_24 IN NUMBER
24287 --Distribution Type
24288 , p_source_25 IN VARCHAR2
24289 --Entered Amount
24290 , p_source_26 IN NUMBER
24291 --Currency Code
24292 , p_source_27 IN VARCHAR2
24293 --Exchange Rate
24294 , p_source_29 IN NUMBER
24295 --Exchange Rate Type
24296 , p_source_30 IN VARCHAR2
24297 --Applied To Document Accounting Amount
24298 , p_source_31 IN NUMBER
24299 --Federal Account Valid Flag
24300 , p_source_58 IN VARCHAR2
24301 --Applied To Document Exchange Date
24302 , p_source_59 IN DATE
24303 )
24304 IS
24305
24306 l_component_type VARCHAR2(80);
24307 l_component_code VARCHAR2(30);
24308 l_component_type_code VARCHAR2(1);
24309 l_component_appl_id INTEGER;
24310 l_amb_context_code VARCHAR2(30);
24311 l_entity_code VARCHAR2(30);
24312 l_event_class_code VARCHAR2(30);
24313 l_ae_header_id NUMBER;
24314 l_event_type_code VARCHAR2(30);
24315 l_line_definition_code VARCHAR2(30);
24316 l_line_definition_owner_code VARCHAR2(1);
24317 --
24318 -- adr variables
24319 l_segment VARCHAR2(30);
24320 l_ccid NUMBER;
24321 l_adr_transaction_coa_id NUMBER;
24322 l_adr_accounting_coa_id NUMBER;
24323 l_adr_flexfield_segment_code VARCHAR2(30);
24324 l_adr_flex_value_set_id NUMBER;
24325 l_adr_value_type_code VARCHAR2(30);
24326 l_adr_value_combination_id NUMBER;
24327 l_adr_value_segment_code VARCHAR2(30);
24328
24329 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
24330 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
24331 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
24332 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
24333
24337 l_acc_rev_flag VARCHAR2(1);
24334 -- 4262811 Variables ------------------------------------------------------------------------------------------
24335 l_entered_amt_idx NUMBER;
24336 l_accted_amt_idx NUMBER;
24338 l_accrual_line_num NUMBER;
24339 l_tmp_amt NUMBER;
24340 l_acc_rev_natural_side_code VARCHAR2(1);
24341
24342 l_num_entries NUMBER;
24343 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
24344 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
24345 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
24346 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
24347 l_recog_line_1 NUMBER;
24348 l_recog_line_2 NUMBER;
24349
24350 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
24351 l_bflow_applied_to_amt NUMBER; -- 5132302
24352 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
24353
24354 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
24355
24356 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
24357 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
24358
24359 ---------------------------------------------------------------------------------------------------------------
24360
24361
24362 --
24363 -- bulk performance
24364 --
24365 l_balance_type_code VARCHAR2(1);
24366 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
24367 l_log_module VARCHAR2(240);
24368
24369 --
24370 -- Upgrade strategy
24371 --
24372 l_actual_upg_option VARCHAR2(1);
24373 l_enc_upg_option VARCHAR2(1);
24374
24375 --
24376 BEGIN
24377 --
24378 IF g_log_enabled THEN
24379 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_68';
24380 END IF;
24381 --
24382 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24383
24384 trace
24385 (p_msg => 'BEGIN of AcctLineType_68'
24386 ,p_level => C_LEVEL_PROCEDURE
24387 ,p_module => l_log_module);
24388
24389 END IF;
24390 --
24391 l_component_type := 'AMB_JLT';
24392 l_component_code := 'FV_MISC_RCT_REIM_WO_ADV_CR';
24393 l_component_type_code := 'S';
24394 l_component_appl_id := 222;
24395 l_amb_context_code := 'DEFAULT';
24396 l_entity_code := 'RECEIPTS';
24397 l_event_class_code := 'MISC_RECEIPT';
24398 l_event_type_code := 'MISC_RECEIPT_ALL';
24399 l_line_definition_owner_code := 'S';
24400 l_line_definition_code := 'MFAR_FED_AR_MISC_REC_ACCOUNT';
24401 --
24402 l_balance_type_code := 'A';
24403 l_segment := NULL;
24404 l_ccid := NULL;
24405 l_adr_transaction_coa_id := NULL;
24406 l_adr_accounting_coa_id := NULL;
24407 l_adr_flexfield_segment_code := NULL;
24408 l_adr_flex_value_set_id := NULL;
24409 l_adr_value_type_code := NULL;
24410 l_adr_value_combination_id := NULL;
24411 l_adr_value_segment_code := NULL;
24412
24413 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
24414 l_bflow_class_code := ''; -- 4219869 Business Flow
24415 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
24416 l_budgetary_control_flag := 'N';
24417
24418 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24419 l_bflow_applied_to_amt := NULL; -- 5132302
24420 l_entered_amt_idx := NULL; -- 4262811
24421 l_accted_amt_idx := NULL; -- 4262811
24422 l_acc_rev_flag := NULL; -- 4262811
24423 l_accrual_line_num := NULL; -- 4262811
24424 l_tmp_amt := NULL; -- 4262811
24425 --
24426
24427 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
24428 l_balance_type_code <> 'B' THEN
24429 IF NVL(p_source_22,'
24430 ') = 'MISCCASH' AND
24431 NVL(p_source_11,'
24432 ') = 'Reimbursable' AND
24433 NVL(p_source_58,'
24434 ') = 'Y'
24435 THEN
24436
24437 --
24438 XLA_AE_LINES_PKG.SetNewLine;
24439
24440 p_balance_type_code := l_balance_type_code;
24441 -- set the flag so later we will know whether the gain loss line needs to be created
24442
24443 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
24444 p_actual_flag :='A';
24445 END IF;
24446
24447 --
24448 -- bulk performance
24449 --
24450 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
24451 p_header_num => 0); -- 4262811
24452 --
24453 -- set accounting line options
24454 --
24455 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
24456 p_natural_side_code => 'C'
24457 , p_gain_or_loss_flag => 'N'
24458 , p_gl_transfer_mode_code => 'S'
24459 , p_acct_entry_type_code => 'A'
24460 , p_switch_side_flag => 'Y'
24461 , p_merge_duplicate_code => 'A'
24462 );
24463 --
24464 l_acc_rev_natural_side_code := 'D'; -- 4262811
24468 --
24465 --
24466 --
24467 -- set accounting line type info
24469 xla_ae_lines_pkg.SetAcctLineType
24470 (p_component_type => l_component_type
24471 ,p_event_type_code => l_event_type_code
24472 ,p_line_definition_owner_code => l_line_definition_owner_code
24473 ,p_line_definition_code => l_line_definition_code
24474 ,p_accounting_line_code => l_component_code
24475 ,p_accounting_line_type_code => l_component_type_code
24476 ,p_accounting_line_appl_id => l_component_appl_id
24477 ,p_amb_context_code => l_amb_context_code
24478 ,p_entity_code => l_entity_code
24479 ,p_event_class_code => l_event_class_code);
24480 --
24481 -- set accounting class
24482 --
24483 xla_ae_lines_pkg.SetAcctClass(
24484 p_accounting_class_code => 'FV_MISCCASH_CR'
24485 , p_ae_header_id => l_ae_header_id
24486 );
24487
24488 --
24489 -- set rounding class
24490 --
24491 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
24492 'RECEIVABLE';
24493
24494 --
24495 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
24496 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
24497 --
24498 -- bulk performance
24499 --
24500 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
24501
24502 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
24503 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
24504
24505 -- 4955764
24506 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24507 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
24508
24509 -- 4458381 Public Sector Enh
24510
24511 --
24512 -- set accounting attributes for the line type
24513 --
24514 l_entered_amt_idx := 3;
24515 l_accted_amt_idx := 8;
24516 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24517 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
24518 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
24519 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
24520 l_rec_acct_attrs.array_char_value(2) := p_source_25;
24521 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
24522 l_rec_acct_attrs.array_num_value(3) := p_source_26;
24523 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
24524 l_rec_acct_attrs.array_char_value(4) := p_source_27;
24525 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
24526 l_rec_acct_attrs.array_date_value(5) := p_source_59;
24527 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
24528 l_rec_acct_attrs.array_num_value(6) := p_source_29;
24529 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
24530 l_rec_acct_attrs.array_char_value(7) := p_source_30;
24531 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
24532 l_rec_acct_attrs.array_num_value(8) := p_source_31;
24533
24534 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
24535 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
24536
24537 ---------------------------------------------------------------------------------------------------------------
24538 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
24539 ---------------------------------------------------------------------------------------------------------------
24540 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
24541
24542 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24543 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24544
24545 IF xla_accounting_cache_pkg.GetValueChar
24546 (p_source_code => 'LEDGER_CATEGORY_CODE'
24547 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
24548 AND l_bflow_method_code = 'PRIOR_ENTRY'
24549 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
24550 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
24551 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
24552 )
24553 THEN
24554 xla_ae_lines_pkg.BflowUpgEntry
24555 (p_business_method_code => l_bflow_method_code
24556 ,p_business_class_code => l_bflow_class_code
24557 ,p_balance_type => l_balance_type_code);
24558 ELSE
24559 NULL;
24560 -- No business flow processing for business flow method of NONE.
24561 END IF;
24562
24563 --
24564 -- call analytical criteria
24565 --
24566
24567 --
24568 -- call description
24569 --
24570 -- No description or it is inherited.
24571 --
24572 -- call ADRs
24573 -- Bug 4922099
24574 --
24575 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24576 (NVL(l_actual_upg_option, 'N') = 'O') OR
24577 (NVL(l_enc_upg_option, 'N') = 'O')
24578 )
24579 THEN
24580 NULL;
24581 --
24582 --
24586 , p_ae_header_id => l_ae_header_id
24583
24584 l_ccid := AcctDerRule_11(
24585 p_application_id => p_application_id
24587 , p_source_10 => p_source_10
24588 , x_transaction_coa_id => l_adr_transaction_coa_id
24589 , x_accounting_coa_id => l_adr_accounting_coa_id
24590 , x_value_type_code => l_adr_value_type_code
24591 , p_side => 'NA'
24592 );
24593
24594 xla_ae_lines_pkg.set_ccid(
24595 p_code_combination_id => l_ccid
24596 , p_value_type_code => l_adr_value_type_code
24597 , p_transaction_coa_id => l_adr_transaction_coa_id
24598 , p_accounting_coa_id => l_adr_accounting_coa_id
24599 , p_adr_code => 'DIST_CCID'
24600 , p_adr_type_code => 'S'
24601 , p_component_type => l_component_type
24602 , p_component_code => l_component_code
24603 , p_component_type_code => l_component_type_code
24604 , p_component_appl_id => l_component_appl_id
24605 , p_amb_context_code => l_amb_context_code
24606 , p_side => 'NA'
24607 );
24608
24609
24610 l_segment := AcctDerRule_12(
24611 p_application_id => p_application_id
24612 , p_ae_header_id => l_ae_header_id
24613 , p_source_11 => p_source_11
24614 , x_transaction_coa_id => l_adr_transaction_coa_id
24615 , x_accounting_coa_id => l_adr_accounting_coa_id
24616 , x_flexfield_segment_code => l_adr_flexfield_segment_code
24617 , x_flex_value_set_id => l_adr_flex_value_set_id
24618 , x_value_type_code => l_adr_value_type_code
24619 , x_value_combination_id => l_adr_value_combination_id
24620 , x_value_segment_code => l_adr_value_segment_code
24621 , p_side => 'NA'
24622 , p_override_seg_flag => 'Y'
24623 );
24624
24625 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
24626
24627 xla_ae_lines_pkg.set_segment(
24628 p_to_segment_code => 'GL_ACCOUNT'
24629 , p_segment_value => l_segment
24630 , p_from_segment_code => l_adr_value_segment_code
24631 , p_from_combination_id => l_adr_value_combination_id
24632 , p_value_type_code => l_adr_value_type_code
24633 , p_transaction_coa_id => l_adr_transaction_coa_id
24634 , p_accounting_coa_id => l_adr_accounting_coa_id
24635 , p_flexfield_segment_code => l_adr_flexfield_segment_code
24636 , p_flex_value_set_id => l_adr_flex_value_set_id
24637 , p_adr_code => 'FV_AR_422101_MISC_RCT_CR'
24638 , p_adr_type_code => 'S'
24639 , p_component_type => l_component_type
24640 , p_component_code => l_component_code
24641 , p_component_type_code => l_component_type_code
24642 , p_component_appl_id => l_component_appl_id
24643 , p_amb_context_code => l_amb_context_code
24644 , p_entity_code => 'RECEIPTS'
24645 , p_event_class_code => 'MISC_RECEIPT'
24646 , p_side => 'NA'
24647 );
24648
24649 END IF;
24650
24651 --
24652 --
24653 END IF;
24654 --
24655 -- Bug 4922099
24656 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
24657 (NVL(l_enc_upg_option, 'N') = 'O')
24658 ) AND
24659 (l_bflow_method_code = 'PRIOR_ENTRY')
24660 )
24661 THEN
24662 IF
24663 --
24664 1 = 2
24665 --
24666 THEN
24667 xla_accounting_err_pkg.build_message
24668 (p_appli_s_name => 'XLA'
24669 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24670 ,p_token_1 => 'LINE_NUMBER'
24671 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
24672 ,p_token_2 => 'LINE_TYPE_NAME'
24673 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
24674 l_component_type
24675 ,l_component_code
24676 ,l_component_type_code
24677 ,l_component_appl_id
24678 ,l_amb_context_code
24679 ,l_entity_code
24680 ,l_event_class_code
24681 )
24682 ,p_token_3 => 'OWNER'
24683 ,p_value_3 => xla_lookups_pkg.get_meaning(
24684 p_lookup_type => 'XLA_OWNER_TYPE'
24685 ,p_lookup_code => l_component_type_code
24686 )
24690 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
24687 ,p_token_4 => 'PRODUCT_NAME'
24688 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
24689 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
24691 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
24692 ,p_ae_header_id => NULL
24693 );
24694
24695 IF (C_LEVEL_ERROR>= g_log_level) THEN
24696 trace
24697 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24698 ,p_level => C_LEVEL_ERROR
24699 ,p_module => l_log_module);
24700 END IF;
24701 END IF;
24702 END IF;
24703 --
24704 --
24705 ------------------------------------------------------------------------------------------------
24706 -- 4219869 Business Flow
24707 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
24708 -- Prior Entry. Currently, the following code is always generated.
24709 ------------------------------------------------------------------------------------------------
24710 XLA_AE_LINES_PKG.ValidateCurrentLine;
24711
24712 ------------------------------------------------------------------------------------
24713 -- 4219869 Business Flow
24714 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
24715 ------------------------------------------------------------------------------------
24716 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24717
24718 ----------------------------------------------------------------------------------
24719 -- 4219869 Business Flow
24720 -- Update journal entry status -- Need to generate this within IF <condition>
24721 ----------------------------------------------------------------------------------
24722 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24723 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
24724 ,p_balance_type_code => l_balance_type_code
24725 );
24726
24727 -------------------------------------------------------------------------------------------
24728 -- 4262811 - Generate the Accrual Reversal lines
24729 -------------------------------------------------------------------------------------------
24730 BEGIN
24731 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
24732 (g_array_event(p_event_id).array_value_num('header_index'));
24733 IF l_acc_rev_flag IS NULL THEN
24734 l_acc_rev_flag := 'N';
24735 END IF;
24736 EXCEPTION
24737 WHEN OTHERS THEN
24738 l_acc_rev_flag := 'N';
24739 END;
24740 --
24741 IF (l_acc_rev_flag = 'Y') THEN
24742
24743 -- 4645092 ------------------------------------------------------------------------------
24744 -- To allow MPA report to determine if it should generate report process
24745 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
24746 ------------------------------------------------------------------------------------------
24747
24748 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
24749 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
24750 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
24751 -- call ADRs
24752 -- Bug 4922099
24753 --
24754 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24755 (NVL(l_actual_upg_option, 'N') = 'O') OR
24756 (NVL(l_enc_upg_option, 'N') = 'O')
24757 )
24758 THEN
24759 NULL;
24760 --
24761 --
24762
24763 l_ccid := AcctDerRule_11(
24764 p_application_id => p_application_id
24765 , p_ae_header_id => l_ae_header_id
24766 , p_source_10 => p_source_10
24767 , x_transaction_coa_id => l_adr_transaction_coa_id
24768 , x_accounting_coa_id => l_adr_accounting_coa_id
24769 , x_value_type_code => l_adr_value_type_code
24770 , p_side => 'NA'
24771 );
24772
24773 xla_ae_lines_pkg.set_ccid(
24774 p_code_combination_id => l_ccid
24775 , p_value_type_code => l_adr_value_type_code
24776 , p_transaction_coa_id => l_adr_transaction_coa_id
24777 , p_accounting_coa_id => l_adr_accounting_coa_id
24778 , p_adr_code => 'DIST_CCID'
24779 , p_adr_type_code => 'S'
24780 , p_component_type => l_component_type
24781 , p_component_code => l_component_code
24782 , p_component_type_code => l_component_type_code
24783 , p_component_appl_id => l_component_appl_id
24784 , p_amb_context_code => l_amb_context_code
24785 , p_side => 'NA'
24786 );
24787
24788
24789 l_segment := AcctDerRule_12(
24790 p_application_id => p_application_id
24791 , p_ae_header_id => l_ae_header_id
24792 , p_source_11 => p_source_11
24793 , x_transaction_coa_id => l_adr_transaction_coa_id
24794 , x_accounting_coa_id => l_adr_accounting_coa_id
24795 , x_flexfield_segment_code => l_adr_flexfield_segment_code
24799 , x_value_segment_code => l_adr_value_segment_code
24796 , x_flex_value_set_id => l_adr_flex_value_set_id
24797 , x_value_type_code => l_adr_value_type_code
24798 , x_value_combination_id => l_adr_value_combination_id
24800 , p_side => 'NA'
24801 , p_override_seg_flag => 'Y'
24802 );
24803
24804 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
24805
24806 xla_ae_lines_pkg.set_segment(
24807 p_to_segment_code => 'GL_ACCOUNT'
24808 , p_segment_value => l_segment
24809 , p_from_segment_code => l_adr_value_segment_code
24810 , p_from_combination_id => l_adr_value_combination_id
24811 , p_value_type_code => l_adr_value_type_code
24812 , p_transaction_coa_id => l_adr_transaction_coa_id
24813 , p_accounting_coa_id => l_adr_accounting_coa_id
24814 , p_flexfield_segment_code => l_adr_flexfield_segment_code
24815 , p_flex_value_set_id => l_adr_flex_value_set_id
24816 , p_adr_code => 'FV_AR_422101_MISC_RCT_CR'
24817 , p_adr_type_code => 'S'
24818 , p_component_type => l_component_type
24819 , p_component_code => l_component_code
24820 , p_component_type_code => l_component_type_code
24821 , p_component_appl_id => l_component_appl_id
24822 , p_amb_context_code => l_amb_context_code
24823 , p_entity_code => 'RECEIPTS'
24824 , p_event_class_code => 'MISC_RECEIPT'
24825 , p_side => 'NA'
24826 );
24827
24828 END IF;
24829
24830 --
24831 --
24832 END IF;
24833
24834 --
24835 -- Update the line information that should be overwritten
24836 --
24837 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
24838 p_header_num => 1);
24839 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
24840
24841 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
24842
24843 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
24844 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
24845 END IF;
24846
24847 --
24848 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
24849 --
24850 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
24851 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
24852 ELSE
24853 ---------------------------------------------------------------------------------------------------
24854 -- 4262811a Switch Sign
24855 ---------------------------------------------------------------------------------------------------
24856 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
24857 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24858 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24859 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24860 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24861 -- 5132302
24862 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
24863 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24864
24865 END IF;
24866
24867 -- 4955764
24868 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24869 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
24870
24871
24872 XLA_AE_LINES_PKG.ValidateCurrentLine;
24873 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24874
24875 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24876 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
24877 ,p_balance_type_code => l_balance_type_code);
24878
24879 END IF;
24880
24881 -----------------------------------------------------------------------------------------
24882 -- 4262811 Multiperiod Accounting
24883 -----------------------------------------------------------------------------------------
24884 -- No MPA option is assigned.
24885
24886
24887 END IF;
24888 END IF;
24889 --
24890
24891 --
24892 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24893 trace
24894 (p_msg => 'END of AcctLineType_68'
24895 ,p_level => C_LEVEL_PROCEDURE
24896 ,p_module => l_log_module);
24897 END IF;
24898 --
24899 EXCEPTION
24900 WHEN xla_exceptions_pkg.application_exception THEN
24901 RAISE;
24902 WHEN OTHERS THEN
24903 xla_exceptions_pkg.raise_message
24904 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_68');
24905 END AcctLineType_68;
24906 --
24907
24908 ---------------------------------------
24909 --
24913 ---------------------------------------
24910 -- PRIVATE FUNCTION
24911 -- AcctLineType_69
24912 --
24914 PROCEDURE AcctLineType_69 (
24915 p_application_id IN NUMBER
24916 ,p_event_id IN NUMBER
24917 ,p_calculate_acctd_flag IN VARCHAR2
24918 ,p_calculate_g_l_flag IN VARCHAR2
24919 ,p_actual_flag IN OUT VARCHAR2
24920 ,p_balance_type_code OUT VARCHAR2
24921 ,p_gain_or_loss_ref OUT VARCHAR2
24922
24923 --Distribution GL Account
24924 , p_source_10 IN NUMBER
24925 --Federal Fund Category
24926 , p_source_11 IN VARCHAR2
24927 --Distribution Source Type
24928 , p_source_22 IN VARCHAR2
24929 --Distribution Line Identifier
24930 , p_source_24 IN NUMBER
24931 --Distribution Type
24932 , p_source_25 IN VARCHAR2
24933 --Entered Amount
24934 , p_source_26 IN NUMBER
24935 --Currency Code
24936 , p_source_27 IN VARCHAR2
24937 --Exchange Rate
24938 , p_source_29 IN NUMBER
24939 --Exchange Rate Type
24940 , p_source_30 IN VARCHAR2
24941 --Applied To Document Accounting Amount
24942 , p_source_31 IN NUMBER
24943 --Federal Account Valid Flag
24944 , p_source_58 IN VARCHAR2
24945 --Applied To Document Exchange Date
24946 , p_source_59 IN DATE
24947 )
24948 IS
24949
24950 l_component_type VARCHAR2(80);
24951 l_component_code VARCHAR2(30);
24952 l_component_type_code VARCHAR2(1);
24953 l_component_appl_id INTEGER;
24954 l_amb_context_code VARCHAR2(30);
24955 l_entity_code VARCHAR2(30);
24956 l_event_class_code VARCHAR2(30);
24957 l_ae_header_id NUMBER;
24958 l_event_type_code VARCHAR2(30);
24959 l_line_definition_code VARCHAR2(30);
24960 l_line_definition_owner_code VARCHAR2(1);
24961 --
24962 -- adr variables
24963 l_segment VARCHAR2(30);
24964 l_ccid NUMBER;
24965 l_adr_transaction_coa_id NUMBER;
24966 l_adr_accounting_coa_id NUMBER;
24967 l_adr_flexfield_segment_code VARCHAR2(30);
24968 l_adr_flex_value_set_id NUMBER;
24969 l_adr_value_type_code VARCHAR2(30);
24970 l_adr_value_combination_id NUMBER;
24971 l_adr_value_segment_code VARCHAR2(30);
24972
24973 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
24974 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
24975 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
24976 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
24977
24978 -- 4262811 Variables ------------------------------------------------------------------------------------------
24979 l_entered_amt_idx NUMBER;
24980 l_accted_amt_idx NUMBER;
24981 l_acc_rev_flag VARCHAR2(1);
24982 l_accrual_line_num NUMBER;
24983 l_tmp_amt NUMBER;
24984 l_acc_rev_natural_side_code VARCHAR2(1);
24985
24986 l_num_entries NUMBER;
24987 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
24988 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
24989 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
24990 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
24991 l_recog_line_1 NUMBER;
24992 l_recog_line_2 NUMBER;
24993
24994 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
24995 l_bflow_applied_to_amt NUMBER; -- 5132302
24996 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
24997
24998 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
24999
25000 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
25001 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
25002
25003 ---------------------------------------------------------------------------------------------------------------
25004
25005
25006 --
25007 -- bulk performance
25008 --
25009 l_balance_type_code VARCHAR2(1);
25010 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
25011 l_log_module VARCHAR2(240);
25012
25013 --
25014 -- Upgrade strategy
25015 --
25016 l_actual_upg_option VARCHAR2(1);
25017 l_enc_upg_option VARCHAR2(1);
25018
25019 --
25020 BEGIN
25021 --
25022 IF g_log_enabled THEN
25023 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_69';
25024 END IF;
25025 --
25026 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25027
25028 trace
25029 (p_msg => 'BEGIN of AcctLineType_69'
25030 ,p_level => C_LEVEL_PROCEDURE
25031 ,p_module => l_log_module);
25032
25033 END IF;
25034 --
25035 l_component_type := 'AMB_JLT';
25036 l_component_code := 'FV_MISC_RCT_REIM_WO_ADV_DR';
25037 l_component_type_code := 'S';
25038 l_component_appl_id := 222;
25039 l_amb_context_code := 'DEFAULT';
25040 l_entity_code := 'RECEIPTS';
25041 l_event_class_code := 'MISC_RECEIPT';
25042 l_event_type_code := 'MISC_RECEIPT_ALL';
25046 l_balance_type_code := 'A';
25043 l_line_definition_owner_code := 'S';
25044 l_line_definition_code := 'MFAR_FED_AR_MISC_REC_ACCOUNT';
25045 --
25047 l_segment := NULL;
25048 l_ccid := NULL;
25049 l_adr_transaction_coa_id := NULL;
25050 l_adr_accounting_coa_id := NULL;
25051 l_adr_flexfield_segment_code := NULL;
25052 l_adr_flex_value_set_id := NULL;
25053 l_adr_value_type_code := NULL;
25054 l_adr_value_combination_id := NULL;
25055 l_adr_value_segment_code := NULL;
25056
25057 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
25058 l_bflow_class_code := ''; -- 4219869 Business Flow
25059 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
25060 l_budgetary_control_flag := 'N';
25061
25062 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25063 l_bflow_applied_to_amt := NULL; -- 5132302
25064 l_entered_amt_idx := NULL; -- 4262811
25065 l_accted_amt_idx := NULL; -- 4262811
25066 l_acc_rev_flag := NULL; -- 4262811
25067 l_accrual_line_num := NULL; -- 4262811
25068 l_tmp_amt := NULL; -- 4262811
25069 --
25070
25071 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
25072 l_balance_type_code <> 'B' THEN
25073 IF NVL(p_source_22,'
25074 ') = 'MISCCASH' AND
25075 NVL(p_source_11,'
25076 ') = 'Reimbursable' AND
25077 NVL(p_source_58,'
25078 ') = 'Y'
25079 THEN
25080
25081 --
25082 XLA_AE_LINES_PKG.SetNewLine;
25083
25084 p_balance_type_code := l_balance_type_code;
25085 -- set the flag so later we will know whether the gain loss line needs to be created
25086
25087 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
25088 p_actual_flag :='A';
25089 END IF;
25090
25091 --
25092 -- bulk performance
25093 --
25094 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
25095 p_header_num => 0); -- 4262811
25096 --
25097 -- set accounting line options
25098 --
25099 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
25100 p_natural_side_code => 'D'
25101 , p_gain_or_loss_flag => 'N'
25102 , p_gl_transfer_mode_code => 'S'
25103 , p_acct_entry_type_code => 'A'
25104 , p_switch_side_flag => 'Y'
25105 , p_merge_duplicate_code => 'A'
25106 );
25107 --
25108 l_acc_rev_natural_side_code := 'C'; -- 4262811
25109 --
25110 --
25111 -- set accounting line type info
25112 --
25113 xla_ae_lines_pkg.SetAcctLineType
25114 (p_component_type => l_component_type
25115 ,p_event_type_code => l_event_type_code
25116 ,p_line_definition_owner_code => l_line_definition_owner_code
25117 ,p_line_definition_code => l_line_definition_code
25118 ,p_accounting_line_code => l_component_code
25119 ,p_accounting_line_type_code => l_component_type_code
25120 ,p_accounting_line_appl_id => l_component_appl_id
25121 ,p_amb_context_code => l_amb_context_code
25122 ,p_entity_code => l_entity_code
25123 ,p_event_class_code => l_event_class_code);
25124 --
25125 -- set accounting class
25126 --
25127 xla_ae_lines_pkg.SetAcctClass(
25128 p_accounting_class_code => 'FV_MISCCASH_DR'
25129 , p_ae_header_id => l_ae_header_id
25130 );
25131
25132 --
25133 -- set rounding class
25134 --
25135 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
25136 'RECEIVABLE';
25137
25138 --
25139 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
25140 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
25141 --
25142 -- bulk performance
25143 --
25144 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
25145
25146 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
25147 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
25148
25149 -- 4955764
25150 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25151 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
25152
25153 -- 4458381 Public Sector Enh
25154
25155 --
25156 -- set accounting attributes for the line type
25157 --
25158 l_entered_amt_idx := 3;
25159 l_accted_amt_idx := 8;
25160 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25161 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
25162 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
25163 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
25164 l_rec_acct_attrs.array_char_value(2) := p_source_25;
25165 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
25166 l_rec_acct_attrs.array_num_value(3) := p_source_26;
25167 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
25168 l_rec_acct_attrs.array_char_value(4) := p_source_27;
25169 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
25173 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
25170 l_rec_acct_attrs.array_date_value(5) := p_source_59;
25171 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
25172 l_rec_acct_attrs.array_num_value(6) := p_source_29;
25174 l_rec_acct_attrs.array_char_value(7) := p_source_30;
25175 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
25176 l_rec_acct_attrs.array_num_value(8) := p_source_31;
25177
25178 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
25179 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
25180
25181 ---------------------------------------------------------------------------------------------------------------
25182 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
25183 ---------------------------------------------------------------------------------------------------------------
25184 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
25185
25186 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25187 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25188
25189 IF xla_accounting_cache_pkg.GetValueChar
25190 (p_source_code => 'LEDGER_CATEGORY_CODE'
25191 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
25192 AND l_bflow_method_code = 'PRIOR_ENTRY'
25193 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
25194 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
25195 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
25196 )
25197 THEN
25198 xla_ae_lines_pkg.BflowUpgEntry
25199 (p_business_method_code => l_bflow_method_code
25200 ,p_business_class_code => l_bflow_class_code
25201 ,p_balance_type => l_balance_type_code);
25202 ELSE
25203 NULL;
25204 -- No business flow processing for business flow method of NONE.
25205 END IF;
25206
25207 --
25208 -- call analytical criteria
25209 --
25210
25211 --
25212 -- call description
25213 --
25214 -- No description or it is inherited.
25215 --
25216 -- call ADRs
25217 -- Bug 4922099
25218 --
25219 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25220 (NVL(l_actual_upg_option, 'N') = 'O') OR
25221 (NVL(l_enc_upg_option, 'N') = 'O')
25222 )
25223 THEN
25224 NULL;
25225 --
25226 --
25227
25228 l_ccid := AcctDerRule_11(
25229 p_application_id => p_application_id
25230 , p_ae_header_id => l_ae_header_id
25231 , p_source_10 => p_source_10
25232 , x_transaction_coa_id => l_adr_transaction_coa_id
25233 , x_accounting_coa_id => l_adr_accounting_coa_id
25234 , x_value_type_code => l_adr_value_type_code
25235 , p_side => 'NA'
25236 );
25237
25238 xla_ae_lines_pkg.set_ccid(
25239 p_code_combination_id => l_ccid
25240 , p_value_type_code => l_adr_value_type_code
25241 , p_transaction_coa_id => l_adr_transaction_coa_id
25242 , p_accounting_coa_id => l_adr_accounting_coa_id
25243 , p_adr_code => 'DIST_CCID'
25244 , p_adr_type_code => 'S'
25245 , p_component_type => l_component_type
25246 , p_component_code => l_component_code
25247 , p_component_type_code => l_component_type_code
25248 , p_component_appl_id => l_component_appl_id
25249 , p_amb_context_code => l_amb_context_code
25250 , p_side => 'NA'
25251 );
25252
25253
25254 l_segment := AcctDerRule_15(
25255 p_application_id => p_application_id
25256 , p_ae_header_id => l_ae_header_id
25257 , p_source_11 => p_source_11
25258 , x_transaction_coa_id => l_adr_transaction_coa_id
25259 , x_accounting_coa_id => l_adr_accounting_coa_id
25260 , x_flexfield_segment_code => l_adr_flexfield_segment_code
25261 , x_flex_value_set_id => l_adr_flex_value_set_id
25262 , x_value_type_code => l_adr_value_type_code
25263 , x_value_combination_id => l_adr_value_combination_id
25264 , x_value_segment_code => l_adr_value_segment_code
25265 , p_side => 'NA'
25266 , p_override_seg_flag => 'Y'
25267 );
25268
25269 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
25270
25271 xla_ae_lines_pkg.set_segment(
25272 p_to_segment_code => 'GL_ACCOUNT'
25273 , p_segment_value => l_segment
25274 , p_from_segment_code => l_adr_value_segment_code
25275 , p_from_combination_id => l_adr_value_combination_id
25276 , p_value_type_code => l_adr_value_type_code
25277 , p_transaction_coa_id => l_adr_transaction_coa_id
25278 , p_accounting_coa_id => l_adr_accounting_coa_id
25279 , p_flexfield_segment_code => l_adr_flexfield_segment_code
25280 , p_flex_value_set_id => l_adr_flex_value_set_id
25281 , p_adr_code => 'FV_AR_425201_MISC_RCT_DR'
25282 , p_adr_type_code => 'S'
25286 , p_component_appl_id => l_component_appl_id
25283 , p_component_type => l_component_type
25284 , p_component_code => l_component_code
25285 , p_component_type_code => l_component_type_code
25287 , p_amb_context_code => l_amb_context_code
25288 , p_entity_code => 'RECEIPTS'
25289 , p_event_class_code => 'MISC_RECEIPT'
25290 , p_side => 'NA'
25291 );
25292
25293 END IF;
25294
25295 --
25296 --
25297 END IF;
25298 --
25299 -- Bug 4922099
25300 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
25301 (NVL(l_enc_upg_option, 'N') = 'O')
25302 ) AND
25303 (l_bflow_method_code = 'PRIOR_ENTRY')
25304 )
25305 THEN
25306 IF
25307 --
25308 1 = 2
25309 --
25310 THEN
25311 xla_accounting_err_pkg.build_message
25312 (p_appli_s_name => 'XLA'
25313 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25314 ,p_token_1 => 'LINE_NUMBER'
25315 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
25316 ,p_token_2 => 'LINE_TYPE_NAME'
25317 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
25318 l_component_type
25319 ,l_component_code
25320 ,l_component_type_code
25321 ,l_component_appl_id
25322 ,l_amb_context_code
25323 ,l_entity_code
25324 ,l_event_class_code
25325 )
25326 ,p_token_3 => 'OWNER'
25327 ,p_value_3 => xla_lookups_pkg.get_meaning(
25328 p_lookup_type => 'XLA_OWNER_TYPE'
25329 ,p_lookup_code => l_component_type_code
25330 )
25331 ,p_token_4 => 'PRODUCT_NAME'
25332 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
25333 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
25334 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
25335 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
25336 ,p_ae_header_id => NULL
25337 );
25338
25339 IF (C_LEVEL_ERROR>= g_log_level) THEN
25340 trace
25341 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25342 ,p_level => C_LEVEL_ERROR
25343 ,p_module => l_log_module);
25344 END IF;
25345 END IF;
25346 END IF;
25347 --
25348 --
25349 ------------------------------------------------------------------------------------------------
25350 -- 4219869 Business Flow
25351 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
25352 -- Prior Entry. Currently, the following code is always generated.
25353 ------------------------------------------------------------------------------------------------
25354 XLA_AE_LINES_PKG.ValidateCurrentLine;
25355
25356 ------------------------------------------------------------------------------------
25357 -- 4219869 Business Flow
25358 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
25359 ------------------------------------------------------------------------------------
25360 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25361
25362 ----------------------------------------------------------------------------------
25363 -- 4219869 Business Flow
25364 -- Update journal entry status -- Need to generate this within IF <condition>
25365 ----------------------------------------------------------------------------------
25366 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25367 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
25368 ,p_balance_type_code => l_balance_type_code
25369 );
25370
25371 -------------------------------------------------------------------------------------------
25372 -- 4262811 - Generate the Accrual Reversal lines
25373 -------------------------------------------------------------------------------------------
25374 BEGIN
25375 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
25376 (g_array_event(p_event_id).array_value_num('header_index'));
25377 IF l_acc_rev_flag IS NULL THEN
25381 WHEN OTHERS THEN
25378 l_acc_rev_flag := 'N';
25379 END IF;
25380 EXCEPTION
25382 l_acc_rev_flag := 'N';
25383 END;
25384 --
25385 IF (l_acc_rev_flag = 'Y') THEN
25386
25387 -- 4645092 ------------------------------------------------------------------------------
25388 -- To allow MPA report to determine if it should generate report process
25389 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
25390 ------------------------------------------------------------------------------------------
25391
25392 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
25393 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
25394 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
25395 -- call ADRs
25396 -- Bug 4922099
25397 --
25398 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25399 (NVL(l_actual_upg_option, 'N') = 'O') OR
25400 (NVL(l_enc_upg_option, 'N') = 'O')
25401 )
25402 THEN
25403 NULL;
25404 --
25405 --
25406
25407 l_ccid := AcctDerRule_11(
25408 p_application_id => p_application_id
25409 , p_ae_header_id => l_ae_header_id
25410 , p_source_10 => p_source_10
25411 , x_transaction_coa_id => l_adr_transaction_coa_id
25412 , x_accounting_coa_id => l_adr_accounting_coa_id
25413 , x_value_type_code => l_adr_value_type_code
25414 , p_side => 'NA'
25415 );
25416
25417 xla_ae_lines_pkg.set_ccid(
25418 p_code_combination_id => l_ccid
25419 , p_value_type_code => l_adr_value_type_code
25420 , p_transaction_coa_id => l_adr_transaction_coa_id
25421 , p_accounting_coa_id => l_adr_accounting_coa_id
25422 , p_adr_code => 'DIST_CCID'
25423 , p_adr_type_code => 'S'
25424 , p_component_type => l_component_type
25425 , p_component_code => l_component_code
25426 , p_component_type_code => l_component_type_code
25427 , p_component_appl_id => l_component_appl_id
25428 , p_amb_context_code => l_amb_context_code
25429 , p_side => 'NA'
25430 );
25431
25432
25433 l_segment := AcctDerRule_15(
25434 p_application_id => p_application_id
25435 , p_ae_header_id => l_ae_header_id
25436 , p_source_11 => p_source_11
25437 , x_transaction_coa_id => l_adr_transaction_coa_id
25438 , x_accounting_coa_id => l_adr_accounting_coa_id
25439 , x_flexfield_segment_code => l_adr_flexfield_segment_code
25440 , x_flex_value_set_id => l_adr_flex_value_set_id
25441 , x_value_type_code => l_adr_value_type_code
25442 , x_value_combination_id => l_adr_value_combination_id
25443 , x_value_segment_code => l_adr_value_segment_code
25444 , p_side => 'NA'
25445 , p_override_seg_flag => 'Y'
25446 );
25447
25448 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
25449
25450 xla_ae_lines_pkg.set_segment(
25451 p_to_segment_code => 'GL_ACCOUNT'
25452 , p_segment_value => l_segment
25453 , p_from_segment_code => l_adr_value_segment_code
25454 , p_from_combination_id => l_adr_value_combination_id
25455 , p_value_type_code => l_adr_value_type_code
25456 , p_transaction_coa_id => l_adr_transaction_coa_id
25457 , p_accounting_coa_id => l_adr_accounting_coa_id
25458 , p_flexfield_segment_code => l_adr_flexfield_segment_code
25459 , p_flex_value_set_id => l_adr_flex_value_set_id
25460 , p_adr_code => 'FV_AR_425201_MISC_RCT_DR'
25461 , p_adr_type_code => 'S'
25462 , p_component_type => l_component_type
25463 , p_component_code => l_component_code
25464 , p_component_type_code => l_component_type_code
25465 , p_component_appl_id => l_component_appl_id
25466 , p_amb_context_code => l_amb_context_code
25467 , p_entity_code => 'RECEIPTS'
25468 , p_event_class_code => 'MISC_RECEIPT'
25469 , p_side => 'NA'
25470 );
25471
25472 END IF;
25473
25474 --
25475 --
25476 END IF;
25477
25478 --
25479 -- Update the line information that should be overwritten
25480 --
25481 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
25482 p_header_num => 1);
25483 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
25484
25485 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
25486
25487 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
25488 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
25489 END IF;
25490
25491 --
25492 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
25493 --
25497 ---------------------------------------------------------------------------------------------------
25494 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
25495 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
25496 ELSE
25498 -- 4262811a Switch Sign
25499 ---------------------------------------------------------------------------------------------------
25500 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
25501 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25502 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25503 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25504 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25505 -- 5132302
25506 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
25507 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25508
25509 END IF;
25510
25511 -- 4955764
25512 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25513 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
25514
25515
25516 XLA_AE_LINES_PKG.ValidateCurrentLine;
25517 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25518
25519 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25520 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
25521 ,p_balance_type_code => l_balance_type_code);
25522
25523 END IF;
25524
25525 -----------------------------------------------------------------------------------------
25526 -- 4262811 Multiperiod Accounting
25527 -----------------------------------------------------------------------------------------
25528 -- No MPA option is assigned.
25529
25530
25531 END IF;
25532 END IF;
25533 --
25534
25535 --
25536 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25537 trace
25538 (p_msg => 'END of AcctLineType_69'
25539 ,p_level => C_LEVEL_PROCEDURE
25540 ,p_module => l_log_module);
25541 END IF;
25542 --
25543 EXCEPTION
25544 WHEN xla_exceptions_pkg.application_exception THEN
25545 RAISE;
25546 WHEN OTHERS THEN
25547 xla_exceptions_pkg.raise_message
25548 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_69');
25549 END AcctLineType_69;
25550 --
25551
25552 ---------------------------------------
25553 --
25554 -- PRIVATE FUNCTION
25555 -- AcctLineType_70
25556 --
25557 ---------------------------------------
25558 PROCEDURE AcctLineType_70 (
25559 p_application_id IN NUMBER
25560 ,p_event_id IN NUMBER
25561 ,p_calculate_acctd_flag IN VARCHAR2
25562 ,p_calculate_g_l_flag IN VARCHAR2
25563 ,p_actual_flag IN OUT VARCHAR2
25564 ,p_balance_type_code OUT VARCHAR2
25565 ,p_gain_or_loss_ref OUT VARCHAR2
25566
25567 --Federal Account Rule
25568 , p_source_13 IN VARCHAR2
25569 --Federal Fund Expired Status
25570 , p_source_14 IN VARCHAR2
25571 --Federal Prior Year Flag
25572 , p_source_15 IN VARCHAR2
25573 --Federal Fund Time Frame
25574 , p_source_16 IN VARCHAR2
25575 --Transaction Distribution GL Account
25576 , p_source_21 IN NUMBER
25577 --Distribution Source Type
25578 , p_source_22 IN VARCHAR2
25579 --Distribution Line Identifier
25580 , p_source_24 IN NUMBER
25581 --Distribution Type
25582 , p_source_25 IN VARCHAR2
25583 --Entered Amount
25584 , p_source_26 IN NUMBER
25585 --Exchange Rate Type
25586 , p_source_30 IN VARCHAR2
25587 --Applied To Document Accounting Amount
25588 , p_source_31 IN NUMBER
25589 --Transaction Distribution Account Class
25590 , p_source_35 IN VARCHAR2
25591 --Transaction Distribution Identifier
25592 , p_source_36 IN NUMBER
25593 --Transaction Distribution Type
25594 , p_source_37 IN VARCHAR2
25595 --Federal Account Valid Flag
25596 , p_source_58 IN VARCHAR2
25597 --Applied To Document Exchange Date
25598 , p_source_59 IN DATE
25599 --Receipt Applied To Application Identifier
25600 , p_source_60 IN NUMBER
25601 --Transaction Entity Code
25602 , p_source_61 IN VARCHAR2
25603 --Transaction Identifier
25604 , p_source_62 IN NUMBER
25605 --Applying Document Currency Code
25606 , p_source_63 IN VARCHAR2
25607 --Applied To Document Exchange Rate
25608 , p_source_64 IN NUMBER
25609 --Distribution Party Identifier
25610 , p_source_65 IN NUMBER
25611 --Distribution Party Site Id
25612 , p_source_66 IN NUMBER
25613 --Distribution Party Type
25614 , p_source_67 IN VARCHAR2
25615 )
25616 IS
25617
25618 l_component_type VARCHAR2(80);
25619 l_component_code VARCHAR2(30);
25620 l_component_type_code VARCHAR2(1);
25621 l_component_appl_id INTEGER;
25625 l_ae_header_id NUMBER;
25622 l_amb_context_code VARCHAR2(30);
25623 l_entity_code VARCHAR2(30);
25624 l_event_class_code VARCHAR2(30);
25626 l_event_type_code VARCHAR2(30);
25627 l_line_definition_code VARCHAR2(30);
25628 l_line_definition_owner_code VARCHAR2(1);
25629 --
25630 -- adr variables
25631 l_segment VARCHAR2(30);
25632 l_ccid NUMBER;
25633 l_adr_transaction_coa_id NUMBER;
25634 l_adr_accounting_coa_id NUMBER;
25635 l_adr_flexfield_segment_code VARCHAR2(30);
25636 l_adr_flex_value_set_id NUMBER;
25637 l_adr_value_type_code VARCHAR2(30);
25638 l_adr_value_combination_id NUMBER;
25639 l_adr_value_segment_code VARCHAR2(30);
25640
25641 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
25642 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
25643 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
25644 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
25645
25646 -- 4262811 Variables ------------------------------------------------------------------------------------------
25647 l_entered_amt_idx NUMBER;
25648 l_accted_amt_idx NUMBER;
25649 l_acc_rev_flag VARCHAR2(1);
25650 l_accrual_line_num NUMBER;
25651 l_tmp_amt NUMBER;
25652 l_acc_rev_natural_side_code VARCHAR2(1);
25653
25654 l_num_entries NUMBER;
25655 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
25656 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
25657 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
25658 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
25659 l_recog_line_1 NUMBER;
25660 l_recog_line_2 NUMBER;
25661
25662 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
25663 l_bflow_applied_to_amt NUMBER; -- 5132302
25664 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
25665
25666 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
25667
25668 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
25669 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
25670
25671 ---------------------------------------------------------------------------------------------------------------
25672
25673
25674 --
25675 -- bulk performance
25676 --
25677 l_balance_type_code VARCHAR2(1);
25678 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
25679 l_log_module VARCHAR2(240);
25680
25681 --
25682 -- Upgrade strategy
25683 --
25684 l_actual_upg_option VARCHAR2(1);
25685 l_enc_upg_option VARCHAR2(1);
25686
25687 --
25688 BEGIN
25689 --
25690 IF g_log_enabled THEN
25691 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_70';
25692 END IF;
25693 --
25694 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25695
25696 trace
25697 (p_msg => 'BEGIN of AcctLineType_70'
25698 ,p_level => C_LEVEL_PROCEDURE
25699 ,p_module => l_log_module);
25700
25701 END IF;
25702 --
25703 l_component_type := 'AMB_JLT';
25704 l_component_code := 'FV_RCT_REF_OAP_EF_CR';
25705 l_component_type_code := 'S';
25706 l_component_appl_id := 222;
25707 l_amb_context_code := 'DEFAULT';
25708 l_entity_code := 'RECEIPTS';
25709 l_event_class_code := 'RECEIPT';
25710 l_event_type_code := 'RECEIPT_ALL';
25711 l_line_definition_owner_code := 'S';
25712 l_line_definition_code := 'MFAR_FED_AR_RCT_ACCOUNT';
25713 --
25714 l_balance_type_code := 'A';
25715 l_segment := NULL;
25716 l_ccid := NULL;
25717 l_adr_transaction_coa_id := NULL;
25718 l_adr_accounting_coa_id := NULL;
25719 l_adr_flexfield_segment_code := NULL;
25720 l_adr_flex_value_set_id := NULL;
25721 l_adr_value_type_code := NULL;
25722 l_adr_value_combination_id := NULL;
25723 l_adr_value_segment_code := NULL;
25724
25725 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
25726 l_bflow_class_code := ''; -- 4219869 Business Flow
25727 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
25728 l_budgetary_control_flag := 'N';
25729
25730 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25731 l_bflow_applied_to_amt := NULL; -- 5132302
25732 l_entered_amt_idx := NULL; -- 4262811
25733 l_accted_amt_idx := NULL; -- 4262811
25734 l_acc_rev_flag := NULL; -- 4262811
25735 l_accrual_line_num := NULL; -- 4262811
25736 l_tmp_amt := NULL; -- 4262811
25737 --
25738
25739 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
25740 l_balance_type_code <> 'B' THEN
25741 IF NVL(p_source_22,'
25742 ') = 'REC' AND
25743 NVL(p_source_35,'
25744 ') = 'REV' AND
25745 NVL(p_source_14,'
25746 ') = 'Expired' AND
25747 NVL(p_source_15,'
25748 ') = 'Y' AND
25749 (NVL(p_source_16,'
25750 ') = 'SINGLE' OR
25751 NVL(p_source_16,'
25752 ') = 'MULTIPLE' OR
25756 ') = 'Overpayment Refund' OR
25753 NVL(p_source_16,'
25754 ') = 'NO_YEAR') AND
25755 (NVL(p_source_13,'
25757 NVL(p_source_13,'
25758 ') = 'Advance Refund') AND
25759 NVL(p_source_58,'
25760 ') = 'Y'
25761 THEN
25762
25763 --
25764 XLA_AE_LINES_PKG.SetNewLine;
25765
25766 p_balance_type_code := l_balance_type_code;
25767 -- set the flag so later we will know whether the gain loss line needs to be created
25768
25769 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
25770 p_actual_flag :='A';
25771 END IF;
25772
25773 --
25774 -- bulk performance
25775 --
25776 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
25777 p_header_num => 0); -- 4262811
25778 --
25779 -- set accounting line options
25780 --
25781 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
25782 p_natural_side_code => 'C'
25783 , p_gain_or_loss_flag => 'N'
25784 , p_gl_transfer_mode_code => 'S'
25785 , p_acct_entry_type_code => 'A'
25786 , p_switch_side_flag => 'Y'
25787 , p_merge_duplicate_code => 'A'
25788 );
25789 --
25790 l_acc_rev_natural_side_code := 'D'; -- 4262811
25791 --
25792 --
25793 -- set accounting line type info
25794 --
25795 xla_ae_lines_pkg.SetAcctLineType
25796 (p_component_type => l_component_type
25797 ,p_event_type_code => l_event_type_code
25798 ,p_line_definition_owner_code => l_line_definition_owner_code
25799 ,p_line_definition_code => l_line_definition_code
25800 ,p_accounting_line_code => l_component_code
25801 ,p_accounting_line_type_code => l_component_type_code
25802 ,p_accounting_line_appl_id => l_component_appl_id
25803 ,p_amb_context_code => l_amb_context_code
25804 ,p_entity_code => l_entity_code
25805 ,p_event_class_code => l_event_class_code);
25806 --
25807 -- set accounting class
25808 --
25809 xla_ae_lines_pkg.SetAcctClass(
25810 p_accounting_class_code => 'FV_CASH_CR'
25811 , p_ae_header_id => l_ae_header_id
25812 );
25813
25814 --
25815 -- set rounding class
25816 --
25817 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
25818 'RECEIVABLE';
25819
25820 --
25821 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
25822 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
25823 --
25824 -- bulk performance
25825 --
25826 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
25827
25828 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
25829 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
25830
25831 -- 4955764
25832 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25833 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
25834
25835 -- 4458381 Public Sector Enh
25836
25837 --
25838 -- set accounting attributes for the line type
25839 --
25840 l_entered_amt_idx := 8;
25841 l_accted_amt_idx := 13;
25842 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25843 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
25844 l_rec_acct_attrs.array_num_value(1) := p_source_60;
25845 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
25846 l_rec_acct_attrs.array_char_value(2) := p_source_37;
25847 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
25848 l_rec_acct_attrs.array_char_value(3) := p_source_61;
25849 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
25850 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
25851 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
25852 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
25853 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
25854 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
25855 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
25856 l_rec_acct_attrs.array_char_value(7) := p_source_25;
25857 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
25858 l_rec_acct_attrs.array_num_value(8) := p_source_26;
25859 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
25860 l_rec_acct_attrs.array_char_value(9) := p_source_63;
25861 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
25862 l_rec_acct_attrs.array_date_value(10) := p_source_59;
25863 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
25864 l_rec_acct_attrs.array_num_value(11) := p_source_64;
25865 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
25866 l_rec_acct_attrs.array_char_value(12) := p_source_30;
25867 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
25868 l_rec_acct_attrs.array_num_value(13) := p_source_31;
25869 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
25870 l_rec_acct_attrs.array_num_value(14) := p_source_65;
25871 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
25875
25872 l_rec_acct_attrs.array_num_value(15) := p_source_66;
25873 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
25874 l_rec_acct_attrs.array_char_value(16) := p_source_67;
25876 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
25877 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
25878
25879 ---------------------------------------------------------------------------------------------------------------
25880 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
25881 ---------------------------------------------------------------------------------------------------------------
25882 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
25883
25884 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25885 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25886
25887 IF xla_accounting_cache_pkg.GetValueChar
25888 (p_source_code => 'LEDGER_CATEGORY_CODE'
25889 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
25890 AND l_bflow_method_code = 'PRIOR_ENTRY'
25891 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
25892 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
25893 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
25894 )
25895 THEN
25896 xla_ae_lines_pkg.BflowUpgEntry
25897 (p_business_method_code => l_bflow_method_code
25898 ,p_business_class_code => l_bflow_class_code
25899 ,p_balance_type => l_balance_type_code);
25900 ELSE
25901 NULL;
25902 -- No business flow processing for business flow method of NONE.
25903 END IF;
25904
25905 --
25906 -- call analytical criteria
25907 --
25908
25909 --
25910 -- call description
25911 --
25912 -- No description or it is inherited.
25913 --
25914 -- call ADRs
25915 -- Bug 4922099
25916 --
25917 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25918 (NVL(l_actual_upg_option, 'N') = 'O') OR
25919 (NVL(l_enc_upg_option, 'N') = 'O')
25920 )
25921 THEN
25922 NULL;
25923 --
25924 --
25925
25926 l_ccid := AcctDerRule_34(
25927 p_application_id => p_application_id
25928 , p_ae_header_id => l_ae_header_id
25929 , p_source_21 => p_source_21
25930 , x_transaction_coa_id => l_adr_transaction_coa_id
25931 , x_accounting_coa_id => l_adr_accounting_coa_id
25932 , x_value_type_code => l_adr_value_type_code
25933 , p_side => 'NA'
25934 );
25935
25936 xla_ae_lines_pkg.set_ccid(
25937 p_code_combination_id => l_ccid
25938 , p_value_type_code => l_adr_value_type_code
25939 , p_transaction_coa_id => l_adr_transaction_coa_id
25940 , p_accounting_coa_id => l_adr_accounting_coa_id
25941 , p_adr_code => 'TRX_DIST_CCID'
25942 , p_adr_type_code => 'S'
25943 , p_component_type => l_component_type
25944 , p_component_code => l_component_code
25945 , p_component_type_code => l_component_type_code
25946 , p_component_appl_id => l_component_appl_id
25947 , p_amb_context_code => l_amb_context_code
25948 , p_side => 'NA'
25949 );
25950
25951
25952 l_segment := AcctDerRule_21(
25953 p_application_id => p_application_id
25954 , p_ae_header_id => l_ae_header_id
25955 , p_source_14 => p_source_14
25956 , p_source_15 => p_source_15
25957 , p_source_16 => p_source_16
25958 , x_transaction_coa_id => l_adr_transaction_coa_id
25959 , x_accounting_coa_id => l_adr_accounting_coa_id
25960 , x_flexfield_segment_code => l_adr_flexfield_segment_code
25961 , x_flex_value_set_id => l_adr_flex_value_set_id
25962 , x_value_type_code => l_adr_value_type_code
25963 , x_value_combination_id => l_adr_value_combination_id
25964 , x_value_segment_code => l_adr_value_segment_code
25965 , p_side => 'NA'
25966 , p_override_seg_flag => 'Y'
25967 );
25968
25969 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
25970
25971 xla_ae_lines_pkg.set_segment(
25972 p_to_segment_code => 'GL_ACCOUNT'
25973 , p_segment_value => l_segment
25974 , p_from_segment_code => l_adr_value_segment_code
25975 , p_from_combination_id => l_adr_value_combination_id
25976 , p_value_type_code => l_adr_value_type_code
25977 , p_transaction_coa_id => l_adr_transaction_coa_id
25978 , p_accounting_coa_id => l_adr_accounting_coa_id
25979 , p_flexfield_segment_code => l_adr_flexfield_segment_code
25980 , p_flex_value_set_id => l_adr_flex_value_set_id
25981 , p_adr_code => 'FV_AR_465002_RCT_CR'
25982 , p_adr_type_code => 'S'
25983 , p_component_type => l_component_type
25984 , p_component_code => l_component_code
25988 , p_entity_code => 'RECEIPTS'
25985 , p_component_type_code => l_component_type_code
25986 , p_component_appl_id => l_component_appl_id
25987 , p_amb_context_code => l_amb_context_code
25989 , p_event_class_code => 'RECEIPT'
25990 , p_side => 'NA'
25991 );
25992
25993 END IF;
25994
25995 --
25996 --
25997 END IF;
25998 --
25999 -- Bug 4922099
26000 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
26001 (NVL(l_enc_upg_option, 'N') = 'O')
26002 ) AND
26003 (l_bflow_method_code = 'PRIOR_ENTRY')
26004 )
26005 THEN
26006 IF
26007 --
26008 1 = 2
26009 --
26010 THEN
26011 xla_accounting_err_pkg.build_message
26012 (p_appli_s_name => 'XLA'
26013 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26014 ,p_token_1 => 'LINE_NUMBER'
26015 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
26016 ,p_token_2 => 'LINE_TYPE_NAME'
26017 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
26018 l_component_type
26019 ,l_component_code
26020 ,l_component_type_code
26021 ,l_component_appl_id
26022 ,l_amb_context_code
26023 ,l_entity_code
26024 ,l_event_class_code
26025 )
26026 ,p_token_3 => 'OWNER'
26027 ,p_value_3 => xla_lookups_pkg.get_meaning(
26028 p_lookup_type => 'XLA_OWNER_TYPE'
26029 ,p_lookup_code => l_component_type_code
26030 )
26031 ,p_token_4 => 'PRODUCT_NAME'
26032 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
26033 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
26034 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
26035 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
26036 ,p_ae_header_id => NULL
26037 );
26038
26039 IF (C_LEVEL_ERROR>= g_log_level) THEN
26040 trace
26041 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26042 ,p_level => C_LEVEL_ERROR
26043 ,p_module => l_log_module);
26044 END IF;
26045 END IF;
26046 END IF;
26047 --
26048 --
26049 ------------------------------------------------------------------------------------------------
26050 -- 4219869 Business Flow
26051 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
26052 -- Prior Entry. Currently, the following code is always generated.
26053 ------------------------------------------------------------------------------------------------
26054 XLA_AE_LINES_PKG.ValidateCurrentLine;
26055
26056 ------------------------------------------------------------------------------------
26057 -- 4219869 Business Flow
26058 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
26059 ------------------------------------------------------------------------------------
26060 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26061
26062 ----------------------------------------------------------------------------------
26063 -- 4219869 Business Flow
26064 -- Update journal entry status -- Need to generate this within IF <condition>
26065 ----------------------------------------------------------------------------------
26066 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26067 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
26068 ,p_balance_type_code => l_balance_type_code
26069 );
26070
26071 -------------------------------------------------------------------------------------------
26072 -- 4262811 - Generate the Accrual Reversal lines
26073 -------------------------------------------------------------------------------------------
26074 BEGIN
26075 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
26076 (g_array_event(p_event_id).array_value_num('header_index'));
26077 IF l_acc_rev_flag IS NULL THEN
26078 l_acc_rev_flag := 'N';
26079 END IF;
26083 END;
26080 EXCEPTION
26081 WHEN OTHERS THEN
26082 l_acc_rev_flag := 'N';
26084 --
26085 IF (l_acc_rev_flag = 'Y') THEN
26086
26087 -- 4645092 ------------------------------------------------------------------------------
26088 -- To allow MPA report to determine if it should generate report process
26089 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
26090 ------------------------------------------------------------------------------------------
26091
26092 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
26093 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
26094 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
26095 -- call ADRs
26096 -- Bug 4922099
26097 --
26098 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26099 (NVL(l_actual_upg_option, 'N') = 'O') OR
26100 (NVL(l_enc_upg_option, 'N') = 'O')
26101 )
26102 THEN
26103 NULL;
26104 --
26105 --
26106
26107 l_ccid := AcctDerRule_34(
26108 p_application_id => p_application_id
26109 , p_ae_header_id => l_ae_header_id
26110 , p_source_21 => p_source_21
26111 , x_transaction_coa_id => l_adr_transaction_coa_id
26112 , x_accounting_coa_id => l_adr_accounting_coa_id
26113 , x_value_type_code => l_adr_value_type_code
26114 , p_side => 'NA'
26115 );
26116
26117 xla_ae_lines_pkg.set_ccid(
26118 p_code_combination_id => l_ccid
26119 , p_value_type_code => l_adr_value_type_code
26120 , p_transaction_coa_id => l_adr_transaction_coa_id
26121 , p_accounting_coa_id => l_adr_accounting_coa_id
26122 , p_adr_code => 'TRX_DIST_CCID'
26123 , p_adr_type_code => 'S'
26124 , p_component_type => l_component_type
26125 , p_component_code => l_component_code
26126 , p_component_type_code => l_component_type_code
26127 , p_component_appl_id => l_component_appl_id
26128 , p_amb_context_code => l_amb_context_code
26129 , p_side => 'NA'
26130 );
26131
26132
26133 l_segment := AcctDerRule_21(
26134 p_application_id => p_application_id
26135 , p_ae_header_id => l_ae_header_id
26136 , p_source_14 => p_source_14
26137 , p_source_15 => p_source_15
26138 , p_source_16 => p_source_16
26139 , x_transaction_coa_id => l_adr_transaction_coa_id
26140 , x_accounting_coa_id => l_adr_accounting_coa_id
26141 , x_flexfield_segment_code => l_adr_flexfield_segment_code
26142 , x_flex_value_set_id => l_adr_flex_value_set_id
26143 , x_value_type_code => l_adr_value_type_code
26144 , x_value_combination_id => l_adr_value_combination_id
26145 , x_value_segment_code => l_adr_value_segment_code
26146 , p_side => 'NA'
26147 , p_override_seg_flag => 'Y'
26148 );
26149
26150 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
26151
26152 xla_ae_lines_pkg.set_segment(
26153 p_to_segment_code => 'GL_ACCOUNT'
26154 , p_segment_value => l_segment
26155 , p_from_segment_code => l_adr_value_segment_code
26156 , p_from_combination_id => l_adr_value_combination_id
26157 , p_value_type_code => l_adr_value_type_code
26158 , p_transaction_coa_id => l_adr_transaction_coa_id
26159 , p_accounting_coa_id => l_adr_accounting_coa_id
26160 , p_flexfield_segment_code => l_adr_flexfield_segment_code
26161 , p_flex_value_set_id => l_adr_flex_value_set_id
26162 , p_adr_code => 'FV_AR_465002_RCT_CR'
26163 , p_adr_type_code => 'S'
26164 , p_component_type => l_component_type
26165 , p_component_code => l_component_code
26166 , p_component_type_code => l_component_type_code
26167 , p_component_appl_id => l_component_appl_id
26168 , p_amb_context_code => l_amb_context_code
26169 , p_entity_code => 'RECEIPTS'
26170 , p_event_class_code => 'RECEIPT'
26171 , p_side => 'NA'
26172 );
26173
26174 END IF;
26175
26176 --
26177 --
26178 END IF;
26179
26180 --
26181 -- Update the line information that should be overwritten
26182 --
26183 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
26184 p_header_num => 1);
26185 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
26186
26187 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
26188
26189 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
26190 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
26191 END IF;
26192
26193 --
26194 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
26195 --
26196 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
26200 -- 4262811a Switch Sign
26197 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
26198 ELSE
26199 ---------------------------------------------------------------------------------------------------
26201 ---------------------------------------------------------------------------------------------------
26202 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
26203 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26204 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26205 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26206 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26207 -- 5132302
26208 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
26209 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26210
26211 END IF;
26212
26213 -- 4955764
26214 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26215 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
26216
26217
26218 XLA_AE_LINES_PKG.ValidateCurrentLine;
26219 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26220
26221 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26222 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
26223 ,p_balance_type_code => l_balance_type_code);
26224
26225 END IF;
26226
26227 -----------------------------------------------------------------------------------------
26228 -- 4262811 Multiperiod Accounting
26229 -----------------------------------------------------------------------------------------
26230 -- No MPA option is assigned.
26231
26232
26233 END IF;
26234 END IF;
26235 --
26236
26237 --
26238 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26239 trace
26240 (p_msg => 'END of AcctLineType_70'
26241 ,p_level => C_LEVEL_PROCEDURE
26242 ,p_module => l_log_module);
26243 END IF;
26244 --
26245 EXCEPTION
26246 WHEN xla_exceptions_pkg.application_exception THEN
26247 RAISE;
26248 WHEN OTHERS THEN
26249 xla_exceptions_pkg.raise_message
26250 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_70');
26251 END AcctLineType_70;
26252 --
26253
26254 ---------------------------------------
26255 --
26256 -- PRIVATE FUNCTION
26257 -- AcctLineType_71
26258 --
26259 ---------------------------------------
26260 PROCEDURE AcctLineType_71 (
26261 p_application_id IN NUMBER
26262 ,p_event_id IN NUMBER
26263 ,p_calculate_acctd_flag IN VARCHAR2
26264 ,p_calculate_g_l_flag IN VARCHAR2
26265 ,p_actual_flag IN OUT VARCHAR2
26266 ,p_balance_type_code OUT VARCHAR2
26267 ,p_gain_or_loss_ref OUT VARCHAR2
26268
26269 --Federal Account Rule
26270 , p_source_13 IN VARCHAR2
26271 --Federal Fund Expired Status
26272 , p_source_14 IN VARCHAR2
26273 --Federal Prior Year Flag
26274 , p_source_15 IN VARCHAR2
26275 --Federal Fund Time Frame
26276 , p_source_16 IN VARCHAR2
26277 --Transaction Distribution GL Account
26278 , p_source_21 IN NUMBER
26279 --Distribution Source Type
26280 , p_source_22 IN VARCHAR2
26281 --Distribution Line Identifier
26282 , p_source_24 IN NUMBER
26283 --Distribution Type
26284 , p_source_25 IN VARCHAR2
26285 --Entered Amount
26286 , p_source_26 IN NUMBER
26287 --Exchange Rate Type
26288 , p_source_30 IN VARCHAR2
26289 --Applied To Document Accounting Amount
26290 , p_source_31 IN NUMBER
26291 --Transaction Distribution Account Class
26292 , p_source_35 IN VARCHAR2
26293 --Transaction Distribution Identifier
26294 , p_source_36 IN NUMBER
26295 --Transaction Distribution Type
26296 , p_source_37 IN VARCHAR2
26297 --Federal Account Valid Flag
26298 , p_source_58 IN VARCHAR2
26299 --Applied To Document Exchange Date
26300 , p_source_59 IN DATE
26301 --Receipt Applied To Application Identifier
26302 , p_source_60 IN NUMBER
26303 --Transaction Entity Code
26304 , p_source_61 IN VARCHAR2
26305 --Transaction Identifier
26306 , p_source_62 IN NUMBER
26307 --Applying Document Currency Code
26308 , p_source_63 IN VARCHAR2
26309 --Applied To Document Exchange Rate
26310 , p_source_64 IN NUMBER
26311 --Distribution Party Identifier
26312 , p_source_65 IN NUMBER
26313 --Distribution Party Site Id
26314 , p_source_66 IN NUMBER
26315 --Distribution Party Type
26316 , p_source_67 IN VARCHAR2
26317 )
26318 IS
26319
26320 l_component_type VARCHAR2(80);
26321 l_component_code VARCHAR2(30);
26322 l_component_type_code VARCHAR2(1);
26323 l_component_appl_id INTEGER;
26324 l_amb_context_code VARCHAR2(30);
26325 l_entity_code VARCHAR2(30);
26326 l_event_class_code VARCHAR2(30);
26330 l_line_definition_owner_code VARCHAR2(1);
26327 l_ae_header_id NUMBER;
26328 l_event_type_code VARCHAR2(30);
26329 l_line_definition_code VARCHAR2(30);
26331 --
26332 -- adr variables
26333 l_segment VARCHAR2(30);
26334 l_ccid NUMBER;
26335 l_adr_transaction_coa_id NUMBER;
26336 l_adr_accounting_coa_id NUMBER;
26337 l_adr_flexfield_segment_code VARCHAR2(30);
26338 l_adr_flex_value_set_id NUMBER;
26339 l_adr_value_type_code VARCHAR2(30);
26340 l_adr_value_combination_id NUMBER;
26341 l_adr_value_segment_code VARCHAR2(30);
26342
26343 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
26344 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
26345 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
26346 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
26347
26348 -- 4262811 Variables ------------------------------------------------------------------------------------------
26349 l_entered_amt_idx NUMBER;
26350 l_accted_amt_idx NUMBER;
26351 l_acc_rev_flag VARCHAR2(1);
26352 l_accrual_line_num NUMBER;
26353 l_tmp_amt NUMBER;
26354 l_acc_rev_natural_side_code VARCHAR2(1);
26355
26356 l_num_entries NUMBER;
26357 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
26358 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
26359 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
26360 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
26361 l_recog_line_1 NUMBER;
26362 l_recog_line_2 NUMBER;
26363
26364 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
26365 l_bflow_applied_to_amt NUMBER; -- 5132302
26366 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
26367
26368 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
26369
26370 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
26371 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
26372
26373 ---------------------------------------------------------------------------------------------------------------
26374
26375
26376 --
26377 -- bulk performance
26378 --
26379 l_balance_type_code VARCHAR2(1);
26380 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
26381 l_log_module VARCHAR2(240);
26382
26383 --
26384 -- Upgrade strategy
26385 --
26386 l_actual_upg_option VARCHAR2(1);
26387 l_enc_upg_option VARCHAR2(1);
26388
26389 --
26390 BEGIN
26391 --
26392 IF g_log_enabled THEN
26393 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_71';
26394 END IF;
26395 --
26396 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26397
26398 trace
26399 (p_msg => 'BEGIN of AcctLineType_71'
26400 ,p_level => C_LEVEL_PROCEDURE
26401 ,p_module => l_log_module);
26402
26403 END IF;
26404 --
26405 l_component_type := 'AMB_JLT';
26406 l_component_code := 'FV_RCT_REF_OAP_EF_DR';
26407 l_component_type_code := 'S';
26408 l_component_appl_id := 222;
26409 l_amb_context_code := 'DEFAULT';
26410 l_entity_code := 'RECEIPTS';
26411 l_event_class_code := 'RECEIPT';
26412 l_event_type_code := 'RECEIPT_ALL';
26413 l_line_definition_owner_code := 'S';
26414 l_line_definition_code := 'MFAR_FED_AR_RCT_ACCOUNT';
26415 --
26416 l_balance_type_code := 'A';
26417 l_segment := NULL;
26418 l_ccid := NULL;
26419 l_adr_transaction_coa_id := NULL;
26420 l_adr_accounting_coa_id := NULL;
26421 l_adr_flexfield_segment_code := NULL;
26422 l_adr_flex_value_set_id := NULL;
26423 l_adr_value_type_code := NULL;
26424 l_adr_value_combination_id := NULL;
26425 l_adr_value_segment_code := NULL;
26426
26427 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
26428 l_bflow_class_code := ''; -- 4219869 Business Flow
26429 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
26430 l_budgetary_control_flag := 'N';
26431
26432 l_bflow_applied_to_amt_idx := NULL; -- 5132302
26433 l_bflow_applied_to_amt := NULL; -- 5132302
26434 l_entered_amt_idx := NULL; -- 4262811
26435 l_accted_amt_idx := NULL; -- 4262811
26436 l_acc_rev_flag := NULL; -- 4262811
26437 l_accrual_line_num := NULL; -- 4262811
26438 l_tmp_amt := NULL; -- 4262811
26439 --
26440
26441 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
26442 l_balance_type_code <> 'B' THEN
26443 IF NVL(p_source_22,'
26444 ') = 'REC' AND
26445 NVL(p_source_35,'
26446 ') = 'REV' AND
26447 NVL(p_source_14,'
26448 ') = 'Expired' AND
26449 NVL(p_source_15,'
26450 ') = 'Y' AND
26451 (NVL(p_source_16,'
26452 ') = 'SINGLE' OR
26453 NVL(p_source_16,'
26454 ') = 'MULTIPLE' OR
26455 NVL(p_source_16,'
26456 ') = 'NO_YEAR') AND
26457 (NVL(p_source_13,'
26458 ') = 'Overpayment Refund' OR
26462 ') = 'Y'
26459 NVL(p_source_13,'
26460 ') = 'Advance Refund') AND
26461 NVL(p_source_58,'
26463 THEN
26464
26465 --
26466 XLA_AE_LINES_PKG.SetNewLine;
26467
26468 p_balance_type_code := l_balance_type_code;
26469 -- set the flag so later we will know whether the gain loss line needs to be created
26470
26471 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
26472 p_actual_flag :='A';
26473 END IF;
26474
26475 --
26476 -- bulk performance
26477 --
26478 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
26479 p_header_num => 0); -- 4262811
26480 --
26481 -- set accounting line options
26482 --
26483 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
26484 p_natural_side_code => 'D'
26485 , p_gain_or_loss_flag => 'N'
26486 , p_gl_transfer_mode_code => 'S'
26487 , p_acct_entry_type_code => 'A'
26488 , p_switch_side_flag => 'Y'
26489 , p_merge_duplicate_code => 'A'
26490 );
26491 --
26492 l_acc_rev_natural_side_code := 'C'; -- 4262811
26493 --
26494 --
26495 -- set accounting line type info
26496 --
26497 xla_ae_lines_pkg.SetAcctLineType
26498 (p_component_type => l_component_type
26499 ,p_event_type_code => l_event_type_code
26500 ,p_line_definition_owner_code => l_line_definition_owner_code
26501 ,p_line_definition_code => l_line_definition_code
26502 ,p_accounting_line_code => l_component_code
26503 ,p_accounting_line_type_code => l_component_type_code
26504 ,p_accounting_line_appl_id => l_component_appl_id
26505 ,p_amb_context_code => l_amb_context_code
26506 ,p_entity_code => l_entity_code
26507 ,p_event_class_code => l_event_class_code);
26508 --
26509 -- set accounting class
26510 --
26511 xla_ae_lines_pkg.SetAcctClass(
26512 p_accounting_class_code => 'FV_CASH_DR'
26513 , p_ae_header_id => l_ae_header_id
26514 );
26515
26516 --
26517 -- set rounding class
26518 --
26519 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
26520 'RECEIVABLE';
26521
26522 --
26523 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
26524 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
26525 --
26526 -- bulk performance
26527 --
26528 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
26529
26530 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
26531 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
26532
26533 -- 4955764
26534 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26535 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
26536
26537 -- 4458381 Public Sector Enh
26538
26539 --
26540 -- set accounting attributes for the line type
26541 --
26542 l_entered_amt_idx := 8;
26543 l_accted_amt_idx := 13;
26544 l_bflow_applied_to_amt_idx := NULL; -- 5132302
26545 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
26546 l_rec_acct_attrs.array_num_value(1) := p_source_60;
26547 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
26548 l_rec_acct_attrs.array_char_value(2) := p_source_37;
26549 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
26550 l_rec_acct_attrs.array_char_value(3) := p_source_61;
26551 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
26552 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
26553 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
26554 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
26555 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
26556 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
26557 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
26558 l_rec_acct_attrs.array_char_value(7) := p_source_25;
26559 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
26560 l_rec_acct_attrs.array_num_value(8) := p_source_26;
26561 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
26562 l_rec_acct_attrs.array_char_value(9) := p_source_63;
26563 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
26564 l_rec_acct_attrs.array_date_value(10) := p_source_59;
26565 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
26566 l_rec_acct_attrs.array_num_value(11) := p_source_64;
26567 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
26568 l_rec_acct_attrs.array_char_value(12) := p_source_30;
26569 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
26570 l_rec_acct_attrs.array_num_value(13) := p_source_31;
26571 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
26572 l_rec_acct_attrs.array_num_value(14) := p_source_65;
26573 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
26577
26574 l_rec_acct_attrs.array_num_value(15) := p_source_66;
26575 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
26576 l_rec_acct_attrs.array_char_value(16) := p_source_67;
26578 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
26579 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
26580
26581 ---------------------------------------------------------------------------------------------------------------
26582 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
26583 ---------------------------------------------------------------------------------------------------------------
26584 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
26585
26586 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26587 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26588
26589 IF xla_accounting_cache_pkg.GetValueChar
26590 (p_source_code => 'LEDGER_CATEGORY_CODE'
26591 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
26592 AND l_bflow_method_code = 'PRIOR_ENTRY'
26593 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
26594 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
26595 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
26596 )
26597 THEN
26598 xla_ae_lines_pkg.BflowUpgEntry
26599 (p_business_method_code => l_bflow_method_code
26600 ,p_business_class_code => l_bflow_class_code
26601 ,p_balance_type => l_balance_type_code);
26602 ELSE
26603 NULL;
26604 -- No business flow processing for business flow method of NONE.
26605 END IF;
26606
26607 --
26608 -- call analytical criteria
26609 --
26610
26611 --
26612 -- call description
26613 --
26614 -- No description or it is inherited.
26615 --
26616 -- call ADRs
26617 -- Bug 4922099
26618 --
26619 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26620 (NVL(l_actual_upg_option, 'N') = 'O') OR
26621 (NVL(l_enc_upg_option, 'N') = 'O')
26622 )
26623 THEN
26624 NULL;
26625 --
26626 --
26627
26628 l_ccid := AcctDerRule_34(
26629 p_application_id => p_application_id
26630 , p_ae_header_id => l_ae_header_id
26631 , p_source_21 => p_source_21
26632 , x_transaction_coa_id => l_adr_transaction_coa_id
26633 , x_accounting_coa_id => l_adr_accounting_coa_id
26634 , x_value_type_code => l_adr_value_type_code
26635 , p_side => 'NA'
26636 );
26637
26638 xla_ae_lines_pkg.set_ccid(
26639 p_code_combination_id => l_ccid
26640 , p_value_type_code => l_adr_value_type_code
26641 , p_transaction_coa_id => l_adr_transaction_coa_id
26642 , p_accounting_coa_id => l_adr_accounting_coa_id
26643 , p_adr_code => 'TRX_DIST_CCID'
26644 , p_adr_type_code => 'S'
26645 , p_component_type => l_component_type
26646 , p_component_code => l_component_code
26647 , p_component_type_code => l_component_type_code
26648 , p_component_appl_id => l_component_appl_id
26649 , p_amb_context_code => l_amb_context_code
26650 , p_side => 'NA'
26651 );
26652
26653
26654 l_segment := AcctDerRule_27(
26655 p_application_id => p_application_id
26656 , p_ae_header_id => l_ae_header_id
26657 , p_source_13 => p_source_13
26658 , p_source_14 => p_source_14
26659 , p_source_15 => p_source_15
26660 , p_source_16 => p_source_16
26661 , x_transaction_coa_id => l_adr_transaction_coa_id
26662 , x_accounting_coa_id => l_adr_accounting_coa_id
26663 , x_flexfield_segment_code => l_adr_flexfield_segment_code
26664 , x_flex_value_set_id => l_adr_flex_value_set_id
26665 , x_value_type_code => l_adr_value_type_code
26666 , x_value_combination_id => l_adr_value_combination_id
26667 , x_value_segment_code => l_adr_value_segment_code
26668 , p_side => 'NA'
26669 , p_override_seg_flag => 'Y'
26670 );
26671
26672 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
26673
26674 xla_ae_lines_pkg.set_segment(
26675 p_to_segment_code => 'GL_ACCOUNT'
26676 , p_segment_value => l_segment
26677 , p_from_segment_code => l_adr_value_segment_code
26678 , p_from_combination_id => l_adr_value_combination_id
26679 , p_value_type_code => l_adr_value_type_code
26680 , p_transaction_coa_id => l_adr_transaction_coa_id
26681 , p_accounting_coa_id => l_adr_accounting_coa_id
26682 , p_flexfield_segment_code => l_adr_flexfield_segment_code
26683 , p_flex_value_set_id => l_adr_flex_value_set_id
26684 , p_adr_code => 'FV_AR_4X7201_RCT_DR'
26685 , p_adr_type_code => 'S'
26689 , p_component_appl_id => l_component_appl_id
26686 , p_component_type => l_component_type
26687 , p_component_code => l_component_code
26688 , p_component_type_code => l_component_type_code
26690 , p_amb_context_code => l_amb_context_code
26691 , p_entity_code => 'RECEIPTS'
26692 , p_event_class_code => 'RECEIPT'
26693 , p_side => 'NA'
26694 );
26695
26696 END IF;
26697
26698 --
26699 --
26700 END IF;
26701 --
26702 -- Bug 4922099
26703 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
26704 (NVL(l_enc_upg_option, 'N') = 'O')
26705 ) AND
26706 (l_bflow_method_code = 'PRIOR_ENTRY')
26707 )
26708 THEN
26709 IF
26710 --
26711 1 = 2
26712 --
26713 THEN
26714 xla_accounting_err_pkg.build_message
26715 (p_appli_s_name => 'XLA'
26716 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26717 ,p_token_1 => 'LINE_NUMBER'
26718 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
26719 ,p_token_2 => 'LINE_TYPE_NAME'
26720 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
26721 l_component_type
26722 ,l_component_code
26723 ,l_component_type_code
26724 ,l_component_appl_id
26725 ,l_amb_context_code
26726 ,l_entity_code
26727 ,l_event_class_code
26728 )
26729 ,p_token_3 => 'OWNER'
26730 ,p_value_3 => xla_lookups_pkg.get_meaning(
26731 p_lookup_type => 'XLA_OWNER_TYPE'
26732 ,p_lookup_code => l_component_type_code
26733 )
26734 ,p_token_4 => 'PRODUCT_NAME'
26735 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
26736 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
26737 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
26738 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
26739 ,p_ae_header_id => NULL
26740 );
26741
26742 IF (C_LEVEL_ERROR>= g_log_level) THEN
26743 trace
26744 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26745 ,p_level => C_LEVEL_ERROR
26746 ,p_module => l_log_module);
26747 END IF;
26748 END IF;
26749 END IF;
26750 --
26751 --
26752 ------------------------------------------------------------------------------------------------
26753 -- 4219869 Business Flow
26754 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
26755 -- Prior Entry. Currently, the following code is always generated.
26756 ------------------------------------------------------------------------------------------------
26757 XLA_AE_LINES_PKG.ValidateCurrentLine;
26758
26759 ------------------------------------------------------------------------------------
26760 -- 4219869 Business Flow
26761 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
26762 ------------------------------------------------------------------------------------
26763 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26764
26765 ----------------------------------------------------------------------------------
26766 -- 4219869 Business Flow
26767 -- Update journal entry status -- Need to generate this within IF <condition>
26768 ----------------------------------------------------------------------------------
26769 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26770 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
26771 ,p_balance_type_code => l_balance_type_code
26772 );
26773
26774 -------------------------------------------------------------------------------------------
26775 -- 4262811 - Generate the Accrual Reversal lines
26776 -------------------------------------------------------------------------------------------
26777 BEGIN
26778 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
26779 (g_array_event(p_event_id).array_value_num('header_index'));
26780 IF l_acc_rev_flag IS NULL THEN
26781 l_acc_rev_flag := 'N';
26782 END IF;
26786 END;
26783 EXCEPTION
26784 WHEN OTHERS THEN
26785 l_acc_rev_flag := 'N';
26787 --
26788 IF (l_acc_rev_flag = 'Y') THEN
26789
26790 -- 4645092 ------------------------------------------------------------------------------
26791 -- To allow MPA report to determine if it should generate report process
26792 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
26793 ------------------------------------------------------------------------------------------
26794
26795 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
26796 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
26797 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
26798 -- call ADRs
26799 -- Bug 4922099
26800 --
26801 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26802 (NVL(l_actual_upg_option, 'N') = 'O') OR
26803 (NVL(l_enc_upg_option, 'N') = 'O')
26804 )
26805 THEN
26806 NULL;
26807 --
26808 --
26809
26810 l_ccid := AcctDerRule_34(
26811 p_application_id => p_application_id
26812 , p_ae_header_id => l_ae_header_id
26813 , p_source_21 => p_source_21
26814 , x_transaction_coa_id => l_adr_transaction_coa_id
26815 , x_accounting_coa_id => l_adr_accounting_coa_id
26816 , x_value_type_code => l_adr_value_type_code
26817 , p_side => 'NA'
26818 );
26819
26820 xla_ae_lines_pkg.set_ccid(
26821 p_code_combination_id => l_ccid
26822 , p_value_type_code => l_adr_value_type_code
26823 , p_transaction_coa_id => l_adr_transaction_coa_id
26824 , p_accounting_coa_id => l_adr_accounting_coa_id
26825 , p_adr_code => 'TRX_DIST_CCID'
26826 , p_adr_type_code => 'S'
26827 , p_component_type => l_component_type
26828 , p_component_code => l_component_code
26829 , p_component_type_code => l_component_type_code
26830 , p_component_appl_id => l_component_appl_id
26831 , p_amb_context_code => l_amb_context_code
26832 , p_side => 'NA'
26833 );
26834
26835
26836 l_segment := AcctDerRule_27(
26837 p_application_id => p_application_id
26838 , p_ae_header_id => l_ae_header_id
26839 , p_source_13 => p_source_13
26840 , p_source_14 => p_source_14
26841 , p_source_15 => p_source_15
26842 , p_source_16 => p_source_16
26843 , x_transaction_coa_id => l_adr_transaction_coa_id
26844 , x_accounting_coa_id => l_adr_accounting_coa_id
26845 , x_flexfield_segment_code => l_adr_flexfield_segment_code
26846 , x_flex_value_set_id => l_adr_flex_value_set_id
26847 , x_value_type_code => l_adr_value_type_code
26848 , x_value_combination_id => l_adr_value_combination_id
26849 , x_value_segment_code => l_adr_value_segment_code
26850 , p_side => 'NA'
26851 , p_override_seg_flag => 'Y'
26852 );
26853
26854 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
26855
26856 xla_ae_lines_pkg.set_segment(
26857 p_to_segment_code => 'GL_ACCOUNT'
26858 , p_segment_value => l_segment
26859 , p_from_segment_code => l_adr_value_segment_code
26860 , p_from_combination_id => l_adr_value_combination_id
26861 , p_value_type_code => l_adr_value_type_code
26862 , p_transaction_coa_id => l_adr_transaction_coa_id
26863 , p_accounting_coa_id => l_adr_accounting_coa_id
26864 , p_flexfield_segment_code => l_adr_flexfield_segment_code
26865 , p_flex_value_set_id => l_adr_flex_value_set_id
26866 , p_adr_code => 'FV_AR_4X7201_RCT_DR'
26867 , p_adr_type_code => 'S'
26868 , p_component_type => l_component_type
26869 , p_component_code => l_component_code
26870 , p_component_type_code => l_component_type_code
26871 , p_component_appl_id => l_component_appl_id
26872 , p_amb_context_code => l_amb_context_code
26873 , p_entity_code => 'RECEIPTS'
26874 , p_event_class_code => 'RECEIPT'
26875 , p_side => 'NA'
26876 );
26877
26878 END IF;
26879
26880 --
26881 --
26882 END IF;
26883
26884 --
26885 -- Update the line information that should be overwritten
26886 --
26887 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
26888 p_header_num => 1);
26889 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
26890
26891 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
26892
26893 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
26894 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
26895 END IF;
26896
26897 --
26898 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
26899 --
26900 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
26904 -- 4262811a Switch Sign
26901 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
26902 ELSE
26903 ---------------------------------------------------------------------------------------------------
26905 ---------------------------------------------------------------------------------------------------
26906 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
26907 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26908 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26909 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26910 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26911 -- 5132302
26912 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
26913 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26914
26915 END IF;
26916
26917 -- 4955764
26918 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26919 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
26920
26921
26922 XLA_AE_LINES_PKG.ValidateCurrentLine;
26923 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26924
26925 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26926 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
26927 ,p_balance_type_code => l_balance_type_code);
26928
26929 END IF;
26930
26931 -----------------------------------------------------------------------------------------
26932 -- 4262811 Multiperiod Accounting
26933 -----------------------------------------------------------------------------------------
26934 -- No MPA option is assigned.
26935
26936
26937 END IF;
26938 END IF;
26939 --
26940
26941 --
26942 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26943 trace
26944 (p_msg => 'END of AcctLineType_71'
26945 ,p_level => C_LEVEL_PROCEDURE
26946 ,p_module => l_log_module);
26947 END IF;
26948 --
26949 EXCEPTION
26950 WHEN xla_exceptions_pkg.application_exception THEN
26951 RAISE;
26952 WHEN OTHERS THEN
26953 xla_exceptions_pkg.raise_message
26954 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_71');
26955 END AcctLineType_71;
26956 --
26957
26958 ---------------------------------------
26959 --
26960 -- PRIVATE FUNCTION
26961 -- AcctLineType_72
26962 --
26963 ---------------------------------------
26964 PROCEDURE AcctLineType_72 (
26965 p_application_id IN NUMBER
26966 ,p_event_id IN NUMBER
26967 ,p_calculate_acctd_flag IN VARCHAR2
26968 ,p_calculate_g_l_flag IN VARCHAR2
26969 ,p_actual_flag IN OUT VARCHAR2
26970 ,p_balance_type_code OUT VARCHAR2
26971 ,p_gain_or_loss_ref OUT VARCHAR2
26972
26973 --Federal Account Rule
26974 , p_source_13 IN VARCHAR2
26975 --Federal Fund Expired Status
26976 , p_source_14 IN VARCHAR2
26977 --Federal Prior Year Flag
26978 , p_source_15 IN VARCHAR2
26979 --Federal Fund Time Frame
26980 , p_source_16 IN VARCHAR2
26981 --Federal Apportionment Category
26982 , p_source_17 IN VARCHAR2
26983 --Transaction Distribution GL Account
26984 , p_source_21 IN NUMBER
26985 --Distribution Source Type
26986 , p_source_22 IN VARCHAR2
26987 --Distribution Line Identifier
26988 , p_source_24 IN NUMBER
26989 --Distribution Type
26990 , p_source_25 IN VARCHAR2
26991 --Entered Amount
26992 , p_source_26 IN NUMBER
26993 --Exchange Rate Type
26994 , p_source_30 IN VARCHAR2
26995 --Applied To Document Accounting Amount
26996 , p_source_31 IN NUMBER
26997 --Transaction Distribution Account Class
26998 , p_source_35 IN VARCHAR2
26999 --Transaction Distribution Identifier
27000 , p_source_36 IN NUMBER
27001 --Transaction Distribution Type
27002 , p_source_37 IN VARCHAR2
27003 --Federal Account Valid Flag
27004 , p_source_58 IN VARCHAR2
27005 --Applied To Document Exchange Date
27006 , p_source_59 IN DATE
27007 --Receipt Applied To Application Identifier
27008 , p_source_60 IN NUMBER
27009 --Transaction Entity Code
27010 , p_source_61 IN VARCHAR2
27011 --Transaction Identifier
27012 , p_source_62 IN NUMBER
27013 --Applying Document Currency Code
27014 , p_source_63 IN VARCHAR2
27015 --Applied To Document Exchange Rate
27016 , p_source_64 IN NUMBER
27017 --Distribution Party Identifier
27018 , p_source_65 IN NUMBER
27019 --Distribution Party Site Id
27020 , p_source_66 IN NUMBER
27021 --Distribution Party Type
27022 , p_source_67 IN VARCHAR2
27023 )
27024 IS
27025
27026 l_component_type VARCHAR2(80);
27027 l_component_code VARCHAR2(30);
27028 l_component_type_code VARCHAR2(1);
27029 l_component_appl_id INTEGER;
27030 l_amb_context_code VARCHAR2(30);
27034 l_event_type_code VARCHAR2(30);
27031 l_entity_code VARCHAR2(30);
27032 l_event_class_code VARCHAR2(30);
27033 l_ae_header_id NUMBER;
27035 l_line_definition_code VARCHAR2(30);
27036 l_line_definition_owner_code VARCHAR2(1);
27037 --
27038 -- adr variables
27039 l_segment VARCHAR2(30);
27040 l_ccid NUMBER;
27041 l_adr_transaction_coa_id NUMBER;
27042 l_adr_accounting_coa_id NUMBER;
27043 l_adr_flexfield_segment_code VARCHAR2(30);
27044 l_adr_flex_value_set_id NUMBER;
27045 l_adr_value_type_code VARCHAR2(30);
27046 l_adr_value_combination_id NUMBER;
27047 l_adr_value_segment_code VARCHAR2(30);
27048
27049 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
27050 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
27051 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
27052 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
27053
27054 -- 4262811 Variables ------------------------------------------------------------------------------------------
27055 l_entered_amt_idx NUMBER;
27056 l_accted_amt_idx NUMBER;
27057 l_acc_rev_flag VARCHAR2(1);
27058 l_accrual_line_num NUMBER;
27059 l_tmp_amt NUMBER;
27060 l_acc_rev_natural_side_code VARCHAR2(1);
27061
27062 l_num_entries NUMBER;
27063 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
27064 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
27065 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
27066 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
27067 l_recog_line_1 NUMBER;
27068 l_recog_line_2 NUMBER;
27069
27070 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
27071 l_bflow_applied_to_amt NUMBER; -- 5132302
27072 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
27073
27074 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
27075
27076 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
27077 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
27078
27079 ---------------------------------------------------------------------------------------------------------------
27080
27081
27082 --
27083 -- bulk performance
27084 --
27085 l_balance_type_code VARCHAR2(1);
27086 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
27087 l_log_module VARCHAR2(240);
27088
27089 --
27090 -- Upgrade strategy
27091 --
27092 l_actual_upg_option VARCHAR2(1);
27093 l_enc_upg_option VARCHAR2(1);
27094
27095 --
27096 BEGIN
27097 --
27098 IF g_log_enabled THEN
27099 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_72';
27100 END IF;
27101 --
27102 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27103
27104 trace
27105 (p_msg => 'BEGIN of AcctLineType_72'
27106 ,p_level => C_LEVEL_PROCEDURE
27107 ,p_module => l_log_module);
27108
27109 END IF;
27110 --
27111 l_component_type := 'AMB_JLT';
27112 l_component_code := 'FV_RCT_REF_OAP_UFC_CR';
27113 l_component_type_code := 'S';
27114 l_component_appl_id := 222;
27115 l_amb_context_code := 'DEFAULT';
27116 l_entity_code := 'RECEIPTS';
27117 l_event_class_code := 'RECEIPT';
27118 l_event_type_code := 'RECEIPT_ALL';
27119 l_line_definition_owner_code := 'S';
27120 l_line_definition_code := 'MFAR_FED_AR_RCT_ACCOUNT';
27121 --
27122 l_balance_type_code := 'A';
27123 l_segment := NULL;
27124 l_ccid := NULL;
27125 l_adr_transaction_coa_id := NULL;
27126 l_adr_accounting_coa_id := NULL;
27127 l_adr_flexfield_segment_code := NULL;
27128 l_adr_flex_value_set_id := NULL;
27129 l_adr_value_type_code := NULL;
27130 l_adr_value_combination_id := NULL;
27131 l_adr_value_segment_code := NULL;
27132
27133 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
27134 l_bflow_class_code := ''; -- 4219869 Business Flow
27135 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
27136 l_budgetary_control_flag := 'N';
27137
27138 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27139 l_bflow_applied_to_amt := NULL; -- 5132302
27140 l_entered_amt_idx := NULL; -- 4262811
27141 l_accted_amt_idx := NULL; -- 4262811
27142 l_acc_rev_flag := NULL; -- 4262811
27143 l_accrual_line_num := NULL; -- 4262811
27144 l_tmp_amt := NULL; -- 4262811
27145 --
27146
27147 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
27148 l_balance_type_code <> 'B' THEN
27149 IF NVL(p_source_22,'
27150 ') = 'REC' AND
27151 NVL(p_source_35,'
27152 ') = 'REV' AND
27153 NVL(p_source_14,'
27154 ') = 'Unexpired' AND
27155 NVL(p_source_15,'
27156 ') = 'N' AND
27157 (NVL(p_source_17,'
27158 ') = 'A' OR
27162 ') = 'C') AND
27159 NVL(p_source_17,'
27160 ') = 'B' OR
27161 NVL(p_source_17,'
27163 (NVL(p_source_16,'
27164 ') = 'SINGLE' OR
27165 NVL(p_source_16,'
27166 ') = 'MUTIPLE' OR
27167 NVL(p_source_16,'
27168 ') = 'NO_YEAR') AND
27169 (NVL(p_source_13,'
27170 ') = 'Overpayment Refund' OR
27171 NVL(p_source_13,'
27172 ') = 'Advance Refund') AND
27173 NVL(p_source_58,'
27174 ') = 'Y'
27175 THEN
27176
27177 --
27178 XLA_AE_LINES_PKG.SetNewLine;
27179
27180 p_balance_type_code := l_balance_type_code;
27181 -- set the flag so later we will know whether the gain loss line needs to be created
27182
27183 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
27184 p_actual_flag :='A';
27185 END IF;
27186
27187 --
27188 -- bulk performance
27189 --
27190 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
27191 p_header_num => 0); -- 4262811
27192 --
27193 -- set accounting line options
27194 --
27195 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
27196 p_natural_side_code => 'C'
27197 , p_gain_or_loss_flag => 'N'
27198 , p_gl_transfer_mode_code => 'S'
27199 , p_acct_entry_type_code => 'A'
27200 , p_switch_side_flag => 'Y'
27201 , p_merge_duplicate_code => 'A'
27202 );
27203 --
27204 l_acc_rev_natural_side_code := 'D'; -- 4262811
27205 --
27206 --
27207 -- set accounting line type info
27208 --
27209 xla_ae_lines_pkg.SetAcctLineType
27210 (p_component_type => l_component_type
27211 ,p_event_type_code => l_event_type_code
27212 ,p_line_definition_owner_code => l_line_definition_owner_code
27213 ,p_line_definition_code => l_line_definition_code
27214 ,p_accounting_line_code => l_component_code
27215 ,p_accounting_line_type_code => l_component_type_code
27216 ,p_accounting_line_appl_id => l_component_appl_id
27217 ,p_amb_context_code => l_amb_context_code
27218 ,p_entity_code => l_entity_code
27219 ,p_event_class_code => l_event_class_code);
27220 --
27221 -- set accounting class
27222 --
27223 xla_ae_lines_pkg.SetAcctClass(
27224 p_accounting_class_code => 'FV_CASH_CR'
27225 , p_ae_header_id => l_ae_header_id
27226 );
27227
27228 --
27229 -- set rounding class
27230 --
27231 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
27232 'RECEIVABLE';
27233
27234 --
27235 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
27236 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
27237 --
27238 -- bulk performance
27239 --
27240 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
27241
27242 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
27243 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
27244
27245 -- 4955764
27246 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27247 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
27248
27249 -- 4458381 Public Sector Enh
27250
27251 --
27252 -- set accounting attributes for the line type
27253 --
27254 l_entered_amt_idx := 8;
27255 l_accted_amt_idx := 13;
27256 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27257 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
27258 l_rec_acct_attrs.array_num_value(1) := p_source_60;
27259 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
27260 l_rec_acct_attrs.array_char_value(2) := p_source_37;
27261 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
27262 l_rec_acct_attrs.array_char_value(3) := p_source_61;
27263 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
27264 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
27265 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
27266 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
27267 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
27268 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
27269 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
27270 l_rec_acct_attrs.array_char_value(7) := p_source_25;
27271 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
27272 l_rec_acct_attrs.array_num_value(8) := p_source_26;
27273 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
27274 l_rec_acct_attrs.array_char_value(9) := p_source_63;
27275 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
27276 l_rec_acct_attrs.array_date_value(10) := p_source_59;
27277 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
27278 l_rec_acct_attrs.array_num_value(11) := p_source_64;
27279 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
27280 l_rec_acct_attrs.array_char_value(12) := p_source_30;
27284 l_rec_acct_attrs.array_num_value(14) := p_source_65;
27281 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
27282 l_rec_acct_attrs.array_num_value(13) := p_source_31;
27283 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
27285 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
27286 l_rec_acct_attrs.array_num_value(15) := p_source_66;
27287 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
27288 l_rec_acct_attrs.array_char_value(16) := p_source_67;
27289
27290 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
27291 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
27292
27293 ---------------------------------------------------------------------------------------------------------------
27294 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
27295 ---------------------------------------------------------------------------------------------------------------
27296 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
27297
27298 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27299 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27300
27301 IF xla_accounting_cache_pkg.GetValueChar
27302 (p_source_code => 'LEDGER_CATEGORY_CODE'
27303 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
27304 AND l_bflow_method_code = 'PRIOR_ENTRY'
27305 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
27306 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
27307 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
27308 )
27309 THEN
27310 xla_ae_lines_pkg.BflowUpgEntry
27311 (p_business_method_code => l_bflow_method_code
27312 ,p_business_class_code => l_bflow_class_code
27313 ,p_balance_type => l_balance_type_code);
27314 ELSE
27315 NULL;
27316 -- No business flow processing for business flow method of NONE.
27317 END IF;
27318
27319 --
27320 -- call analytical criteria
27321 --
27322
27323 --
27324 -- call description
27325 --
27326 -- No description or it is inherited.
27327 --
27328 -- call ADRs
27329 -- Bug 4922099
27330 --
27331 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27332 (NVL(l_actual_upg_option, 'N') = 'O') OR
27333 (NVL(l_enc_upg_option, 'N') = 'O')
27334 )
27335 THEN
27336 NULL;
27337 --
27338 --
27339
27340 l_ccid := AcctDerRule_34(
27341 p_application_id => p_application_id
27342 , p_ae_header_id => l_ae_header_id
27343 , p_source_21 => p_source_21
27344 , x_transaction_coa_id => l_adr_transaction_coa_id
27345 , x_accounting_coa_id => l_adr_accounting_coa_id
27346 , x_value_type_code => l_adr_value_type_code
27347 , p_side => 'NA'
27348 );
27349
27350 xla_ae_lines_pkg.set_ccid(
27351 p_code_combination_id => l_ccid
27352 , p_value_type_code => l_adr_value_type_code
27353 , p_transaction_coa_id => l_adr_transaction_coa_id
27354 , p_accounting_coa_id => l_adr_accounting_coa_id
27355 , p_adr_code => 'TRX_DIST_CCID'
27356 , p_adr_type_code => 'S'
27357 , p_component_type => l_component_type
27358 , p_component_code => l_component_code
27359 , p_component_type_code => l_component_type_code
27360 , p_component_appl_id => l_component_appl_id
27361 , p_amb_context_code => l_amb_context_code
27362 , p_side => 'NA'
27363 );
27364
27365
27366 l_segment := AcctDerRule_23(
27367 p_application_id => p_application_id
27368 , p_ae_header_id => l_ae_header_id
27369 , p_source_14 => p_source_14
27370 , p_source_15 => p_source_15
27371 , p_source_16 => p_source_16
27372 , p_source_17 => p_source_17
27373 , x_transaction_coa_id => l_adr_transaction_coa_id
27374 , x_accounting_coa_id => l_adr_accounting_coa_id
27375 , x_flexfield_segment_code => l_adr_flexfield_segment_code
27376 , x_flex_value_set_id => l_adr_flex_value_set_id
27377 , x_value_type_code => l_adr_value_type_code
27378 , x_value_combination_id => l_adr_value_combination_id
27379 , x_value_segment_code => l_adr_value_segment_code
27380 , p_side => 'NA'
27381 , p_override_seg_flag => 'Y'
27382 );
27383
27384 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
27385
27386 xla_ae_lines_pkg.set_segment(
27387 p_to_segment_code => 'GL_ACCOUNT'
27388 , p_segment_value => l_segment
27389 , p_from_segment_code => l_adr_value_segment_code
27390 , p_from_combination_id => l_adr_value_combination_id
27391 , p_value_type_code => l_adr_value_type_code
27392 , p_transaction_coa_id => l_adr_transaction_coa_id
27393 , p_accounting_coa_id => l_adr_accounting_coa_id
27394 , p_flexfield_segment_code => l_adr_flexfield_segment_code
27395 , p_flex_value_set_id => l_adr_flex_value_set_id
27399 , p_component_code => l_component_code
27396 , p_adr_code => 'FV_AR_46X002_RCT_CR'
27397 , p_adr_type_code => 'S'
27398 , p_component_type => l_component_type
27400 , p_component_type_code => l_component_type_code
27401 , p_component_appl_id => l_component_appl_id
27402 , p_amb_context_code => l_amb_context_code
27403 , p_entity_code => 'RECEIPTS'
27404 , p_event_class_code => 'RECEIPT'
27405 , p_side => 'NA'
27406 );
27407
27408 END IF;
27409
27410 --
27411 --
27412 END IF;
27413 --
27414 -- Bug 4922099
27415 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
27416 (NVL(l_enc_upg_option, 'N') = 'O')
27417 ) AND
27418 (l_bflow_method_code = 'PRIOR_ENTRY')
27419 )
27420 THEN
27421 IF
27422 --
27423 1 = 2
27424 --
27425 THEN
27426 xla_accounting_err_pkg.build_message
27427 (p_appli_s_name => 'XLA'
27428 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27429 ,p_token_1 => 'LINE_NUMBER'
27430 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
27431 ,p_token_2 => 'LINE_TYPE_NAME'
27432 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
27433 l_component_type
27434 ,l_component_code
27435 ,l_component_type_code
27436 ,l_component_appl_id
27437 ,l_amb_context_code
27438 ,l_entity_code
27439 ,l_event_class_code
27440 )
27441 ,p_token_3 => 'OWNER'
27442 ,p_value_3 => xla_lookups_pkg.get_meaning(
27443 p_lookup_type => 'XLA_OWNER_TYPE'
27444 ,p_lookup_code => l_component_type_code
27445 )
27446 ,p_token_4 => 'PRODUCT_NAME'
27447 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
27448 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
27449 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
27450 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
27451 ,p_ae_header_id => NULL
27452 );
27453
27454 IF (C_LEVEL_ERROR>= g_log_level) THEN
27455 trace
27456 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27457 ,p_level => C_LEVEL_ERROR
27458 ,p_module => l_log_module);
27459 END IF;
27460 END IF;
27461 END IF;
27462 --
27463 --
27464 ------------------------------------------------------------------------------------------------
27465 -- 4219869 Business Flow
27466 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
27467 -- Prior Entry. Currently, the following code is always generated.
27468 ------------------------------------------------------------------------------------------------
27469 XLA_AE_LINES_PKG.ValidateCurrentLine;
27470
27471 ------------------------------------------------------------------------------------
27472 -- 4219869 Business Flow
27473 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
27474 ------------------------------------------------------------------------------------
27475 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27476
27477 ----------------------------------------------------------------------------------
27478 -- 4219869 Business Flow
27479 -- Update journal entry status -- Need to generate this within IF <condition>
27480 ----------------------------------------------------------------------------------
27481 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27482 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
27483 ,p_balance_type_code => l_balance_type_code
27484 );
27485
27486 -------------------------------------------------------------------------------------------
27487 -- 4262811 - Generate the Accrual Reversal lines
27488 -------------------------------------------------------------------------------------------
27489 BEGIN
27490 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
27494 END IF;
27491 (g_array_event(p_event_id).array_value_num('header_index'));
27492 IF l_acc_rev_flag IS NULL THEN
27493 l_acc_rev_flag := 'N';
27495 EXCEPTION
27496 WHEN OTHERS THEN
27497 l_acc_rev_flag := 'N';
27498 END;
27499 --
27500 IF (l_acc_rev_flag = 'Y') THEN
27501
27502 -- 4645092 ------------------------------------------------------------------------------
27503 -- To allow MPA report to determine if it should generate report process
27504 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
27505 ------------------------------------------------------------------------------------------
27506
27507 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
27508 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
27509 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
27510 -- call ADRs
27511 -- Bug 4922099
27512 --
27513 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27514 (NVL(l_actual_upg_option, 'N') = 'O') OR
27515 (NVL(l_enc_upg_option, 'N') = 'O')
27516 )
27517 THEN
27518 NULL;
27519 --
27520 --
27521
27522 l_ccid := AcctDerRule_34(
27523 p_application_id => p_application_id
27524 , p_ae_header_id => l_ae_header_id
27525 , p_source_21 => p_source_21
27526 , x_transaction_coa_id => l_adr_transaction_coa_id
27527 , x_accounting_coa_id => l_adr_accounting_coa_id
27528 , x_value_type_code => l_adr_value_type_code
27529 , p_side => 'NA'
27530 );
27531
27532 xla_ae_lines_pkg.set_ccid(
27533 p_code_combination_id => l_ccid
27534 , p_value_type_code => l_adr_value_type_code
27535 , p_transaction_coa_id => l_adr_transaction_coa_id
27536 , p_accounting_coa_id => l_adr_accounting_coa_id
27537 , p_adr_code => 'TRX_DIST_CCID'
27538 , p_adr_type_code => 'S'
27539 , p_component_type => l_component_type
27540 , p_component_code => l_component_code
27541 , p_component_type_code => l_component_type_code
27542 , p_component_appl_id => l_component_appl_id
27543 , p_amb_context_code => l_amb_context_code
27544 , p_side => 'NA'
27545 );
27546
27547
27548 l_segment := AcctDerRule_23(
27549 p_application_id => p_application_id
27550 , p_ae_header_id => l_ae_header_id
27551 , p_source_14 => p_source_14
27552 , p_source_15 => p_source_15
27553 , p_source_16 => p_source_16
27554 , p_source_17 => p_source_17
27555 , x_transaction_coa_id => l_adr_transaction_coa_id
27556 , x_accounting_coa_id => l_adr_accounting_coa_id
27557 , x_flexfield_segment_code => l_adr_flexfield_segment_code
27558 , x_flex_value_set_id => l_adr_flex_value_set_id
27559 , x_value_type_code => l_adr_value_type_code
27560 , x_value_combination_id => l_adr_value_combination_id
27561 , x_value_segment_code => l_adr_value_segment_code
27562 , p_side => 'NA'
27563 , p_override_seg_flag => 'Y'
27564 );
27565
27566 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
27567
27568 xla_ae_lines_pkg.set_segment(
27569 p_to_segment_code => 'GL_ACCOUNT'
27570 , p_segment_value => l_segment
27571 , p_from_segment_code => l_adr_value_segment_code
27572 , p_from_combination_id => l_adr_value_combination_id
27573 , p_value_type_code => l_adr_value_type_code
27574 , p_transaction_coa_id => l_adr_transaction_coa_id
27575 , p_accounting_coa_id => l_adr_accounting_coa_id
27576 , p_flexfield_segment_code => l_adr_flexfield_segment_code
27577 , p_flex_value_set_id => l_adr_flex_value_set_id
27578 , p_adr_code => 'FV_AR_46X002_RCT_CR'
27579 , p_adr_type_code => 'S'
27580 , p_component_type => l_component_type
27581 , p_component_code => l_component_code
27582 , p_component_type_code => l_component_type_code
27583 , p_component_appl_id => l_component_appl_id
27584 , p_amb_context_code => l_amb_context_code
27585 , p_entity_code => 'RECEIPTS'
27586 , p_event_class_code => 'RECEIPT'
27587 , p_side => 'NA'
27588 );
27589
27590 END IF;
27591
27592 --
27593 --
27594 END IF;
27595
27596 --
27597 -- Update the line information that should be overwritten
27598 --
27599 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
27600 p_header_num => 1);
27601 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
27602
27603 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
27604
27605 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
27606 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
27607 END IF;
27608
27609 --
27610 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
27614 ELSE
27611 --
27612 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
27613 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
27615 ---------------------------------------------------------------------------------------------------
27616 -- 4262811a Switch Sign
27617 ---------------------------------------------------------------------------------------------------
27618 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
27619 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27620 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27621 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27622 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27623 -- 5132302
27624 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
27625 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27626
27627 END IF;
27628
27629 -- 4955764
27630 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27631 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
27632
27633
27634 XLA_AE_LINES_PKG.ValidateCurrentLine;
27635 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27636
27637 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27638 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
27639 ,p_balance_type_code => l_balance_type_code);
27640
27641 END IF;
27642
27643 -----------------------------------------------------------------------------------------
27644 -- 4262811 Multiperiod Accounting
27645 -----------------------------------------------------------------------------------------
27646 -- No MPA option is assigned.
27647
27648
27649 END IF;
27650 END IF;
27651 --
27652
27653 --
27654 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27655 trace
27656 (p_msg => 'END of AcctLineType_72'
27657 ,p_level => C_LEVEL_PROCEDURE
27658 ,p_module => l_log_module);
27659 END IF;
27660 --
27661 EXCEPTION
27662 WHEN xla_exceptions_pkg.application_exception THEN
27663 RAISE;
27664 WHEN OTHERS THEN
27665 xla_exceptions_pkg.raise_message
27666 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_72');
27667 END AcctLineType_72;
27668 --
27669
27670 ---------------------------------------
27671 --
27672 -- PRIVATE FUNCTION
27673 -- AcctLineType_73
27674 --
27675 ---------------------------------------
27676 PROCEDURE AcctLineType_73 (
27677 p_application_id IN NUMBER
27678 ,p_event_id IN NUMBER
27679 ,p_calculate_acctd_flag IN VARCHAR2
27680 ,p_calculate_g_l_flag IN VARCHAR2
27681 ,p_actual_flag IN OUT VARCHAR2
27682 ,p_balance_type_code OUT VARCHAR2
27683 ,p_gain_or_loss_ref OUT VARCHAR2
27684
27685 --Federal Account Rule
27686 , p_source_13 IN VARCHAR2
27687 --Federal Fund Expired Status
27688 , p_source_14 IN VARCHAR2
27689 --Federal Prior Year Flag
27690 , p_source_15 IN VARCHAR2
27691 --Federal Fund Time Frame
27692 , p_source_16 IN VARCHAR2
27693 --Federal Apportionment Category
27694 , p_source_17 IN VARCHAR2
27695 --Transaction Distribution GL Account
27696 , p_source_21 IN NUMBER
27697 --Distribution Source Type
27698 , p_source_22 IN VARCHAR2
27699 --Distribution Line Identifier
27700 , p_source_24 IN NUMBER
27701 --Distribution Type
27702 , p_source_25 IN VARCHAR2
27703 --Entered Amount
27704 , p_source_26 IN NUMBER
27705 --Exchange Rate Type
27706 , p_source_30 IN VARCHAR2
27707 --Applied To Document Accounting Amount
27708 , p_source_31 IN NUMBER
27709 --Transaction Distribution Account Class
27710 , p_source_35 IN VARCHAR2
27711 --Transaction Distribution Identifier
27712 , p_source_36 IN NUMBER
27713 --Transaction Distribution Type
27714 , p_source_37 IN VARCHAR2
27715 --Federal Account Valid Flag
27716 , p_source_58 IN VARCHAR2
27717 --Applied To Document Exchange Date
27718 , p_source_59 IN DATE
27719 --Receipt Applied To Application Identifier
27720 , p_source_60 IN NUMBER
27721 --Transaction Entity Code
27722 , p_source_61 IN VARCHAR2
27723 --Transaction Identifier
27724 , p_source_62 IN NUMBER
27725 --Applying Document Currency Code
27726 , p_source_63 IN VARCHAR2
27727 --Applied To Document Exchange Rate
27728 , p_source_64 IN NUMBER
27729 --Distribution Party Identifier
27730 , p_source_65 IN NUMBER
27731 --Distribution Party Site Id
27732 , p_source_66 IN NUMBER
27733 --Distribution Party Type
27734 , p_source_67 IN VARCHAR2
27735 )
27736 IS
27737
27738 l_component_type VARCHAR2(80);
27742 l_amb_context_code VARCHAR2(30);
27739 l_component_code VARCHAR2(30);
27740 l_component_type_code VARCHAR2(1);
27741 l_component_appl_id INTEGER;
27743 l_entity_code VARCHAR2(30);
27744 l_event_class_code VARCHAR2(30);
27745 l_ae_header_id NUMBER;
27746 l_event_type_code VARCHAR2(30);
27747 l_line_definition_code VARCHAR2(30);
27748 l_line_definition_owner_code VARCHAR2(1);
27749 --
27750 -- adr variables
27751 l_segment VARCHAR2(30);
27752 l_ccid NUMBER;
27753 l_adr_transaction_coa_id NUMBER;
27754 l_adr_accounting_coa_id NUMBER;
27755 l_adr_flexfield_segment_code VARCHAR2(30);
27756 l_adr_flex_value_set_id NUMBER;
27757 l_adr_value_type_code VARCHAR2(30);
27758 l_adr_value_combination_id NUMBER;
27759 l_adr_value_segment_code VARCHAR2(30);
27760
27761 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
27762 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
27763 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
27764 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
27765
27766 -- 4262811 Variables ------------------------------------------------------------------------------------------
27767 l_entered_amt_idx NUMBER;
27768 l_accted_amt_idx NUMBER;
27769 l_acc_rev_flag VARCHAR2(1);
27770 l_accrual_line_num NUMBER;
27771 l_tmp_amt NUMBER;
27772 l_acc_rev_natural_side_code VARCHAR2(1);
27773
27774 l_num_entries NUMBER;
27775 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
27776 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
27777 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
27778 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
27779 l_recog_line_1 NUMBER;
27780 l_recog_line_2 NUMBER;
27781
27782 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
27783 l_bflow_applied_to_amt NUMBER; -- 5132302
27784 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
27785
27786 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
27787
27788 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
27789 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
27790
27791 ---------------------------------------------------------------------------------------------------------------
27792
27793
27794 --
27795 -- bulk performance
27796 --
27797 l_balance_type_code VARCHAR2(1);
27798 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
27799 l_log_module VARCHAR2(240);
27800
27801 --
27802 -- Upgrade strategy
27803 --
27804 l_actual_upg_option VARCHAR2(1);
27805 l_enc_upg_option VARCHAR2(1);
27806
27807 --
27808 BEGIN
27809 --
27810 IF g_log_enabled THEN
27811 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_73';
27812 END IF;
27813 --
27814 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27815
27816 trace
27817 (p_msg => 'BEGIN of AcctLineType_73'
27818 ,p_level => C_LEVEL_PROCEDURE
27819 ,p_module => l_log_module);
27820
27821 END IF;
27822 --
27823 l_component_type := 'AMB_JLT';
27824 l_component_code := 'FV_RCT_REF_OAP_UFC_DR';
27825 l_component_type_code := 'S';
27826 l_component_appl_id := 222;
27827 l_amb_context_code := 'DEFAULT';
27828 l_entity_code := 'RECEIPTS';
27829 l_event_class_code := 'RECEIPT';
27830 l_event_type_code := 'RECEIPT_ALL';
27831 l_line_definition_owner_code := 'S';
27832 l_line_definition_code := 'MFAR_FED_AR_RCT_ACCOUNT';
27833 --
27834 l_balance_type_code := 'A';
27835 l_segment := NULL;
27836 l_ccid := NULL;
27837 l_adr_transaction_coa_id := NULL;
27838 l_adr_accounting_coa_id := NULL;
27839 l_adr_flexfield_segment_code := NULL;
27840 l_adr_flex_value_set_id := NULL;
27841 l_adr_value_type_code := NULL;
27842 l_adr_value_combination_id := NULL;
27843 l_adr_value_segment_code := NULL;
27844
27845 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
27846 l_bflow_class_code := ''; -- 4219869 Business Flow
27847 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
27848 l_budgetary_control_flag := 'N';
27849
27850 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27851 l_bflow_applied_to_amt := NULL; -- 5132302
27852 l_entered_amt_idx := NULL; -- 4262811
27853 l_accted_amt_idx := NULL; -- 4262811
27854 l_acc_rev_flag := NULL; -- 4262811
27855 l_accrual_line_num := NULL; -- 4262811
27856 l_tmp_amt := NULL; -- 4262811
27857 --
27858
27859 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
27860 l_balance_type_code <> 'B' THEN
27861 IF NVL(p_source_22,'
27862 ') = 'REC' AND
27866 ') = 'Unexpired' AND
27863 NVL(p_source_35,'
27864 ') = 'REV' AND
27865 NVL(p_source_14,'
27867 NVL(p_source_15,'
27868 ') = 'N' AND
27869 (NVL(p_source_17,'
27870 ') = 'A' OR
27871 NVL(p_source_17,'
27872 ') = 'B' OR
27873 NVL(p_source_17,'
27874 ') = 'C') AND
27875 (NVL(p_source_16,'
27876 ') = 'SINGLE' OR
27877 NVL(p_source_16,'
27878 ') = 'MUTIPLE' OR
27879 NVL(p_source_16,'
27880 ') = 'NO_YEAR') AND
27881 (NVL(p_source_13,'
27882 ') = 'Overpayment Refund' OR
27883 NVL(p_source_13,'
27884 ') = 'Advance Refund') AND
27885 NVL(p_source_58,'
27886 ') = 'Y'
27887 THEN
27888
27889 --
27890 XLA_AE_LINES_PKG.SetNewLine;
27891
27892 p_balance_type_code := l_balance_type_code;
27893 -- set the flag so later we will know whether the gain loss line needs to be created
27894
27895 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
27896 p_actual_flag :='A';
27897 END IF;
27898
27899 --
27900 -- bulk performance
27901 --
27902 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
27903 p_header_num => 0); -- 4262811
27904 --
27905 -- set accounting line options
27906 --
27907 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
27908 p_natural_side_code => 'D'
27909 , p_gain_or_loss_flag => 'N'
27910 , p_gl_transfer_mode_code => 'S'
27911 , p_acct_entry_type_code => 'A'
27912 , p_switch_side_flag => 'Y'
27913 , p_merge_duplicate_code => 'A'
27914 );
27915 --
27916 l_acc_rev_natural_side_code := 'C'; -- 4262811
27917 --
27918 --
27919 -- set accounting line type info
27920 --
27921 xla_ae_lines_pkg.SetAcctLineType
27922 (p_component_type => l_component_type
27923 ,p_event_type_code => l_event_type_code
27924 ,p_line_definition_owner_code => l_line_definition_owner_code
27925 ,p_line_definition_code => l_line_definition_code
27926 ,p_accounting_line_code => l_component_code
27927 ,p_accounting_line_type_code => l_component_type_code
27928 ,p_accounting_line_appl_id => l_component_appl_id
27929 ,p_amb_context_code => l_amb_context_code
27930 ,p_entity_code => l_entity_code
27931 ,p_event_class_code => l_event_class_code);
27932 --
27933 -- set accounting class
27934 --
27935 xla_ae_lines_pkg.SetAcctClass(
27936 p_accounting_class_code => 'FV_CASH_DR'
27937 , p_ae_header_id => l_ae_header_id
27938 );
27939
27940 --
27941 -- set rounding class
27942 --
27943 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
27944 'RECEIVABLE';
27945
27946 --
27947 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
27948 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
27949 --
27950 -- bulk performance
27951 --
27952 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
27953
27954 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
27955 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
27956
27957 -- 4955764
27958 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27959 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
27960
27961 -- 4458381 Public Sector Enh
27962
27963 --
27964 -- set accounting attributes for the line type
27965 --
27966 l_entered_amt_idx := 8;
27967 l_accted_amt_idx := 13;
27968 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27969 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
27970 l_rec_acct_attrs.array_num_value(1) := p_source_60;
27971 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
27972 l_rec_acct_attrs.array_char_value(2) := p_source_37;
27973 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
27974 l_rec_acct_attrs.array_char_value(3) := p_source_61;
27975 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
27976 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
27977 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
27978 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
27979 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
27980 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
27981 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
27982 l_rec_acct_attrs.array_char_value(7) := p_source_25;
27983 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
27984 l_rec_acct_attrs.array_num_value(8) := p_source_26;
27985 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
27986 l_rec_acct_attrs.array_char_value(9) := p_source_63;
27987 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
27988 l_rec_acct_attrs.array_date_value(10) := p_source_59;
27989 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
27990 l_rec_acct_attrs.array_num_value(11) := p_source_64;
27994 l_rec_acct_attrs.array_num_value(13) := p_source_31;
27991 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
27992 l_rec_acct_attrs.array_char_value(12) := p_source_30;
27993 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
27995 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
27996 l_rec_acct_attrs.array_num_value(14) := p_source_65;
27997 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
27998 l_rec_acct_attrs.array_num_value(15) := p_source_66;
27999 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
28000 l_rec_acct_attrs.array_char_value(16) := p_source_67;
28001
28002 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
28003 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
28004
28005 ---------------------------------------------------------------------------------------------------------------
28006 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
28007 ---------------------------------------------------------------------------------------------------------------
28008 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
28009
28010 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28011 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28012
28013 IF xla_accounting_cache_pkg.GetValueChar
28014 (p_source_code => 'LEDGER_CATEGORY_CODE'
28015 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
28016 AND l_bflow_method_code = 'PRIOR_ENTRY'
28017 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
28018 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
28019 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
28020 )
28021 THEN
28022 xla_ae_lines_pkg.BflowUpgEntry
28023 (p_business_method_code => l_bflow_method_code
28024 ,p_business_class_code => l_bflow_class_code
28025 ,p_balance_type => l_balance_type_code);
28026 ELSE
28027 NULL;
28028 -- No business flow processing for business flow method of NONE.
28029 END IF;
28030
28031 --
28032 -- call analytical criteria
28033 --
28034
28035 --
28036 -- call description
28037 --
28038 -- No description or it is inherited.
28039 --
28040 -- call ADRs
28041 -- Bug 4922099
28042 --
28043 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28044 (NVL(l_actual_upg_option, 'N') = 'O') OR
28045 (NVL(l_enc_upg_option, 'N') = 'O')
28046 )
28047 THEN
28048 NULL;
28049 --
28050 --
28051
28052 l_ccid := AcctDerRule_34(
28053 p_application_id => p_application_id
28054 , p_ae_header_id => l_ae_header_id
28055 , p_source_21 => p_source_21
28056 , x_transaction_coa_id => l_adr_transaction_coa_id
28057 , x_accounting_coa_id => l_adr_accounting_coa_id
28058 , x_value_type_code => l_adr_value_type_code
28059 , p_side => 'NA'
28060 );
28061
28062 xla_ae_lines_pkg.set_ccid(
28063 p_code_combination_id => l_ccid
28064 , p_value_type_code => l_adr_value_type_code
28065 , p_transaction_coa_id => l_adr_transaction_coa_id
28066 , p_accounting_coa_id => l_adr_accounting_coa_id
28067 , p_adr_code => 'TRX_DIST_CCID'
28068 , p_adr_type_code => 'S'
28069 , p_component_type => l_component_type
28070 , p_component_code => l_component_code
28071 , p_component_type_code => l_component_type_code
28072 , p_component_appl_id => l_component_appl_id
28073 , p_amb_context_code => l_amb_context_code
28074 , p_side => 'NA'
28075 );
28076
28077
28078 l_segment := AcctDerRule_26(
28079 p_application_id => p_application_id
28080 , p_ae_header_id => l_ae_header_id
28081 , p_source_13 => p_source_13
28082 , p_source_14 => p_source_14
28083 , p_source_15 => p_source_15
28084 , p_source_16 => p_source_16
28085 , p_source_17 => p_source_17
28086 , x_transaction_coa_id => l_adr_transaction_coa_id
28087 , x_accounting_coa_id => l_adr_accounting_coa_id
28088 , x_flexfield_segment_code => l_adr_flexfield_segment_code
28089 , x_flex_value_set_id => l_adr_flex_value_set_id
28090 , x_value_type_code => l_adr_value_type_code
28091 , x_value_combination_id => l_adr_value_combination_id
28092 , x_value_segment_code => l_adr_value_segment_code
28093 , p_side => 'NA'
28094 , p_override_seg_flag => 'Y'
28095 );
28096
28097 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
28098
28099 xla_ae_lines_pkg.set_segment(
28100 p_to_segment_code => 'GL_ACCOUNT'
28101 , p_segment_value => l_segment
28102 , p_from_segment_code => l_adr_value_segment_code
28103 , p_from_combination_id => l_adr_value_combination_id
28104 , p_value_type_code => l_adr_value_type_code
28105 , p_transaction_coa_id => l_adr_transaction_coa_id
28109 , p_adr_code => 'FV_AR_4X0201_RCT_DR'
28106 , p_accounting_coa_id => l_adr_accounting_coa_id
28107 , p_flexfield_segment_code => l_adr_flexfield_segment_code
28108 , p_flex_value_set_id => l_adr_flex_value_set_id
28110 , p_adr_type_code => 'S'
28111 , p_component_type => l_component_type
28112 , p_component_code => l_component_code
28113 , p_component_type_code => l_component_type_code
28114 , p_component_appl_id => l_component_appl_id
28115 , p_amb_context_code => l_amb_context_code
28116 , p_entity_code => 'RECEIPTS'
28117 , p_event_class_code => 'RECEIPT'
28118 , p_side => 'NA'
28119 );
28120
28121 END IF;
28122
28123 --
28124 --
28125 END IF;
28126 --
28127 -- Bug 4922099
28128 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
28129 (NVL(l_enc_upg_option, 'N') = 'O')
28130 ) AND
28131 (l_bflow_method_code = 'PRIOR_ENTRY')
28132 )
28133 THEN
28134 IF
28135 --
28136 1 = 2
28137 --
28138 THEN
28139 xla_accounting_err_pkg.build_message
28140 (p_appli_s_name => 'XLA'
28141 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28142 ,p_token_1 => 'LINE_NUMBER'
28143 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
28144 ,p_token_2 => 'LINE_TYPE_NAME'
28145 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
28146 l_component_type
28147 ,l_component_code
28148 ,l_component_type_code
28149 ,l_component_appl_id
28150 ,l_amb_context_code
28151 ,l_entity_code
28152 ,l_event_class_code
28153 )
28154 ,p_token_3 => 'OWNER'
28155 ,p_value_3 => xla_lookups_pkg.get_meaning(
28156 p_lookup_type => 'XLA_OWNER_TYPE'
28157 ,p_lookup_code => l_component_type_code
28158 )
28159 ,p_token_4 => 'PRODUCT_NAME'
28160 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
28161 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
28162 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
28163 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
28164 ,p_ae_header_id => NULL
28165 );
28166
28167 IF (C_LEVEL_ERROR>= g_log_level) THEN
28168 trace
28169 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28170 ,p_level => C_LEVEL_ERROR
28171 ,p_module => l_log_module);
28172 END IF;
28173 END IF;
28174 END IF;
28175 --
28176 --
28177 ------------------------------------------------------------------------------------------------
28178 -- 4219869 Business Flow
28179 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
28180 -- Prior Entry. Currently, the following code is always generated.
28181 ------------------------------------------------------------------------------------------------
28182 XLA_AE_LINES_PKG.ValidateCurrentLine;
28183
28184 ------------------------------------------------------------------------------------
28185 -- 4219869 Business Flow
28186 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
28187 ------------------------------------------------------------------------------------
28188 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28189
28190 ----------------------------------------------------------------------------------
28191 -- 4219869 Business Flow
28192 -- Update journal entry status -- Need to generate this within IF <condition>
28193 ----------------------------------------------------------------------------------
28194 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28195 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
28196 ,p_balance_type_code => l_balance_type_code
28197 );
28198
28199 -------------------------------------------------------------------------------------------
28200 -- 4262811 - Generate the Accrual Reversal lines
28204 (g_array_event(p_event_id).array_value_num('header_index'));
28201 -------------------------------------------------------------------------------------------
28202 BEGIN
28203 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
28205 IF l_acc_rev_flag IS NULL THEN
28206 l_acc_rev_flag := 'N';
28207 END IF;
28208 EXCEPTION
28209 WHEN OTHERS THEN
28210 l_acc_rev_flag := 'N';
28211 END;
28212 --
28213 IF (l_acc_rev_flag = 'Y') THEN
28214
28215 -- 4645092 ------------------------------------------------------------------------------
28216 -- To allow MPA report to determine if it should generate report process
28217 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
28218 ------------------------------------------------------------------------------------------
28219
28220 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
28221 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
28222 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
28223 -- call ADRs
28224 -- Bug 4922099
28225 --
28226 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28227 (NVL(l_actual_upg_option, 'N') = 'O') OR
28228 (NVL(l_enc_upg_option, 'N') = 'O')
28229 )
28230 THEN
28231 NULL;
28232 --
28233 --
28234
28235 l_ccid := AcctDerRule_34(
28236 p_application_id => p_application_id
28237 , p_ae_header_id => l_ae_header_id
28238 , p_source_21 => p_source_21
28239 , x_transaction_coa_id => l_adr_transaction_coa_id
28240 , x_accounting_coa_id => l_adr_accounting_coa_id
28241 , x_value_type_code => l_adr_value_type_code
28242 , p_side => 'NA'
28243 );
28244
28245 xla_ae_lines_pkg.set_ccid(
28246 p_code_combination_id => l_ccid
28247 , p_value_type_code => l_adr_value_type_code
28248 , p_transaction_coa_id => l_adr_transaction_coa_id
28249 , p_accounting_coa_id => l_adr_accounting_coa_id
28250 , p_adr_code => 'TRX_DIST_CCID'
28251 , p_adr_type_code => 'S'
28252 , p_component_type => l_component_type
28253 , p_component_code => l_component_code
28254 , p_component_type_code => l_component_type_code
28255 , p_component_appl_id => l_component_appl_id
28256 , p_amb_context_code => l_amb_context_code
28257 , p_side => 'NA'
28258 );
28259
28260
28261 l_segment := AcctDerRule_26(
28262 p_application_id => p_application_id
28263 , p_ae_header_id => l_ae_header_id
28264 , p_source_13 => p_source_13
28265 , p_source_14 => p_source_14
28266 , p_source_15 => p_source_15
28267 , p_source_16 => p_source_16
28268 , p_source_17 => p_source_17
28269 , x_transaction_coa_id => l_adr_transaction_coa_id
28270 , x_accounting_coa_id => l_adr_accounting_coa_id
28271 , x_flexfield_segment_code => l_adr_flexfield_segment_code
28272 , x_flex_value_set_id => l_adr_flex_value_set_id
28273 , x_value_type_code => l_adr_value_type_code
28274 , x_value_combination_id => l_adr_value_combination_id
28275 , x_value_segment_code => l_adr_value_segment_code
28276 , p_side => 'NA'
28277 , p_override_seg_flag => 'Y'
28278 );
28279
28280 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
28281
28282 xla_ae_lines_pkg.set_segment(
28283 p_to_segment_code => 'GL_ACCOUNT'
28284 , p_segment_value => l_segment
28285 , p_from_segment_code => l_adr_value_segment_code
28286 , p_from_combination_id => l_adr_value_combination_id
28287 , p_value_type_code => l_adr_value_type_code
28288 , p_transaction_coa_id => l_adr_transaction_coa_id
28289 , p_accounting_coa_id => l_adr_accounting_coa_id
28290 , p_flexfield_segment_code => l_adr_flexfield_segment_code
28291 , p_flex_value_set_id => l_adr_flex_value_set_id
28292 , p_adr_code => 'FV_AR_4X0201_RCT_DR'
28293 , p_adr_type_code => 'S'
28294 , p_component_type => l_component_type
28295 , p_component_code => l_component_code
28296 , p_component_type_code => l_component_type_code
28297 , p_component_appl_id => l_component_appl_id
28298 , p_amb_context_code => l_amb_context_code
28299 , p_entity_code => 'RECEIPTS'
28300 , p_event_class_code => 'RECEIPT'
28301 , p_side => 'NA'
28302 );
28303
28304 END IF;
28305
28306 --
28307 --
28308 END IF;
28309
28310 --
28311 -- Update the line information that should be overwritten
28312 --
28313 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
28314 p_header_num => 1);
28315 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
28316
28320 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
28317 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
28318
28319 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
28321 END IF;
28322
28323 --
28324 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
28325 --
28326 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
28327 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
28328 ELSE
28329 ---------------------------------------------------------------------------------------------------
28330 -- 4262811a Switch Sign
28331 ---------------------------------------------------------------------------------------------------
28332 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
28333 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28334 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28335 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28336 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28337 -- 5132302
28338 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
28339 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28340
28341 END IF;
28342
28343 -- 4955764
28344 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28345 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
28346
28347
28348 XLA_AE_LINES_PKG.ValidateCurrentLine;
28349 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28350
28351 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28352 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
28353 ,p_balance_type_code => l_balance_type_code);
28354
28355 END IF;
28356
28357 -----------------------------------------------------------------------------------------
28358 -- 4262811 Multiperiod Accounting
28359 -----------------------------------------------------------------------------------------
28360 -- No MPA option is assigned.
28361
28362
28363 END IF;
28364 END IF;
28365 --
28366
28367 --
28368 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28369 trace
28370 (p_msg => 'END of AcctLineType_73'
28371 ,p_level => C_LEVEL_PROCEDURE
28372 ,p_module => l_log_module);
28373 END IF;
28374 --
28375 EXCEPTION
28376 WHEN xla_exceptions_pkg.application_exception THEN
28377 RAISE;
28378 WHEN OTHERS THEN
28379 xla_exceptions_pkg.raise_message
28380 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_73');
28381 END AcctLineType_73;
28382 --
28383
28384 ---------------------------------------
28385 --
28386 -- PRIVATE FUNCTION
28387 -- AcctLineType_74
28388 --
28389 ---------------------------------------
28390 PROCEDURE AcctLineType_74 (
28391 p_application_id IN NUMBER
28392 ,p_event_id IN NUMBER
28393 ,p_calculate_acctd_flag IN VARCHAR2
28394 ,p_calculate_g_l_flag IN VARCHAR2
28395 ,p_actual_flag IN OUT VARCHAR2
28396 ,p_balance_type_code OUT VARCHAR2
28397 ,p_gain_or_loss_ref OUT VARCHAR2
28398
28399 --Federal Account Rule
28400 , p_source_13 IN VARCHAR2
28401 --Federal Fund Expired Status
28402 , p_source_14 IN VARCHAR2
28403 --Federal Prior Year Flag
28404 , p_source_15 IN VARCHAR2
28405 --Federal Fund Time Frame
28406 , p_source_16 IN VARCHAR2
28407 --Transaction Distribution GL Account
28408 , p_source_21 IN NUMBER
28409 --Distribution Source Type
28410 , p_source_22 IN VARCHAR2
28411 --Distribution Line Identifier
28412 , p_source_24 IN NUMBER
28413 --Distribution Type
28414 , p_source_25 IN VARCHAR2
28415 --Entered Amount
28416 , p_source_26 IN NUMBER
28417 --Exchange Rate Type
28418 , p_source_30 IN VARCHAR2
28419 --Applied To Document Accounting Amount
28420 , p_source_31 IN NUMBER
28421 --Transaction Distribution Account Class
28422 , p_source_35 IN VARCHAR2
28423 --Transaction Distribution Identifier
28424 , p_source_36 IN NUMBER
28425 --Transaction Distribution Type
28426 , p_source_37 IN VARCHAR2
28427 --Federal Account Valid Flag
28428 , p_source_58 IN VARCHAR2
28429 --Applied To Document Exchange Date
28430 , p_source_59 IN DATE
28431 --Receipt Applied To Application Identifier
28432 , p_source_60 IN NUMBER
28433 --Transaction Entity Code
28434 , p_source_61 IN VARCHAR2
28435 --Transaction Identifier
28436 , p_source_62 IN NUMBER
28437 --Applying Document Currency Code
28438 , p_source_63 IN VARCHAR2
28439 --Applied To Document Exchange Rate
28440 , p_source_64 IN NUMBER
28444 , p_source_66 IN NUMBER
28441 --Distribution Party Identifier
28442 , p_source_65 IN NUMBER
28443 --Distribution Party Site Id
28445 --Distribution Party Type
28446 , p_source_67 IN VARCHAR2
28447 )
28448 IS
28449
28450 l_component_type VARCHAR2(80);
28451 l_component_code VARCHAR2(30);
28452 l_component_type_code VARCHAR2(1);
28453 l_component_appl_id INTEGER;
28454 l_amb_context_code VARCHAR2(30);
28455 l_entity_code VARCHAR2(30);
28456 l_event_class_code VARCHAR2(30);
28457 l_ae_header_id NUMBER;
28458 l_event_type_code VARCHAR2(30);
28459 l_line_definition_code VARCHAR2(30);
28460 l_line_definition_owner_code VARCHAR2(1);
28461 --
28462 -- adr variables
28463 l_segment VARCHAR2(30);
28464 l_ccid NUMBER;
28465 l_adr_transaction_coa_id NUMBER;
28466 l_adr_accounting_coa_id NUMBER;
28467 l_adr_flexfield_segment_code VARCHAR2(30);
28468 l_adr_flex_value_set_id NUMBER;
28469 l_adr_value_type_code VARCHAR2(30);
28470 l_adr_value_combination_id NUMBER;
28471 l_adr_value_segment_code VARCHAR2(30);
28472
28473 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
28474 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
28475 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
28476 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
28477
28478 -- 4262811 Variables ------------------------------------------------------------------------------------------
28479 l_entered_amt_idx NUMBER;
28480 l_accted_amt_idx NUMBER;
28481 l_acc_rev_flag VARCHAR2(1);
28482 l_accrual_line_num NUMBER;
28483 l_tmp_amt NUMBER;
28484 l_acc_rev_natural_side_code VARCHAR2(1);
28485
28486 l_num_entries NUMBER;
28487 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
28488 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
28489 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
28490 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
28491 l_recog_line_1 NUMBER;
28492 l_recog_line_2 NUMBER;
28493
28494 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
28495 l_bflow_applied_to_amt NUMBER; -- 5132302
28496 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
28497
28498 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
28499
28500 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
28501 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
28502
28503 ---------------------------------------------------------------------------------------------------------------
28504
28505
28506 --
28507 -- bulk performance
28508 --
28509 l_balance_type_code VARCHAR2(1);
28510 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
28511 l_log_module VARCHAR2(240);
28512
28513 --
28514 -- Upgrade strategy
28515 --
28516 l_actual_upg_option VARCHAR2(1);
28517 l_enc_upg_option VARCHAR2(1);
28518
28519 --
28520 BEGIN
28521 --
28522 IF g_log_enabled THEN
28523 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_74';
28524 END IF;
28525 --
28526 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28527
28528 trace
28529 (p_msg => 'BEGIN of AcctLineType_74'
28530 ,p_level => C_LEVEL_PROCEDURE
28531 ,p_module => l_log_module);
28532
28533 END IF;
28534 --
28535 l_component_type := 'AMB_JLT';
28536 l_component_code := 'FV_RCT_REF_OAP_UFP_CR';
28537 l_component_type_code := 'S';
28538 l_component_appl_id := 222;
28539 l_amb_context_code := 'DEFAULT';
28540 l_entity_code := 'RECEIPTS';
28541 l_event_class_code := 'RECEIPT';
28542 l_event_type_code := 'RECEIPT_ALL';
28543 l_line_definition_owner_code := 'S';
28544 l_line_definition_code := 'MFAR_FED_AR_RCT_ACCOUNT';
28545 --
28546 l_balance_type_code := 'A';
28547 l_segment := NULL;
28548 l_ccid := NULL;
28549 l_adr_transaction_coa_id := NULL;
28550 l_adr_accounting_coa_id := NULL;
28551 l_adr_flexfield_segment_code := NULL;
28552 l_adr_flex_value_set_id := NULL;
28553 l_adr_value_type_code := NULL;
28554 l_adr_value_combination_id := NULL;
28555 l_adr_value_segment_code := NULL;
28556
28557 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
28558 l_bflow_class_code := ''; -- 4219869 Business Flow
28559 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
28560 l_budgetary_control_flag := 'N';
28561
28562 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28563 l_bflow_applied_to_amt := NULL; -- 5132302
28564 l_entered_amt_idx := NULL; -- 4262811
28565 l_accted_amt_idx := NULL; -- 4262811
28566 l_acc_rev_flag := NULL; -- 4262811
28567 l_accrual_line_num := NULL; -- 4262811
28568 l_tmp_amt := NULL; -- 4262811
28569 --
28570
28574 ') = 'REC' AND
28571 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
28572 l_balance_type_code <> 'B' THEN
28573 IF NVL(p_source_22,'
28575 NVL(p_source_35,'
28576 ') = 'REV' AND
28577 NVL(p_source_14,'
28578 ') = 'Unexpired' AND
28579 NVL(p_source_15,'
28580 ') = 'Y' AND
28581 (NVL(p_source_16,'
28582 ') = 'MUTIPLE' OR
28583 NVL(p_source_16,'
28584 ') = 'NO_YEAR') AND
28585 (NVL(p_source_13,'
28586 ') = 'Overpayment Refund' OR
28587 NVL(p_source_13,'
28588 ') = 'Advance Refund') AND
28589 NVL(p_source_58,'
28590 ') = 'Y'
28591 THEN
28592
28593 --
28594 XLA_AE_LINES_PKG.SetNewLine;
28595
28596 p_balance_type_code := l_balance_type_code;
28597 -- set the flag so later we will know whether the gain loss line needs to be created
28598
28599 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
28600 p_actual_flag :='A';
28601 END IF;
28602
28603 --
28604 -- bulk performance
28605 --
28606 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
28607 p_header_num => 0); -- 4262811
28608 --
28609 -- set accounting line options
28610 --
28611 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
28612 p_natural_side_code => 'C'
28613 , p_gain_or_loss_flag => 'N'
28614 , p_gl_transfer_mode_code => 'S'
28615 , p_acct_entry_type_code => 'A'
28616 , p_switch_side_flag => 'Y'
28617 , p_merge_duplicate_code => 'A'
28618 );
28619 --
28620 l_acc_rev_natural_side_code := 'D'; -- 4262811
28621 --
28622 --
28623 -- set accounting line type info
28624 --
28625 xla_ae_lines_pkg.SetAcctLineType
28626 (p_component_type => l_component_type
28627 ,p_event_type_code => l_event_type_code
28628 ,p_line_definition_owner_code => l_line_definition_owner_code
28629 ,p_line_definition_code => l_line_definition_code
28630 ,p_accounting_line_code => l_component_code
28631 ,p_accounting_line_type_code => l_component_type_code
28632 ,p_accounting_line_appl_id => l_component_appl_id
28633 ,p_amb_context_code => l_amb_context_code
28634 ,p_entity_code => l_entity_code
28635 ,p_event_class_code => l_event_class_code);
28636 --
28637 -- set accounting class
28638 --
28639 xla_ae_lines_pkg.SetAcctClass(
28640 p_accounting_class_code => 'FV_CASH_CR'
28641 , p_ae_header_id => l_ae_header_id
28642 );
28643
28644 --
28645 -- set rounding class
28646 --
28647 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
28648 'RECEIVABLE';
28649
28650 --
28651 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
28652 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
28653 --
28654 -- bulk performance
28655 --
28656 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
28657
28658 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
28659 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
28660
28661 -- 4955764
28662 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28663 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
28664
28665 -- 4458381 Public Sector Enh
28666
28667 --
28668 -- set accounting attributes for the line type
28669 --
28670 l_entered_amt_idx := 8;
28671 l_accted_amt_idx := 13;
28672 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28673 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
28674 l_rec_acct_attrs.array_num_value(1) := p_source_60;
28675 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
28676 l_rec_acct_attrs.array_char_value(2) := p_source_37;
28677 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
28678 l_rec_acct_attrs.array_char_value(3) := p_source_61;
28679 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
28680 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
28681 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
28682 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
28683 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
28684 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
28685 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
28686 l_rec_acct_attrs.array_char_value(7) := p_source_25;
28687 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
28688 l_rec_acct_attrs.array_num_value(8) := p_source_26;
28689 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
28690 l_rec_acct_attrs.array_char_value(9) := p_source_63;
28691 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
28692 l_rec_acct_attrs.array_date_value(10) := p_source_59;
28693 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
28697 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
28694 l_rec_acct_attrs.array_num_value(11) := p_source_64;
28695 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
28696 l_rec_acct_attrs.array_char_value(12) := p_source_30;
28698 l_rec_acct_attrs.array_num_value(13) := p_source_31;
28699 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
28700 l_rec_acct_attrs.array_num_value(14) := p_source_65;
28701 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
28702 l_rec_acct_attrs.array_num_value(15) := p_source_66;
28703 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
28704 l_rec_acct_attrs.array_char_value(16) := p_source_67;
28705
28706 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
28707 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
28708
28709 ---------------------------------------------------------------------------------------------------------------
28710 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
28711 ---------------------------------------------------------------------------------------------------------------
28712 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
28713
28714 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28715 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28716
28717 IF xla_accounting_cache_pkg.GetValueChar
28718 (p_source_code => 'LEDGER_CATEGORY_CODE'
28719 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
28720 AND l_bflow_method_code = 'PRIOR_ENTRY'
28721 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
28722 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
28723 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
28724 )
28725 THEN
28726 xla_ae_lines_pkg.BflowUpgEntry
28727 (p_business_method_code => l_bflow_method_code
28728 ,p_business_class_code => l_bflow_class_code
28729 ,p_balance_type => l_balance_type_code);
28730 ELSE
28731 NULL;
28732 -- No business flow processing for business flow method of NONE.
28733 END IF;
28734
28735 --
28736 -- call analytical criteria
28737 --
28738
28739 --
28740 -- call description
28741 --
28742 -- No description or it is inherited.
28743 --
28744 -- call ADRs
28745 -- Bug 4922099
28746 --
28747 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28748 (NVL(l_actual_upg_option, 'N') = 'O') OR
28749 (NVL(l_enc_upg_option, 'N') = 'O')
28750 )
28751 THEN
28752 NULL;
28753 --
28754 --
28755
28756 l_ccid := AcctDerRule_34(
28757 p_application_id => p_application_id
28758 , p_ae_header_id => l_ae_header_id
28759 , p_source_21 => p_source_21
28760 , x_transaction_coa_id => l_adr_transaction_coa_id
28761 , x_accounting_coa_id => l_adr_accounting_coa_id
28762 , x_value_type_code => l_adr_value_type_code
28763 , p_side => 'NA'
28764 );
28765
28766 xla_ae_lines_pkg.set_ccid(
28767 p_code_combination_id => l_ccid
28768 , p_value_type_code => l_adr_value_type_code
28769 , p_transaction_coa_id => l_adr_transaction_coa_id
28770 , p_accounting_coa_id => l_adr_accounting_coa_id
28771 , p_adr_code => 'TRX_DIST_CCID'
28772 , p_adr_type_code => 'S'
28773 , p_component_type => l_component_type
28774 , p_component_code => l_component_code
28775 , p_component_type_code => l_component_type_code
28776 , p_component_appl_id => l_component_appl_id
28777 , p_amb_context_code => l_amb_context_code
28778 , p_side => 'NA'
28779 );
28780
28781
28782 l_segment := AcctDerRule_19(
28783 p_application_id => p_application_id
28784 , p_ae_header_id => l_ae_header_id
28785 , p_source_14 => p_source_14
28786 , p_source_15 => p_source_15
28787 , p_source_16 => p_source_16
28788 , x_transaction_coa_id => l_adr_transaction_coa_id
28789 , x_accounting_coa_id => l_adr_accounting_coa_id
28790 , x_flexfield_segment_code => l_adr_flexfield_segment_code
28791 , x_flex_value_set_id => l_adr_flex_value_set_id
28792 , x_value_type_code => l_adr_value_type_code
28793 , x_value_combination_id => l_adr_value_combination_id
28794 , x_value_segment_code => l_adr_value_segment_code
28795 , p_side => 'NA'
28796 , p_override_seg_flag => 'Y'
28797 );
28798
28799 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
28800
28801 xla_ae_lines_pkg.set_segment(
28802 p_to_segment_code => 'GL_ACCOUNT'
28803 , p_segment_value => l_segment
28804 , p_from_segment_code => l_adr_value_segment_code
28805 , p_from_combination_id => l_adr_value_combination_id
28806 , p_value_type_code => l_adr_value_type_code
28810 , p_flex_value_set_id => l_adr_flex_value_set_id
28807 , p_transaction_coa_id => l_adr_transaction_coa_id
28808 , p_accounting_coa_id => l_adr_accounting_coa_id
28809 , p_flexfield_segment_code => l_adr_flexfield_segment_code
28811 , p_adr_code => 'FV_AR_445001_RCT_CR'
28812 , p_adr_type_code => 'S'
28813 , p_component_type => l_component_type
28814 , p_component_code => l_component_code
28815 , p_component_type_code => l_component_type_code
28816 , p_component_appl_id => l_component_appl_id
28817 , p_amb_context_code => l_amb_context_code
28818 , p_entity_code => 'RECEIPTS'
28819 , p_event_class_code => 'RECEIPT'
28820 , p_side => 'NA'
28821 );
28822
28823 END IF;
28824
28825 --
28826 --
28827 END IF;
28828 --
28829 -- Bug 4922099
28830 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
28831 (NVL(l_enc_upg_option, 'N') = 'O')
28832 ) AND
28833 (l_bflow_method_code = 'PRIOR_ENTRY')
28834 )
28835 THEN
28836 IF
28837 --
28838 1 = 2
28839 --
28840 THEN
28841 xla_accounting_err_pkg.build_message
28842 (p_appli_s_name => 'XLA'
28843 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28844 ,p_token_1 => 'LINE_NUMBER'
28845 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
28846 ,p_token_2 => 'LINE_TYPE_NAME'
28847 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
28848 l_component_type
28849 ,l_component_code
28850 ,l_component_type_code
28851 ,l_component_appl_id
28852 ,l_amb_context_code
28853 ,l_entity_code
28854 ,l_event_class_code
28855 )
28856 ,p_token_3 => 'OWNER'
28857 ,p_value_3 => xla_lookups_pkg.get_meaning(
28858 p_lookup_type => 'XLA_OWNER_TYPE'
28859 ,p_lookup_code => l_component_type_code
28860 )
28861 ,p_token_4 => 'PRODUCT_NAME'
28862 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
28863 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
28864 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
28865 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
28866 ,p_ae_header_id => NULL
28867 );
28868
28869 IF (C_LEVEL_ERROR>= g_log_level) THEN
28870 trace
28871 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28872 ,p_level => C_LEVEL_ERROR
28873 ,p_module => l_log_module);
28874 END IF;
28875 END IF;
28876 END IF;
28877 --
28878 --
28879 ------------------------------------------------------------------------------------------------
28880 -- 4219869 Business Flow
28881 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
28882 -- Prior Entry. Currently, the following code is always generated.
28883 ------------------------------------------------------------------------------------------------
28884 XLA_AE_LINES_PKG.ValidateCurrentLine;
28885
28886 ------------------------------------------------------------------------------------
28887 -- 4219869 Business Flow
28888 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
28889 ------------------------------------------------------------------------------------
28890 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28891
28892 ----------------------------------------------------------------------------------
28893 -- 4219869 Business Flow
28894 -- Update journal entry status -- Need to generate this within IF <condition>
28895 ----------------------------------------------------------------------------------
28896 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28897 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
28898 ,p_balance_type_code => l_balance_type_code
28899 );
28900
28904 BEGIN
28901 -------------------------------------------------------------------------------------------
28902 -- 4262811 - Generate the Accrual Reversal lines
28903 -------------------------------------------------------------------------------------------
28905 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
28906 (g_array_event(p_event_id).array_value_num('header_index'));
28907 IF l_acc_rev_flag IS NULL THEN
28908 l_acc_rev_flag := 'N';
28909 END IF;
28910 EXCEPTION
28911 WHEN OTHERS THEN
28912 l_acc_rev_flag := 'N';
28913 END;
28914 --
28915 IF (l_acc_rev_flag = 'Y') THEN
28916
28917 -- 4645092 ------------------------------------------------------------------------------
28918 -- To allow MPA report to determine if it should generate report process
28919 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
28920 ------------------------------------------------------------------------------------------
28921
28922 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
28923 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
28924 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
28925 -- call ADRs
28926 -- Bug 4922099
28927 --
28928 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28929 (NVL(l_actual_upg_option, 'N') = 'O') OR
28930 (NVL(l_enc_upg_option, 'N') = 'O')
28931 )
28932 THEN
28933 NULL;
28934 --
28935 --
28936
28937 l_ccid := AcctDerRule_34(
28938 p_application_id => p_application_id
28939 , p_ae_header_id => l_ae_header_id
28940 , p_source_21 => p_source_21
28941 , x_transaction_coa_id => l_adr_transaction_coa_id
28942 , x_accounting_coa_id => l_adr_accounting_coa_id
28943 , x_value_type_code => l_adr_value_type_code
28944 , p_side => 'NA'
28945 );
28946
28947 xla_ae_lines_pkg.set_ccid(
28948 p_code_combination_id => l_ccid
28949 , p_value_type_code => l_adr_value_type_code
28950 , p_transaction_coa_id => l_adr_transaction_coa_id
28951 , p_accounting_coa_id => l_adr_accounting_coa_id
28952 , p_adr_code => 'TRX_DIST_CCID'
28953 , p_adr_type_code => 'S'
28954 , p_component_type => l_component_type
28955 , p_component_code => l_component_code
28956 , p_component_type_code => l_component_type_code
28957 , p_component_appl_id => l_component_appl_id
28958 , p_amb_context_code => l_amb_context_code
28959 , p_side => 'NA'
28960 );
28961
28962
28963 l_segment := AcctDerRule_19(
28964 p_application_id => p_application_id
28965 , p_ae_header_id => l_ae_header_id
28966 , p_source_14 => p_source_14
28967 , p_source_15 => p_source_15
28968 , p_source_16 => p_source_16
28969 , x_transaction_coa_id => l_adr_transaction_coa_id
28970 , x_accounting_coa_id => l_adr_accounting_coa_id
28971 , x_flexfield_segment_code => l_adr_flexfield_segment_code
28972 , x_flex_value_set_id => l_adr_flex_value_set_id
28973 , x_value_type_code => l_adr_value_type_code
28974 , x_value_combination_id => l_adr_value_combination_id
28975 , x_value_segment_code => l_adr_value_segment_code
28976 , p_side => 'NA'
28977 , p_override_seg_flag => 'Y'
28978 );
28979
28980 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
28981
28982 xla_ae_lines_pkg.set_segment(
28983 p_to_segment_code => 'GL_ACCOUNT'
28984 , p_segment_value => l_segment
28985 , p_from_segment_code => l_adr_value_segment_code
28986 , p_from_combination_id => l_adr_value_combination_id
28987 , p_value_type_code => l_adr_value_type_code
28988 , p_transaction_coa_id => l_adr_transaction_coa_id
28989 , p_accounting_coa_id => l_adr_accounting_coa_id
28990 , p_flexfield_segment_code => l_adr_flexfield_segment_code
28991 , p_flex_value_set_id => l_adr_flex_value_set_id
28992 , p_adr_code => 'FV_AR_445001_RCT_CR'
28993 , p_adr_type_code => 'S'
28994 , p_component_type => l_component_type
28995 , p_component_code => l_component_code
28996 , p_component_type_code => l_component_type_code
28997 , p_component_appl_id => l_component_appl_id
28998 , p_amb_context_code => l_amb_context_code
28999 , p_entity_code => 'RECEIPTS'
29000 , p_event_class_code => 'RECEIPT'
29001 , p_side => 'NA'
29002 );
29003
29004 END IF;
29005
29006 --
29007 --
29008 END IF;
29009
29010 --
29011 -- Update the line information that should be overwritten
29012 --
29013 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
29014 p_header_num => 1);
29015 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
29016
29020 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
29017 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
29018
29019 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
29021 END IF;
29022
29023 --
29024 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
29025 --
29026 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
29027 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
29028 ELSE
29029 ---------------------------------------------------------------------------------------------------
29030 -- 4262811a Switch Sign
29031 ---------------------------------------------------------------------------------------------------
29032 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
29033 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29034 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29035 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29036 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29037 -- 5132302
29038 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
29039 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29040
29041 END IF;
29042
29043 -- 4955764
29044 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
29045 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
29046
29047
29048 XLA_AE_LINES_PKG.ValidateCurrentLine;
29049 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29050
29051 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29052 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
29053 ,p_balance_type_code => l_balance_type_code);
29054
29055 END IF;
29056
29057 -----------------------------------------------------------------------------------------
29058 -- 4262811 Multiperiod Accounting
29059 -----------------------------------------------------------------------------------------
29060 -- No MPA option is assigned.
29061
29062
29063 END IF;
29064 END IF;
29065 --
29066
29067 --
29068 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29069 trace
29070 (p_msg => 'END of AcctLineType_74'
29071 ,p_level => C_LEVEL_PROCEDURE
29072 ,p_module => l_log_module);
29073 END IF;
29074 --
29075 EXCEPTION
29076 WHEN xla_exceptions_pkg.application_exception THEN
29077 RAISE;
29078 WHEN OTHERS THEN
29079 xla_exceptions_pkg.raise_message
29080 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_74');
29081 END AcctLineType_74;
29082 --
29083
29084 ---------------------------------------
29085 --
29086 -- PRIVATE FUNCTION
29087 -- AcctLineType_75
29088 --
29089 ---------------------------------------
29090 PROCEDURE AcctLineType_75 (
29091 p_application_id IN NUMBER
29092 ,p_event_id IN NUMBER
29093 ,p_calculate_acctd_flag IN VARCHAR2
29094 ,p_calculate_g_l_flag IN VARCHAR2
29095 ,p_actual_flag IN OUT VARCHAR2
29096 ,p_balance_type_code OUT VARCHAR2
29097 ,p_gain_or_loss_ref OUT VARCHAR2
29098
29099 --Federal Account Rule
29100 , p_source_13 IN VARCHAR2
29101 --Federal Fund Expired Status
29102 , p_source_14 IN VARCHAR2
29103 --Federal Prior Year Flag
29104 , p_source_15 IN VARCHAR2
29105 --Federal Fund Time Frame
29106 , p_source_16 IN VARCHAR2
29107 --Transaction Distribution GL Account
29108 , p_source_21 IN NUMBER
29109 --Distribution Source Type
29110 , p_source_22 IN VARCHAR2
29111 --Distribution Line Identifier
29112 , p_source_24 IN NUMBER
29113 --Distribution Type
29114 , p_source_25 IN VARCHAR2
29115 --Entered Amount
29116 , p_source_26 IN NUMBER
29117 --Exchange Rate Type
29118 , p_source_30 IN VARCHAR2
29119 --Applied To Document Accounting Amount
29120 , p_source_31 IN NUMBER
29121 --Transaction Distribution Account Class
29122 , p_source_35 IN VARCHAR2
29123 --Transaction Distribution Identifier
29124 , p_source_36 IN NUMBER
29125 --Transaction Distribution Type
29126 , p_source_37 IN VARCHAR2
29127 --Federal Account Valid Flag
29128 , p_source_58 IN VARCHAR2
29129 --Applied To Document Exchange Date
29130 , p_source_59 IN DATE
29131 --Receipt Applied To Application Identifier
29132 , p_source_60 IN NUMBER
29133 --Transaction Entity Code
29134 , p_source_61 IN VARCHAR2
29135 --Transaction Identifier
29136 , p_source_62 IN NUMBER
29137 --Applying Document Currency Code
29138 , p_source_63 IN VARCHAR2
29139 --Applied To Document Exchange Rate
29140 , p_source_64 IN NUMBER
29141 --Distribution Party Identifier
29142 , p_source_65 IN NUMBER
29146 , p_source_67 IN VARCHAR2
29143 --Distribution Party Site Id
29144 , p_source_66 IN NUMBER
29145 --Distribution Party Type
29147 )
29148 IS
29149
29150 l_component_type VARCHAR2(80);
29151 l_component_code VARCHAR2(30);
29152 l_component_type_code VARCHAR2(1);
29153 l_component_appl_id INTEGER;
29154 l_amb_context_code VARCHAR2(30);
29155 l_entity_code VARCHAR2(30);
29156 l_event_class_code VARCHAR2(30);
29157 l_ae_header_id NUMBER;
29158 l_event_type_code VARCHAR2(30);
29159 l_line_definition_code VARCHAR2(30);
29160 l_line_definition_owner_code VARCHAR2(1);
29161 --
29162 -- adr variables
29163 l_segment VARCHAR2(30);
29164 l_ccid NUMBER;
29165 l_adr_transaction_coa_id NUMBER;
29166 l_adr_accounting_coa_id NUMBER;
29167 l_adr_flexfield_segment_code VARCHAR2(30);
29168 l_adr_flex_value_set_id NUMBER;
29169 l_adr_value_type_code VARCHAR2(30);
29170 l_adr_value_combination_id NUMBER;
29171 l_adr_value_segment_code VARCHAR2(30);
29172
29173 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
29174 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
29175 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
29176 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
29177
29178 -- 4262811 Variables ------------------------------------------------------------------------------------------
29179 l_entered_amt_idx NUMBER;
29180 l_accted_amt_idx NUMBER;
29181 l_acc_rev_flag VARCHAR2(1);
29182 l_accrual_line_num NUMBER;
29183 l_tmp_amt NUMBER;
29184 l_acc_rev_natural_side_code VARCHAR2(1);
29185
29186 l_num_entries NUMBER;
29187 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
29188 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
29189 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
29190 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
29191 l_recog_line_1 NUMBER;
29192 l_recog_line_2 NUMBER;
29193
29194 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
29195 l_bflow_applied_to_amt NUMBER; -- 5132302
29196 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
29197
29198 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
29199
29200 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
29201 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
29202
29203 ---------------------------------------------------------------------------------------------------------------
29204
29205
29206 --
29207 -- bulk performance
29208 --
29209 l_balance_type_code VARCHAR2(1);
29210 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
29211 l_log_module VARCHAR2(240);
29212
29213 --
29214 -- Upgrade strategy
29215 --
29216 l_actual_upg_option VARCHAR2(1);
29217 l_enc_upg_option VARCHAR2(1);
29218
29219 --
29220 BEGIN
29221 --
29222 IF g_log_enabled THEN
29223 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_75';
29224 END IF;
29225 --
29226 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29227
29228 trace
29229 (p_msg => 'BEGIN of AcctLineType_75'
29230 ,p_level => C_LEVEL_PROCEDURE
29231 ,p_module => l_log_module);
29232
29233 END IF;
29234 --
29235 l_component_type := 'AMB_JLT';
29236 l_component_code := 'FV_RCT_REF_OAP_UFP_DR';
29237 l_component_type_code := 'S';
29238 l_component_appl_id := 222;
29239 l_amb_context_code := 'DEFAULT';
29240 l_entity_code := 'RECEIPTS';
29241 l_event_class_code := 'RECEIPT';
29242 l_event_type_code := 'RECEIPT_ALL';
29243 l_line_definition_owner_code := 'S';
29244 l_line_definition_code := 'MFAR_FED_AR_RCT_ACCOUNT';
29245 --
29246 l_balance_type_code := 'A';
29247 l_segment := NULL;
29248 l_ccid := NULL;
29249 l_adr_transaction_coa_id := NULL;
29250 l_adr_accounting_coa_id := NULL;
29251 l_adr_flexfield_segment_code := NULL;
29252 l_adr_flex_value_set_id := NULL;
29253 l_adr_value_type_code := NULL;
29254 l_adr_value_combination_id := NULL;
29255 l_adr_value_segment_code := NULL;
29256
29257 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
29258 l_bflow_class_code := ''; -- 4219869 Business Flow
29259 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
29260 l_budgetary_control_flag := 'N';
29261
29262 l_bflow_applied_to_amt_idx := NULL; -- 5132302
29263 l_bflow_applied_to_amt := NULL; -- 5132302
29264 l_entered_amt_idx := NULL; -- 4262811
29265 l_accted_amt_idx := NULL; -- 4262811
29266 l_acc_rev_flag := NULL; -- 4262811
29267 l_accrual_line_num := NULL; -- 4262811
29268 l_tmp_amt := NULL; -- 4262811
29269 --
29270
29274 ') = 'REC' AND
29271 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
29272 l_balance_type_code <> 'B' THEN
29273 IF NVL(p_source_22,'
29275 NVL(p_source_35,'
29276 ') = 'REV' AND
29277 NVL(p_source_14,'
29278 ') = 'Unexpired' AND
29279 NVL(p_source_15,'
29280 ') = 'Y' AND
29281 (NVL(p_source_16,'
29282 ') = 'MUTIPLE' OR
29283 NVL(p_source_16,'
29284 ') = 'NO_YEAR') AND
29285 (NVL(p_source_13,'
29286 ') = 'Overpayment Refund' OR
29287 NVL(p_source_13,'
29288 ') = 'Advance Refund') AND
29289 NVL(p_source_58,'
29290 ') = 'Y'
29291 THEN
29292
29293 --
29294 XLA_AE_LINES_PKG.SetNewLine;
29295
29296 p_balance_type_code := l_balance_type_code;
29297 -- set the flag so later we will know whether the gain loss line needs to be created
29298
29299 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
29300 p_actual_flag :='A';
29301 END IF;
29302
29303 --
29304 -- bulk performance
29305 --
29306 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
29307 p_header_num => 0); -- 4262811
29308 --
29309 -- set accounting line options
29310 --
29311 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
29312 p_natural_side_code => 'D'
29313 , p_gain_or_loss_flag => 'N'
29314 , p_gl_transfer_mode_code => 'S'
29315 , p_acct_entry_type_code => 'A'
29316 , p_switch_side_flag => 'Y'
29317 , p_merge_duplicate_code => 'A'
29318 );
29319 --
29320 l_acc_rev_natural_side_code := 'C'; -- 4262811
29321 --
29322 --
29323 -- set accounting line type info
29324 --
29325 xla_ae_lines_pkg.SetAcctLineType
29326 (p_component_type => l_component_type
29327 ,p_event_type_code => l_event_type_code
29328 ,p_line_definition_owner_code => l_line_definition_owner_code
29329 ,p_line_definition_code => l_line_definition_code
29330 ,p_accounting_line_code => l_component_code
29331 ,p_accounting_line_type_code => l_component_type_code
29332 ,p_accounting_line_appl_id => l_component_appl_id
29333 ,p_amb_context_code => l_amb_context_code
29334 ,p_entity_code => l_entity_code
29335 ,p_event_class_code => l_event_class_code);
29336 --
29337 -- set accounting class
29338 --
29339 xla_ae_lines_pkg.SetAcctClass(
29340 p_accounting_class_code => 'FV_CASH_DR'
29341 , p_ae_header_id => l_ae_header_id
29342 );
29343
29344 --
29345 -- set rounding class
29346 --
29347 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
29348 'RECEIVABLE';
29349
29350 --
29351 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
29352 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
29353 --
29354 -- bulk performance
29355 --
29356 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
29357
29358 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
29359 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
29360
29361 -- 4955764
29362 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
29363 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
29364
29365 -- 4458381 Public Sector Enh
29366
29367 --
29368 -- set accounting attributes for the line type
29369 --
29370 l_entered_amt_idx := 8;
29371 l_accted_amt_idx := 13;
29372 l_bflow_applied_to_amt_idx := NULL; -- 5132302
29373 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
29374 l_rec_acct_attrs.array_num_value(1) := p_source_60;
29375 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
29376 l_rec_acct_attrs.array_char_value(2) := p_source_37;
29377 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
29378 l_rec_acct_attrs.array_char_value(3) := p_source_61;
29379 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
29380 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
29381 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
29382 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
29383 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
29384 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
29385 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
29386 l_rec_acct_attrs.array_char_value(7) := p_source_25;
29387 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
29388 l_rec_acct_attrs.array_num_value(8) := p_source_26;
29389 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
29390 l_rec_acct_attrs.array_char_value(9) := p_source_63;
29391 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
29392 l_rec_acct_attrs.array_date_value(10) := p_source_59;
29393 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
29394 l_rec_acct_attrs.array_num_value(11) := p_source_64;
29398 l_rec_acct_attrs.array_num_value(13) := p_source_31;
29395 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
29396 l_rec_acct_attrs.array_char_value(12) := p_source_30;
29397 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
29399 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
29400 l_rec_acct_attrs.array_num_value(14) := p_source_65;
29401 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
29402 l_rec_acct_attrs.array_num_value(15) := p_source_66;
29403 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
29404 l_rec_acct_attrs.array_char_value(16) := p_source_67;
29405
29406 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
29407 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
29408
29409 ---------------------------------------------------------------------------------------------------------------
29410 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
29411 ---------------------------------------------------------------------------------------------------------------
29412 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
29413
29414 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
29415 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
29416
29417 IF xla_accounting_cache_pkg.GetValueChar
29418 (p_source_code => 'LEDGER_CATEGORY_CODE'
29419 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
29420 AND l_bflow_method_code = 'PRIOR_ENTRY'
29421 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
29422 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
29423 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
29424 )
29425 THEN
29426 xla_ae_lines_pkg.BflowUpgEntry
29427 (p_business_method_code => l_bflow_method_code
29428 ,p_business_class_code => l_bflow_class_code
29429 ,p_balance_type => l_balance_type_code);
29430 ELSE
29431 NULL;
29432 -- No business flow processing for business flow method of NONE.
29433 END IF;
29434
29435 --
29436 -- call analytical criteria
29437 --
29438
29439 --
29440 -- call description
29441 --
29442 -- No description or it is inherited.
29443 --
29444 -- call ADRs
29445 -- Bug 4922099
29446 --
29447 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
29448 (NVL(l_actual_upg_option, 'N') = 'O') OR
29449 (NVL(l_enc_upg_option, 'N') = 'O')
29450 )
29451 THEN
29452 NULL;
29453 --
29454 --
29455
29456 l_ccid := AcctDerRule_34(
29457 p_application_id => p_application_id
29458 , p_ae_header_id => l_ae_header_id
29459 , p_source_21 => p_source_21
29460 , x_transaction_coa_id => l_adr_transaction_coa_id
29461 , x_accounting_coa_id => l_adr_accounting_coa_id
29462 , x_value_type_code => l_adr_value_type_code
29463 , p_side => 'NA'
29464 );
29465
29466 xla_ae_lines_pkg.set_ccid(
29467 p_code_combination_id => l_ccid
29468 , p_value_type_code => l_adr_value_type_code
29469 , p_transaction_coa_id => l_adr_transaction_coa_id
29470 , p_accounting_coa_id => l_adr_accounting_coa_id
29471 , p_adr_code => 'TRX_DIST_CCID'
29472 , p_adr_type_code => 'S'
29473 , p_component_type => l_component_type
29474 , p_component_code => l_component_code
29475 , p_component_type_code => l_component_type_code
29476 , p_component_appl_id => l_component_appl_id
29477 , p_amb_context_code => l_amb_context_code
29478 , p_side => 'NA'
29479 );
29480
29481
29482 l_segment := AcctDerRule_27(
29483 p_application_id => p_application_id
29484 , p_ae_header_id => l_ae_header_id
29485 , p_source_13 => p_source_13
29486 , p_source_14 => p_source_14
29487 , p_source_15 => p_source_15
29488 , p_source_16 => p_source_16
29489 , x_transaction_coa_id => l_adr_transaction_coa_id
29490 , x_accounting_coa_id => l_adr_accounting_coa_id
29491 , x_flexfield_segment_code => l_adr_flexfield_segment_code
29492 , x_flex_value_set_id => l_adr_flex_value_set_id
29493 , x_value_type_code => l_adr_value_type_code
29494 , x_value_combination_id => l_adr_value_combination_id
29495 , x_value_segment_code => l_adr_value_segment_code
29496 , p_side => 'NA'
29497 , p_override_seg_flag => 'Y'
29498 );
29499
29500 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
29501
29502 xla_ae_lines_pkg.set_segment(
29503 p_to_segment_code => 'GL_ACCOUNT'
29504 , p_segment_value => l_segment
29505 , p_from_segment_code => l_adr_value_segment_code
29506 , p_from_combination_id => l_adr_value_combination_id
29507 , p_value_type_code => l_adr_value_type_code
29511 , p_flex_value_set_id => l_adr_flex_value_set_id
29508 , p_transaction_coa_id => l_adr_transaction_coa_id
29509 , p_accounting_coa_id => l_adr_accounting_coa_id
29510 , p_flexfield_segment_code => l_adr_flexfield_segment_code
29512 , p_adr_code => 'FV_AR_4X7201_RCT_DR'
29513 , p_adr_type_code => 'S'
29514 , p_component_type => l_component_type
29515 , p_component_code => l_component_code
29516 , p_component_type_code => l_component_type_code
29517 , p_component_appl_id => l_component_appl_id
29518 , p_amb_context_code => l_amb_context_code
29519 , p_entity_code => 'RECEIPTS'
29520 , p_event_class_code => 'RECEIPT'
29521 , p_side => 'NA'
29522 );
29523
29524 END IF;
29525
29526 --
29527 --
29528 END IF;
29529 --
29530 -- Bug 4922099
29531 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
29532 (NVL(l_enc_upg_option, 'N') = 'O')
29533 ) AND
29534 (l_bflow_method_code = 'PRIOR_ENTRY')
29535 )
29536 THEN
29537 IF
29538 --
29539 1 = 2
29540 --
29541 THEN
29542 xla_accounting_err_pkg.build_message
29543 (p_appli_s_name => 'XLA'
29544 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29545 ,p_token_1 => 'LINE_NUMBER'
29546 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
29547 ,p_token_2 => 'LINE_TYPE_NAME'
29548 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
29549 l_component_type
29550 ,l_component_code
29551 ,l_component_type_code
29552 ,l_component_appl_id
29553 ,l_amb_context_code
29554 ,l_entity_code
29555 ,l_event_class_code
29556 )
29557 ,p_token_3 => 'OWNER'
29558 ,p_value_3 => xla_lookups_pkg.get_meaning(
29559 p_lookup_type => 'XLA_OWNER_TYPE'
29560 ,p_lookup_code => l_component_type_code
29561 )
29562 ,p_token_4 => 'PRODUCT_NAME'
29563 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
29564 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
29565 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
29566 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
29567 ,p_ae_header_id => NULL
29568 );
29569
29570 IF (C_LEVEL_ERROR>= g_log_level) THEN
29571 trace
29572 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29573 ,p_level => C_LEVEL_ERROR
29574 ,p_module => l_log_module);
29575 END IF;
29576 END IF;
29577 END IF;
29578 --
29579 --
29580 ------------------------------------------------------------------------------------------------
29581 -- 4219869 Business Flow
29582 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
29583 -- Prior Entry. Currently, the following code is always generated.
29584 ------------------------------------------------------------------------------------------------
29585 XLA_AE_LINES_PKG.ValidateCurrentLine;
29586
29587 ------------------------------------------------------------------------------------
29588 -- 4219869 Business Flow
29589 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
29590 ------------------------------------------------------------------------------------
29591 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29592
29593 ----------------------------------------------------------------------------------
29594 -- 4219869 Business Flow
29595 -- Update journal entry status -- Need to generate this within IF <condition>
29596 ----------------------------------------------------------------------------------
29597 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29598 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
29599 ,p_balance_type_code => l_balance_type_code
29600 );
29601
29605 BEGIN
29602 -------------------------------------------------------------------------------------------
29603 -- 4262811 - Generate the Accrual Reversal lines
29604 -------------------------------------------------------------------------------------------
29606 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
29607 (g_array_event(p_event_id).array_value_num('header_index'));
29608 IF l_acc_rev_flag IS NULL THEN
29609 l_acc_rev_flag := 'N';
29610 END IF;
29611 EXCEPTION
29612 WHEN OTHERS THEN
29613 l_acc_rev_flag := 'N';
29614 END;
29615 --
29616 IF (l_acc_rev_flag = 'Y') THEN
29617
29618 -- 4645092 ------------------------------------------------------------------------------
29619 -- To allow MPA report to determine if it should generate report process
29620 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
29621 ------------------------------------------------------------------------------------------
29622
29623 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
29624 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
29625 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
29626 -- call ADRs
29627 -- Bug 4922099
29628 --
29629 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
29630 (NVL(l_actual_upg_option, 'N') = 'O') OR
29631 (NVL(l_enc_upg_option, 'N') = 'O')
29632 )
29633 THEN
29634 NULL;
29635 --
29636 --
29637
29638 l_ccid := AcctDerRule_34(
29639 p_application_id => p_application_id
29640 , p_ae_header_id => l_ae_header_id
29641 , p_source_21 => p_source_21
29642 , x_transaction_coa_id => l_adr_transaction_coa_id
29643 , x_accounting_coa_id => l_adr_accounting_coa_id
29644 , x_value_type_code => l_adr_value_type_code
29645 , p_side => 'NA'
29646 );
29647
29648 xla_ae_lines_pkg.set_ccid(
29649 p_code_combination_id => l_ccid
29650 , p_value_type_code => l_adr_value_type_code
29651 , p_transaction_coa_id => l_adr_transaction_coa_id
29652 , p_accounting_coa_id => l_adr_accounting_coa_id
29653 , p_adr_code => 'TRX_DIST_CCID'
29654 , p_adr_type_code => 'S'
29655 , p_component_type => l_component_type
29656 , p_component_code => l_component_code
29657 , p_component_type_code => l_component_type_code
29658 , p_component_appl_id => l_component_appl_id
29659 , p_amb_context_code => l_amb_context_code
29660 , p_side => 'NA'
29661 );
29662
29663
29664 l_segment := AcctDerRule_27(
29665 p_application_id => p_application_id
29666 , p_ae_header_id => l_ae_header_id
29667 , p_source_13 => p_source_13
29668 , p_source_14 => p_source_14
29669 , p_source_15 => p_source_15
29670 , p_source_16 => p_source_16
29671 , x_transaction_coa_id => l_adr_transaction_coa_id
29672 , x_accounting_coa_id => l_adr_accounting_coa_id
29673 , x_flexfield_segment_code => l_adr_flexfield_segment_code
29674 , x_flex_value_set_id => l_adr_flex_value_set_id
29675 , x_value_type_code => l_adr_value_type_code
29676 , x_value_combination_id => l_adr_value_combination_id
29677 , x_value_segment_code => l_adr_value_segment_code
29678 , p_side => 'NA'
29679 , p_override_seg_flag => 'Y'
29680 );
29681
29682 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
29683
29684 xla_ae_lines_pkg.set_segment(
29685 p_to_segment_code => 'GL_ACCOUNT'
29686 , p_segment_value => l_segment
29687 , p_from_segment_code => l_adr_value_segment_code
29688 , p_from_combination_id => l_adr_value_combination_id
29689 , p_value_type_code => l_adr_value_type_code
29690 , p_transaction_coa_id => l_adr_transaction_coa_id
29691 , p_accounting_coa_id => l_adr_accounting_coa_id
29692 , p_flexfield_segment_code => l_adr_flexfield_segment_code
29693 , p_flex_value_set_id => l_adr_flex_value_set_id
29694 , p_adr_code => 'FV_AR_4X7201_RCT_DR'
29695 , p_adr_type_code => 'S'
29696 , p_component_type => l_component_type
29697 , p_component_code => l_component_code
29698 , p_component_type_code => l_component_type_code
29699 , p_component_appl_id => l_component_appl_id
29700 , p_amb_context_code => l_amb_context_code
29701 , p_entity_code => 'RECEIPTS'
29702 , p_event_class_code => 'RECEIPT'
29703 , p_side => 'NA'
29704 );
29705
29706 END IF;
29707
29708 --
29709 --
29710 END IF;
29711
29712 --
29713 -- Update the line information that should be overwritten
29714 --
29715 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
29716 p_header_num => 1);
29717 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
29718
29719 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
29720
29724
29721 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
29722 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
29723 END IF;
29725 --
29726 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
29727 --
29728 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
29729 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
29730 ELSE
29731 ---------------------------------------------------------------------------------------------------
29732 -- 4262811a Switch Sign
29733 ---------------------------------------------------------------------------------------------------
29734 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
29735 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29736 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29737 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29738 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29739 -- 5132302
29740 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
29741 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29742
29743 END IF;
29744
29745 -- 4955764
29746 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
29747 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
29748
29749
29750 XLA_AE_LINES_PKG.ValidateCurrentLine;
29751 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29752
29753 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29754 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
29755 ,p_balance_type_code => l_balance_type_code);
29756
29757 END IF;
29758
29759 -----------------------------------------------------------------------------------------
29760 -- 4262811 Multiperiod Accounting
29761 -----------------------------------------------------------------------------------------
29762 -- No MPA option is assigned.
29763
29764
29765 END IF;
29766 END IF;
29767 --
29768
29769 --
29770 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29771 trace
29772 (p_msg => 'END of AcctLineType_75'
29773 ,p_level => C_LEVEL_PROCEDURE
29774 ,p_module => l_log_module);
29775 END IF;
29776 --
29777 EXCEPTION
29778 WHEN xla_exceptions_pkg.application_exception THEN
29779 RAISE;
29780 WHEN OTHERS THEN
29781 xla_exceptions_pkg.raise_message
29782 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_75');
29783 END AcctLineType_75;
29784 --
29785
29786 ---------------------------------------
29787 --
29788 -- PRIVATE FUNCTION
29789 -- AcctLineType_76
29790 --
29791 ---------------------------------------
29792 PROCEDURE AcctLineType_76 (
29793 p_application_id IN NUMBER
29794 ,p_event_id IN NUMBER
29795 ,p_calculate_acctd_flag IN VARCHAR2
29796 ,p_calculate_g_l_flag IN VARCHAR2
29797 ,p_actual_flag IN OUT VARCHAR2
29798 ,p_balance_type_code OUT VARCHAR2
29799 ,p_gain_or_loss_ref OUT VARCHAR2
29800
29801 --Bill To Customer Classification
29802 , p_source_12 IN VARCHAR2
29803 --Federal Account Rule
29804 , p_source_13 IN VARCHAR2
29805 --Transaction Distribution GL Account
29806 , p_source_21 IN NUMBER
29807 --Distribution Source Type
29808 , p_source_22 IN VARCHAR2
29809 --Distribution Line Identifier
29810 , p_source_24 IN NUMBER
29811 --Distribution Type
29812 , p_source_25 IN VARCHAR2
29813 --Entered Amount
29814 , p_source_26 IN NUMBER
29815 --Exchange Date
29816 , p_source_28 IN DATE
29817 --Exchange Rate
29818 , p_source_29 IN NUMBER
29819 --Exchange Rate Type
29820 , p_source_30 IN VARCHAR2
29821 --Applied To Document Accounting Amount
29822 , p_source_31 IN NUMBER
29823 --Transaction Distribution Account Class
29824 , p_source_35 IN VARCHAR2
29825 --Transaction Distribution Identifier
29826 , p_source_36 IN NUMBER
29827 --Transaction Distribution Type
29828 , p_source_37 IN VARCHAR2
29829 --Federal Account Valid Flag
29830 , p_source_58 IN VARCHAR2
29831 --Receipt Applied To Application Identifier
29832 , p_source_60 IN NUMBER
29833 --Transaction Entity Code
29834 , p_source_61 IN VARCHAR2
29835 --Transaction Identifier
29836 , p_source_62 IN NUMBER
29837 --Applying Document Currency Code
29838 , p_source_63 IN VARCHAR2
29839 --Distribution Party Identifier
29840 , p_source_65 IN NUMBER
29841 --Distribution Party Site Id
29842 , p_source_66 IN NUMBER
29843 --Distribution Party Type
29844 , p_source_67 IN VARCHAR2
29845 )
29846 IS
29847
29851 l_component_appl_id INTEGER;
29848 l_component_type VARCHAR2(80);
29849 l_component_code VARCHAR2(30);
29850 l_component_type_code VARCHAR2(1);
29852 l_amb_context_code VARCHAR2(30);
29853 l_entity_code VARCHAR2(30);
29854 l_event_class_code VARCHAR2(30);
29855 l_ae_header_id NUMBER;
29856 l_event_type_code VARCHAR2(30);
29857 l_line_definition_code VARCHAR2(30);
29858 l_line_definition_owner_code VARCHAR2(1);
29859 --
29860 -- adr variables
29861 l_segment VARCHAR2(30);
29862 l_ccid NUMBER;
29863 l_adr_transaction_coa_id NUMBER;
29864 l_adr_accounting_coa_id NUMBER;
29865 l_adr_flexfield_segment_code VARCHAR2(30);
29866 l_adr_flex_value_set_id NUMBER;
29867 l_adr_value_type_code VARCHAR2(30);
29868 l_adr_value_combination_id NUMBER;
29869 l_adr_value_segment_code VARCHAR2(30);
29870
29871 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
29872 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
29873 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
29874 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
29875
29876 -- 4262811 Variables ------------------------------------------------------------------------------------------
29877 l_entered_amt_idx NUMBER;
29878 l_accted_amt_idx NUMBER;
29879 l_acc_rev_flag VARCHAR2(1);
29880 l_accrual_line_num NUMBER;
29881 l_tmp_amt NUMBER;
29882 l_acc_rev_natural_side_code VARCHAR2(1);
29883
29884 l_num_entries NUMBER;
29885 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
29886 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
29887 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
29888 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
29889 l_recog_line_1 NUMBER;
29890 l_recog_line_2 NUMBER;
29891
29892 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
29893 l_bflow_applied_to_amt NUMBER; -- 5132302
29894 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
29895
29896 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
29897
29898 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
29899 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
29900
29901 ---------------------------------------------------------------------------------------------------------------
29902
29903
29904 --
29905 -- bulk performance
29906 --
29907 l_balance_type_code VARCHAR2(1);
29908 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
29909 l_log_module VARCHAR2(240);
29910
29911 --
29912 -- Upgrade strategy
29913 --
29914 l_actual_upg_option VARCHAR2(1);
29915 l_enc_upg_option VARCHAR2(1);
29916
29917 --
29918 BEGIN
29919 --
29920 IF g_log_enabled THEN
29921 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_76';
29922 END IF;
29923 --
29924 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29925
29926 trace
29927 (p_msg => 'BEGIN of AcctLineType_76'
29928 ,p_level => C_LEVEL_PROCEDURE
29929 ,p_module => l_log_module);
29930
29931 END IF;
29932 --
29933 l_component_type := 'AMB_JLT';
29934 l_component_code := 'FV_RCT_REIM_WO_ADV_CR';
29935 l_component_type_code := 'S';
29936 l_component_appl_id := 222;
29937 l_amb_context_code := 'DEFAULT';
29938 l_entity_code := 'RECEIPTS';
29939 l_event_class_code := 'RECEIPT';
29940 l_event_type_code := 'RECEIPT_ALL';
29941 l_line_definition_owner_code := 'S';
29942 l_line_definition_code := 'MFAR_FED_AR_RCT_ACCOUNT';
29943 --
29944 l_balance_type_code := 'A';
29945 l_segment := NULL;
29946 l_ccid := NULL;
29947 l_adr_transaction_coa_id := NULL;
29948 l_adr_accounting_coa_id := NULL;
29949 l_adr_flexfield_segment_code := NULL;
29950 l_adr_flex_value_set_id := NULL;
29951 l_adr_value_type_code := NULL;
29952 l_adr_value_combination_id := NULL;
29953 l_adr_value_segment_code := NULL;
29954
29955 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
29956 l_bflow_class_code := ''; -- 4219869 Business Flow
29957 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
29958 l_budgetary_control_flag := 'N';
29959
29960 l_bflow_applied_to_amt_idx := NULL; -- 5132302
29961 l_bflow_applied_to_amt := NULL; -- 5132302
29962 l_entered_amt_idx := NULL; -- 4262811
29963 l_accted_amt_idx := NULL; -- 4262811
29964 l_acc_rev_flag := NULL; -- 4262811
29965 l_accrual_line_num := NULL; -- 4262811
29966 l_tmp_amt := NULL; -- 4262811
29967 --
29968
29969 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
29970 l_balance_type_code <> 'B' THEN
29971 IF NVL(p_source_22,'
29972 ') = 'REC' AND
29973 NVL(p_source_35,'
29974 ') = 'REV' AND
29975 NVL(p_source_12,'
29979 NVL(p_source_58,'
29976 ') = 'FEDERAL' AND
29977 NVL(p_source_13,'
29978 ') = 'Order No Advance' AND
29980 ') = 'Y'
29981 THEN
29982
29983 --
29984 XLA_AE_LINES_PKG.SetNewLine;
29985
29986 p_balance_type_code := l_balance_type_code;
29987 -- set the flag so later we will know whether the gain loss line needs to be created
29988
29989 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
29990 p_actual_flag :='A';
29991 END IF;
29992
29993 --
29994 -- bulk performance
29995 --
29996 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
29997 p_header_num => 0); -- 4262811
29998 --
29999 -- set accounting line options
30000 --
30001 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
30002 p_natural_side_code => 'C'
30003 , p_gain_or_loss_flag => 'N'
30004 , p_gl_transfer_mode_code => 'S'
30005 , p_acct_entry_type_code => 'A'
30006 , p_switch_side_flag => 'Y'
30007 , p_merge_duplicate_code => 'A'
30008 );
30009 --
30010 l_acc_rev_natural_side_code := 'D'; -- 4262811
30011 --
30012 --
30013 -- set accounting line type info
30014 --
30015 xla_ae_lines_pkg.SetAcctLineType
30016 (p_component_type => l_component_type
30017 ,p_event_type_code => l_event_type_code
30018 ,p_line_definition_owner_code => l_line_definition_owner_code
30019 ,p_line_definition_code => l_line_definition_code
30020 ,p_accounting_line_code => l_component_code
30021 ,p_accounting_line_type_code => l_component_type_code
30022 ,p_accounting_line_appl_id => l_component_appl_id
30023 ,p_amb_context_code => l_amb_context_code
30024 ,p_entity_code => l_entity_code
30025 ,p_event_class_code => l_event_class_code);
30026 --
30027 -- set accounting class
30028 --
30029 xla_ae_lines_pkg.SetAcctClass(
30030 p_accounting_class_code => 'FV_CASH_CR'
30031 , p_ae_header_id => l_ae_header_id
30032 );
30033
30034 --
30035 -- set rounding class
30036 --
30037 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
30038 'RECEIVABLE';
30039
30040 --
30041 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
30042 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
30043 --
30044 -- bulk performance
30045 --
30046 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
30047
30048 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
30049 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
30050
30051 -- 4955764
30052 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
30053 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
30054
30055 -- 4458381 Public Sector Enh
30056
30057 --
30058 -- set accounting attributes for the line type
30059 --
30060 l_entered_amt_idx := 8;
30061 l_accted_amt_idx := 13;
30062 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30063 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
30064 l_rec_acct_attrs.array_num_value(1) := p_source_60;
30065 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
30066 l_rec_acct_attrs.array_char_value(2) := p_source_37;
30067 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
30068 l_rec_acct_attrs.array_char_value(3) := p_source_61;
30069 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
30070 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
30071 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
30072 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
30073 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
30074 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
30075 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
30076 l_rec_acct_attrs.array_char_value(7) := p_source_25;
30077 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
30078 l_rec_acct_attrs.array_num_value(8) := p_source_26;
30079 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
30080 l_rec_acct_attrs.array_char_value(9) := p_source_63;
30081 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
30082 l_rec_acct_attrs.array_date_value(10) := p_source_28;
30083 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
30084 l_rec_acct_attrs.array_num_value(11) := p_source_29;
30085 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
30086 l_rec_acct_attrs.array_char_value(12) := p_source_30;
30087 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
30088 l_rec_acct_attrs.array_num_value(13) := p_source_31;
30089 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
30090 l_rec_acct_attrs.array_num_value(14) := p_source_65;
30094 l_rec_acct_attrs.array_char_value(16) := p_source_67;
30091 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
30092 l_rec_acct_attrs.array_num_value(15) := p_source_66;
30093 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
30095
30096 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
30097 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
30098
30099 ---------------------------------------------------------------------------------------------------------------
30100 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
30101 ---------------------------------------------------------------------------------------------------------------
30102 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
30103
30104 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30105 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30106
30107 IF xla_accounting_cache_pkg.GetValueChar
30108 (p_source_code => 'LEDGER_CATEGORY_CODE'
30109 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
30110 AND l_bflow_method_code = 'PRIOR_ENTRY'
30111 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
30112 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
30113 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
30114 )
30115 THEN
30116 xla_ae_lines_pkg.BflowUpgEntry
30117 (p_business_method_code => l_bflow_method_code
30118 ,p_business_class_code => l_bflow_class_code
30119 ,p_balance_type => l_balance_type_code);
30120 ELSE
30121 NULL;
30122 -- No business flow processing for business flow method of NONE.
30123 END IF;
30124
30125 --
30126 -- call analytical criteria
30127 --
30128
30129 --
30130 -- call description
30131 --
30132 -- No description or it is inherited.
30133 --
30134 -- call ADRs
30135 -- Bug 4922099
30136 --
30137 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30138 (NVL(l_actual_upg_option, 'N') = 'O') OR
30139 (NVL(l_enc_upg_option, 'N') = 'O')
30140 )
30141 THEN
30142 NULL;
30143 --
30144 --
30145
30146 l_ccid := AcctDerRule_34(
30147 p_application_id => p_application_id
30148 , p_ae_header_id => l_ae_header_id
30149 , p_source_21 => p_source_21
30150 , x_transaction_coa_id => l_adr_transaction_coa_id
30151 , x_accounting_coa_id => l_adr_accounting_coa_id
30152 , x_value_type_code => l_adr_value_type_code
30153 , p_side => 'NA'
30154 );
30155
30156 xla_ae_lines_pkg.set_ccid(
30157 p_code_combination_id => l_ccid
30158 , p_value_type_code => l_adr_value_type_code
30159 , p_transaction_coa_id => l_adr_transaction_coa_id
30160 , p_accounting_coa_id => l_adr_accounting_coa_id
30161 , p_adr_code => 'TRX_DIST_CCID'
30162 , p_adr_type_code => 'S'
30163 , p_component_type => l_component_type
30164 , p_component_code => l_component_code
30165 , p_component_type_code => l_component_type_code
30166 , p_component_appl_id => l_component_appl_id
30167 , p_amb_context_code => l_amb_context_code
30168 , p_side => 'NA'
30169 );
30170
30171
30172 l_segment := AcctDerRule_14(
30173 p_application_id => p_application_id
30174 , p_ae_header_id => l_ae_header_id
30175 , p_source_13 => p_source_13
30176 , x_transaction_coa_id => l_adr_transaction_coa_id
30177 , x_accounting_coa_id => l_adr_accounting_coa_id
30178 , x_flexfield_segment_code => l_adr_flexfield_segment_code
30179 , x_flex_value_set_id => l_adr_flex_value_set_id
30180 , x_value_type_code => l_adr_value_type_code
30181 , x_value_combination_id => l_adr_value_combination_id
30182 , x_value_segment_code => l_adr_value_segment_code
30183 , p_side => 'NA'
30184 , p_override_seg_flag => 'Y'
30185 );
30186
30187 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
30188
30189 xla_ae_lines_pkg.set_segment(
30190 p_to_segment_code => 'GL_ACCOUNT'
30191 , p_segment_value => l_segment
30192 , p_from_segment_code => l_adr_value_segment_code
30193 , p_from_combination_id => l_adr_value_combination_id
30194 , p_value_type_code => l_adr_value_type_code
30195 , p_transaction_coa_id => l_adr_transaction_coa_id
30196 , p_accounting_coa_id => l_adr_accounting_coa_id
30197 , p_flexfield_segment_code => l_adr_flexfield_segment_code
30198 , p_flex_value_set_id => l_adr_flex_value_set_id
30199 , p_adr_code => 'FV_AR_425101_RCT_CR'
30200 , p_adr_type_code => 'S'
30201 , p_component_type => l_component_type
30205 , p_amb_context_code => l_amb_context_code
30202 , p_component_code => l_component_code
30203 , p_component_type_code => l_component_type_code
30204 , p_component_appl_id => l_component_appl_id
30206 , p_entity_code => 'RECEIPTS'
30207 , p_event_class_code => 'RECEIPT'
30208 , p_side => 'NA'
30209 );
30210
30211 END IF;
30212
30213 --
30214 --
30215 END IF;
30216 --
30217 -- Bug 4922099
30218 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
30219 (NVL(l_enc_upg_option, 'N') = 'O')
30220 ) AND
30221 (l_bflow_method_code = 'PRIOR_ENTRY')
30222 )
30223 THEN
30224 IF
30225 --
30226 1 = 2
30227 --
30228 THEN
30229 xla_accounting_err_pkg.build_message
30230 (p_appli_s_name => 'XLA'
30231 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
30232 ,p_token_1 => 'LINE_NUMBER'
30233 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
30234 ,p_token_2 => 'LINE_TYPE_NAME'
30235 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
30236 l_component_type
30237 ,l_component_code
30238 ,l_component_type_code
30239 ,l_component_appl_id
30240 ,l_amb_context_code
30241 ,l_entity_code
30242 ,l_event_class_code
30243 )
30244 ,p_token_3 => 'OWNER'
30245 ,p_value_3 => xla_lookups_pkg.get_meaning(
30246 p_lookup_type => 'XLA_OWNER_TYPE'
30247 ,p_lookup_code => l_component_type_code
30248 )
30249 ,p_token_4 => 'PRODUCT_NAME'
30250 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
30251 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
30252 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
30253 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
30254 ,p_ae_header_id => NULL
30255 );
30256
30257 IF (C_LEVEL_ERROR>= g_log_level) THEN
30258 trace
30259 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
30260 ,p_level => C_LEVEL_ERROR
30261 ,p_module => l_log_module);
30262 END IF;
30263 END IF;
30264 END IF;
30265 --
30266 --
30267 ------------------------------------------------------------------------------------------------
30268 -- 4219869 Business Flow
30269 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
30270 -- Prior Entry. Currently, the following code is always generated.
30271 ------------------------------------------------------------------------------------------------
30272 XLA_AE_LINES_PKG.ValidateCurrentLine;
30273
30274 ------------------------------------------------------------------------------------
30275 -- 4219869 Business Flow
30276 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
30277 ------------------------------------------------------------------------------------
30278 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
30279
30280 ----------------------------------------------------------------------------------
30281 -- 4219869 Business Flow
30282 -- Update journal entry status -- Need to generate this within IF <condition>
30283 ----------------------------------------------------------------------------------
30284 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
30285 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
30286 ,p_balance_type_code => l_balance_type_code
30287 );
30288
30289 -------------------------------------------------------------------------------------------
30290 -- 4262811 - Generate the Accrual Reversal lines
30291 -------------------------------------------------------------------------------------------
30292 BEGIN
30293 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
30294 (g_array_event(p_event_id).array_value_num('header_index'));
30295 IF l_acc_rev_flag IS NULL THEN
30296 l_acc_rev_flag := 'N';
30297 END IF;
30298 EXCEPTION
30299 WHEN OTHERS THEN
30303 IF (l_acc_rev_flag = 'Y') THEN
30300 l_acc_rev_flag := 'N';
30301 END;
30302 --
30304
30305 -- 4645092 ------------------------------------------------------------------------------
30306 -- To allow MPA report to determine if it should generate report process
30307 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
30308 ------------------------------------------------------------------------------------------
30309
30310 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
30311 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
30312 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
30313 -- call ADRs
30314 -- Bug 4922099
30315 --
30316 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30317 (NVL(l_actual_upg_option, 'N') = 'O') OR
30318 (NVL(l_enc_upg_option, 'N') = 'O')
30319 )
30320 THEN
30321 NULL;
30322 --
30323 --
30324
30325 l_ccid := AcctDerRule_34(
30326 p_application_id => p_application_id
30327 , p_ae_header_id => l_ae_header_id
30328 , p_source_21 => p_source_21
30329 , x_transaction_coa_id => l_adr_transaction_coa_id
30330 , x_accounting_coa_id => l_adr_accounting_coa_id
30331 , x_value_type_code => l_adr_value_type_code
30332 , p_side => 'NA'
30333 );
30334
30335 xla_ae_lines_pkg.set_ccid(
30336 p_code_combination_id => l_ccid
30337 , p_value_type_code => l_adr_value_type_code
30338 , p_transaction_coa_id => l_adr_transaction_coa_id
30339 , p_accounting_coa_id => l_adr_accounting_coa_id
30340 , p_adr_code => 'TRX_DIST_CCID'
30341 , p_adr_type_code => 'S'
30342 , p_component_type => l_component_type
30343 , p_component_code => l_component_code
30344 , p_component_type_code => l_component_type_code
30345 , p_component_appl_id => l_component_appl_id
30346 , p_amb_context_code => l_amb_context_code
30347 , p_side => 'NA'
30348 );
30349
30350
30351 l_segment := AcctDerRule_14(
30352 p_application_id => p_application_id
30353 , p_ae_header_id => l_ae_header_id
30354 , p_source_13 => p_source_13
30355 , x_transaction_coa_id => l_adr_transaction_coa_id
30356 , x_accounting_coa_id => l_adr_accounting_coa_id
30357 , x_flexfield_segment_code => l_adr_flexfield_segment_code
30358 , x_flex_value_set_id => l_adr_flex_value_set_id
30359 , x_value_type_code => l_adr_value_type_code
30360 , x_value_combination_id => l_adr_value_combination_id
30361 , x_value_segment_code => l_adr_value_segment_code
30362 , p_side => 'NA'
30363 , p_override_seg_flag => 'Y'
30364 );
30365
30366 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
30367
30368 xla_ae_lines_pkg.set_segment(
30369 p_to_segment_code => 'GL_ACCOUNT'
30370 , p_segment_value => l_segment
30371 , p_from_segment_code => l_adr_value_segment_code
30372 , p_from_combination_id => l_adr_value_combination_id
30373 , p_value_type_code => l_adr_value_type_code
30374 , p_transaction_coa_id => l_adr_transaction_coa_id
30375 , p_accounting_coa_id => l_adr_accounting_coa_id
30376 , p_flexfield_segment_code => l_adr_flexfield_segment_code
30377 , p_flex_value_set_id => l_adr_flex_value_set_id
30378 , p_adr_code => 'FV_AR_425101_RCT_CR'
30379 , p_adr_type_code => 'S'
30380 , p_component_type => l_component_type
30381 , p_component_code => l_component_code
30382 , p_component_type_code => l_component_type_code
30383 , p_component_appl_id => l_component_appl_id
30384 , p_amb_context_code => l_amb_context_code
30385 , p_entity_code => 'RECEIPTS'
30386 , p_event_class_code => 'RECEIPT'
30387 , p_side => 'NA'
30388 );
30389
30390 END IF;
30391
30392 --
30393 --
30394 END IF;
30395
30396 --
30397 -- Update the line information that should be overwritten
30398 --
30399 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
30400 p_header_num => 1);
30401 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
30402
30403 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
30404
30405 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
30406 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
30407 END IF;
30408
30409 --
30410 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
30411 --
30412 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
30413 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
30414 ELSE
30418 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
30415 ---------------------------------------------------------------------------------------------------
30416 -- 4262811a Switch Sign
30417 ---------------------------------------------------------------------------------------------------
30419 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
30420 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30421 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
30422 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30423 -- 5132302
30424 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
30425 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30426
30427 END IF;
30428
30429 -- 4955764
30430 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
30431 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
30432
30433
30434 XLA_AE_LINES_PKG.ValidateCurrentLine;
30435 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
30436
30437 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
30438 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
30439 ,p_balance_type_code => l_balance_type_code);
30440
30441 END IF;
30442
30443 -----------------------------------------------------------------------------------------
30444 -- 4262811 Multiperiod Accounting
30445 -----------------------------------------------------------------------------------------
30446 -- No MPA option is assigned.
30447
30448
30449 END IF;
30450 END IF;
30451 --
30452
30453 --
30454 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
30455 trace
30456 (p_msg => 'END of AcctLineType_76'
30457 ,p_level => C_LEVEL_PROCEDURE
30458 ,p_module => l_log_module);
30459 END IF;
30460 --
30461 EXCEPTION
30462 WHEN xla_exceptions_pkg.application_exception THEN
30463 RAISE;
30464 WHEN OTHERS THEN
30465 xla_exceptions_pkg.raise_message
30466 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_76');
30467 END AcctLineType_76;
30468 --
30469
30470 ---------------------------------------
30471 --
30472 -- PRIVATE FUNCTION
30473 -- AcctLineType_77
30474 --
30475 ---------------------------------------
30476 PROCEDURE AcctLineType_77 (
30477 p_application_id IN NUMBER
30478 ,p_event_id IN NUMBER
30479 ,p_calculate_acctd_flag IN VARCHAR2
30480 ,p_calculate_g_l_flag IN VARCHAR2
30481 ,p_actual_flag IN OUT VARCHAR2
30482 ,p_balance_type_code OUT VARCHAR2
30483 ,p_gain_or_loss_ref OUT VARCHAR2
30484
30485 --Bill To Customer Classification
30486 , p_source_12 IN VARCHAR2
30487 --Federal Account Rule
30488 , p_source_13 IN VARCHAR2
30489 --Transaction Distribution GL Account
30490 , p_source_21 IN NUMBER
30491 --Distribution Source Type
30492 , p_source_22 IN VARCHAR2
30493 --Distribution Line Identifier
30494 , p_source_24 IN NUMBER
30495 --Distribution Type
30496 , p_source_25 IN VARCHAR2
30497 --Entered Amount
30498 , p_source_26 IN NUMBER
30499 --Exchange Rate Type
30500 , p_source_30 IN VARCHAR2
30501 --Applied To Document Accounting Amount
30502 , p_source_31 IN NUMBER
30503 --Transaction Distribution Account Class
30504 , p_source_35 IN VARCHAR2
30505 --Transaction Distribution Identifier
30506 , p_source_36 IN NUMBER
30507 --Transaction Distribution Type
30508 , p_source_37 IN VARCHAR2
30509 --Federal Account Valid Flag
30510 , p_source_58 IN VARCHAR2
30511 --Applied To Document Exchange Date
30512 , p_source_59 IN DATE
30513 --Receipt Applied To Application Identifier
30514 , p_source_60 IN NUMBER
30515 --Transaction Entity Code
30516 , p_source_61 IN VARCHAR2
30517 --Transaction Identifier
30518 , p_source_62 IN NUMBER
30519 --Applying Document Currency Code
30520 , p_source_63 IN VARCHAR2
30521 --Applied To Document Exchange Rate
30522 , p_source_64 IN NUMBER
30523 --Distribution Party Identifier
30524 , p_source_65 IN NUMBER
30525 --Distribution Party Site Id
30526 , p_source_66 IN NUMBER
30527 --Distribution Party Type
30528 , p_source_67 IN VARCHAR2
30529 )
30530 IS
30531
30532 l_component_type VARCHAR2(80);
30533 l_component_code VARCHAR2(30);
30534 l_component_type_code VARCHAR2(1);
30535 l_component_appl_id INTEGER;
30536 l_amb_context_code VARCHAR2(30);
30537 l_entity_code VARCHAR2(30);
30538 l_event_class_code VARCHAR2(30);
30539 l_ae_header_id NUMBER;
30540 l_event_type_code VARCHAR2(30);
30541 l_line_definition_code VARCHAR2(30);
30542 l_line_definition_owner_code VARCHAR2(1);
30543 --
30544 -- adr variables
30545 l_segment VARCHAR2(30);
30549 l_adr_flexfield_segment_code VARCHAR2(30);
30546 l_ccid NUMBER;
30547 l_adr_transaction_coa_id NUMBER;
30548 l_adr_accounting_coa_id NUMBER;
30550 l_adr_flex_value_set_id NUMBER;
30551 l_adr_value_type_code VARCHAR2(30);
30552 l_adr_value_combination_id NUMBER;
30553 l_adr_value_segment_code VARCHAR2(30);
30554
30555 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
30556 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
30557 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
30558 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
30559
30560 -- 4262811 Variables ------------------------------------------------------------------------------------------
30561 l_entered_amt_idx NUMBER;
30562 l_accted_amt_idx NUMBER;
30563 l_acc_rev_flag VARCHAR2(1);
30564 l_accrual_line_num NUMBER;
30565 l_tmp_amt NUMBER;
30566 l_acc_rev_natural_side_code VARCHAR2(1);
30567
30568 l_num_entries NUMBER;
30569 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
30570 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
30571 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
30572 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
30573 l_recog_line_1 NUMBER;
30574 l_recog_line_2 NUMBER;
30575
30576 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
30577 l_bflow_applied_to_amt NUMBER; -- 5132302
30578 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
30579
30580 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
30581
30582 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
30583 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
30584
30585 ---------------------------------------------------------------------------------------------------------------
30586
30587
30588 --
30589 -- bulk performance
30590 --
30591 l_balance_type_code VARCHAR2(1);
30592 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
30593 l_log_module VARCHAR2(240);
30594
30595 --
30596 -- Upgrade strategy
30597 --
30598 l_actual_upg_option VARCHAR2(1);
30599 l_enc_upg_option VARCHAR2(1);
30600
30601 --
30602 BEGIN
30603 --
30604 IF g_log_enabled THEN
30605 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_77';
30606 END IF;
30607 --
30608 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
30609
30610 trace
30611 (p_msg => 'BEGIN of AcctLineType_77'
30612 ,p_level => C_LEVEL_PROCEDURE
30613 ,p_module => l_log_module);
30614
30615 END IF;
30616 --
30617 l_component_type := 'AMB_JLT';
30618 l_component_code := 'FV_RCT_REIM_WO_ADV_DR';
30619 l_component_type_code := 'S';
30620 l_component_appl_id := 222;
30621 l_amb_context_code := 'DEFAULT';
30622 l_entity_code := 'RECEIPTS';
30623 l_event_class_code := 'RECEIPT';
30624 l_event_type_code := 'RECEIPT_ALL';
30625 l_line_definition_owner_code := 'S';
30626 l_line_definition_code := 'MFAR_FED_AR_RCT_ACCOUNT';
30627 --
30628 l_balance_type_code := 'A';
30629 l_segment := NULL;
30630 l_ccid := NULL;
30631 l_adr_transaction_coa_id := NULL;
30632 l_adr_accounting_coa_id := NULL;
30633 l_adr_flexfield_segment_code := NULL;
30634 l_adr_flex_value_set_id := NULL;
30635 l_adr_value_type_code := NULL;
30636 l_adr_value_combination_id := NULL;
30637 l_adr_value_segment_code := NULL;
30638
30639 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
30640 l_bflow_class_code := ''; -- 4219869 Business Flow
30641 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
30642 l_budgetary_control_flag := 'N';
30643
30644 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30645 l_bflow_applied_to_amt := NULL; -- 5132302
30646 l_entered_amt_idx := NULL; -- 4262811
30647 l_accted_amt_idx := NULL; -- 4262811
30648 l_acc_rev_flag := NULL; -- 4262811
30649 l_accrual_line_num := NULL; -- 4262811
30650 l_tmp_amt := NULL; -- 4262811
30651 --
30652
30653 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
30654 l_balance_type_code <> 'B' THEN
30655 IF NVL(p_source_22,'
30656 ') = 'REC' AND
30657 NVL(p_source_35,'
30658 ') = 'REV' AND
30659 NVL(p_source_12,'
30660 ') = 'FEDERAL' AND
30661 NVL(p_source_13,'
30662 ') = 'Order No Advance' AND
30663 NVL(p_source_58,'
30664 ') = 'Y'
30665 THEN
30666
30667 --
30668 XLA_AE_LINES_PKG.SetNewLine;
30669
30670 p_balance_type_code := l_balance_type_code;
30671 -- set the flag so later we will know whether the gain loss line needs to be created
30672
30673 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
30674 p_actual_flag :='A';
30678 -- bulk performance
30675 END IF;
30676
30677 --
30679 --
30680 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
30681 p_header_num => 0); -- 4262811
30682 --
30683 -- set accounting line options
30684 --
30685 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
30686 p_natural_side_code => 'D'
30687 , p_gain_or_loss_flag => 'N'
30688 , p_gl_transfer_mode_code => 'S'
30689 , p_acct_entry_type_code => 'A'
30690 , p_switch_side_flag => 'Y'
30691 , p_merge_duplicate_code => 'A'
30692 );
30693 --
30694 l_acc_rev_natural_side_code := 'C'; -- 4262811
30695 --
30696 --
30697 -- set accounting line type info
30698 --
30699 xla_ae_lines_pkg.SetAcctLineType
30700 (p_component_type => l_component_type
30701 ,p_event_type_code => l_event_type_code
30702 ,p_line_definition_owner_code => l_line_definition_owner_code
30703 ,p_line_definition_code => l_line_definition_code
30704 ,p_accounting_line_code => l_component_code
30705 ,p_accounting_line_type_code => l_component_type_code
30706 ,p_accounting_line_appl_id => l_component_appl_id
30707 ,p_amb_context_code => l_amb_context_code
30708 ,p_entity_code => l_entity_code
30709 ,p_event_class_code => l_event_class_code);
30710 --
30711 -- set accounting class
30712 --
30713 xla_ae_lines_pkg.SetAcctClass(
30714 p_accounting_class_code => 'FV_CASH_DR'
30715 , p_ae_header_id => l_ae_header_id
30716 );
30717
30718 --
30719 -- set rounding class
30720 --
30721 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
30722 'RECEIVABLE';
30723
30724 --
30725 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
30726 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
30727 --
30728 -- bulk performance
30729 --
30730 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
30731
30732 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
30733 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
30734
30735 -- 4955764
30736 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
30737 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
30738
30739 -- 4458381 Public Sector Enh
30740
30741 --
30742 -- set accounting attributes for the line type
30743 --
30744 l_entered_amt_idx := 8;
30745 l_accted_amt_idx := 13;
30746 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30747 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
30748 l_rec_acct_attrs.array_num_value(1) := p_source_60;
30749 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
30750 l_rec_acct_attrs.array_char_value(2) := p_source_37;
30751 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
30752 l_rec_acct_attrs.array_char_value(3) := p_source_61;
30753 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
30754 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
30755 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
30756 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
30757 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
30758 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
30759 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
30760 l_rec_acct_attrs.array_char_value(7) := p_source_25;
30761 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
30762 l_rec_acct_attrs.array_num_value(8) := p_source_26;
30763 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
30764 l_rec_acct_attrs.array_char_value(9) := p_source_63;
30765 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
30766 l_rec_acct_attrs.array_date_value(10) := p_source_59;
30767 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
30768 l_rec_acct_attrs.array_num_value(11) := p_source_64;
30769 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
30770 l_rec_acct_attrs.array_char_value(12) := p_source_30;
30771 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
30772 l_rec_acct_attrs.array_num_value(13) := p_source_31;
30773 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
30774 l_rec_acct_attrs.array_num_value(14) := p_source_65;
30775 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
30776 l_rec_acct_attrs.array_num_value(15) := p_source_66;
30777 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
30778 l_rec_acct_attrs.array_char_value(16) := p_source_67;
30779
30780 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
30781 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
30782
30783 ---------------------------------------------------------------------------------------------------------------
30787
30784 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
30785 ---------------------------------------------------------------------------------------------------------------
30786 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
30788 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30789 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30790
30791 IF xla_accounting_cache_pkg.GetValueChar
30792 (p_source_code => 'LEDGER_CATEGORY_CODE'
30793 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
30794 AND l_bflow_method_code = 'PRIOR_ENTRY'
30795 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
30796 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
30797 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
30798 )
30799 THEN
30800 xla_ae_lines_pkg.BflowUpgEntry
30801 (p_business_method_code => l_bflow_method_code
30802 ,p_business_class_code => l_bflow_class_code
30803 ,p_balance_type => l_balance_type_code);
30804 ELSE
30805 NULL;
30806 -- No business flow processing for business flow method of NONE.
30807 END IF;
30808
30809 --
30810 -- call analytical criteria
30811 --
30812
30813 --
30814 -- call description
30815 --
30816 -- No description or it is inherited.
30817 --
30818 -- call ADRs
30819 -- Bug 4922099
30820 --
30821 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30822 (NVL(l_actual_upg_option, 'N') = 'O') OR
30823 (NVL(l_enc_upg_option, 'N') = 'O')
30824 )
30825 THEN
30826 NULL;
30827 --
30828 --
30829
30830 l_ccid := AcctDerRule_34(
30831 p_application_id => p_application_id
30832 , p_ae_header_id => l_ae_header_id
30833 , p_source_21 => p_source_21
30834 , x_transaction_coa_id => l_adr_transaction_coa_id
30835 , x_accounting_coa_id => l_adr_accounting_coa_id
30836 , x_value_type_code => l_adr_value_type_code
30837 , p_side => 'NA'
30838 );
30839
30840 xla_ae_lines_pkg.set_ccid(
30841 p_code_combination_id => l_ccid
30842 , p_value_type_code => l_adr_value_type_code
30843 , p_transaction_coa_id => l_adr_transaction_coa_id
30844 , p_accounting_coa_id => l_adr_accounting_coa_id
30845 , p_adr_code => 'TRX_DIST_CCID'
30846 , p_adr_type_code => 'S'
30847 , p_component_type => l_component_type
30848 , p_component_code => l_component_code
30849 , p_component_type_code => l_component_type_code
30850 , p_component_appl_id => l_component_appl_id
30851 , p_amb_context_code => l_amb_context_code
30852 , p_side => 'NA'
30853 );
30854
30855
30856 l_segment := AcctDerRule_16(
30857 p_application_id => p_application_id
30858 , p_ae_header_id => l_ae_header_id
30859 , p_source_13 => p_source_13
30860 , x_transaction_coa_id => l_adr_transaction_coa_id
30861 , x_accounting_coa_id => l_adr_accounting_coa_id
30862 , x_flexfield_segment_code => l_adr_flexfield_segment_code
30863 , x_flex_value_set_id => l_adr_flex_value_set_id
30864 , x_value_type_code => l_adr_value_type_code
30865 , x_value_combination_id => l_adr_value_combination_id
30866 , x_value_segment_code => l_adr_value_segment_code
30867 , p_side => 'NA'
30868 , p_override_seg_flag => 'Y'
30869 );
30870
30871 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
30872
30873 xla_ae_lines_pkg.set_segment(
30874 p_to_segment_code => 'GL_ACCOUNT'
30875 , p_segment_value => l_segment
30876 , p_from_segment_code => l_adr_value_segment_code
30877 , p_from_combination_id => l_adr_value_combination_id
30878 , p_value_type_code => l_adr_value_type_code
30879 , p_transaction_coa_id => l_adr_transaction_coa_id
30880 , p_accounting_coa_id => l_adr_accounting_coa_id
30881 , p_flexfield_segment_code => l_adr_flexfield_segment_code
30882 , p_flex_value_set_id => l_adr_flex_value_set_id
30883 , p_adr_code => 'FV_AR_425201_RCT_DR'
30884 , p_adr_type_code => 'S'
30885 , p_component_type => l_component_type
30886 , p_component_code => l_component_code
30887 , p_component_type_code => l_component_type_code
30888 , p_component_appl_id => l_component_appl_id
30889 , p_amb_context_code => l_amb_context_code
30890 , p_entity_code => 'RECEIPTS'
30891 , p_event_class_code => 'RECEIPT'
30892 , p_side => 'NA'
30893 );
30894
30895 END IF;
30896
30897 --
30898 --
30899 END IF;
30900 --
30901 -- Bug 4922099
30902 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
30903 (NVL(l_enc_upg_option, 'N') = 'O')
30904 ) AND
30905 (l_bflow_method_code = 'PRIOR_ENTRY')
30909 --
30906 )
30907 THEN
30908 IF
30910 1 = 2
30911 --
30912 THEN
30913 xla_accounting_err_pkg.build_message
30914 (p_appli_s_name => 'XLA'
30915 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
30916 ,p_token_1 => 'LINE_NUMBER'
30917 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
30918 ,p_token_2 => 'LINE_TYPE_NAME'
30919 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
30920 l_component_type
30921 ,l_component_code
30922 ,l_component_type_code
30923 ,l_component_appl_id
30924 ,l_amb_context_code
30925 ,l_entity_code
30926 ,l_event_class_code
30927 )
30928 ,p_token_3 => 'OWNER'
30929 ,p_value_3 => xla_lookups_pkg.get_meaning(
30930 p_lookup_type => 'XLA_OWNER_TYPE'
30931 ,p_lookup_code => l_component_type_code
30932 )
30933 ,p_token_4 => 'PRODUCT_NAME'
30934 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
30935 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
30936 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
30937 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
30938 ,p_ae_header_id => NULL
30939 );
30940
30941 IF (C_LEVEL_ERROR>= g_log_level) THEN
30942 trace
30943 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
30944 ,p_level => C_LEVEL_ERROR
30945 ,p_module => l_log_module);
30946 END IF;
30947 END IF;
30948 END IF;
30949 --
30950 --
30951 ------------------------------------------------------------------------------------------------
30952 -- 4219869 Business Flow
30953 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
30954 -- Prior Entry. Currently, the following code is always generated.
30955 ------------------------------------------------------------------------------------------------
30956 XLA_AE_LINES_PKG.ValidateCurrentLine;
30957
30958 ------------------------------------------------------------------------------------
30959 -- 4219869 Business Flow
30960 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
30961 ------------------------------------------------------------------------------------
30962 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
30963
30964 ----------------------------------------------------------------------------------
30965 -- 4219869 Business Flow
30966 -- Update journal entry status -- Need to generate this within IF <condition>
30967 ----------------------------------------------------------------------------------
30968 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
30969 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
30970 ,p_balance_type_code => l_balance_type_code
30971 );
30972
30973 -------------------------------------------------------------------------------------------
30974 -- 4262811 - Generate the Accrual Reversal lines
30975 -------------------------------------------------------------------------------------------
30976 BEGIN
30977 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
30978 (g_array_event(p_event_id).array_value_num('header_index'));
30979 IF l_acc_rev_flag IS NULL THEN
30980 l_acc_rev_flag := 'N';
30981 END IF;
30982 EXCEPTION
30983 WHEN OTHERS THEN
30984 l_acc_rev_flag := 'N';
30985 END;
30986 --
30987 IF (l_acc_rev_flag = 'Y') THEN
30988
30989 -- 4645092 ------------------------------------------------------------------------------
30990 -- To allow MPA report to determine if it should generate report process
30991 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
30992 ------------------------------------------------------------------------------------------
30993
30994 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
30995 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
30996 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
31000 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30997 -- call ADRs
30998 -- Bug 4922099
30999 --
31001 (NVL(l_actual_upg_option, 'N') = 'O') OR
31002 (NVL(l_enc_upg_option, 'N') = 'O')
31003 )
31004 THEN
31005 NULL;
31006 --
31007 --
31008
31009 l_ccid := AcctDerRule_34(
31010 p_application_id => p_application_id
31011 , p_ae_header_id => l_ae_header_id
31012 , p_source_21 => p_source_21
31013 , x_transaction_coa_id => l_adr_transaction_coa_id
31014 , x_accounting_coa_id => l_adr_accounting_coa_id
31015 , x_value_type_code => l_adr_value_type_code
31016 , p_side => 'NA'
31017 );
31018
31019 xla_ae_lines_pkg.set_ccid(
31020 p_code_combination_id => l_ccid
31021 , p_value_type_code => l_adr_value_type_code
31022 , p_transaction_coa_id => l_adr_transaction_coa_id
31023 , p_accounting_coa_id => l_adr_accounting_coa_id
31024 , p_adr_code => 'TRX_DIST_CCID'
31025 , p_adr_type_code => 'S'
31026 , p_component_type => l_component_type
31027 , p_component_code => l_component_code
31028 , p_component_type_code => l_component_type_code
31029 , p_component_appl_id => l_component_appl_id
31030 , p_amb_context_code => l_amb_context_code
31031 , p_side => 'NA'
31032 );
31033
31034
31035 l_segment := AcctDerRule_16(
31036 p_application_id => p_application_id
31037 , p_ae_header_id => l_ae_header_id
31038 , p_source_13 => p_source_13
31039 , x_transaction_coa_id => l_adr_transaction_coa_id
31040 , x_accounting_coa_id => l_adr_accounting_coa_id
31041 , x_flexfield_segment_code => l_adr_flexfield_segment_code
31042 , x_flex_value_set_id => l_adr_flex_value_set_id
31043 , x_value_type_code => l_adr_value_type_code
31044 , x_value_combination_id => l_adr_value_combination_id
31045 , x_value_segment_code => l_adr_value_segment_code
31046 , p_side => 'NA'
31047 , p_override_seg_flag => 'Y'
31048 );
31049
31050 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
31051
31052 xla_ae_lines_pkg.set_segment(
31053 p_to_segment_code => 'GL_ACCOUNT'
31054 , p_segment_value => l_segment
31055 , p_from_segment_code => l_adr_value_segment_code
31056 , p_from_combination_id => l_adr_value_combination_id
31057 , p_value_type_code => l_adr_value_type_code
31058 , p_transaction_coa_id => l_adr_transaction_coa_id
31059 , p_accounting_coa_id => l_adr_accounting_coa_id
31060 , p_flexfield_segment_code => l_adr_flexfield_segment_code
31061 , p_flex_value_set_id => l_adr_flex_value_set_id
31062 , p_adr_code => 'FV_AR_425201_RCT_DR'
31063 , p_adr_type_code => 'S'
31064 , p_component_type => l_component_type
31065 , p_component_code => l_component_code
31066 , p_component_type_code => l_component_type_code
31067 , p_component_appl_id => l_component_appl_id
31068 , p_amb_context_code => l_amb_context_code
31069 , p_entity_code => 'RECEIPTS'
31070 , p_event_class_code => 'RECEIPT'
31071 , p_side => 'NA'
31072 );
31073
31074 END IF;
31075
31076 --
31077 --
31078 END IF;
31079
31080 --
31081 -- Update the line information that should be overwritten
31082 --
31083 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
31084 p_header_num => 1);
31085 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
31086
31087 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
31088
31089 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
31090 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
31091 END IF;
31092
31093 --
31094 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
31095 --
31096 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
31097 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
31098 ELSE
31099 ---------------------------------------------------------------------------------------------------
31100 -- 4262811a Switch Sign
31101 ---------------------------------------------------------------------------------------------------
31102 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
31103 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31104 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31105 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31109 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31106 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31107 -- 5132302
31108 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
31110
31111 END IF;
31112
31113 -- 4955764
31114 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31115 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
31116
31117
31118 XLA_AE_LINES_PKG.ValidateCurrentLine;
31119 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31120
31121 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31122 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
31123 ,p_balance_type_code => l_balance_type_code);
31124
31125 END IF;
31126
31127 -----------------------------------------------------------------------------------------
31128 -- 4262811 Multiperiod Accounting
31129 -----------------------------------------------------------------------------------------
31130 -- No MPA option is assigned.
31131
31132
31133 END IF;
31134 END IF;
31135 --
31136
31137 --
31138 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31139 trace
31140 (p_msg => 'END of AcctLineType_77'
31141 ,p_level => C_LEVEL_PROCEDURE
31142 ,p_module => l_log_module);
31143 END IF;
31144 --
31145 EXCEPTION
31146 WHEN xla_exceptions_pkg.application_exception THEN
31147 RAISE;
31148 WHEN OTHERS THEN
31149 xla_exceptions_pkg.raise_message
31150 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_77');
31151 END AcctLineType_77;
31152 --
31153
31154 ---------------------------------------
31155 --
31156 -- PRIVATE FUNCTION
31157 -- AcctLineType_78
31158 --
31159 ---------------------------------------
31160 PROCEDURE AcctLineType_78 (
31161 p_application_id IN NUMBER
31162 ,p_event_id IN NUMBER
31163 ,p_calculate_acctd_flag IN VARCHAR2
31164 ,p_calculate_g_l_flag IN VARCHAR2
31165 ,p_actual_flag IN OUT VARCHAR2
31166 ,p_balance_type_code OUT VARCHAR2
31167 ,p_gain_or_loss_ref OUT VARCHAR2
31168
31169 --Transaction Distribution GL Account
31170 , p_source_21 IN NUMBER
31171 --Bill To Customer Account Identifier
31172 , p_source_32 IN NUMBER
31173 --Bill To Customer Site Use Identifier
31174 , p_source_33 IN NUMBER
31175 --SLA Party Type
31176 , p_source_34 IN VARCHAR2
31177 --Transaction Distribution Account Class
31178 , p_source_35 IN VARCHAR2
31179 --Transaction Distribution Identifier
31180 , p_source_36 IN NUMBER
31181 --Transaction Distribution Type
31182 , p_source_37 IN VARCHAR2
31183 --Transaction Distribution Entered Amount
31184 , p_source_38 IN NUMBER
31185 --Transaction Currency Code
31186 , p_source_39 IN VARCHAR2
31187 --Transaction Exchange Date
31188 , p_source_40 IN DATE
31189 --Transaction Exchange Rate
31190 , p_source_41 IN NUMBER
31191 --Transaction Exchange Rate Type
31192 , p_source_42 IN VARCHAR2
31193 --Transaction Accounting Amount
31194 , p_source_43 IN NUMBER
31195 )
31196 IS
31197
31198 l_component_type VARCHAR2(80);
31199 l_component_code VARCHAR2(30);
31200 l_component_type_code VARCHAR2(1);
31201 l_component_appl_id INTEGER;
31202 l_amb_context_code VARCHAR2(30);
31203 l_entity_code VARCHAR2(30);
31204 l_event_class_code VARCHAR2(30);
31205 l_ae_header_id NUMBER;
31206 l_event_type_code VARCHAR2(30);
31207 l_line_definition_code VARCHAR2(30);
31208 l_line_definition_owner_code VARCHAR2(1);
31209 --
31210 -- adr variables
31211 l_segment VARCHAR2(30);
31212 l_ccid NUMBER;
31213 l_adr_transaction_coa_id NUMBER;
31214 l_adr_accounting_coa_id NUMBER;
31215 l_adr_flexfield_segment_code VARCHAR2(30);
31216 l_adr_flex_value_set_id NUMBER;
31217 l_adr_value_type_code VARCHAR2(30);
31218 l_adr_value_combination_id NUMBER;
31219 l_adr_value_segment_code VARCHAR2(30);
31220
31221 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
31222 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
31223 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
31224 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
31225
31226 -- 4262811 Variables ------------------------------------------------------------------------------------------
31227 l_entered_amt_idx NUMBER;
31228 l_accted_amt_idx NUMBER;
31229 l_acc_rev_flag VARCHAR2(1);
31230 l_accrual_line_num NUMBER;
31231 l_tmp_amt NUMBER;
31232 l_acc_rev_natural_side_code VARCHAR2(1);
31233
31234 l_num_entries NUMBER;
31235 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
31236 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
31240 l_recog_line_2 NUMBER;
31237 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
31238 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
31239 l_recog_line_1 NUMBER;
31241
31242 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
31243 l_bflow_applied_to_amt NUMBER; -- 5132302
31244 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
31245
31246 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
31247
31248 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
31249 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
31250
31251 ---------------------------------------------------------------------------------------------------------------
31252
31253
31254 --
31255 -- bulk performance
31256 --
31257 l_balance_type_code VARCHAR2(1);
31258 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
31259 l_log_module VARCHAR2(240);
31260
31261 --
31262 -- Upgrade strategy
31263 --
31264 l_actual_upg_option VARCHAR2(1);
31265 l_enc_upg_option VARCHAR2(1);
31266
31267 --
31268 BEGIN
31269 --
31270 IF g_log_enabled THEN
31271 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_78';
31272 END IF;
31273 --
31274 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31275
31276 trace
31277 (p_msg => 'BEGIN of AcctLineType_78'
31278 ,p_level => C_LEVEL_PROCEDURE
31279 ,p_module => l_log_module);
31280
31281 END IF;
31282 --
31283 l_component_type := 'AMB_JLT';
31284 l_component_code := 'GUAR_DEFAULT_REC';
31285 l_component_type_code := 'S';
31286 l_component_appl_id := 222;
31287 l_amb_context_code := 'DEFAULT';
31288 l_entity_code := 'TRANSACTIONS';
31289 l_event_class_code := 'GUARANTEE';
31290 l_event_type_code := 'GUARANTEE_ALL';
31291 l_line_definition_owner_code := 'S';
31292 l_line_definition_code := 'AR_GUAR_DEFAULT_ACCRUAL';
31293 --
31294 l_balance_type_code := 'A';
31295 l_segment := NULL;
31296 l_ccid := NULL;
31297 l_adr_transaction_coa_id := NULL;
31298 l_adr_accounting_coa_id := NULL;
31299 l_adr_flexfield_segment_code := NULL;
31300 l_adr_flex_value_set_id := NULL;
31301 l_adr_value_type_code := NULL;
31302 l_adr_value_combination_id := NULL;
31303 l_adr_value_segment_code := NULL;
31304
31305 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
31306 l_bflow_class_code := ''; -- 4219869 Business Flow
31307 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
31308 l_budgetary_control_flag := 'N';
31309
31310 l_bflow_applied_to_amt_idx := NULL; -- 5132302
31311 l_bflow_applied_to_amt := NULL; -- 5132302
31312 l_entered_amt_idx := NULL; -- 4262811
31313 l_accted_amt_idx := NULL; -- 4262811
31314 l_acc_rev_flag := NULL; -- 4262811
31315 l_accrual_line_num := NULL; -- 4262811
31316 l_tmp_amt := NULL; -- 4262811
31317 --
31318
31319 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
31320 l_balance_type_code <> 'B' THEN
31321 IF NVL(p_source_35,'
31322 ') = 'REC'
31323 THEN
31324
31325 --
31326 XLA_AE_LINES_PKG.SetNewLine;
31327
31328 p_balance_type_code := l_balance_type_code;
31329 -- set the flag so later we will know whether the gain loss line needs to be created
31330
31331 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
31332 p_actual_flag :='A';
31333 END IF;
31334
31335 --
31336 -- bulk performance
31337 --
31338 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
31339 p_header_num => 0); -- 4262811
31340 --
31341 -- set accounting line options
31342 --
31343 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
31344 p_natural_side_code => 'D'
31345 , p_gain_or_loss_flag => 'N'
31346 , p_gl_transfer_mode_code => 'S'
31347 , p_acct_entry_type_code => 'A'
31348 , p_switch_side_flag => 'Y'
31349 , p_merge_duplicate_code => 'A'
31350 );
31351 --
31352 l_acc_rev_natural_side_code := 'C'; -- 4262811
31353 --
31354 --
31355 -- set accounting line type info
31356 --
31357 xla_ae_lines_pkg.SetAcctLineType
31358 (p_component_type => l_component_type
31359 ,p_event_type_code => l_event_type_code
31360 ,p_line_definition_owner_code => l_line_definition_owner_code
31361 ,p_line_definition_code => l_line_definition_code
31362 ,p_accounting_line_code => l_component_code
31363 ,p_accounting_line_type_code => l_component_type_code
31364 ,p_accounting_line_appl_id => l_component_appl_id
31365 ,p_amb_context_code => l_amb_context_code
31366 ,p_entity_code => l_entity_code
31367 ,p_event_class_code => l_event_class_code);
31368 --
31372 p_accounting_class_code => 'RECEIVABLE'
31369 -- set accounting class
31370 --
31371 xla_ae_lines_pkg.SetAcctClass(
31373 , p_ae_header_id => l_ae_header_id
31374 );
31375
31376 --
31377 -- set rounding class
31378 --
31379 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
31380 'RECEIVABLE';
31381
31382 --
31383 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
31384 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
31385 --
31386 -- bulk performance
31387 --
31388 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
31389
31390 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
31391 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
31392
31393 -- 4955764
31394 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31395 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
31396
31397 -- 4458381 Public Sector Enh
31398
31399 --
31400 -- set accounting attributes for the line type
31401 --
31402 l_entered_amt_idx := 3;
31403 l_accted_amt_idx := 8;
31404 l_bflow_applied_to_amt_idx := NULL; -- 5132302
31405 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
31406 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
31407 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
31408 l_rec_acct_attrs.array_char_value(2) := p_source_37;
31409 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
31410 l_rec_acct_attrs.array_num_value(3) := p_source_38;
31411 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
31412 l_rec_acct_attrs.array_char_value(4) := p_source_39;
31413 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
31414 l_rec_acct_attrs.array_date_value(5) := p_source_40;
31415 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
31416 l_rec_acct_attrs.array_num_value(6) := p_source_41;
31417 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
31418 l_rec_acct_attrs.array_char_value(7) := p_source_42;
31419 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
31420 l_rec_acct_attrs.array_num_value(8) := p_source_43;
31421 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
31422 l_rec_acct_attrs.array_num_value(9) := p_source_32;
31423 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
31424 l_rec_acct_attrs.array_num_value(10) := p_source_33;
31425 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
31426 l_rec_acct_attrs.array_char_value(11) := p_source_34;
31427
31428 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
31429 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
31430
31431 ---------------------------------------------------------------------------------------------------------------
31432 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
31433 ---------------------------------------------------------------------------------------------------------------
31434 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
31435
31436 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
31437 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
31438
31439 IF xla_accounting_cache_pkg.GetValueChar
31440 (p_source_code => 'LEDGER_CATEGORY_CODE'
31441 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
31442 AND l_bflow_method_code = 'PRIOR_ENTRY'
31443 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
31444 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
31445 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
31446 )
31447 THEN
31448 xla_ae_lines_pkg.BflowUpgEntry
31449 (p_business_method_code => l_bflow_method_code
31450 ,p_business_class_code => l_bflow_class_code
31451 ,p_balance_type => l_balance_type_code);
31452 ELSE
31453 NULL;
31454 -- No business flow processing for business flow method of NONE.
31455 END IF;
31456
31457 --
31458 -- call analytical criteria
31459 --
31460
31461 --
31462 -- call description
31463 --
31464 -- No description or it is inherited.
31465 --
31466 -- call ADRs
31467 -- Bug 4922099
31468 --
31469 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
31470 (NVL(l_actual_upg_option, 'N') = 'O') OR
31471 (NVL(l_enc_upg_option, 'N') = 'O')
31472 )
31473 THEN
31474 NULL;
31475 --
31476 --
31477
31478 l_ccid := AcctDerRule_34(
31479 p_application_id => p_application_id
31480 , p_ae_header_id => l_ae_header_id
31481 , p_source_21 => p_source_21
31482 , x_transaction_coa_id => l_adr_transaction_coa_id
31483 , x_accounting_coa_id => l_adr_accounting_coa_id
31487
31484 , x_value_type_code => l_adr_value_type_code
31485 , p_side => 'NA'
31486 );
31488 xla_ae_lines_pkg.set_ccid(
31489 p_code_combination_id => l_ccid
31490 , p_value_type_code => l_adr_value_type_code
31491 , p_transaction_coa_id => l_adr_transaction_coa_id
31492 , p_accounting_coa_id => l_adr_accounting_coa_id
31493 , p_adr_code => 'TRX_DIST_CCID'
31494 , p_adr_type_code => 'S'
31495 , p_component_type => l_component_type
31496 , p_component_code => l_component_code
31497 , p_component_type_code => l_component_type_code
31498 , p_component_appl_id => l_component_appl_id
31499 , p_amb_context_code => l_amb_context_code
31500 , p_side => 'NA'
31501 );
31502
31503
31504 --
31505 --
31506 END IF;
31507 --
31508 -- Bug 4922099
31509 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
31510 (NVL(l_enc_upg_option, 'N') = 'O')
31511 ) AND
31512 (l_bflow_method_code = 'PRIOR_ENTRY')
31513 )
31514 THEN
31515 IF
31516 --
31517 1 = 2
31518 --
31519 THEN
31520 xla_accounting_err_pkg.build_message
31521 (p_appli_s_name => 'XLA'
31522 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
31523 ,p_token_1 => 'LINE_NUMBER'
31524 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
31525 ,p_token_2 => 'LINE_TYPE_NAME'
31526 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
31527 l_component_type
31528 ,l_component_code
31529 ,l_component_type_code
31530 ,l_component_appl_id
31531 ,l_amb_context_code
31532 ,l_entity_code
31533 ,l_event_class_code
31534 )
31535 ,p_token_3 => 'OWNER'
31536 ,p_value_3 => xla_lookups_pkg.get_meaning(
31537 p_lookup_type => 'XLA_OWNER_TYPE'
31538 ,p_lookup_code => l_component_type_code
31539 )
31540 ,p_token_4 => 'PRODUCT_NAME'
31541 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
31542 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
31543 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
31544 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
31545 ,p_ae_header_id => NULL
31546 );
31547
31548 IF (C_LEVEL_ERROR>= g_log_level) THEN
31549 trace
31550 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
31551 ,p_level => C_LEVEL_ERROR
31552 ,p_module => l_log_module);
31553 END IF;
31554 END IF;
31555 END IF;
31556 --
31557 --
31558 ------------------------------------------------------------------------------------------------
31559 -- 4219869 Business Flow
31560 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
31561 -- Prior Entry. Currently, the following code is always generated.
31562 ------------------------------------------------------------------------------------------------
31563 XLA_AE_LINES_PKG.ValidateCurrentLine;
31564
31565 ------------------------------------------------------------------------------------
31566 -- 4219869 Business Flow
31567 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
31568 ------------------------------------------------------------------------------------
31569 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31570
31571 ----------------------------------------------------------------------------------
31572 -- 4219869 Business Flow
31573 -- Update journal entry status -- Need to generate this within IF <condition>
31574 ----------------------------------------------------------------------------------
31575 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31576 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
31577 ,p_balance_type_code => l_balance_type_code
31578 );
31579
31580 -------------------------------------------------------------------------------------------
31584 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
31581 -- 4262811 - Generate the Accrual Reversal lines
31582 -------------------------------------------------------------------------------------------
31583 BEGIN
31585 (g_array_event(p_event_id).array_value_num('header_index'));
31586 IF l_acc_rev_flag IS NULL THEN
31587 l_acc_rev_flag := 'N';
31588 END IF;
31589 EXCEPTION
31590 WHEN OTHERS THEN
31591 l_acc_rev_flag := 'N';
31592 END;
31593 --
31594 IF (l_acc_rev_flag = 'Y') THEN
31595
31596 -- 4645092 ------------------------------------------------------------------------------
31597 -- To allow MPA report to determine if it should generate report process
31598 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
31599 ------------------------------------------------------------------------------------------
31600
31601 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
31602 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
31603 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
31604 -- call ADRs
31605 -- Bug 4922099
31606 --
31607 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
31608 (NVL(l_actual_upg_option, 'N') = 'O') OR
31609 (NVL(l_enc_upg_option, 'N') = 'O')
31610 )
31611 THEN
31612 NULL;
31613 --
31614 --
31615
31616 l_ccid := AcctDerRule_34(
31617 p_application_id => p_application_id
31618 , p_ae_header_id => l_ae_header_id
31619 , p_source_21 => p_source_21
31620 , x_transaction_coa_id => l_adr_transaction_coa_id
31621 , x_accounting_coa_id => l_adr_accounting_coa_id
31622 , x_value_type_code => l_adr_value_type_code
31623 , p_side => 'NA'
31624 );
31625
31626 xla_ae_lines_pkg.set_ccid(
31627 p_code_combination_id => l_ccid
31628 , p_value_type_code => l_adr_value_type_code
31629 , p_transaction_coa_id => l_adr_transaction_coa_id
31630 , p_accounting_coa_id => l_adr_accounting_coa_id
31631 , p_adr_code => 'TRX_DIST_CCID'
31632 , p_adr_type_code => 'S'
31633 , p_component_type => l_component_type
31634 , p_component_code => l_component_code
31635 , p_component_type_code => l_component_type_code
31636 , p_component_appl_id => l_component_appl_id
31637 , p_amb_context_code => l_amb_context_code
31638 , p_side => 'NA'
31639 );
31640
31641
31642 --
31643 --
31644 END IF;
31645
31646 --
31647 -- Update the line information that should be overwritten
31648 --
31649 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
31650 p_header_num => 1);
31651 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
31652
31653 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
31654
31655 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
31656 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
31657 END IF;
31658
31659 --
31660 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
31661 --
31662 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
31663 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
31664 ELSE
31665 ---------------------------------------------------------------------------------------------------
31666 -- 4262811a Switch Sign
31667 ---------------------------------------------------------------------------------------------------
31668 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
31669 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31670 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31671 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31672 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31673 -- 5132302
31674 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
31675 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31676
31677 END IF;
31678
31679 -- 4955764
31680 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31681 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
31682
31683
31684 XLA_AE_LINES_PKG.ValidateCurrentLine;
31685 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31686
31687 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31688 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
31689 ,p_balance_type_code => l_balance_type_code);
31690
31694 -- 4262811 Multiperiod Accounting
31691 END IF;
31692
31693 -----------------------------------------------------------------------------------------
31695 -----------------------------------------------------------------------------------------
31696 -- No MPA option is assigned.
31697
31698
31699 END IF;
31700 END IF;
31701 --
31702
31703 --
31704 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31705 trace
31706 (p_msg => 'END of AcctLineType_78'
31707 ,p_level => C_LEVEL_PROCEDURE
31708 ,p_module => l_log_module);
31709 END IF;
31710 --
31711 EXCEPTION
31712 WHEN xla_exceptions_pkg.application_exception THEN
31713 RAISE;
31714 WHEN OTHERS THEN
31715 xla_exceptions_pkg.raise_message
31716 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_78');
31717 END AcctLineType_78;
31718 --
31719
31720 ---------------------------------------
31721 --
31722 -- PRIVATE FUNCTION
31723 -- AcctLineType_79
31724 --
31725 ---------------------------------------
31726 PROCEDURE AcctLineType_79 (
31727 p_application_id IN NUMBER
31728 ,p_event_id IN NUMBER
31729 ,p_calculate_acctd_flag IN VARCHAR2
31730 ,p_calculate_g_l_flag IN VARCHAR2
31731 ,p_actual_flag IN OUT VARCHAR2
31732 ,p_balance_type_code OUT VARCHAR2
31733 ,p_gain_or_loss_ref OUT VARCHAR2
31734
31735 --Transaction Distribution GL Account
31736 , p_source_21 IN NUMBER
31737 --Bill To Customer Account Identifier
31738 , p_source_32 IN NUMBER
31739 --Bill To Customer Site Use Identifier
31740 , p_source_33 IN NUMBER
31741 --SLA Party Type
31742 , p_source_34 IN VARCHAR2
31743 --Transaction Distribution Account Class
31744 , p_source_35 IN VARCHAR2
31745 --Transaction Distribution Identifier
31746 , p_source_36 IN NUMBER
31747 --Transaction Distribution Type
31748 , p_source_37 IN VARCHAR2
31749 --Transaction Distribution Entered Amount
31750 , p_source_38 IN NUMBER
31751 --Transaction Currency Code
31752 , p_source_39 IN VARCHAR2
31753 --Transaction Exchange Date
31754 , p_source_40 IN DATE
31755 --Transaction Exchange Rate
31756 , p_source_41 IN NUMBER
31757 --Transaction Exchange Rate Type
31758 , p_source_42 IN VARCHAR2
31759 --Transaction Accounting Amount
31760 , p_source_43 IN NUMBER
31761 )
31762 IS
31763
31764 l_component_type VARCHAR2(80);
31765 l_component_code VARCHAR2(30);
31766 l_component_type_code VARCHAR2(1);
31767 l_component_appl_id INTEGER;
31768 l_amb_context_code VARCHAR2(30);
31769 l_entity_code VARCHAR2(30);
31770 l_event_class_code VARCHAR2(30);
31771 l_ae_header_id NUMBER;
31772 l_event_type_code VARCHAR2(30);
31773 l_line_definition_code VARCHAR2(30);
31774 l_line_definition_owner_code VARCHAR2(1);
31775 --
31776 -- adr variables
31777 l_segment VARCHAR2(30);
31778 l_ccid NUMBER;
31779 l_adr_transaction_coa_id NUMBER;
31780 l_adr_accounting_coa_id NUMBER;
31781 l_adr_flexfield_segment_code VARCHAR2(30);
31782 l_adr_flex_value_set_id NUMBER;
31783 l_adr_value_type_code VARCHAR2(30);
31784 l_adr_value_combination_id NUMBER;
31785 l_adr_value_segment_code VARCHAR2(30);
31786
31787 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
31788 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
31789 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
31790 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
31791
31792 -- 4262811 Variables ------------------------------------------------------------------------------------------
31793 l_entered_amt_idx NUMBER;
31794 l_accted_amt_idx NUMBER;
31795 l_acc_rev_flag VARCHAR2(1);
31796 l_accrual_line_num NUMBER;
31797 l_tmp_amt NUMBER;
31798 l_acc_rev_natural_side_code VARCHAR2(1);
31799
31800 l_num_entries NUMBER;
31801 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
31802 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
31803 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
31804 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
31805 l_recog_line_1 NUMBER;
31806 l_recog_line_2 NUMBER;
31807
31808 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
31809 l_bflow_applied_to_amt NUMBER; -- 5132302
31810 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
31811
31812 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
31813
31814 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
31815 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
31816
31817 ---------------------------------------------------------------------------------------------------------------
31818
31819
31820 --
31821 -- bulk performance
31822 --
31823 l_balance_type_code VARCHAR2(1);
31827 --
31824 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
31825 l_log_module VARCHAR2(240);
31826
31828 -- Upgrade strategy
31829 --
31830 l_actual_upg_option VARCHAR2(1);
31831 l_enc_upg_option VARCHAR2(1);
31832
31833 --
31834 BEGIN
31835 --
31836 IF g_log_enabled THEN
31837 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_79';
31838 END IF;
31839 --
31840 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31841
31842 trace
31843 (p_msg => 'BEGIN of AcctLineType_79'
31844 ,p_level => C_LEVEL_PROCEDURE
31845 ,p_module => l_log_module);
31846
31847 END IF;
31848 --
31849 l_component_type := 'AMB_JLT';
31850 l_component_code := 'GUAR_REV';
31851 l_component_type_code := 'S';
31852 l_component_appl_id := 222;
31853 l_amb_context_code := 'DEFAULT';
31854 l_entity_code := 'TRANSACTIONS';
31855 l_event_class_code := 'GUARANTEE';
31856 l_event_type_code := 'GUARANTEE_ALL';
31857 l_line_definition_owner_code := 'S';
31858 l_line_definition_code := 'AR_GUAR_DEFAULT_ACCRUAL';
31859 --
31860 l_balance_type_code := 'A';
31861 l_segment := NULL;
31862 l_ccid := NULL;
31863 l_adr_transaction_coa_id := NULL;
31864 l_adr_accounting_coa_id := NULL;
31865 l_adr_flexfield_segment_code := NULL;
31866 l_adr_flex_value_set_id := NULL;
31867 l_adr_value_type_code := NULL;
31868 l_adr_value_combination_id := NULL;
31869 l_adr_value_segment_code := NULL;
31870
31871 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
31872 l_bflow_class_code := ''; -- 4219869 Business Flow
31873 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
31874 l_budgetary_control_flag := 'N';
31875
31876 l_bflow_applied_to_amt_idx := NULL; -- 5132302
31877 l_bflow_applied_to_amt := NULL; -- 5132302
31878 l_entered_amt_idx := NULL; -- 4262811
31879 l_accted_amt_idx := NULL; -- 4262811
31880 l_acc_rev_flag := NULL; -- 4262811
31881 l_accrual_line_num := NULL; -- 4262811
31882 l_tmp_amt := NULL; -- 4262811
31883 --
31884
31885 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
31886 l_balance_type_code <> 'B' THEN
31887 IF NVL(p_source_35,'
31888 ') = 'REV'
31889 THEN
31890
31891 --
31892 XLA_AE_LINES_PKG.SetNewLine;
31893
31894 p_balance_type_code := l_balance_type_code;
31895 -- set the flag so later we will know whether the gain loss line needs to be created
31896
31897 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
31898 p_actual_flag :='A';
31899 END IF;
31900
31901 --
31902 -- bulk performance
31903 --
31904 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
31905 p_header_num => 0); -- 4262811
31906 --
31907 -- set accounting line options
31908 --
31909 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
31910 p_natural_side_code => 'C'
31911 , p_gain_or_loss_flag => 'N'
31912 , p_gl_transfer_mode_code => 'S'
31913 , p_acct_entry_type_code => 'A'
31914 , p_switch_side_flag => 'Y'
31915 , p_merge_duplicate_code => 'A'
31916 );
31917 --
31918 l_acc_rev_natural_side_code := 'D'; -- 4262811
31919 --
31920 --
31921 -- set accounting line type info
31922 --
31923 xla_ae_lines_pkg.SetAcctLineType
31924 (p_component_type => l_component_type
31925 ,p_event_type_code => l_event_type_code
31926 ,p_line_definition_owner_code => l_line_definition_owner_code
31927 ,p_line_definition_code => l_line_definition_code
31928 ,p_accounting_line_code => l_component_code
31929 ,p_accounting_line_type_code => l_component_type_code
31930 ,p_accounting_line_appl_id => l_component_appl_id
31931 ,p_amb_context_code => l_amb_context_code
31932 ,p_entity_code => l_entity_code
31933 ,p_event_class_code => l_event_class_code);
31934 --
31935 -- set accounting class
31936 --
31937 xla_ae_lines_pkg.SetAcctClass(
31938 p_accounting_class_code => 'REVENUE'
31939 , p_ae_header_id => l_ae_header_id
31940 );
31941
31942 --
31943 -- set rounding class
31944 --
31945 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
31946 'RECEIVABLE';
31947
31948 --
31949 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
31950 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
31951 --
31952 -- bulk performance
31953 --
31954 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
31955
31956 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
31957 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
31958
31959 -- 4955764
31963 -- 4458381 Public Sector Enh
31960 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31961 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
31962
31964
31965 --
31966 -- set accounting attributes for the line type
31967 --
31968 l_entered_amt_idx := 3;
31969 l_accted_amt_idx := 8;
31970 l_bflow_applied_to_amt_idx := NULL; -- 5132302
31971 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
31972 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
31973 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
31974 l_rec_acct_attrs.array_char_value(2) := p_source_37;
31975 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
31976 l_rec_acct_attrs.array_num_value(3) := p_source_38;
31977 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
31978 l_rec_acct_attrs.array_char_value(4) := p_source_39;
31979 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
31980 l_rec_acct_attrs.array_date_value(5) := p_source_40;
31981 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
31982 l_rec_acct_attrs.array_num_value(6) := p_source_41;
31983 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
31984 l_rec_acct_attrs.array_char_value(7) := p_source_42;
31985 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
31986 l_rec_acct_attrs.array_num_value(8) := p_source_43;
31987 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
31988 l_rec_acct_attrs.array_num_value(9) := p_source_32;
31989 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
31990 l_rec_acct_attrs.array_num_value(10) := p_source_33;
31991 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
31992 l_rec_acct_attrs.array_char_value(11) := p_source_34;
31993
31994 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
31995 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
31996
31997 ---------------------------------------------------------------------------------------------------------------
31998 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
31999 ---------------------------------------------------------------------------------------------------------------
32000 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
32001
32002 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
32003 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
32004
32005 IF xla_accounting_cache_pkg.GetValueChar
32006 (p_source_code => 'LEDGER_CATEGORY_CODE'
32007 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
32008 AND l_bflow_method_code = 'PRIOR_ENTRY'
32009 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
32010 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
32011 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
32012 )
32013 THEN
32014 xla_ae_lines_pkg.BflowUpgEntry
32015 (p_business_method_code => l_bflow_method_code
32016 ,p_business_class_code => l_bflow_class_code
32017 ,p_balance_type => l_balance_type_code);
32018 ELSE
32019 NULL;
32020 -- No business flow processing for business flow method of NONE.
32021 END IF;
32022
32023 --
32024 -- call analytical criteria
32025 --
32026
32027 --
32028 -- call description
32029 --
32030 -- No description or it is inherited.
32031 --
32032 -- call ADRs
32033 -- Bug 4922099
32034 --
32035 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
32036 (NVL(l_actual_upg_option, 'N') = 'O') OR
32037 (NVL(l_enc_upg_option, 'N') = 'O')
32038 )
32039 THEN
32040 NULL;
32041 --
32042 --
32043
32044 l_ccid := AcctDerRule_34(
32045 p_application_id => p_application_id
32046 , p_ae_header_id => l_ae_header_id
32047 , p_source_21 => p_source_21
32048 , x_transaction_coa_id => l_adr_transaction_coa_id
32049 , x_accounting_coa_id => l_adr_accounting_coa_id
32050 , x_value_type_code => l_adr_value_type_code
32051 , p_side => 'NA'
32052 );
32053
32054 xla_ae_lines_pkg.set_ccid(
32055 p_code_combination_id => l_ccid
32056 , p_value_type_code => l_adr_value_type_code
32057 , p_transaction_coa_id => l_adr_transaction_coa_id
32058 , p_accounting_coa_id => l_adr_accounting_coa_id
32059 , p_adr_code => 'TRX_DIST_CCID'
32060 , p_adr_type_code => 'S'
32061 , p_component_type => l_component_type
32062 , p_component_code => l_component_code
32063 , p_component_type_code => l_component_type_code
32064 , p_component_appl_id => l_component_appl_id
32065 , p_amb_context_code => l_amb_context_code
32066 , p_side => 'NA'
32067 );
32068
32069
32070 --
32071 --
32072 END IF;
32073 --
32074 -- Bug 4922099
32078 (l_bflow_method_code = 'PRIOR_ENTRY')
32075 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
32076 (NVL(l_enc_upg_option, 'N') = 'O')
32077 ) AND
32079 )
32080 THEN
32081 IF
32082 --
32083 1 = 2
32084 --
32085 THEN
32086 xla_accounting_err_pkg.build_message
32087 (p_appli_s_name => 'XLA'
32088 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32089 ,p_token_1 => 'LINE_NUMBER'
32090 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
32091 ,p_token_2 => 'LINE_TYPE_NAME'
32092 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
32093 l_component_type
32094 ,l_component_code
32095 ,l_component_type_code
32096 ,l_component_appl_id
32097 ,l_amb_context_code
32098 ,l_entity_code
32099 ,l_event_class_code
32100 )
32101 ,p_token_3 => 'OWNER'
32102 ,p_value_3 => xla_lookups_pkg.get_meaning(
32103 p_lookup_type => 'XLA_OWNER_TYPE'
32104 ,p_lookup_code => l_component_type_code
32105 )
32106 ,p_token_4 => 'PRODUCT_NAME'
32107 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
32108 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
32109 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
32110 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
32111 ,p_ae_header_id => NULL
32112 );
32113
32114 IF (C_LEVEL_ERROR>= g_log_level) THEN
32115 trace
32116 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32117 ,p_level => C_LEVEL_ERROR
32118 ,p_module => l_log_module);
32119 END IF;
32120 END IF;
32121 END IF;
32122 --
32123 --
32124 ------------------------------------------------------------------------------------------------
32125 -- 4219869 Business Flow
32126 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
32127 -- Prior Entry. Currently, the following code is always generated.
32128 ------------------------------------------------------------------------------------------------
32129 XLA_AE_LINES_PKG.ValidateCurrentLine;
32130
32131 ------------------------------------------------------------------------------------
32132 -- 4219869 Business Flow
32133 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
32134 ------------------------------------------------------------------------------------
32135 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32136
32137 ----------------------------------------------------------------------------------
32138 -- 4219869 Business Flow
32139 -- Update journal entry status -- Need to generate this within IF <condition>
32140 ----------------------------------------------------------------------------------
32141 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32142 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
32143 ,p_balance_type_code => l_balance_type_code
32144 );
32145
32146 -------------------------------------------------------------------------------------------
32147 -- 4262811 - Generate the Accrual Reversal lines
32148 -------------------------------------------------------------------------------------------
32149 BEGIN
32150 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
32151 (g_array_event(p_event_id).array_value_num('header_index'));
32152 IF l_acc_rev_flag IS NULL THEN
32153 l_acc_rev_flag := 'N';
32154 END IF;
32155 EXCEPTION
32156 WHEN OTHERS THEN
32157 l_acc_rev_flag := 'N';
32158 END;
32159 --
32160 IF (l_acc_rev_flag = 'Y') THEN
32161
32162 -- 4645092 ------------------------------------------------------------------------------
32163 -- To allow MPA report to determine if it should generate report process
32164 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
32165 ------------------------------------------------------------------------------------------
32166
32170 -- call ADRs
32167 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
32168 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
32169 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
32171 -- Bug 4922099
32172 --
32173 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
32174 (NVL(l_actual_upg_option, 'N') = 'O') OR
32175 (NVL(l_enc_upg_option, 'N') = 'O')
32176 )
32177 THEN
32178 NULL;
32179 --
32180 --
32181
32182 l_ccid := AcctDerRule_34(
32183 p_application_id => p_application_id
32184 , p_ae_header_id => l_ae_header_id
32185 , p_source_21 => p_source_21
32186 , x_transaction_coa_id => l_adr_transaction_coa_id
32187 , x_accounting_coa_id => l_adr_accounting_coa_id
32188 , x_value_type_code => l_adr_value_type_code
32189 , p_side => 'NA'
32190 );
32191
32192 xla_ae_lines_pkg.set_ccid(
32193 p_code_combination_id => l_ccid
32194 , p_value_type_code => l_adr_value_type_code
32195 , p_transaction_coa_id => l_adr_transaction_coa_id
32196 , p_accounting_coa_id => l_adr_accounting_coa_id
32197 , p_adr_code => 'TRX_DIST_CCID'
32198 , p_adr_type_code => 'S'
32199 , p_component_type => l_component_type
32200 , p_component_code => l_component_code
32201 , p_component_type_code => l_component_type_code
32202 , p_component_appl_id => l_component_appl_id
32203 , p_amb_context_code => l_amb_context_code
32204 , p_side => 'NA'
32205 );
32206
32207
32208 --
32209 --
32210 END IF;
32211
32212 --
32213 -- Update the line information that should be overwritten
32214 --
32215 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
32216 p_header_num => 1);
32217 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
32218
32219 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
32220
32221 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
32222 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
32223 END IF;
32224
32225 --
32226 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
32227 --
32228 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
32229 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
32230 ELSE
32231 ---------------------------------------------------------------------------------------------------
32232 -- 4262811a Switch Sign
32233 ---------------------------------------------------------------------------------------------------
32234 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
32235 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32236 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32237 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32238 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32239 -- 5132302
32240 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
32241 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32242
32243 END IF;
32244
32245 -- 4955764
32246 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
32247 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
32248
32249
32250 XLA_AE_LINES_PKG.ValidateCurrentLine;
32251 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32252
32253 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32254 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
32255 ,p_balance_type_code => l_balance_type_code);
32256
32257 END IF;
32258
32259 -----------------------------------------------------------------------------------------
32260 -- 4262811 Multiperiod Accounting
32261 -----------------------------------------------------------------------------------------
32262 -- No MPA option is assigned.
32263
32264
32265 END IF;
32266 END IF;
32267 --
32268
32269 --
32270 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32271 trace
32272 (p_msg => 'END of AcctLineType_79'
32273 ,p_level => C_LEVEL_PROCEDURE
32274 ,p_module => l_log_module);
32275 END IF;
32276 --
32277 EXCEPTION
32278 WHEN xla_exceptions_pkg.application_exception THEN
32279 RAISE;
32280 WHEN OTHERS THEN
32281 xla_exceptions_pkg.raise_message
32282 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_79');
32283 END AcctLineType_79;
32284 --
32285
32289 -- AcctLineType_80
32286 ---------------------------------------
32287 --
32288 -- PRIVATE FUNCTION
32290 --
32291 ---------------------------------------
32292 PROCEDURE AcctLineType_80 (
32293 p_application_id IN NUMBER
32294 ,p_event_id IN NUMBER
32295 ,p_calculate_acctd_flag IN VARCHAR2
32296 ,p_calculate_g_l_flag IN VARCHAR2
32297 ,p_actual_flag IN OUT VARCHAR2
32298 ,p_balance_type_code OUT VARCHAR2
32299 ,p_gain_or_loss_ref OUT VARCHAR2
32300
32301 --Transaction Distribution GL Account
32302 , p_source_21 IN NUMBER
32303 --Bill To Customer Account Identifier
32304 , p_source_32 IN NUMBER
32305 --Bill To Customer Site Use Identifier
32306 , p_source_33 IN NUMBER
32307 --SLA Party Type
32308 , p_source_34 IN VARCHAR2
32309 --Transaction Distribution Account Class
32310 , p_source_35 IN VARCHAR2
32311 --Transaction Distribution Identifier
32312 , p_source_36 IN NUMBER
32313 --Transaction Distribution Type
32314 , p_source_37 IN VARCHAR2
32315 --Transaction Distribution Entered Amount
32316 , p_source_38 IN NUMBER
32317 --Transaction Currency Code
32318 , p_source_39 IN VARCHAR2
32319 --Transaction Exchange Date
32320 , p_source_40 IN DATE
32321 --Transaction Exchange Rate
32322 , p_source_41 IN NUMBER
32323 --Transaction Exchange Rate Type
32324 , p_source_42 IN VARCHAR2
32325 --Transaction Accounting Amount
32326 , p_source_43 IN NUMBER
32327 --Transaction Tax Line Identifier
32328 , p_source_57 IN NUMBER
32329 )
32330 IS
32331
32332 l_component_type VARCHAR2(80);
32333 l_component_code VARCHAR2(30);
32334 l_component_type_code VARCHAR2(1);
32335 l_component_appl_id INTEGER;
32336 l_amb_context_code VARCHAR2(30);
32337 l_entity_code VARCHAR2(30);
32338 l_event_class_code VARCHAR2(30);
32339 l_ae_header_id NUMBER;
32340 l_event_type_code VARCHAR2(30);
32341 l_line_definition_code VARCHAR2(30);
32342 l_line_definition_owner_code VARCHAR2(1);
32343 --
32344 -- adr variables
32345 l_segment VARCHAR2(30);
32346 l_ccid NUMBER;
32347 l_adr_transaction_coa_id NUMBER;
32348 l_adr_accounting_coa_id NUMBER;
32349 l_adr_flexfield_segment_code VARCHAR2(30);
32350 l_adr_flex_value_set_id NUMBER;
32351 l_adr_value_type_code VARCHAR2(30);
32352 l_adr_value_combination_id NUMBER;
32353 l_adr_value_segment_code VARCHAR2(30);
32354
32355 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
32356 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
32357 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
32358 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
32359
32360 -- 4262811 Variables ------------------------------------------------------------------------------------------
32361 l_entered_amt_idx NUMBER;
32362 l_accted_amt_idx NUMBER;
32363 l_acc_rev_flag VARCHAR2(1);
32364 l_accrual_line_num NUMBER;
32365 l_tmp_amt NUMBER;
32366 l_acc_rev_natural_side_code VARCHAR2(1);
32367
32368 l_num_entries NUMBER;
32369 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
32370 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
32371 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
32372 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
32373 l_recog_line_1 NUMBER;
32374 l_recog_line_2 NUMBER;
32375
32376 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
32377 l_bflow_applied_to_amt NUMBER; -- 5132302
32378 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
32379
32380 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
32381
32382 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
32383 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
32384
32385 ---------------------------------------------------------------------------------------------------------------
32386
32387
32388 --
32389 -- bulk performance
32390 --
32391 l_balance_type_code VARCHAR2(1);
32392 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
32393 l_log_module VARCHAR2(240);
32394
32395 --
32396 -- Upgrade strategy
32397 --
32398 l_actual_upg_option VARCHAR2(1);
32399 l_enc_upg_option VARCHAR2(1);
32400
32401 --
32402 BEGIN
32403 --
32404 IF g_log_enabled THEN
32405 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_80';
32406 END IF;
32407 --
32408 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32409
32410 trace
32411 (p_msg => 'BEGIN of AcctLineType_80'
32412 ,p_level => C_LEVEL_PROCEDURE
32413 ,p_module => l_log_module);
32414
32415 END IF;
32416 --
32417 l_component_type := 'AMB_JLT';
32418 l_component_code := 'INV_CHARGES';
32419 l_component_type_code := 'S';
32420 l_component_appl_id := 222;
32424 l_event_type_code := 'INVOICE_ALL';
32421 l_amb_context_code := 'DEFAULT';
32422 l_entity_code := 'TRANSACTIONS';
32423 l_event_class_code := 'INVOICE';
32425 l_line_definition_owner_code := 'S';
32426 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
32427 --
32428 l_balance_type_code := 'A';
32429 l_segment := NULL;
32430 l_ccid := NULL;
32431 l_adr_transaction_coa_id := NULL;
32432 l_adr_accounting_coa_id := NULL;
32433 l_adr_flexfield_segment_code := NULL;
32434 l_adr_flex_value_set_id := NULL;
32435 l_adr_value_type_code := NULL;
32436 l_adr_value_combination_id := NULL;
32437 l_adr_value_segment_code := NULL;
32438
32439 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
32440 l_bflow_class_code := ''; -- 4219869 Business Flow
32441 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
32442 l_budgetary_control_flag := 'N';
32443
32444 l_bflow_applied_to_amt_idx := NULL; -- 5132302
32445 l_bflow_applied_to_amt := NULL; -- 5132302
32446 l_entered_amt_idx := NULL; -- 4262811
32447 l_accted_amt_idx := NULL; -- 4262811
32448 l_acc_rev_flag := NULL; -- 4262811
32449 l_accrual_line_num := NULL; -- 4262811
32450 l_tmp_amt := NULL; -- 4262811
32451 --
32452
32453 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
32454 l_balance_type_code <> 'B' THEN
32455 IF NVL(p_source_35,'
32456 ') = 'CHARGES'
32457 THEN
32458
32459 --
32460 XLA_AE_LINES_PKG.SetNewLine;
32461
32462 p_balance_type_code := l_balance_type_code;
32463 -- set the flag so later we will know whether the gain loss line needs to be created
32464
32465 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
32466 p_actual_flag :='A';
32467 END IF;
32468
32469 --
32470 -- bulk performance
32471 --
32472 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
32473 p_header_num => 0); -- 4262811
32474 --
32475 -- set accounting line options
32476 --
32477 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
32478 p_natural_side_code => 'C'
32479 , p_gain_or_loss_flag => 'N'
32480 , p_gl_transfer_mode_code => 'S'
32481 , p_acct_entry_type_code => 'A'
32482 , p_switch_side_flag => 'Y'
32483 , p_merge_duplicate_code => 'A'
32484 );
32485 --
32486 l_acc_rev_natural_side_code := 'D'; -- 4262811
32487 --
32488 --
32489 -- set accounting line type info
32490 --
32491 xla_ae_lines_pkg.SetAcctLineType
32492 (p_component_type => l_component_type
32493 ,p_event_type_code => l_event_type_code
32494 ,p_line_definition_owner_code => l_line_definition_owner_code
32495 ,p_line_definition_code => l_line_definition_code
32496 ,p_accounting_line_code => l_component_code
32497 ,p_accounting_line_type_code => l_component_type_code
32498 ,p_accounting_line_appl_id => l_component_appl_id
32499 ,p_amb_context_code => l_amb_context_code
32500 ,p_entity_code => l_entity_code
32501 ,p_event_class_code => l_event_class_code);
32502 --
32503 -- set accounting class
32504 --
32505 xla_ae_lines_pkg.SetAcctClass(
32506 p_accounting_class_code => 'CHARGES'
32507 , p_ae_header_id => l_ae_header_id
32508 );
32509
32510 --
32511 -- set rounding class
32512 --
32513 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
32514 'RECEIVABLE';
32515
32516 --
32517 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
32518 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
32519 --
32520 -- bulk performance
32521 --
32522 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
32523
32524 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
32525 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
32526
32527 -- 4955764
32528 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
32529 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
32530
32531 -- 4458381 Public Sector Enh
32532
32533 --
32534 -- set accounting attributes for the line type
32535 --
32536 l_entered_amt_idx := 3;
32537 l_accted_amt_idx := 8;
32538 l_bflow_applied_to_amt_idx := NULL; -- 5132302
32539 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
32540 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
32541 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
32542 l_rec_acct_attrs.array_char_value(2) := p_source_37;
32543 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
32544 l_rec_acct_attrs.array_num_value(3) := p_source_38;
32548 l_rec_acct_attrs.array_date_value(5) := p_source_40;
32545 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
32546 l_rec_acct_attrs.array_char_value(4) := p_source_39;
32547 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
32549 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
32550 l_rec_acct_attrs.array_num_value(6) := p_source_41;
32551 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
32552 l_rec_acct_attrs.array_char_value(7) := p_source_42;
32553 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
32554 l_rec_acct_attrs.array_num_value(8) := p_source_43;
32555 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
32556 l_rec_acct_attrs.array_num_value(9) := p_source_32;
32557 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
32558 l_rec_acct_attrs.array_num_value(10) := p_source_33;
32559 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
32560 l_rec_acct_attrs.array_char_value(11) := p_source_34;
32561 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
32562 l_rec_acct_attrs.array_num_value(12) := p_source_57;
32563
32564 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
32565 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
32566
32567 ---------------------------------------------------------------------------------------------------------------
32568 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
32569 ---------------------------------------------------------------------------------------------------------------
32570 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
32571
32572 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
32573 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
32574
32575 IF xla_accounting_cache_pkg.GetValueChar
32576 (p_source_code => 'LEDGER_CATEGORY_CODE'
32577 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
32578 AND l_bflow_method_code = 'PRIOR_ENTRY'
32579 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
32580 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
32581 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
32582 )
32583 THEN
32584 xla_ae_lines_pkg.BflowUpgEntry
32585 (p_business_method_code => l_bflow_method_code
32586 ,p_business_class_code => l_bflow_class_code
32587 ,p_balance_type => l_balance_type_code);
32588 ELSE
32589 NULL;
32590 -- No business flow processing for business flow method of NONE.
32591 END IF;
32592
32593 --
32594 -- call analytical criteria
32595 --
32596
32597 --
32598 -- call description
32599 --
32600 -- No description or it is inherited.
32601 --
32602 -- call ADRs
32603 -- Bug 4922099
32604 --
32605 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
32606 (NVL(l_actual_upg_option, 'N') = 'O') OR
32607 (NVL(l_enc_upg_option, 'N') = 'O')
32608 )
32609 THEN
32610 NULL;
32611 --
32612 --
32613
32614 l_ccid := AcctDerRule_34(
32615 p_application_id => p_application_id
32616 , p_ae_header_id => l_ae_header_id
32617 , p_source_21 => p_source_21
32618 , x_transaction_coa_id => l_adr_transaction_coa_id
32619 , x_accounting_coa_id => l_adr_accounting_coa_id
32620 , x_value_type_code => l_adr_value_type_code
32621 , p_side => 'NA'
32622 );
32623
32624 xla_ae_lines_pkg.set_ccid(
32625 p_code_combination_id => l_ccid
32626 , p_value_type_code => l_adr_value_type_code
32627 , p_transaction_coa_id => l_adr_transaction_coa_id
32628 , p_accounting_coa_id => l_adr_accounting_coa_id
32629 , p_adr_code => 'TRX_DIST_CCID'
32630 , p_adr_type_code => 'S'
32631 , p_component_type => l_component_type
32632 , p_component_code => l_component_code
32633 , p_component_type_code => l_component_type_code
32634 , p_component_appl_id => l_component_appl_id
32635 , p_amb_context_code => l_amb_context_code
32636 , p_side => 'NA'
32637 );
32638
32639
32640 --
32641 --
32642 END IF;
32643 --
32644 -- Bug 4922099
32645 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
32646 (NVL(l_enc_upg_option, 'N') = 'O')
32647 ) AND
32648 (l_bflow_method_code = 'PRIOR_ENTRY')
32649 )
32650 THEN
32651 IF
32652 --
32653 1 = 2
32654 --
32655 THEN
32656 xla_accounting_err_pkg.build_message
32657 (p_appli_s_name => 'XLA'
32658 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32659 ,p_token_1 => 'LINE_NUMBER'
32660 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
32664 ,l_component_code
32661 ,p_token_2 => 'LINE_TYPE_NAME'
32662 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
32663 l_component_type
32665 ,l_component_type_code
32666 ,l_component_appl_id
32667 ,l_amb_context_code
32668 ,l_entity_code
32669 ,l_event_class_code
32670 )
32671 ,p_token_3 => 'OWNER'
32672 ,p_value_3 => xla_lookups_pkg.get_meaning(
32673 p_lookup_type => 'XLA_OWNER_TYPE'
32674 ,p_lookup_code => l_component_type_code
32675 )
32676 ,p_token_4 => 'PRODUCT_NAME'
32677 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
32678 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
32679 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
32680 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
32681 ,p_ae_header_id => NULL
32682 );
32683
32684 IF (C_LEVEL_ERROR>= g_log_level) THEN
32685 trace
32686 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32687 ,p_level => C_LEVEL_ERROR
32688 ,p_module => l_log_module);
32689 END IF;
32690 END IF;
32691 END IF;
32692 --
32693 --
32694 ------------------------------------------------------------------------------------------------
32695 -- 4219869 Business Flow
32696 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
32697 -- Prior Entry. Currently, the following code is always generated.
32698 ------------------------------------------------------------------------------------------------
32699 XLA_AE_LINES_PKG.ValidateCurrentLine;
32700
32701 ------------------------------------------------------------------------------------
32702 -- 4219869 Business Flow
32703 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
32704 ------------------------------------------------------------------------------------
32705 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32706
32707 ----------------------------------------------------------------------------------
32708 -- 4219869 Business Flow
32709 -- Update journal entry status -- Need to generate this within IF <condition>
32710 ----------------------------------------------------------------------------------
32711 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32712 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
32713 ,p_balance_type_code => l_balance_type_code
32714 );
32715
32716 -------------------------------------------------------------------------------------------
32717 -- 4262811 - Generate the Accrual Reversal lines
32718 -------------------------------------------------------------------------------------------
32719 BEGIN
32720 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
32721 (g_array_event(p_event_id).array_value_num('header_index'));
32722 IF l_acc_rev_flag IS NULL THEN
32723 l_acc_rev_flag := 'N';
32724 END IF;
32725 EXCEPTION
32726 WHEN OTHERS THEN
32727 l_acc_rev_flag := 'N';
32728 END;
32729 --
32730 IF (l_acc_rev_flag = 'Y') THEN
32731
32732 -- 4645092 ------------------------------------------------------------------------------
32733 -- To allow MPA report to determine if it should generate report process
32734 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
32735 ------------------------------------------------------------------------------------------
32736
32737 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
32738 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
32739 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
32740 -- call ADRs
32741 -- Bug 4922099
32742 --
32743 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
32744 (NVL(l_actual_upg_option, 'N') = 'O') OR
32745 (NVL(l_enc_upg_option, 'N') = 'O')
32746 )
32747 THEN
32748 NULL;
32749 --
32750 --
32751
32752 l_ccid := AcctDerRule_34(
32753 p_application_id => p_application_id
32754 , p_ae_header_id => l_ae_header_id
32755 , p_source_21 => p_source_21
32759 , p_side => 'NA'
32756 , x_transaction_coa_id => l_adr_transaction_coa_id
32757 , x_accounting_coa_id => l_adr_accounting_coa_id
32758 , x_value_type_code => l_adr_value_type_code
32760 );
32761
32762 xla_ae_lines_pkg.set_ccid(
32763 p_code_combination_id => l_ccid
32764 , p_value_type_code => l_adr_value_type_code
32765 , p_transaction_coa_id => l_adr_transaction_coa_id
32766 , p_accounting_coa_id => l_adr_accounting_coa_id
32767 , p_adr_code => 'TRX_DIST_CCID'
32768 , p_adr_type_code => 'S'
32769 , p_component_type => l_component_type
32770 , p_component_code => l_component_code
32771 , p_component_type_code => l_component_type_code
32772 , p_component_appl_id => l_component_appl_id
32773 , p_amb_context_code => l_amb_context_code
32774 , p_side => 'NA'
32775 );
32776
32777
32778 --
32779 --
32780 END IF;
32781
32782 --
32783 -- Update the line information that should be overwritten
32784 --
32785 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
32786 p_header_num => 1);
32787 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
32788
32789 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
32790
32791 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
32792 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
32793 END IF;
32794
32795 --
32796 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
32797 --
32798 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
32799 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
32800 ELSE
32801 ---------------------------------------------------------------------------------------------------
32802 -- 4262811a Switch Sign
32803 ---------------------------------------------------------------------------------------------------
32804 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
32805 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32806 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32807 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32808 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32809 -- 5132302
32810 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
32811 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32812
32813 END IF;
32814
32815 -- 4955764
32816 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
32817 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
32818
32819
32820 XLA_AE_LINES_PKG.ValidateCurrentLine;
32821 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32822
32823 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32824 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
32825 ,p_balance_type_code => l_balance_type_code);
32826
32827 END IF;
32828
32829 -----------------------------------------------------------------------------------------
32830 -- 4262811 Multiperiod Accounting
32831 -----------------------------------------------------------------------------------------
32832 -- No MPA option is assigned.
32833
32834
32835 END IF;
32836 END IF;
32837 --
32838
32839 --
32840 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32841 trace
32842 (p_msg => 'END of AcctLineType_80'
32843 ,p_level => C_LEVEL_PROCEDURE
32844 ,p_module => l_log_module);
32845 END IF;
32846 --
32847 EXCEPTION
32848 WHEN xla_exceptions_pkg.application_exception THEN
32849 RAISE;
32850 WHEN OTHERS THEN
32851 xla_exceptions_pkg.raise_message
32852 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_80');
32853 END AcctLineType_80;
32854 --
32855
32856 ---------------------------------------
32857 --
32858 -- PRIVATE FUNCTION
32859 -- AcctLineType_81
32860 --
32861 ---------------------------------------
32862 PROCEDURE AcctLineType_81 (
32863 p_application_id IN NUMBER
32864 ,p_event_id IN NUMBER
32865 ,p_calculate_acctd_flag IN VARCHAR2
32866 ,p_calculate_g_l_flag IN VARCHAR2
32867 ,p_actual_flag IN OUT VARCHAR2
32868 ,p_balance_type_code OUT VARCHAR2
32869 ,p_gain_or_loss_ref OUT VARCHAR2
32870
32871 --Transaction Distribution GL Account
32872 , p_source_21 IN NUMBER
32873 --Bill To Customer Account Identifier
32874 , p_source_32 IN NUMBER
32875 --Bill To Customer Site Use Identifier
32879 --Transaction Distribution Account Class
32876 , p_source_33 IN NUMBER
32877 --SLA Party Type
32878 , p_source_34 IN VARCHAR2
32880 , p_source_35 IN VARCHAR2
32881 --Transaction Distribution Identifier
32882 , p_source_36 IN NUMBER
32883 --Transaction Distribution Type
32884 , p_source_37 IN VARCHAR2
32885 --Transaction Distribution Entered Amount
32886 , p_source_38 IN NUMBER
32887 --Transaction Currency Code
32888 , p_source_39 IN VARCHAR2
32889 --Transaction Exchange Date
32890 , p_source_40 IN DATE
32891 --Transaction Exchange Rate
32892 , p_source_41 IN NUMBER
32893 --Transaction Exchange Rate Type
32894 , p_source_42 IN VARCHAR2
32895 --Transaction Accounting Amount
32896 , p_source_43 IN NUMBER
32897 --Transaction Tax Line Identifier
32898 , p_source_57 IN NUMBER
32899 )
32900 IS
32901
32902 l_component_type VARCHAR2(80);
32903 l_component_code VARCHAR2(30);
32904 l_component_type_code VARCHAR2(1);
32905 l_component_appl_id INTEGER;
32906 l_amb_context_code VARCHAR2(30);
32907 l_entity_code VARCHAR2(30);
32908 l_event_class_code VARCHAR2(30);
32909 l_ae_header_id NUMBER;
32910 l_event_type_code VARCHAR2(30);
32911 l_line_definition_code VARCHAR2(30);
32912 l_line_definition_owner_code VARCHAR2(1);
32913 --
32914 -- adr variables
32915 l_segment VARCHAR2(30);
32916 l_ccid NUMBER;
32917 l_adr_transaction_coa_id NUMBER;
32918 l_adr_accounting_coa_id NUMBER;
32919 l_adr_flexfield_segment_code VARCHAR2(30);
32920 l_adr_flex_value_set_id NUMBER;
32921 l_adr_value_type_code VARCHAR2(30);
32922 l_adr_value_combination_id NUMBER;
32923 l_adr_value_segment_code VARCHAR2(30);
32924
32925 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
32926 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
32927 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
32928 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
32929
32930 -- 4262811 Variables ------------------------------------------------------------------------------------------
32931 l_entered_amt_idx NUMBER;
32932 l_accted_amt_idx NUMBER;
32933 l_acc_rev_flag VARCHAR2(1);
32934 l_accrual_line_num NUMBER;
32935 l_tmp_amt NUMBER;
32936 l_acc_rev_natural_side_code VARCHAR2(1);
32937
32938 l_num_entries NUMBER;
32939 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
32940 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
32941 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
32942 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
32943 l_recog_line_1 NUMBER;
32944 l_recog_line_2 NUMBER;
32945
32946 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
32947 l_bflow_applied_to_amt NUMBER; -- 5132302
32948 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
32949
32950 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
32951
32952 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
32953 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
32954
32955 ---------------------------------------------------------------------------------------------------------------
32956
32957
32958 --
32959 -- bulk performance
32960 --
32961 l_balance_type_code VARCHAR2(1);
32962 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
32963 l_log_module VARCHAR2(240);
32964
32965 --
32966 -- Upgrade strategy
32967 --
32968 l_actual_upg_option VARCHAR2(1);
32969 l_enc_upg_option VARCHAR2(1);
32970
32971 --
32972 BEGIN
32973 --
32974 IF g_log_enabled THEN
32975 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_81';
32976 END IF;
32977 --
32978 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32979
32980 trace
32981 (p_msg => 'BEGIN of AcctLineType_81'
32982 ,p_level => C_LEVEL_PROCEDURE
32983 ,p_module => l_log_module);
32984
32985 END IF;
32986 --
32987 l_component_type := 'AMB_JLT';
32988 l_component_code := 'INV_FREIGHT';
32989 l_component_type_code := 'S';
32990 l_component_appl_id := 222;
32991 l_amb_context_code := 'DEFAULT';
32992 l_entity_code := 'TRANSACTIONS';
32993 l_event_class_code := 'INVOICE';
32994 l_event_type_code := 'INVOICE_ALL';
32995 l_line_definition_owner_code := 'S';
32996 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
32997 --
32998 l_balance_type_code := 'A';
32999 l_segment := NULL;
33000 l_ccid := NULL;
33001 l_adr_transaction_coa_id := NULL;
33002 l_adr_accounting_coa_id := NULL;
33003 l_adr_flexfield_segment_code := NULL;
33004 l_adr_flex_value_set_id := NULL;
33005 l_adr_value_type_code := NULL;
33006 l_adr_value_combination_id := NULL;
33007 l_adr_value_segment_code := NULL;
33008
33012 l_budgetary_control_flag := 'N';
33009 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
33010 l_bflow_class_code := 'FREIGHT'; -- 4219869 Business Flow
33011 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
33013
33014 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33015 l_bflow_applied_to_amt := NULL; -- 5132302
33016 l_entered_amt_idx := NULL; -- 4262811
33017 l_accted_amt_idx := NULL; -- 4262811
33018 l_acc_rev_flag := NULL; -- 4262811
33019 l_accrual_line_num := NULL; -- 4262811
33020 l_tmp_amt := NULL; -- 4262811
33021 --
33022
33023 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
33024 l_balance_type_code <> 'B' THEN
33025 IF NVL(p_source_35,'
33026 ') = 'FREIGHT'
33027 THEN
33028
33029 --
33030 XLA_AE_LINES_PKG.SetNewLine;
33031
33032 p_balance_type_code := l_balance_type_code;
33033 -- set the flag so later we will know whether the gain loss line needs to be created
33034
33035 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
33036 p_actual_flag :='A';
33037 END IF;
33038
33039 --
33040 -- bulk performance
33041 --
33042 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
33043 p_header_num => 0); -- 4262811
33044 --
33045 -- set accounting line options
33046 --
33047 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
33048 p_natural_side_code => 'C'
33049 , p_gain_or_loss_flag => 'N'
33050 , p_gl_transfer_mode_code => 'S'
33051 , p_acct_entry_type_code => 'A'
33052 , p_switch_side_flag => 'Y'
33053 , p_merge_duplicate_code => 'A'
33054 );
33055 --
33056 l_acc_rev_natural_side_code := 'D'; -- 4262811
33057 --
33058 --
33059 -- set accounting line type info
33060 --
33061 xla_ae_lines_pkg.SetAcctLineType
33062 (p_component_type => l_component_type
33063 ,p_event_type_code => l_event_type_code
33064 ,p_line_definition_owner_code => l_line_definition_owner_code
33065 ,p_line_definition_code => l_line_definition_code
33066 ,p_accounting_line_code => l_component_code
33067 ,p_accounting_line_type_code => l_component_type_code
33068 ,p_accounting_line_appl_id => l_component_appl_id
33069 ,p_amb_context_code => l_amb_context_code
33070 ,p_entity_code => l_entity_code
33071 ,p_event_class_code => l_event_class_code);
33072 --
33073 -- set accounting class
33074 --
33075 xla_ae_lines_pkg.SetAcctClass(
33076 p_accounting_class_code => 'FREIGHT'
33077 , p_ae_header_id => l_ae_header_id
33078 );
33079
33080 --
33081 -- set rounding class
33082 --
33083 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
33084 'RECEIVABLE';
33085
33086 --
33087 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
33088 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
33089 --
33090 -- bulk performance
33091 --
33092 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
33093
33094 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
33095 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
33096
33097 -- 4955764
33098 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
33099 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
33100
33101 -- 4458381 Public Sector Enh
33102
33103 --
33104 -- set accounting attributes for the line type
33105 --
33106 l_entered_amt_idx := 3;
33107 l_accted_amt_idx := 8;
33108 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33109 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
33110 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
33111 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
33112 l_rec_acct_attrs.array_char_value(2) := p_source_37;
33113 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
33114 l_rec_acct_attrs.array_num_value(3) := p_source_38;
33115 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
33116 l_rec_acct_attrs.array_char_value(4) := p_source_39;
33117 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
33118 l_rec_acct_attrs.array_date_value(5) := p_source_40;
33119 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
33120 l_rec_acct_attrs.array_num_value(6) := p_source_41;
33121 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
33122 l_rec_acct_attrs.array_char_value(7) := p_source_42;
33123 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
33124 l_rec_acct_attrs.array_num_value(8) := p_source_43;
33125 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
33126 l_rec_acct_attrs.array_num_value(9) := p_source_32;
33130 l_rec_acct_attrs.array_char_value(11) := p_source_34;
33127 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
33128 l_rec_acct_attrs.array_num_value(10) := p_source_33;
33129 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
33131 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
33132 l_rec_acct_attrs.array_num_value(12) := p_source_57;
33133
33134 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
33135 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
33136
33137 ---------------------------------------------------------------------------------------------------------------
33138 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
33139 ---------------------------------------------------------------------------------------------------------------
33140 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
33141
33142 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33143 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33144
33145 IF xla_accounting_cache_pkg.GetValueChar
33146 (p_source_code => 'LEDGER_CATEGORY_CODE'
33147 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
33148 AND l_bflow_method_code = 'PRIOR_ENTRY'
33149 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
33150 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
33151 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
33152 )
33153 THEN
33154 xla_ae_lines_pkg.BflowUpgEntry
33155 (p_business_method_code => l_bflow_method_code
33156 ,p_business_class_code => l_bflow_class_code
33157 ,p_balance_type => l_balance_type_code);
33158 ELSE
33159 NULL;
33160 -- No business flow processing for business flow method of NONE.
33161 END IF;
33162
33163 --
33164 -- call analytical criteria
33165 --
33166
33167 --
33168 -- call description
33169 --
33170 -- No description or it is inherited.
33171 --
33172 -- call ADRs
33173 -- Bug 4922099
33174 --
33175 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33176 (NVL(l_actual_upg_option, 'N') = 'O') OR
33177 (NVL(l_enc_upg_option, 'N') = 'O')
33178 )
33179 THEN
33180 NULL;
33181 --
33182 --
33183
33184 l_ccid := AcctDerRule_34(
33185 p_application_id => p_application_id
33186 , p_ae_header_id => l_ae_header_id
33187 , p_source_21 => p_source_21
33188 , x_transaction_coa_id => l_adr_transaction_coa_id
33189 , x_accounting_coa_id => l_adr_accounting_coa_id
33190 , x_value_type_code => l_adr_value_type_code
33191 , p_side => 'NA'
33192 );
33193
33194 xla_ae_lines_pkg.set_ccid(
33195 p_code_combination_id => l_ccid
33196 , p_value_type_code => l_adr_value_type_code
33197 , p_transaction_coa_id => l_adr_transaction_coa_id
33198 , p_accounting_coa_id => l_adr_accounting_coa_id
33199 , p_adr_code => 'TRX_DIST_CCID'
33200 , p_adr_type_code => 'S'
33201 , p_component_type => l_component_type
33202 , p_component_code => l_component_code
33203 , p_component_type_code => l_component_type_code
33204 , p_component_appl_id => l_component_appl_id
33205 , p_amb_context_code => l_amb_context_code
33206 , p_side => 'NA'
33207 );
33208
33209
33210 --
33211 --
33212 END IF;
33213 --
33214 -- Bug 4922099
33215 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
33216 (NVL(l_enc_upg_option, 'N') = 'O')
33217 ) AND
33218 (l_bflow_method_code = 'PRIOR_ENTRY')
33219 )
33220 THEN
33221 IF
33222 --
33223 1 = 2
33224 --
33225 THEN
33226 xla_accounting_err_pkg.build_message
33227 (p_appli_s_name => 'XLA'
33228 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33229 ,p_token_1 => 'LINE_NUMBER'
33230 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
33231 ,p_token_2 => 'LINE_TYPE_NAME'
33232 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
33233 l_component_type
33234 ,l_component_code
33235 ,l_component_type_code
33236 ,l_component_appl_id
33237 ,l_amb_context_code
33238 ,l_entity_code
33242 ,p_value_3 => xla_lookups_pkg.get_meaning(
33239 ,l_event_class_code
33240 )
33241 ,p_token_3 => 'OWNER'
33243 p_lookup_type => 'XLA_OWNER_TYPE'
33244 ,p_lookup_code => l_component_type_code
33245 )
33246 ,p_token_4 => 'PRODUCT_NAME'
33247 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
33248 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
33249 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
33250 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
33251 ,p_ae_header_id => NULL
33252 );
33253
33254 IF (C_LEVEL_ERROR>= g_log_level) THEN
33255 trace
33256 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33257 ,p_level => C_LEVEL_ERROR
33258 ,p_module => l_log_module);
33259 END IF;
33260 END IF;
33261 END IF;
33262 --
33263 --
33264 ------------------------------------------------------------------------------------------------
33265 -- 4219869 Business Flow
33266 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
33267 -- Prior Entry. Currently, the following code is always generated.
33268 ------------------------------------------------------------------------------------------------
33269 XLA_AE_LINES_PKG.ValidateCurrentLine;
33270
33271 ------------------------------------------------------------------------------------
33272 -- 4219869 Business Flow
33273 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
33274 ------------------------------------------------------------------------------------
33275 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33276
33277 ----------------------------------------------------------------------------------
33278 -- 4219869 Business Flow
33279 -- Update journal entry status -- Need to generate this within IF <condition>
33280 ----------------------------------------------------------------------------------
33281 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33282 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
33283 ,p_balance_type_code => l_balance_type_code
33284 );
33285
33286 -------------------------------------------------------------------------------------------
33287 -- 4262811 - Generate the Accrual Reversal lines
33288 -------------------------------------------------------------------------------------------
33289 BEGIN
33290 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
33291 (g_array_event(p_event_id).array_value_num('header_index'));
33292 IF l_acc_rev_flag IS NULL THEN
33293 l_acc_rev_flag := 'N';
33294 END IF;
33295 EXCEPTION
33296 WHEN OTHERS THEN
33297 l_acc_rev_flag := 'N';
33298 END;
33299 --
33300 IF (l_acc_rev_flag = 'Y') THEN
33301
33302 -- 4645092 ------------------------------------------------------------------------------
33303 -- To allow MPA report to determine if it should generate report process
33304 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
33305 ------------------------------------------------------------------------------------------
33306
33307 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
33308 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
33309 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
33310 -- call ADRs
33311 -- Bug 4922099
33312 --
33313 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33314 (NVL(l_actual_upg_option, 'N') = 'O') OR
33315 (NVL(l_enc_upg_option, 'N') = 'O')
33316 )
33317 THEN
33318 NULL;
33319 --
33320 --
33321
33322 l_ccid := AcctDerRule_34(
33323 p_application_id => p_application_id
33324 , p_ae_header_id => l_ae_header_id
33325 , p_source_21 => p_source_21
33326 , x_transaction_coa_id => l_adr_transaction_coa_id
33327 , x_accounting_coa_id => l_adr_accounting_coa_id
33328 , x_value_type_code => l_adr_value_type_code
33329 , p_side => 'NA'
33330 );
33331
33332 xla_ae_lines_pkg.set_ccid(
33333 p_code_combination_id => l_ccid
33334 , p_value_type_code => l_adr_value_type_code
33335 , p_transaction_coa_id => l_adr_transaction_coa_id
33336 , p_accounting_coa_id => l_adr_accounting_coa_id
33337 , p_adr_code => 'TRX_DIST_CCID'
33338 , p_adr_type_code => 'S'
33339 , p_component_type => l_component_type
33343 , p_amb_context_code => l_amb_context_code
33340 , p_component_code => l_component_code
33341 , p_component_type_code => l_component_type_code
33342 , p_component_appl_id => l_component_appl_id
33344 , p_side => 'NA'
33345 );
33346
33347
33348 --
33349 --
33350 END IF;
33351
33352 --
33353 -- Update the line information that should be overwritten
33354 --
33355 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
33356 p_header_num => 1);
33357 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
33358
33359 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
33360
33361 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
33362 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
33363 END IF;
33364
33365 --
33366 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
33367 --
33368 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
33369 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
33370 ELSE
33371 ---------------------------------------------------------------------------------------------------
33372 -- 4262811a Switch Sign
33373 ---------------------------------------------------------------------------------------------------
33374 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
33375 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
33376 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33377 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
33378 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33379 -- 5132302
33380 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
33381 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33382
33383 END IF;
33384
33385 -- 4955764
33386 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
33387 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
33388
33389
33390 XLA_AE_LINES_PKG.ValidateCurrentLine;
33391 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33392
33393 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33394 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
33395 ,p_balance_type_code => l_balance_type_code);
33396
33397 END IF;
33398
33399 -----------------------------------------------------------------------------------------
33400 -- 4262811 Multiperiod Accounting
33401 -----------------------------------------------------------------------------------------
33402 -- No MPA option is assigned.
33403
33404
33405 END IF;
33406 END IF;
33407 --
33408
33409 --
33410 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33411 trace
33412 (p_msg => 'END of AcctLineType_81'
33413 ,p_level => C_LEVEL_PROCEDURE
33414 ,p_module => l_log_module);
33415 END IF;
33416 --
33417 EXCEPTION
33418 WHEN xla_exceptions_pkg.application_exception THEN
33419 RAISE;
33420 WHEN OTHERS THEN
33421 xla_exceptions_pkg.raise_message
33422 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_81');
33423 END AcctLineType_81;
33424 --
33425
33426 ---------------------------------------
33427 --
33428 -- PRIVATE FUNCTION
33429 -- AcctLineType_82
33430 --
33431 ---------------------------------------
33432 PROCEDURE AcctLineType_82 (
33433 p_application_id IN NUMBER
33434 ,p_event_id IN NUMBER
33435 ,p_calculate_acctd_flag IN VARCHAR2
33436 ,p_calculate_g_l_flag IN VARCHAR2
33437 ,p_actual_flag IN OUT VARCHAR2
33438 ,p_balance_type_code OUT VARCHAR2
33439 ,p_gain_or_loss_ref OUT VARCHAR2
33440
33441 --Transaction Distribution GL Account
33442 , p_source_21 IN NUMBER
33443 --Bill To Customer Account Identifier
33444 , p_source_32 IN NUMBER
33445 --Bill To Customer Site Use Identifier
33446 , p_source_33 IN NUMBER
33447 --SLA Party Type
33448 , p_source_34 IN VARCHAR2
33449 --Transaction Distribution Account Class
33450 , p_source_35 IN VARCHAR2
33451 --Transaction Distribution Identifier
33452 , p_source_36 IN NUMBER
33453 --Transaction Distribution Type
33454 , p_source_37 IN VARCHAR2
33455 --Transaction Distribution Entered Amount
33456 , p_source_38 IN NUMBER
33457 --Transaction Currency Code
33458 , p_source_39 IN VARCHAR2
33459 --Transaction Exchange Date
33460 , p_source_40 IN DATE
33461 --Transaction Exchange Rate
33462 , p_source_41 IN NUMBER
33463 --Transaction Exchange Rate Type
33464 , p_source_42 IN VARCHAR2
33465 --Transaction Accounting Amount
33469 --Rounding Correction Flag
33466 , p_source_43 IN NUMBER
33467 --Transaction Tax Line Identifier
33468 , p_source_57 IN NUMBER
33470 , p_source_68 IN VARCHAR2
33471 )
33472 IS
33473
33474 l_component_type VARCHAR2(80);
33475 l_component_code VARCHAR2(30);
33476 l_component_type_code VARCHAR2(1);
33477 l_component_appl_id INTEGER;
33478 l_amb_context_code VARCHAR2(30);
33479 l_entity_code VARCHAR2(30);
33480 l_event_class_code VARCHAR2(30);
33481 l_ae_header_id NUMBER;
33482 l_event_type_code VARCHAR2(30);
33483 l_line_definition_code VARCHAR2(30);
33484 l_line_definition_owner_code VARCHAR2(1);
33485 --
33486 -- adr variables
33487 l_segment VARCHAR2(30);
33488 l_ccid NUMBER;
33489 l_adr_transaction_coa_id NUMBER;
33490 l_adr_accounting_coa_id NUMBER;
33491 l_adr_flexfield_segment_code VARCHAR2(30);
33492 l_adr_flex_value_set_id NUMBER;
33493 l_adr_value_type_code VARCHAR2(30);
33494 l_adr_value_combination_id NUMBER;
33495 l_adr_value_segment_code VARCHAR2(30);
33496
33497 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
33498 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
33499 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
33500 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
33501
33502 -- 4262811 Variables ------------------------------------------------------------------------------------------
33503 l_entered_amt_idx NUMBER;
33504 l_accted_amt_idx NUMBER;
33505 l_acc_rev_flag VARCHAR2(1);
33506 l_accrual_line_num NUMBER;
33507 l_tmp_amt NUMBER;
33508 l_acc_rev_natural_side_code VARCHAR2(1);
33509
33510 l_num_entries NUMBER;
33511 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
33512 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
33513 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
33514 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
33515 l_recog_line_1 NUMBER;
33516 l_recog_line_2 NUMBER;
33517
33518 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
33519 l_bflow_applied_to_amt NUMBER; -- 5132302
33520 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
33521
33522 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
33523
33524 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
33525 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
33526
33527 ---------------------------------------------------------------------------------------------------------------
33528
33529
33530 --
33531 -- bulk performance
33532 --
33533 l_balance_type_code VARCHAR2(1);
33534 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
33535 l_log_module VARCHAR2(240);
33536
33537 --
33538 -- Upgrade strategy
33539 --
33540 l_actual_upg_option VARCHAR2(1);
33541 l_enc_upg_option VARCHAR2(1);
33542
33543 --
33544 BEGIN
33545 --
33546 IF g_log_enabled THEN
33547 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_82';
33548 END IF;
33549 --
33550 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33551
33552 trace
33553 (p_msg => 'BEGIN of AcctLineType_82'
33554 ,p_level => C_LEVEL_PROCEDURE
33555 ,p_module => l_log_module);
33556
33557 END IF;
33558 --
33559 l_component_type := 'AMB_JLT';
33560 l_component_code := 'INV_REV';
33561 l_component_type_code := 'S';
33562 l_component_appl_id := 222;
33563 l_amb_context_code := 'DEFAULT';
33564 l_entity_code := 'TRANSACTIONS';
33565 l_event_class_code := 'INVOICE';
33566 l_event_type_code := 'INVOICE_ALL';
33567 l_line_definition_owner_code := 'S';
33568 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
33569 --
33570 l_balance_type_code := 'A';
33571 l_segment := NULL;
33572 l_ccid := NULL;
33573 l_adr_transaction_coa_id := NULL;
33574 l_adr_accounting_coa_id := NULL;
33575 l_adr_flexfield_segment_code := NULL;
33576 l_adr_flex_value_set_id := NULL;
33577 l_adr_value_type_code := NULL;
33578 l_adr_value_combination_id := NULL;
33579 l_adr_value_segment_code := NULL;
33580
33581 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
33582 l_bflow_class_code := 'REVENUE'; -- 4219869 Business Flow
33583 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
33584 l_budgetary_control_flag := 'N';
33585
33586 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33587 l_bflow_applied_to_amt := NULL; -- 5132302
33588 l_entered_amt_idx := NULL; -- 4262811
33589 l_accted_amt_idx := NULL; -- 4262811
33590 l_acc_rev_flag := NULL; -- 4262811
33591 l_accrual_line_num := NULL; -- 4262811
33592 l_tmp_amt := NULL; -- 4262811
33593 --
33594
33598 ') = 'REV' AND
33595 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
33596 l_balance_type_code <> 'B' THEN
33597 IF NVL(p_source_35,'
33599 p_source_68 IS NULL
33600 THEN
33601
33602 --
33603 XLA_AE_LINES_PKG.SetNewLine;
33604
33605 p_balance_type_code := l_balance_type_code;
33606 -- set the flag so later we will know whether the gain loss line needs to be created
33607
33608 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
33609 p_actual_flag :='A';
33610 END IF;
33611
33612 --
33613 -- bulk performance
33614 --
33615 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
33616 p_header_num => 0); -- 4262811
33617 --
33618 -- set accounting line options
33619 --
33620 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
33621 p_natural_side_code => 'C'
33622 , p_gain_or_loss_flag => 'N'
33623 , p_gl_transfer_mode_code => 'S'
33624 , p_acct_entry_type_code => 'A'
33625 , p_switch_side_flag => 'Y'
33626 , p_merge_duplicate_code => 'A'
33627 );
33628 --
33629 l_acc_rev_natural_side_code := 'D'; -- 4262811
33630 --
33631 --
33632 -- set accounting line type info
33633 --
33634 xla_ae_lines_pkg.SetAcctLineType
33635 (p_component_type => l_component_type
33636 ,p_event_type_code => l_event_type_code
33637 ,p_line_definition_owner_code => l_line_definition_owner_code
33638 ,p_line_definition_code => l_line_definition_code
33639 ,p_accounting_line_code => l_component_code
33640 ,p_accounting_line_type_code => l_component_type_code
33641 ,p_accounting_line_appl_id => l_component_appl_id
33642 ,p_amb_context_code => l_amb_context_code
33643 ,p_entity_code => l_entity_code
33644 ,p_event_class_code => l_event_class_code);
33645 --
33646 -- set accounting class
33647 --
33648 xla_ae_lines_pkg.SetAcctClass(
33649 p_accounting_class_code => 'REVENUE'
33650 , p_ae_header_id => l_ae_header_id
33651 );
33652
33653 --
33654 -- set rounding class
33655 --
33656 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
33657 'RECEIVABLE';
33658
33659 --
33660 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
33661 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
33662 --
33663 -- bulk performance
33664 --
33665 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
33666
33667 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
33668 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
33669
33670 -- 4955764
33671 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
33672 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
33673
33674 -- 4458381 Public Sector Enh
33675
33676 --
33677 -- set accounting attributes for the line type
33678 --
33679 l_entered_amt_idx := 3;
33680 l_accted_amt_idx := 8;
33681 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33682 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
33683 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
33684 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
33685 l_rec_acct_attrs.array_char_value(2) := p_source_37;
33686 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
33687 l_rec_acct_attrs.array_num_value(3) := p_source_38;
33688 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
33689 l_rec_acct_attrs.array_char_value(4) := p_source_39;
33690 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
33691 l_rec_acct_attrs.array_date_value(5) := p_source_40;
33692 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
33693 l_rec_acct_attrs.array_num_value(6) := p_source_41;
33694 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
33695 l_rec_acct_attrs.array_char_value(7) := p_source_42;
33696 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
33697 l_rec_acct_attrs.array_num_value(8) := p_source_43;
33698 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
33699 l_rec_acct_attrs.array_num_value(9) := p_source_32;
33700 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
33701 l_rec_acct_attrs.array_num_value(10) := p_source_33;
33702 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
33703 l_rec_acct_attrs.array_char_value(11) := p_source_34;
33704 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
33705 l_rec_acct_attrs.array_num_value(12) := p_source_57;
33706
33707 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
33708 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
33709
33710 ---------------------------------------------------------------------------------------------------------------
33714
33711 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
33712 ---------------------------------------------------------------------------------------------------------------
33713 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
33715 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33716 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33717
33718 IF xla_accounting_cache_pkg.GetValueChar
33719 (p_source_code => 'LEDGER_CATEGORY_CODE'
33720 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
33721 AND l_bflow_method_code = 'PRIOR_ENTRY'
33722 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
33723 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
33724 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
33725 )
33726 THEN
33727 xla_ae_lines_pkg.BflowUpgEntry
33728 (p_business_method_code => l_bflow_method_code
33729 ,p_business_class_code => l_bflow_class_code
33730 ,p_balance_type => l_balance_type_code);
33731 ELSE
33732 NULL;
33733 -- No business flow processing for business flow method of NONE.
33734 END IF;
33735
33736 --
33737 -- call analytical criteria
33738 --
33739
33740 --
33741 -- call description
33742 --
33743 -- No description or it is inherited.
33744 --
33745 -- call ADRs
33746 -- Bug 4922099
33747 --
33748 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33749 (NVL(l_actual_upg_option, 'N') = 'O') OR
33750 (NVL(l_enc_upg_option, 'N') = 'O')
33751 )
33752 THEN
33753 NULL;
33754 --
33755 --
33756
33757 l_ccid := AcctDerRule_34(
33758 p_application_id => p_application_id
33759 , p_ae_header_id => l_ae_header_id
33760 , p_source_21 => p_source_21
33761 , x_transaction_coa_id => l_adr_transaction_coa_id
33762 , x_accounting_coa_id => l_adr_accounting_coa_id
33763 , x_value_type_code => l_adr_value_type_code
33764 , p_side => 'NA'
33765 );
33766
33767 xla_ae_lines_pkg.set_ccid(
33768 p_code_combination_id => l_ccid
33769 , p_value_type_code => l_adr_value_type_code
33770 , p_transaction_coa_id => l_adr_transaction_coa_id
33771 , p_accounting_coa_id => l_adr_accounting_coa_id
33772 , p_adr_code => 'TRX_DIST_CCID'
33773 , p_adr_type_code => 'S'
33774 , p_component_type => l_component_type
33775 , p_component_code => l_component_code
33776 , p_component_type_code => l_component_type_code
33777 , p_component_appl_id => l_component_appl_id
33778 , p_amb_context_code => l_amb_context_code
33779 , p_side => 'NA'
33780 );
33781
33782
33783 --
33784 --
33785 END IF;
33786 --
33787 -- Bug 4922099
33788 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
33789 (NVL(l_enc_upg_option, 'N') = 'O')
33790 ) AND
33791 (l_bflow_method_code = 'PRIOR_ENTRY')
33792 )
33793 THEN
33794 IF
33795 --
33796 1 = 2
33797 --
33798 THEN
33799 xla_accounting_err_pkg.build_message
33800 (p_appli_s_name => 'XLA'
33801 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33802 ,p_token_1 => 'LINE_NUMBER'
33803 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
33804 ,p_token_2 => 'LINE_TYPE_NAME'
33805 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
33806 l_component_type
33807 ,l_component_code
33808 ,l_component_type_code
33809 ,l_component_appl_id
33810 ,l_amb_context_code
33811 ,l_entity_code
33812 ,l_event_class_code
33813 )
33814 ,p_token_3 => 'OWNER'
33815 ,p_value_3 => xla_lookups_pkg.get_meaning(
33816 p_lookup_type => 'XLA_OWNER_TYPE'
33817 ,p_lookup_code => l_component_type_code
33818 )
33819 ,p_token_4 => 'PRODUCT_NAME'
33823 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
33820 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
33821 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
33822 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
33824 ,p_ae_header_id => NULL
33825 );
33826
33827 IF (C_LEVEL_ERROR>= g_log_level) THEN
33828 trace
33829 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33830 ,p_level => C_LEVEL_ERROR
33831 ,p_module => l_log_module);
33832 END IF;
33833 END IF;
33834 END IF;
33835 --
33836 --
33837 ------------------------------------------------------------------------------------------------
33838 -- 4219869 Business Flow
33839 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
33840 -- Prior Entry. Currently, the following code is always generated.
33841 ------------------------------------------------------------------------------------------------
33842 XLA_AE_LINES_PKG.ValidateCurrentLine;
33843
33844 ------------------------------------------------------------------------------------
33845 -- 4219869 Business Flow
33846 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
33847 ------------------------------------------------------------------------------------
33848 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33849
33850 ----------------------------------------------------------------------------------
33851 -- 4219869 Business Flow
33852 -- Update journal entry status -- Need to generate this within IF <condition>
33853 ----------------------------------------------------------------------------------
33854 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33855 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
33856 ,p_balance_type_code => l_balance_type_code
33857 );
33858
33859 -------------------------------------------------------------------------------------------
33860 -- 4262811 - Generate the Accrual Reversal lines
33861 -------------------------------------------------------------------------------------------
33862 BEGIN
33863 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
33864 (g_array_event(p_event_id).array_value_num('header_index'));
33865 IF l_acc_rev_flag IS NULL THEN
33866 l_acc_rev_flag := 'N';
33867 END IF;
33868 EXCEPTION
33869 WHEN OTHERS THEN
33870 l_acc_rev_flag := 'N';
33871 END;
33872 --
33873 IF (l_acc_rev_flag = 'Y') THEN
33874
33875 -- 4645092 ------------------------------------------------------------------------------
33876 -- To allow MPA report to determine if it should generate report process
33877 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
33878 ------------------------------------------------------------------------------------------
33879
33880 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
33881 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
33882 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
33883 -- call ADRs
33884 -- Bug 4922099
33885 --
33886 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33887 (NVL(l_actual_upg_option, 'N') = 'O') OR
33888 (NVL(l_enc_upg_option, 'N') = 'O')
33889 )
33890 THEN
33891 NULL;
33892 --
33893 --
33894
33895 l_ccid := AcctDerRule_34(
33896 p_application_id => p_application_id
33897 , p_ae_header_id => l_ae_header_id
33898 , p_source_21 => p_source_21
33899 , x_transaction_coa_id => l_adr_transaction_coa_id
33900 , x_accounting_coa_id => l_adr_accounting_coa_id
33901 , x_value_type_code => l_adr_value_type_code
33902 , p_side => 'NA'
33903 );
33904
33905 xla_ae_lines_pkg.set_ccid(
33906 p_code_combination_id => l_ccid
33907 , p_value_type_code => l_adr_value_type_code
33908 , p_transaction_coa_id => l_adr_transaction_coa_id
33909 , p_accounting_coa_id => l_adr_accounting_coa_id
33910 , p_adr_code => 'TRX_DIST_CCID'
33911 , p_adr_type_code => 'S'
33912 , p_component_type => l_component_type
33913 , p_component_code => l_component_code
33914 , p_component_type_code => l_component_type_code
33915 , p_component_appl_id => l_component_appl_id
33916 , p_amb_context_code => l_amb_context_code
33917 , p_side => 'NA'
33918 );
33919
33920
33921 --
33922 --
33923 END IF;
33924
33925 --
33926 -- Update the line information that should be overwritten
33927 --
33928 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
33929 p_header_num => 1);
33930 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
33931
33935 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
33932 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
33933
33934 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
33936 END IF;
33937
33938 --
33939 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
33940 --
33941 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
33942 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
33943 ELSE
33944 ---------------------------------------------------------------------------------------------------
33945 -- 4262811a Switch Sign
33946 ---------------------------------------------------------------------------------------------------
33947 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
33948 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
33949 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33950 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
33951 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33952 -- 5132302
33953 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
33954 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33955
33956 END IF;
33957
33958 -- 4955764
33959 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
33960 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
33961
33962
33963 XLA_AE_LINES_PKG.ValidateCurrentLine;
33964 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33965
33966 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33967 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
33968 ,p_balance_type_code => l_balance_type_code);
33969
33970 END IF;
33971
33972 -----------------------------------------------------------------------------------------
33973 -- 4262811 Multiperiod Accounting
33974 -----------------------------------------------------------------------------------------
33975 -- No MPA option is assigned.
33976
33977
33978 END IF;
33979 END IF;
33980 --
33981
33982 --
33983 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33984 trace
33985 (p_msg => 'END of AcctLineType_82'
33986 ,p_level => C_LEVEL_PROCEDURE
33987 ,p_module => l_log_module);
33988 END IF;
33989 --
33990 EXCEPTION
33991 WHEN xla_exceptions_pkg.application_exception THEN
33992 RAISE;
33993 WHEN OTHERS THEN
33994 xla_exceptions_pkg.raise_message
33995 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_82');
33996 END AcctLineType_82;
33997 --
33998
33999 ---------------------------------------
34000 --
34001 -- PRIVATE FUNCTION
34002 -- AcctLineType_83
34003 --
34004 ---------------------------------------
34005 PROCEDURE AcctLineType_83 (
34006 p_application_id IN NUMBER
34007 ,p_event_id IN NUMBER
34008 ,p_calculate_acctd_flag IN VARCHAR2
34009 ,p_calculate_g_l_flag IN VARCHAR2
34010 ,p_actual_flag IN OUT VARCHAR2
34011 ,p_balance_type_code OUT VARCHAR2
34012 ,p_gain_or_loss_ref OUT VARCHAR2
34013
34014 --Transaction Distribution GL Account
34015 , p_source_21 IN NUMBER
34016 --Bill To Customer Account Identifier
34017 , p_source_32 IN NUMBER
34018 --Bill To Customer Site Use Identifier
34019 , p_source_33 IN NUMBER
34020 --SLA Party Type
34021 , p_source_34 IN VARCHAR2
34022 --Transaction Distribution Account Class
34023 , p_source_35 IN VARCHAR2
34024 --Transaction Distribution Identifier
34025 , p_source_36 IN NUMBER
34026 --Transaction Distribution Type
34027 , p_source_37 IN VARCHAR2
34028 --Transaction Distribution Entered Amount
34029 , p_source_38 IN NUMBER
34030 --Transaction Currency Code
34031 , p_source_39 IN VARCHAR2
34032 --Transaction Exchange Date
34033 , p_source_40 IN DATE
34034 --Transaction Exchange Rate
34035 , p_source_41 IN NUMBER
34036 --Transaction Exchange Rate Type
34037 , p_source_42 IN VARCHAR2
34038 --Transaction Accounting Amount
34039 , p_source_43 IN NUMBER
34040 --Transaction Tax Line Identifier
34041 , p_source_57 IN NUMBER
34042 )
34043 IS
34044
34045 l_component_type VARCHAR2(80);
34046 l_component_code VARCHAR2(30);
34047 l_component_type_code VARCHAR2(1);
34048 l_component_appl_id INTEGER;
34049 l_amb_context_code VARCHAR2(30);
34050 l_entity_code VARCHAR2(30);
34051 l_event_class_code VARCHAR2(30);
34052 l_ae_header_id NUMBER;
34053 l_event_type_code VARCHAR2(30);
34054 l_line_definition_code VARCHAR2(30);
34055 l_line_definition_owner_code VARCHAR2(1);
34056 --
34060 l_adr_transaction_coa_id NUMBER;
34057 -- adr variables
34058 l_segment VARCHAR2(30);
34059 l_ccid NUMBER;
34061 l_adr_accounting_coa_id NUMBER;
34062 l_adr_flexfield_segment_code VARCHAR2(30);
34063 l_adr_flex_value_set_id NUMBER;
34064 l_adr_value_type_code VARCHAR2(30);
34065 l_adr_value_combination_id NUMBER;
34066 l_adr_value_segment_code VARCHAR2(30);
34067
34068 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
34069 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
34070 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
34071 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
34072
34073 -- 4262811 Variables ------------------------------------------------------------------------------------------
34074 l_entered_amt_idx NUMBER;
34075 l_accted_amt_idx NUMBER;
34076 l_acc_rev_flag VARCHAR2(1);
34077 l_accrual_line_num NUMBER;
34078 l_tmp_amt NUMBER;
34079 l_acc_rev_natural_side_code VARCHAR2(1);
34080
34081 l_num_entries NUMBER;
34082 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
34083 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
34084 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
34085 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
34086 l_recog_line_1 NUMBER;
34087 l_recog_line_2 NUMBER;
34088
34089 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
34090 l_bflow_applied_to_amt NUMBER; -- 5132302
34091 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
34092
34093 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
34094
34095 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
34096 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
34097
34098 ---------------------------------------------------------------------------------------------------------------
34099
34100
34101 --
34102 -- bulk performance
34103 --
34104 l_balance_type_code VARCHAR2(1);
34105 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
34106 l_log_module VARCHAR2(240);
34107
34108 --
34109 -- Upgrade strategy
34110 --
34111 l_actual_upg_option VARCHAR2(1);
34112 l_enc_upg_option VARCHAR2(1);
34113
34114 --
34115 BEGIN
34116 --
34117 IF g_log_enabled THEN
34118 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_83';
34119 END IF;
34120 --
34121 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34122
34123 trace
34124 (p_msg => 'BEGIN of AcctLineType_83'
34125 ,p_level => C_LEVEL_PROCEDURE
34126 ,p_module => l_log_module);
34127
34128 END IF;
34129 --
34130 l_component_type := 'AMB_JLT';
34131 l_component_code := 'INV_ROUND';
34132 l_component_type_code := 'S';
34133 l_component_appl_id := 222;
34134 l_amb_context_code := 'DEFAULT';
34135 l_entity_code := 'TRANSACTIONS';
34136 l_event_class_code := 'INVOICE';
34137 l_event_type_code := 'INVOICE_ALL';
34138 l_line_definition_owner_code := 'S';
34139 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
34140 --
34141 l_balance_type_code := 'A';
34142 l_segment := NULL;
34143 l_ccid := NULL;
34144 l_adr_transaction_coa_id := NULL;
34145 l_adr_accounting_coa_id := NULL;
34146 l_adr_flexfield_segment_code := NULL;
34147 l_adr_flex_value_set_id := NULL;
34148 l_adr_value_type_code := NULL;
34149 l_adr_value_combination_id := NULL;
34150 l_adr_value_segment_code := NULL;
34151
34152 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
34153 l_bflow_class_code := ''; -- 4219869 Business Flow
34154 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
34155 l_budgetary_control_flag := 'N';
34156
34157 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34158 l_bflow_applied_to_amt := NULL; -- 5132302
34159 l_entered_amt_idx := NULL; -- 4262811
34160 l_accted_amt_idx := NULL; -- 4262811
34161 l_acc_rev_flag := NULL; -- 4262811
34162 l_accrual_line_num := NULL; -- 4262811
34163 l_tmp_amt := NULL; -- 4262811
34164 --
34165
34166 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
34167 l_balance_type_code <> 'B' THEN
34168 IF NVL(p_source_35,'
34169 ') = 'ROUND'
34170 THEN
34171
34172 --
34173 XLA_AE_LINES_PKG.SetNewLine;
34174
34175 p_balance_type_code := l_balance_type_code;
34176 -- set the flag so later we will know whether the gain loss line needs to be created
34177
34178 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
34179 p_actual_flag :='A';
34180 END IF;
34181
34182 --
34183 -- bulk performance
34184 --
34185 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
34186 p_header_num => 0); -- 4262811
34187 --
34191 p_natural_side_code => 'C'
34188 -- set accounting line options
34189 --
34190 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
34192 , p_gain_or_loss_flag => 'N'
34193 , p_gl_transfer_mode_code => 'S'
34194 , p_acct_entry_type_code => 'A'
34195 , p_switch_side_flag => 'Y'
34196 , p_merge_duplicate_code => 'A'
34197 );
34198 --
34199 l_acc_rev_natural_side_code := 'D'; -- 4262811
34200 --
34201 --
34202 -- set accounting line type info
34203 --
34204 xla_ae_lines_pkg.SetAcctLineType
34205 (p_component_type => l_component_type
34206 ,p_event_type_code => l_event_type_code
34207 ,p_line_definition_owner_code => l_line_definition_owner_code
34208 ,p_line_definition_code => l_line_definition_code
34209 ,p_accounting_line_code => l_component_code
34210 ,p_accounting_line_type_code => l_component_type_code
34211 ,p_accounting_line_appl_id => l_component_appl_id
34212 ,p_amb_context_code => l_amb_context_code
34213 ,p_entity_code => l_entity_code
34214 ,p_event_class_code => l_event_class_code);
34215 --
34216 -- set accounting class
34217 --
34218 xla_ae_lines_pkg.SetAcctClass(
34219 p_accounting_class_code => 'ROUNDING'
34220 , p_ae_header_id => l_ae_header_id
34221 );
34222
34223 --
34224 -- set rounding class
34225 --
34226 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
34227 'RECEIVABLE';
34228
34229 --
34230 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
34231 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
34232 --
34233 -- bulk performance
34234 --
34235 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
34236
34237 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
34238 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
34239
34240 -- 4955764
34241 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
34242 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
34243
34244 -- 4458381 Public Sector Enh
34245
34246 --
34247 -- set accounting attributes for the line type
34248 --
34249 l_entered_amt_idx := 3;
34250 l_accted_amt_idx := 8;
34251 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34252 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
34253 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
34254 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
34255 l_rec_acct_attrs.array_char_value(2) := p_source_37;
34256 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
34257 l_rec_acct_attrs.array_num_value(3) := p_source_38;
34258 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
34259 l_rec_acct_attrs.array_char_value(4) := p_source_39;
34260 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
34261 l_rec_acct_attrs.array_date_value(5) := p_source_40;
34262 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
34263 l_rec_acct_attrs.array_num_value(6) := p_source_41;
34264 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
34265 l_rec_acct_attrs.array_char_value(7) := p_source_42;
34266 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
34267 l_rec_acct_attrs.array_num_value(8) := p_source_43;
34268 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
34269 l_rec_acct_attrs.array_num_value(9) := p_source_32;
34270 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
34271 l_rec_acct_attrs.array_num_value(10) := p_source_33;
34272 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
34273 l_rec_acct_attrs.array_char_value(11) := p_source_34;
34274 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
34275 l_rec_acct_attrs.array_num_value(12) := p_source_57;
34276
34277 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
34278 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
34279
34280 ---------------------------------------------------------------------------------------------------------------
34281 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
34282 ---------------------------------------------------------------------------------------------------------------
34283 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
34284
34285 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34286 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34287
34288 IF xla_accounting_cache_pkg.GetValueChar
34289 (p_source_code => 'LEDGER_CATEGORY_CODE'
34290 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
34291 AND l_bflow_method_code = 'PRIOR_ENTRY'
34295 )
34292 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
34293 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
34294 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
34296 THEN
34297 xla_ae_lines_pkg.BflowUpgEntry
34298 (p_business_method_code => l_bflow_method_code
34299 ,p_business_class_code => l_bflow_class_code
34300 ,p_balance_type => l_balance_type_code);
34301 ELSE
34302 NULL;
34303 -- No business flow processing for business flow method of NONE.
34304 END IF;
34305
34306 --
34307 -- call analytical criteria
34308 --
34309
34310 --
34311 -- call description
34312 --
34313 -- No description or it is inherited.
34314 --
34315 -- call ADRs
34316 -- Bug 4922099
34317 --
34318 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
34319 (NVL(l_actual_upg_option, 'N') = 'O') OR
34320 (NVL(l_enc_upg_option, 'N') = 'O')
34321 )
34322 THEN
34323 NULL;
34324 --
34325 --
34326
34327 l_ccid := AcctDerRule_34(
34328 p_application_id => p_application_id
34329 , p_ae_header_id => l_ae_header_id
34330 , p_source_21 => p_source_21
34331 , x_transaction_coa_id => l_adr_transaction_coa_id
34332 , x_accounting_coa_id => l_adr_accounting_coa_id
34333 , x_value_type_code => l_adr_value_type_code
34334 , p_side => 'NA'
34335 );
34336
34337 xla_ae_lines_pkg.set_ccid(
34338 p_code_combination_id => l_ccid
34339 , p_value_type_code => l_adr_value_type_code
34340 , p_transaction_coa_id => l_adr_transaction_coa_id
34341 , p_accounting_coa_id => l_adr_accounting_coa_id
34342 , p_adr_code => 'TRX_DIST_CCID'
34343 , p_adr_type_code => 'S'
34344 , p_component_type => l_component_type
34345 , p_component_code => l_component_code
34346 , p_component_type_code => l_component_type_code
34347 , p_component_appl_id => l_component_appl_id
34348 , p_amb_context_code => l_amb_context_code
34349 , p_side => 'NA'
34350 );
34351
34352
34353 --
34354 --
34355 END IF;
34356 --
34357 -- Bug 4922099
34358 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
34359 (NVL(l_enc_upg_option, 'N') = 'O')
34360 ) AND
34361 (l_bflow_method_code = 'PRIOR_ENTRY')
34362 )
34363 THEN
34364 IF
34365 --
34366 1 = 2
34367 --
34368 THEN
34369 xla_accounting_err_pkg.build_message
34370 (p_appli_s_name => 'XLA'
34371 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
34372 ,p_token_1 => 'LINE_NUMBER'
34373 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
34374 ,p_token_2 => 'LINE_TYPE_NAME'
34375 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
34376 l_component_type
34377 ,l_component_code
34378 ,l_component_type_code
34379 ,l_component_appl_id
34380 ,l_amb_context_code
34381 ,l_entity_code
34382 ,l_event_class_code
34383 )
34384 ,p_token_3 => 'OWNER'
34385 ,p_value_3 => xla_lookups_pkg.get_meaning(
34386 p_lookup_type => 'XLA_OWNER_TYPE'
34387 ,p_lookup_code => l_component_type_code
34388 )
34389 ,p_token_4 => 'PRODUCT_NAME'
34390 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
34391 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
34392 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
34393 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
34394 ,p_ae_header_id => NULL
34395 );
34396
34397 IF (C_LEVEL_ERROR>= g_log_level) THEN
34398 trace
34399 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
34400 ,p_level => C_LEVEL_ERROR
34401 ,p_module => l_log_module);
34405 --
34402 END IF;
34403 END IF;
34404 END IF;
34406 --
34407 ------------------------------------------------------------------------------------------------
34408 -- 4219869 Business Flow
34409 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
34410 -- Prior Entry. Currently, the following code is always generated.
34411 ------------------------------------------------------------------------------------------------
34412 XLA_AE_LINES_PKG.ValidateCurrentLine;
34413
34414 ------------------------------------------------------------------------------------
34415 -- 4219869 Business Flow
34416 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
34417 ------------------------------------------------------------------------------------
34418 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
34419
34420 ----------------------------------------------------------------------------------
34421 -- 4219869 Business Flow
34422 -- Update journal entry status -- Need to generate this within IF <condition>
34423 ----------------------------------------------------------------------------------
34424 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
34425 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
34426 ,p_balance_type_code => l_balance_type_code
34427 );
34428
34429 -------------------------------------------------------------------------------------------
34430 -- 4262811 - Generate the Accrual Reversal lines
34431 -------------------------------------------------------------------------------------------
34432 BEGIN
34433 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
34434 (g_array_event(p_event_id).array_value_num('header_index'));
34435 IF l_acc_rev_flag IS NULL THEN
34436 l_acc_rev_flag := 'N';
34437 END IF;
34438 EXCEPTION
34439 WHEN OTHERS THEN
34440 l_acc_rev_flag := 'N';
34441 END;
34442 --
34443 IF (l_acc_rev_flag = 'Y') THEN
34444
34445 -- 4645092 ------------------------------------------------------------------------------
34446 -- To allow MPA report to determine if it should generate report process
34447 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
34448 ------------------------------------------------------------------------------------------
34449
34450 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
34451 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
34452 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
34453 -- call ADRs
34454 -- Bug 4922099
34455 --
34456 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
34457 (NVL(l_actual_upg_option, 'N') = 'O') OR
34458 (NVL(l_enc_upg_option, 'N') = 'O')
34459 )
34460 THEN
34461 NULL;
34462 --
34463 --
34464
34465 l_ccid := AcctDerRule_34(
34466 p_application_id => p_application_id
34467 , p_ae_header_id => l_ae_header_id
34468 , p_source_21 => p_source_21
34469 , x_transaction_coa_id => l_adr_transaction_coa_id
34470 , x_accounting_coa_id => l_adr_accounting_coa_id
34471 , x_value_type_code => l_adr_value_type_code
34472 , p_side => 'NA'
34473 );
34474
34475 xla_ae_lines_pkg.set_ccid(
34476 p_code_combination_id => l_ccid
34477 , p_value_type_code => l_adr_value_type_code
34478 , p_transaction_coa_id => l_adr_transaction_coa_id
34479 , p_accounting_coa_id => l_adr_accounting_coa_id
34480 , p_adr_code => 'TRX_DIST_CCID'
34481 , p_adr_type_code => 'S'
34482 , p_component_type => l_component_type
34483 , p_component_code => l_component_code
34484 , p_component_type_code => l_component_type_code
34485 , p_component_appl_id => l_component_appl_id
34486 , p_amb_context_code => l_amb_context_code
34487 , p_side => 'NA'
34488 );
34489
34490
34491 --
34492 --
34493 END IF;
34494
34495 --
34496 -- Update the line information that should be overwritten
34497 --
34498 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
34499 p_header_num => 1);
34500 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
34501
34502 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
34503
34504 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
34505 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
34506 END IF;
34507
34508 --
34509 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
34510 --
34511 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
34512 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
34513 ELSE
34514 ---------------------------------------------------------------------------------------------------
34515 -- 4262811a Switch Sign
34519 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34516 ---------------------------------------------------------------------------------------------------
34517 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
34518 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
34520 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
34521 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34522 -- 5132302
34523 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
34524 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34525
34526 END IF;
34527
34528 -- 4955764
34529 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
34530 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
34531
34532
34533 XLA_AE_LINES_PKG.ValidateCurrentLine;
34534 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
34535
34536 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
34537 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
34538 ,p_balance_type_code => l_balance_type_code);
34539
34540 END IF;
34541
34542 -----------------------------------------------------------------------------------------
34543 -- 4262811 Multiperiod Accounting
34544 -----------------------------------------------------------------------------------------
34545 -- No MPA option is assigned.
34546
34547
34548 END IF;
34549 END IF;
34550 --
34551
34552 --
34553 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34554 trace
34555 (p_msg => 'END of AcctLineType_83'
34556 ,p_level => C_LEVEL_PROCEDURE
34557 ,p_module => l_log_module);
34558 END IF;
34559 --
34560 EXCEPTION
34561 WHEN xla_exceptions_pkg.application_exception THEN
34562 RAISE;
34563 WHEN OTHERS THEN
34564 xla_exceptions_pkg.raise_message
34565 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_83');
34566 END AcctLineType_83;
34567 --
34568
34569 ---------------------------------------
34570 --
34571 -- PRIVATE FUNCTION
34572 -- AcctLineType_84
34573 --
34574 ---------------------------------------
34575 PROCEDURE AcctLineType_84 (
34576 p_application_id IN NUMBER
34577 ,p_event_id IN NUMBER
34578 ,p_calculate_acctd_flag IN VARCHAR2
34579 ,p_calculate_g_l_flag IN VARCHAR2
34580 ,p_actual_flag IN OUT VARCHAR2
34581 ,p_balance_type_code OUT VARCHAR2
34582 ,p_gain_or_loss_ref OUT VARCHAR2
34583
34584 --Transaction Distribution GL Account
34585 , p_source_21 IN NUMBER
34586 --Bill To Customer Account Identifier
34587 , p_source_32 IN NUMBER
34588 --Bill To Customer Site Use Identifier
34589 , p_source_33 IN NUMBER
34590 --SLA Party Type
34591 , p_source_34 IN VARCHAR2
34592 --Transaction Distribution Account Class
34593 , p_source_35 IN VARCHAR2
34594 --Transaction Distribution Identifier
34595 , p_source_36 IN NUMBER
34596 --Transaction Distribution Type
34597 , p_source_37 IN VARCHAR2
34598 --Transaction Distribution Entered Amount
34599 , p_source_38 IN NUMBER
34600 --Transaction Currency Code
34601 , p_source_39 IN VARCHAR2
34602 --Transaction Exchange Date
34603 , p_source_40 IN DATE
34604 --Transaction Exchange Rate
34605 , p_source_41 IN NUMBER
34606 --Transaction Exchange Rate Type
34607 , p_source_42 IN VARCHAR2
34608 --Transaction Accounting Amount
34609 , p_source_43 IN NUMBER
34610 --Transaction Tax Line Identifier
34611 , p_source_57 IN NUMBER
34612 )
34613 IS
34614
34615 l_component_type VARCHAR2(80);
34616 l_component_code VARCHAR2(30);
34617 l_component_type_code VARCHAR2(1);
34618 l_component_appl_id INTEGER;
34619 l_amb_context_code VARCHAR2(30);
34620 l_entity_code VARCHAR2(30);
34621 l_event_class_code VARCHAR2(30);
34622 l_ae_header_id NUMBER;
34623 l_event_type_code VARCHAR2(30);
34624 l_line_definition_code VARCHAR2(30);
34625 l_line_definition_owner_code VARCHAR2(1);
34626 --
34627 -- adr variables
34628 l_segment VARCHAR2(30);
34629 l_ccid NUMBER;
34630 l_adr_transaction_coa_id NUMBER;
34631 l_adr_accounting_coa_id NUMBER;
34632 l_adr_flexfield_segment_code VARCHAR2(30);
34633 l_adr_flex_value_set_id NUMBER;
34634 l_adr_value_type_code VARCHAR2(30);
34635 l_adr_value_combination_id NUMBER;
34636 l_adr_value_segment_code VARCHAR2(30);
34637
34638 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
34639 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
34640 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
34641 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
34642
34643 -- 4262811 Variables ------------------------------------------------------------------------------------------
34647 l_accrual_line_num NUMBER;
34644 l_entered_amt_idx NUMBER;
34645 l_accted_amt_idx NUMBER;
34646 l_acc_rev_flag VARCHAR2(1);
34648 l_tmp_amt NUMBER;
34649 l_acc_rev_natural_side_code VARCHAR2(1);
34650
34651 l_num_entries NUMBER;
34652 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
34653 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
34654 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
34655 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
34656 l_recog_line_1 NUMBER;
34657 l_recog_line_2 NUMBER;
34658
34659 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
34660 l_bflow_applied_to_amt NUMBER; -- 5132302
34661 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
34662
34663 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
34664
34665 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
34666 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
34667
34668 ---------------------------------------------------------------------------------------------------------------
34669
34670
34671 --
34672 -- bulk performance
34673 --
34674 l_balance_type_code VARCHAR2(1);
34675 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
34676 l_log_module VARCHAR2(240);
34677
34678 --
34679 -- Upgrade strategy
34680 --
34681 l_actual_upg_option VARCHAR2(1);
34682 l_enc_upg_option VARCHAR2(1);
34683
34684 --
34685 BEGIN
34686 --
34687 IF g_log_enabled THEN
34688 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_84';
34689 END IF;
34690 --
34691 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34692
34693 trace
34694 (p_msg => 'BEGIN of AcctLineType_84'
34695 ,p_level => C_LEVEL_PROCEDURE
34696 ,p_module => l_log_module);
34697
34698 END IF;
34699 --
34700 l_component_type := 'AMB_JLT';
34701 l_component_code := 'INV_TAX';
34702 l_component_type_code := 'S';
34703 l_component_appl_id := 222;
34704 l_amb_context_code := 'DEFAULT';
34705 l_entity_code := 'TRANSACTIONS';
34706 l_event_class_code := 'INVOICE';
34707 l_event_type_code := 'INVOICE_ALL';
34708 l_line_definition_owner_code := 'S';
34709 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
34710 --
34711 l_balance_type_code := 'A';
34712 l_segment := NULL;
34713 l_ccid := NULL;
34714 l_adr_transaction_coa_id := NULL;
34715 l_adr_accounting_coa_id := NULL;
34716 l_adr_flexfield_segment_code := NULL;
34717 l_adr_flex_value_set_id := NULL;
34718 l_adr_value_type_code := NULL;
34719 l_adr_value_combination_id := NULL;
34720 l_adr_value_segment_code := NULL;
34721
34722 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
34723 l_bflow_class_code := 'TAX'; -- 4219869 Business Flow
34724 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
34725 l_budgetary_control_flag := 'N';
34726
34727 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34728 l_bflow_applied_to_amt := NULL; -- 5132302
34729 l_entered_amt_idx := NULL; -- 4262811
34730 l_accted_amt_idx := NULL; -- 4262811
34731 l_acc_rev_flag := NULL; -- 4262811
34732 l_accrual_line_num := NULL; -- 4262811
34733 l_tmp_amt := NULL; -- 4262811
34734 --
34735
34736 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
34737 l_balance_type_code <> 'B' THEN
34738 IF NVL(p_source_35,'
34739 ') = 'TAX'
34740 THEN
34741
34742 --
34743 XLA_AE_LINES_PKG.SetNewLine;
34744
34745 p_balance_type_code := l_balance_type_code;
34746 -- set the flag so later we will know whether the gain loss line needs to be created
34747
34748 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
34749 p_actual_flag :='A';
34750 END IF;
34751
34752 --
34753 -- bulk performance
34754 --
34755 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
34756 p_header_num => 0); -- 4262811
34757 --
34758 -- set accounting line options
34759 --
34760 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
34761 p_natural_side_code => 'C'
34762 , p_gain_or_loss_flag => 'N'
34763 , p_gl_transfer_mode_code => 'S'
34764 , p_acct_entry_type_code => 'A'
34765 , p_switch_side_flag => 'Y'
34766 , p_merge_duplicate_code => 'A'
34767 );
34768 --
34769 l_acc_rev_natural_side_code := 'D'; -- 4262811
34770 --
34771 --
34772 -- set accounting line type info
34773 --
34774 xla_ae_lines_pkg.SetAcctLineType
34775 (p_component_type => l_component_type
34776 ,p_event_type_code => l_event_type_code
34780 ,p_accounting_line_type_code => l_component_type_code
34777 ,p_line_definition_owner_code => l_line_definition_owner_code
34778 ,p_line_definition_code => l_line_definition_code
34779 ,p_accounting_line_code => l_component_code
34781 ,p_accounting_line_appl_id => l_component_appl_id
34782 ,p_amb_context_code => l_amb_context_code
34783 ,p_entity_code => l_entity_code
34784 ,p_event_class_code => l_event_class_code);
34785 --
34786 -- set accounting class
34787 --
34788 xla_ae_lines_pkg.SetAcctClass(
34789 p_accounting_class_code => 'TAX'
34790 , p_ae_header_id => l_ae_header_id
34791 );
34792
34793 --
34794 -- set rounding class
34795 --
34796 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
34797 'RECEIVABLE';
34798
34799 --
34800 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
34801 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
34802 --
34803 -- bulk performance
34804 --
34805 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
34806
34807 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
34808 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
34809
34810 -- 4955764
34811 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
34812 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
34813
34814 -- 4458381 Public Sector Enh
34815
34816 --
34817 -- set accounting attributes for the line type
34818 --
34819 l_entered_amt_idx := 3;
34820 l_accted_amt_idx := 8;
34821 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34822 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
34823 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
34824 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
34825 l_rec_acct_attrs.array_char_value(2) := p_source_37;
34826 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
34827 l_rec_acct_attrs.array_num_value(3) := p_source_38;
34828 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
34829 l_rec_acct_attrs.array_char_value(4) := p_source_39;
34830 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
34831 l_rec_acct_attrs.array_date_value(5) := p_source_40;
34832 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
34833 l_rec_acct_attrs.array_num_value(6) := p_source_41;
34834 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
34835 l_rec_acct_attrs.array_char_value(7) := p_source_42;
34836 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
34837 l_rec_acct_attrs.array_num_value(8) := p_source_43;
34838 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
34839 l_rec_acct_attrs.array_num_value(9) := p_source_32;
34840 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
34841 l_rec_acct_attrs.array_num_value(10) := p_source_33;
34842 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
34843 l_rec_acct_attrs.array_char_value(11) := p_source_34;
34844 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
34845 l_rec_acct_attrs.array_num_value(12) := p_source_57;
34846
34847 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
34848 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
34849
34850 ---------------------------------------------------------------------------------------------------------------
34851 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
34852 ---------------------------------------------------------------------------------------------------------------
34853 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
34854
34855 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34856 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34857
34858 IF xla_accounting_cache_pkg.GetValueChar
34859 (p_source_code => 'LEDGER_CATEGORY_CODE'
34860 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
34861 AND l_bflow_method_code = 'PRIOR_ENTRY'
34862 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
34863 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
34864 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
34865 )
34866 THEN
34867 xla_ae_lines_pkg.BflowUpgEntry
34868 (p_business_method_code => l_bflow_method_code
34869 ,p_business_class_code => l_bflow_class_code
34870 ,p_balance_type => l_balance_type_code);
34871 ELSE
34872 NULL;
34873 -- No business flow processing for business flow method of NONE.
34874 END IF;
34875
34876 --
34877 -- call analytical criteria
34878 --
34879
34880 --
34881 -- call description
34882 --
34883 -- No description or it is inherited.
34884 --
34885 -- call ADRs
34889 (NVL(l_actual_upg_option, 'N') = 'O') OR
34886 -- Bug 4922099
34887 --
34888 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
34890 (NVL(l_enc_upg_option, 'N') = 'O')
34891 )
34892 THEN
34893 NULL;
34894 --
34895 --
34896
34897 l_ccid := AcctDerRule_34(
34898 p_application_id => p_application_id
34899 , p_ae_header_id => l_ae_header_id
34900 , p_source_21 => p_source_21
34901 , x_transaction_coa_id => l_adr_transaction_coa_id
34902 , x_accounting_coa_id => l_adr_accounting_coa_id
34903 , x_value_type_code => l_adr_value_type_code
34904 , p_side => 'NA'
34905 );
34906
34907 xla_ae_lines_pkg.set_ccid(
34908 p_code_combination_id => l_ccid
34909 , p_value_type_code => l_adr_value_type_code
34910 , p_transaction_coa_id => l_adr_transaction_coa_id
34911 , p_accounting_coa_id => l_adr_accounting_coa_id
34912 , p_adr_code => 'TRX_DIST_CCID'
34913 , p_adr_type_code => 'S'
34914 , p_component_type => l_component_type
34915 , p_component_code => l_component_code
34916 , p_component_type_code => l_component_type_code
34917 , p_component_appl_id => l_component_appl_id
34918 , p_amb_context_code => l_amb_context_code
34919 , p_side => 'NA'
34920 );
34921
34922
34923 --
34924 --
34925 END IF;
34926 --
34927 -- Bug 4922099
34928 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
34929 (NVL(l_enc_upg_option, 'N') = 'O')
34930 ) AND
34931 (l_bflow_method_code = 'PRIOR_ENTRY')
34932 )
34933 THEN
34934 IF
34935 --
34936 1 = 2
34937 --
34938 THEN
34939 xla_accounting_err_pkg.build_message
34940 (p_appli_s_name => 'XLA'
34941 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
34942 ,p_token_1 => 'LINE_NUMBER'
34943 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
34944 ,p_token_2 => 'LINE_TYPE_NAME'
34945 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
34946 l_component_type
34947 ,l_component_code
34948 ,l_component_type_code
34949 ,l_component_appl_id
34950 ,l_amb_context_code
34951 ,l_entity_code
34952 ,l_event_class_code
34953 )
34954 ,p_token_3 => 'OWNER'
34955 ,p_value_3 => xla_lookups_pkg.get_meaning(
34956 p_lookup_type => 'XLA_OWNER_TYPE'
34957 ,p_lookup_code => l_component_type_code
34958 )
34959 ,p_token_4 => 'PRODUCT_NAME'
34960 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
34961 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
34962 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
34963 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
34964 ,p_ae_header_id => NULL
34965 );
34966
34967 IF (C_LEVEL_ERROR>= g_log_level) THEN
34968 trace
34969 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
34970 ,p_level => C_LEVEL_ERROR
34971 ,p_module => l_log_module);
34972 END IF;
34973 END IF;
34974 END IF;
34975 --
34976 --
34977 ------------------------------------------------------------------------------------------------
34978 -- 4219869 Business Flow
34979 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
34980 -- Prior Entry. Currently, the following code is always generated.
34981 ------------------------------------------------------------------------------------------------
34982 XLA_AE_LINES_PKG.ValidateCurrentLine;
34983
34984 ------------------------------------------------------------------------------------
34985 -- 4219869 Business Flow
34986 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
34987 ------------------------------------------------------------------------------------
34991 -- 4219869 Business Flow
34988 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
34989
34990 ----------------------------------------------------------------------------------
34992 -- Update journal entry status -- Need to generate this within IF <condition>
34993 ----------------------------------------------------------------------------------
34994 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
34995 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
34996 ,p_balance_type_code => l_balance_type_code
34997 );
34998
34999 -------------------------------------------------------------------------------------------
35000 -- 4262811 - Generate the Accrual Reversal lines
35001 -------------------------------------------------------------------------------------------
35002 BEGIN
35003 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
35004 (g_array_event(p_event_id).array_value_num('header_index'));
35005 IF l_acc_rev_flag IS NULL THEN
35006 l_acc_rev_flag := 'N';
35007 END IF;
35008 EXCEPTION
35009 WHEN OTHERS THEN
35010 l_acc_rev_flag := 'N';
35011 END;
35012 --
35013 IF (l_acc_rev_flag = 'Y') THEN
35014
35015 -- 4645092 ------------------------------------------------------------------------------
35016 -- To allow MPA report to determine if it should generate report process
35017 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
35018 ------------------------------------------------------------------------------------------
35019
35020 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
35021 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
35022 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
35023 -- call ADRs
35024 -- Bug 4922099
35025 --
35026 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
35027 (NVL(l_actual_upg_option, 'N') = 'O') OR
35028 (NVL(l_enc_upg_option, 'N') = 'O')
35029 )
35030 THEN
35031 NULL;
35032 --
35033 --
35034
35035 l_ccid := AcctDerRule_34(
35036 p_application_id => p_application_id
35037 , p_ae_header_id => l_ae_header_id
35038 , p_source_21 => p_source_21
35039 , x_transaction_coa_id => l_adr_transaction_coa_id
35040 , x_accounting_coa_id => l_adr_accounting_coa_id
35041 , x_value_type_code => l_adr_value_type_code
35042 , p_side => 'NA'
35043 );
35044
35045 xla_ae_lines_pkg.set_ccid(
35046 p_code_combination_id => l_ccid
35047 , p_value_type_code => l_adr_value_type_code
35048 , p_transaction_coa_id => l_adr_transaction_coa_id
35049 , p_accounting_coa_id => l_adr_accounting_coa_id
35050 , p_adr_code => 'TRX_DIST_CCID'
35051 , p_adr_type_code => 'S'
35052 , p_component_type => l_component_type
35053 , p_component_code => l_component_code
35054 , p_component_type_code => l_component_type_code
35055 , p_component_appl_id => l_component_appl_id
35056 , p_amb_context_code => l_amb_context_code
35057 , p_side => 'NA'
35058 );
35059
35060
35061 --
35062 --
35063 END IF;
35064
35065 --
35066 -- Update the line information that should be overwritten
35067 --
35068 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
35069 p_header_num => 1);
35070 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
35071
35072 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
35073
35074 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
35075 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
35076 END IF;
35077
35078 --
35079 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
35080 --
35081 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
35082 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
35083 ELSE
35084 ---------------------------------------------------------------------------------------------------
35085 -- 4262811a Switch Sign
35086 ---------------------------------------------------------------------------------------------------
35087 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
35088 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35089 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35090 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35091 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35092 -- 5132302
35093 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
35094 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35095
35096 END IF;
35097
35098 -- 4955764
35102
35099 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
35100 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
35101
35103 XLA_AE_LINES_PKG.ValidateCurrentLine;
35104 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35105
35106 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
35107 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
35108 ,p_balance_type_code => l_balance_type_code);
35109
35110 END IF;
35111
35112 -----------------------------------------------------------------------------------------
35113 -- 4262811 Multiperiod Accounting
35114 -----------------------------------------------------------------------------------------
35115 -- No MPA option is assigned.
35116
35117
35118 END IF;
35119 END IF;
35120 --
35121
35122 --
35123 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
35124 trace
35125 (p_msg => 'END of AcctLineType_84'
35126 ,p_level => C_LEVEL_PROCEDURE
35127 ,p_module => l_log_module);
35128 END IF;
35129 --
35130 EXCEPTION
35131 WHEN xla_exceptions_pkg.application_exception THEN
35132 RAISE;
35133 WHEN OTHERS THEN
35134 xla_exceptions_pkg.raise_message
35135 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_84');
35136 END AcctLineType_84;
35137 --
35138
35139 ---------------------------------------
35140 --
35141 -- PRIVATE FUNCTION
35142 -- AcctLineType_85
35143 --
35144 ---------------------------------------
35145 PROCEDURE AcctLineType_85 (
35146 p_application_id IN NUMBER
35147 ,p_event_id IN NUMBER
35148 ,p_calculate_acctd_flag IN VARCHAR2
35149 ,p_calculate_g_l_flag IN VARCHAR2
35150 ,p_actual_flag IN OUT VARCHAR2
35151 ,p_balance_type_code OUT VARCHAR2
35152 ,p_gain_or_loss_ref OUT VARCHAR2
35153
35154 --Transaction Distribution GL Account
35155 , p_source_21 IN NUMBER
35156 --Bill To Customer Account Identifier
35157 , p_source_32 IN NUMBER
35158 --Bill To Customer Site Use Identifier
35159 , p_source_33 IN NUMBER
35160 --SLA Party Type
35161 , p_source_34 IN VARCHAR2
35162 --Transaction Distribution Account Class
35163 , p_source_35 IN VARCHAR2
35164 --Transaction Distribution Identifier
35165 , p_source_36 IN NUMBER
35166 --Transaction Distribution Type
35167 , p_source_37 IN VARCHAR2
35168 --Transaction Distribution Entered Amount
35169 , p_source_38 IN NUMBER
35170 --Transaction Currency Code
35171 , p_source_39 IN VARCHAR2
35172 --Transaction Exchange Date
35173 , p_source_40 IN DATE
35174 --Transaction Exchange Rate
35175 , p_source_41 IN NUMBER
35176 --Transaction Exchange Rate Type
35177 , p_source_42 IN VARCHAR2
35178 --Transaction Accounting Amount
35179 , p_source_43 IN NUMBER
35180 --Transaction Tax Line Identifier
35181 , p_source_57 IN NUMBER
35182 --Rounding Correction Flag
35183 , p_source_68 IN VARCHAR2
35184 )
35185 IS
35186
35187 l_component_type VARCHAR2(80);
35188 l_component_code VARCHAR2(30);
35189 l_component_type_code VARCHAR2(1);
35190 l_component_appl_id INTEGER;
35191 l_amb_context_code VARCHAR2(30);
35192 l_entity_code VARCHAR2(30);
35193 l_event_class_code VARCHAR2(30);
35194 l_ae_header_id NUMBER;
35195 l_event_type_code VARCHAR2(30);
35196 l_line_definition_code VARCHAR2(30);
35197 l_line_definition_owner_code VARCHAR2(1);
35198 --
35199 -- adr variables
35200 l_segment VARCHAR2(30);
35201 l_ccid NUMBER;
35202 l_adr_transaction_coa_id NUMBER;
35203 l_adr_accounting_coa_id NUMBER;
35204 l_adr_flexfield_segment_code VARCHAR2(30);
35205 l_adr_flex_value_set_id NUMBER;
35206 l_adr_value_type_code VARCHAR2(30);
35207 l_adr_value_combination_id NUMBER;
35208 l_adr_value_segment_code VARCHAR2(30);
35209
35210 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
35211 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
35212 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
35213 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
35214
35215 -- 4262811 Variables ------------------------------------------------------------------------------------------
35216 l_entered_amt_idx NUMBER;
35217 l_accted_amt_idx NUMBER;
35218 l_acc_rev_flag VARCHAR2(1);
35219 l_accrual_line_num NUMBER;
35220 l_tmp_amt NUMBER;
35221 l_acc_rev_natural_side_code VARCHAR2(1);
35222
35223 l_num_entries NUMBER;
35224 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
35225 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
35226 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
35227 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
35228 l_recog_line_1 NUMBER;
35229 l_recog_line_2 NUMBER;
35230
35231 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
35235 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
35232 l_bflow_applied_to_amt NUMBER; -- 5132302
35233 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
35234
35236
35237 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
35238 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
35239
35240 ---------------------------------------------------------------------------------------------------------------
35241
35242
35243 --
35244 -- bulk performance
35245 --
35246 l_balance_type_code VARCHAR2(1);
35247 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
35248 l_log_module VARCHAR2(240);
35249
35250 --
35251 -- Upgrade strategy
35252 --
35253 l_actual_upg_option VARCHAR2(1);
35254 l_enc_upg_option VARCHAR2(1);
35255
35256 --
35257 BEGIN
35258 --
35259 IF g_log_enabled THEN
35260 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_85';
35261 END IF;
35262 --
35263 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
35264
35265 trace
35266 (p_msg => 'BEGIN of AcctLineType_85'
35267 ,p_level => C_LEVEL_PROCEDURE
35268 ,p_module => l_log_module);
35269
35270 END IF;
35271 --
35272 l_component_type := 'AMB_JLT';
35273 l_component_code := 'INV_UNBILL';
35274 l_component_type_code := 'S';
35275 l_component_appl_id := 222;
35276 l_amb_context_code := 'DEFAULT';
35277 l_entity_code := 'TRANSACTIONS';
35278 l_event_class_code := 'INVOICE';
35279 l_event_type_code := 'INVOICE_ALL';
35280 l_line_definition_owner_code := 'S';
35281 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
35282 --
35283 l_balance_type_code := 'A';
35284 l_segment := NULL;
35285 l_ccid := NULL;
35286 l_adr_transaction_coa_id := NULL;
35287 l_adr_accounting_coa_id := NULL;
35288 l_adr_flexfield_segment_code := NULL;
35289 l_adr_flex_value_set_id := NULL;
35290 l_adr_value_type_code := NULL;
35291 l_adr_value_combination_id := NULL;
35292 l_adr_value_segment_code := NULL;
35293
35294 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
35295 l_bflow_class_code := ''; -- 4219869 Business Flow
35296 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
35297 l_budgetary_control_flag := 'N';
35298
35299 l_bflow_applied_to_amt_idx := NULL; -- 5132302
35300 l_bflow_applied_to_amt := NULL; -- 5132302
35301 l_entered_amt_idx := NULL; -- 4262811
35302 l_accted_amt_idx := NULL; -- 4262811
35303 l_acc_rev_flag := NULL; -- 4262811
35304 l_accrual_line_num := NULL; -- 4262811
35305 l_tmp_amt := NULL; -- 4262811
35306 --
35307
35308 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
35309 l_balance_type_code <> 'B' THEN
35310 IF NVL(p_source_35,'
35311 ') = 'UNBILL' AND
35312 p_source_68 IS NULL
35313 THEN
35314
35315 --
35316 XLA_AE_LINES_PKG.SetNewLine;
35317
35318 p_balance_type_code := l_balance_type_code;
35319 -- set the flag so later we will know whether the gain loss line needs to be created
35320
35321 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
35322 p_actual_flag :='A';
35323 END IF;
35324
35325 --
35326 -- bulk performance
35327 --
35328 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
35329 p_header_num => 0); -- 4262811
35330 --
35331 -- set accounting line options
35332 --
35333 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
35334 p_natural_side_code => 'C'
35335 , p_gain_or_loss_flag => 'N'
35336 , p_gl_transfer_mode_code => 'S'
35337 , p_acct_entry_type_code => 'A'
35338 , p_switch_side_flag => 'Y'
35339 , p_merge_duplicate_code => 'A'
35340 );
35341 --
35342 l_acc_rev_natural_side_code := 'D'; -- 4262811
35343 --
35344 --
35345 -- set accounting line type info
35346 --
35347 xla_ae_lines_pkg.SetAcctLineType
35348 (p_component_type => l_component_type
35349 ,p_event_type_code => l_event_type_code
35350 ,p_line_definition_owner_code => l_line_definition_owner_code
35351 ,p_line_definition_code => l_line_definition_code
35352 ,p_accounting_line_code => l_component_code
35353 ,p_accounting_line_type_code => l_component_type_code
35354 ,p_accounting_line_appl_id => l_component_appl_id
35355 ,p_amb_context_code => l_amb_context_code
35356 ,p_entity_code => l_entity_code
35357 ,p_event_class_code => l_event_class_code);
35358 --
35359 -- set accounting class
35360 --
35361 xla_ae_lines_pkg.SetAcctClass(
35362 p_accounting_class_code => 'UNBILL'
35363 , p_ae_header_id => l_ae_header_id
35364 );
35365
35369 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
35366 --
35367 -- set rounding class
35368 --
35370 'UNBILL';
35371
35372 --
35373 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
35374 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
35375 --
35376 -- bulk performance
35377 --
35378 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
35379
35380 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
35381 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
35382
35383 -- 4955764
35384 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
35385 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
35386
35387 -- 4458381 Public Sector Enh
35388
35389 --
35390 -- set accounting attributes for the line type
35391 --
35392 l_entered_amt_idx := 3;
35393 l_accted_amt_idx := 8;
35394 l_bflow_applied_to_amt_idx := NULL; -- 5132302
35395 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
35396 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
35397 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
35398 l_rec_acct_attrs.array_char_value(2) := p_source_37;
35399 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
35400 l_rec_acct_attrs.array_num_value(3) := p_source_38;
35401 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
35402 l_rec_acct_attrs.array_char_value(4) := p_source_39;
35403 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
35404 l_rec_acct_attrs.array_date_value(5) := p_source_40;
35405 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
35406 l_rec_acct_attrs.array_num_value(6) := p_source_41;
35407 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
35408 l_rec_acct_attrs.array_char_value(7) := p_source_42;
35409 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
35410 l_rec_acct_attrs.array_num_value(8) := p_source_43;
35411 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
35412 l_rec_acct_attrs.array_num_value(9) := p_source_32;
35413 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
35414 l_rec_acct_attrs.array_num_value(10) := p_source_33;
35415 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
35416 l_rec_acct_attrs.array_char_value(11) := p_source_34;
35417 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
35418 l_rec_acct_attrs.array_num_value(12) := p_source_57;
35419
35420 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
35421 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
35422
35423 ---------------------------------------------------------------------------------------------------------------
35424 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
35425 ---------------------------------------------------------------------------------------------------------------
35426 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
35427
35428 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
35429 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
35430
35431 IF xla_accounting_cache_pkg.GetValueChar
35432 (p_source_code => 'LEDGER_CATEGORY_CODE'
35433 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
35434 AND l_bflow_method_code = 'PRIOR_ENTRY'
35435 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
35436 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
35437 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
35438 )
35439 THEN
35440 xla_ae_lines_pkg.BflowUpgEntry
35441 (p_business_method_code => l_bflow_method_code
35442 ,p_business_class_code => l_bflow_class_code
35443 ,p_balance_type => l_balance_type_code);
35444 ELSE
35445 NULL;
35446 -- No business flow processing for business flow method of NONE.
35447 END IF;
35448
35449 --
35450 -- call analytical criteria
35451 --
35452
35453 --
35454 -- call description
35455 --
35456 -- No description or it is inherited.
35457 --
35458 -- call ADRs
35459 -- Bug 4922099
35460 --
35461 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
35462 (NVL(l_actual_upg_option, 'N') = 'O') OR
35463 (NVL(l_enc_upg_option, 'N') = 'O')
35464 )
35465 THEN
35466 NULL;
35467 --
35468 --
35469
35470 l_ccid := AcctDerRule_34(
35471 p_application_id => p_application_id
35472 , p_ae_header_id => l_ae_header_id
35473 , p_source_21 => p_source_21
35474 , x_transaction_coa_id => l_adr_transaction_coa_id
35475 , x_accounting_coa_id => l_adr_accounting_coa_id
35476 , x_value_type_code => l_adr_value_type_code
35480 xla_ae_lines_pkg.set_ccid(
35477 , p_side => 'NA'
35478 );
35479
35481 p_code_combination_id => l_ccid
35482 , p_value_type_code => l_adr_value_type_code
35483 , p_transaction_coa_id => l_adr_transaction_coa_id
35484 , p_accounting_coa_id => l_adr_accounting_coa_id
35485 , p_adr_code => 'TRX_DIST_CCID'
35486 , p_adr_type_code => 'S'
35487 , p_component_type => l_component_type
35488 , p_component_code => l_component_code
35489 , p_component_type_code => l_component_type_code
35490 , p_component_appl_id => l_component_appl_id
35491 , p_amb_context_code => l_amb_context_code
35492 , p_side => 'NA'
35493 );
35494
35495
35496 --
35497 --
35498 END IF;
35499 --
35500 -- Bug 4922099
35501 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
35502 (NVL(l_enc_upg_option, 'N') = 'O')
35503 ) AND
35504 (l_bflow_method_code = 'PRIOR_ENTRY')
35505 )
35506 THEN
35507 IF
35508 --
35509 1 = 2
35510 --
35511 THEN
35512 xla_accounting_err_pkg.build_message
35513 (p_appli_s_name => 'XLA'
35514 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
35515 ,p_token_1 => 'LINE_NUMBER'
35516 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
35517 ,p_token_2 => 'LINE_TYPE_NAME'
35518 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
35519 l_component_type
35520 ,l_component_code
35521 ,l_component_type_code
35522 ,l_component_appl_id
35523 ,l_amb_context_code
35524 ,l_entity_code
35525 ,l_event_class_code
35526 )
35527 ,p_token_3 => 'OWNER'
35528 ,p_value_3 => xla_lookups_pkg.get_meaning(
35529 p_lookup_type => 'XLA_OWNER_TYPE'
35530 ,p_lookup_code => l_component_type_code
35531 )
35532 ,p_token_4 => 'PRODUCT_NAME'
35533 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
35534 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
35535 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
35536 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
35537 ,p_ae_header_id => NULL
35538 );
35539
35540 IF (C_LEVEL_ERROR>= g_log_level) THEN
35541 trace
35542 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
35543 ,p_level => C_LEVEL_ERROR
35544 ,p_module => l_log_module);
35545 END IF;
35546 END IF;
35547 END IF;
35548 --
35549 --
35550 ------------------------------------------------------------------------------------------------
35551 -- 4219869 Business Flow
35552 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
35553 -- Prior Entry. Currently, the following code is always generated.
35554 ------------------------------------------------------------------------------------------------
35555 XLA_AE_LINES_PKG.ValidateCurrentLine;
35556
35557 ------------------------------------------------------------------------------------
35558 -- 4219869 Business Flow
35559 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
35560 ------------------------------------------------------------------------------------
35561 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35562
35563 ----------------------------------------------------------------------------------
35564 -- 4219869 Business Flow
35565 -- Update journal entry status -- Need to generate this within IF <condition>
35566 ----------------------------------------------------------------------------------
35567 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
35568 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
35569 ,p_balance_type_code => l_balance_type_code
35570 );
35571
35572 -------------------------------------------------------------------------------------------
35573 -- 4262811 - Generate the Accrual Reversal lines
35577 (g_array_event(p_event_id).array_value_num('header_index'));
35574 -------------------------------------------------------------------------------------------
35575 BEGIN
35576 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
35578 IF l_acc_rev_flag IS NULL THEN
35579 l_acc_rev_flag := 'N';
35580 END IF;
35581 EXCEPTION
35582 WHEN OTHERS THEN
35583 l_acc_rev_flag := 'N';
35584 END;
35585 --
35586 IF (l_acc_rev_flag = 'Y') THEN
35587
35588 -- 4645092 ------------------------------------------------------------------------------
35589 -- To allow MPA report to determine if it should generate report process
35590 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
35591 ------------------------------------------------------------------------------------------
35592
35593 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
35594 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
35595 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
35596 -- call ADRs
35597 -- Bug 4922099
35598 --
35599 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
35600 (NVL(l_actual_upg_option, 'N') = 'O') OR
35601 (NVL(l_enc_upg_option, 'N') = 'O')
35602 )
35603 THEN
35604 NULL;
35605 --
35606 --
35607
35608 l_ccid := AcctDerRule_34(
35609 p_application_id => p_application_id
35610 , p_ae_header_id => l_ae_header_id
35611 , p_source_21 => p_source_21
35612 , x_transaction_coa_id => l_adr_transaction_coa_id
35613 , x_accounting_coa_id => l_adr_accounting_coa_id
35614 , x_value_type_code => l_adr_value_type_code
35615 , p_side => 'NA'
35616 );
35617
35618 xla_ae_lines_pkg.set_ccid(
35619 p_code_combination_id => l_ccid
35620 , p_value_type_code => l_adr_value_type_code
35621 , p_transaction_coa_id => l_adr_transaction_coa_id
35622 , p_accounting_coa_id => l_adr_accounting_coa_id
35623 , p_adr_code => 'TRX_DIST_CCID'
35624 , p_adr_type_code => 'S'
35625 , p_component_type => l_component_type
35626 , p_component_code => l_component_code
35627 , p_component_type_code => l_component_type_code
35628 , p_component_appl_id => l_component_appl_id
35629 , p_amb_context_code => l_amb_context_code
35630 , p_side => 'NA'
35631 );
35632
35633
35634 --
35635 --
35636 END IF;
35637
35638 --
35639 -- Update the line information that should be overwritten
35640 --
35641 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
35642 p_header_num => 1);
35643 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
35644
35645 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
35646
35647 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
35648 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
35649 END IF;
35650
35651 --
35652 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
35653 --
35654 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
35655 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
35656 ELSE
35657 ---------------------------------------------------------------------------------------------------
35658 -- 4262811a Switch Sign
35659 ---------------------------------------------------------------------------------------------------
35660 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
35661 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35662 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35663 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35664 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35665 -- 5132302
35666 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
35667 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35668
35669 END IF;
35670
35671 -- 4955764
35672 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
35673 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
35674
35675
35676 XLA_AE_LINES_PKG.ValidateCurrentLine;
35677 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35678
35679 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
35680 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
35681 ,p_balance_type_code => l_balance_type_code);
35682
35683 END IF;
35684
35688 -- No MPA option is assigned.
35685 -----------------------------------------------------------------------------------------
35686 -- 4262811 Multiperiod Accounting
35687 -----------------------------------------------------------------------------------------
35689
35690
35691 END IF;
35692 END IF;
35693 --
35694
35695 --
35696 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
35697 trace
35698 (p_msg => 'END of AcctLineType_85'
35699 ,p_level => C_LEVEL_PROCEDURE
35700 ,p_module => l_log_module);
35701 END IF;
35702 --
35703 EXCEPTION
35704 WHEN xla_exceptions_pkg.application_exception THEN
35705 RAISE;
35706 WHEN OTHERS THEN
35707 xla_exceptions_pkg.raise_message
35708 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_85');
35709 END AcctLineType_85;
35710 --
35711
35712 ---------------------------------------
35713 --
35714 -- PRIVATE FUNCTION
35715 -- AcctLineType_86
35716 --
35717 ---------------------------------------
35718 PROCEDURE AcctLineType_86 (
35719 p_application_id IN NUMBER
35720 ,p_event_id IN NUMBER
35721 ,p_calculate_acctd_flag IN VARCHAR2
35722 ,p_calculate_g_l_flag IN VARCHAR2
35723 ,p_actual_flag IN OUT VARCHAR2
35724 ,p_balance_type_code OUT VARCHAR2
35725 ,p_gain_or_loss_ref OUT VARCHAR2
35726
35727 --Transaction Distribution GL Account
35728 , p_source_21 IN NUMBER
35729 --Bill To Customer Account Identifier
35730 , p_source_32 IN NUMBER
35731 --Bill To Customer Site Use Identifier
35732 , p_source_33 IN NUMBER
35733 --SLA Party Type
35734 , p_source_34 IN VARCHAR2
35735 --Transaction Distribution Account Class
35736 , p_source_35 IN VARCHAR2
35737 --Transaction Distribution Identifier
35738 , p_source_36 IN NUMBER
35739 --Transaction Distribution Type
35740 , p_source_37 IN VARCHAR2
35741 --Transaction Distribution Entered Amount
35742 , p_source_38 IN NUMBER
35743 --Transaction Currency Code
35744 , p_source_39 IN VARCHAR2
35745 --Transaction Exchange Date
35746 , p_source_40 IN DATE
35747 --Transaction Exchange Rate
35748 , p_source_41 IN NUMBER
35749 --Transaction Exchange Rate Type
35750 , p_source_42 IN VARCHAR2
35751 --Transaction Accounting Amount
35752 , p_source_43 IN NUMBER
35753 --Transaction Tax Line Identifier
35754 , p_source_57 IN NUMBER
35755 --Rounding Correction Flag
35756 , p_source_68 IN VARCHAR2
35757 )
35758 IS
35759
35760 l_component_type VARCHAR2(80);
35761 l_component_code VARCHAR2(30);
35762 l_component_type_code VARCHAR2(1);
35763 l_component_appl_id INTEGER;
35764 l_amb_context_code VARCHAR2(30);
35765 l_entity_code VARCHAR2(30);
35766 l_event_class_code VARCHAR2(30);
35767 l_ae_header_id NUMBER;
35768 l_event_type_code VARCHAR2(30);
35769 l_line_definition_code VARCHAR2(30);
35770 l_line_definition_owner_code VARCHAR2(1);
35771 --
35772 -- adr variables
35773 l_segment VARCHAR2(30);
35774 l_ccid NUMBER;
35775 l_adr_transaction_coa_id NUMBER;
35776 l_adr_accounting_coa_id NUMBER;
35777 l_adr_flexfield_segment_code VARCHAR2(30);
35778 l_adr_flex_value_set_id NUMBER;
35779 l_adr_value_type_code VARCHAR2(30);
35780 l_adr_value_combination_id NUMBER;
35781 l_adr_value_segment_code VARCHAR2(30);
35782
35783 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
35784 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
35785 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
35786 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
35787
35788 -- 4262811 Variables ------------------------------------------------------------------------------------------
35789 l_entered_amt_idx NUMBER;
35790 l_accted_amt_idx NUMBER;
35791 l_acc_rev_flag VARCHAR2(1);
35792 l_accrual_line_num NUMBER;
35793 l_tmp_amt NUMBER;
35794 l_acc_rev_natural_side_code VARCHAR2(1);
35795
35796 l_num_entries NUMBER;
35797 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
35798 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
35799 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
35800 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
35801 l_recog_line_1 NUMBER;
35802 l_recog_line_2 NUMBER;
35803
35804 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
35805 l_bflow_applied_to_amt NUMBER; -- 5132302
35806 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
35807
35808 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
35809
35810 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
35811 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
35812
35813 ---------------------------------------------------------------------------------------------------------------
35814
35815
35816 --
35817 -- bulk performance
35818 --
35822
35819 l_balance_type_code VARCHAR2(1);
35820 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
35821 l_log_module VARCHAR2(240);
35823 --
35824 -- Upgrade strategy
35825 --
35826 l_actual_upg_option VARCHAR2(1);
35827 l_enc_upg_option VARCHAR2(1);
35828
35829 --
35830 BEGIN
35831 --
35832 IF g_log_enabled THEN
35833 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_86';
35834 END IF;
35835 --
35836 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
35837
35838 trace
35839 (p_msg => 'BEGIN of AcctLineType_86'
35840 ,p_level => C_LEVEL_PROCEDURE
35841 ,p_module => l_log_module);
35842
35843 END IF;
35844 --
35845 l_component_type := 'AMB_JLT';
35846 l_component_code := 'INV_UNEARN';
35847 l_component_type_code := 'S';
35848 l_component_appl_id := 222;
35849 l_amb_context_code := 'DEFAULT';
35850 l_entity_code := 'TRANSACTIONS';
35851 l_event_class_code := 'INVOICE';
35852 l_event_type_code := 'INVOICE_ALL';
35853 l_line_definition_owner_code := 'S';
35854 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
35855 --
35856 l_balance_type_code := 'A';
35857 l_segment := NULL;
35858 l_ccid := NULL;
35859 l_adr_transaction_coa_id := NULL;
35860 l_adr_accounting_coa_id := NULL;
35861 l_adr_flexfield_segment_code := NULL;
35862 l_adr_flex_value_set_id := NULL;
35863 l_adr_value_type_code := NULL;
35864 l_adr_value_combination_id := NULL;
35865 l_adr_value_segment_code := NULL;
35866
35867 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
35868 l_bflow_class_code := ''; -- 4219869 Business Flow
35869 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
35870 l_budgetary_control_flag := 'N';
35871
35872 l_bflow_applied_to_amt_idx := NULL; -- 5132302
35873 l_bflow_applied_to_amt := NULL; -- 5132302
35874 l_entered_amt_idx := NULL; -- 4262811
35875 l_accted_amt_idx := NULL; -- 4262811
35876 l_acc_rev_flag := NULL; -- 4262811
35877 l_accrual_line_num := NULL; -- 4262811
35878 l_tmp_amt := NULL; -- 4262811
35879 --
35880
35881 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
35882 l_balance_type_code <> 'B' THEN
35883 IF NVL(p_source_35,'
35884 ') = 'UNEARN' AND
35885 p_source_68 IS NULL
35886 THEN
35887
35888 --
35889 XLA_AE_LINES_PKG.SetNewLine;
35890
35891 p_balance_type_code := l_balance_type_code;
35892 -- set the flag so later we will know whether the gain loss line needs to be created
35893
35894 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
35895 p_actual_flag :='A';
35896 END IF;
35897
35898 --
35899 -- bulk performance
35900 --
35901 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
35902 p_header_num => 0); -- 4262811
35903 --
35904 -- set accounting line options
35905 --
35906 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
35907 p_natural_side_code => 'C'
35908 , p_gain_or_loss_flag => 'N'
35909 , p_gl_transfer_mode_code => 'S'
35910 , p_acct_entry_type_code => 'A'
35911 , p_switch_side_flag => 'Y'
35912 , p_merge_duplicate_code => 'A'
35913 );
35914 --
35915 l_acc_rev_natural_side_code := 'D'; -- 4262811
35916 --
35917 --
35918 -- set accounting line type info
35919 --
35920 xla_ae_lines_pkg.SetAcctLineType
35921 (p_component_type => l_component_type
35922 ,p_event_type_code => l_event_type_code
35923 ,p_line_definition_owner_code => l_line_definition_owner_code
35924 ,p_line_definition_code => l_line_definition_code
35925 ,p_accounting_line_code => l_component_code
35926 ,p_accounting_line_type_code => l_component_type_code
35927 ,p_accounting_line_appl_id => l_component_appl_id
35928 ,p_amb_context_code => l_amb_context_code
35929 ,p_entity_code => l_entity_code
35930 ,p_event_class_code => l_event_class_code);
35931 --
35932 -- set accounting class
35933 --
35934 xla_ae_lines_pkg.SetAcctClass(
35935 p_accounting_class_code => 'UNEARNED_REVENUE'
35936 , p_ae_header_id => l_ae_header_id
35937 );
35938
35939 --
35940 -- set rounding class
35941 --
35942 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
35943 'RECEIVABLE';
35944
35945 --
35946 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
35947 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
35948 --
35949 -- bulk performance
35950 --
35951 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
35952
35956 -- 4955764
35953 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
35954 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
35955
35957 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
35958 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
35959
35960 -- 4458381 Public Sector Enh
35961
35962 --
35963 -- set accounting attributes for the line type
35964 --
35965 l_entered_amt_idx := 3;
35966 l_accted_amt_idx := 8;
35967 l_bflow_applied_to_amt_idx := NULL; -- 5132302
35968 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
35969 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
35970 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
35971 l_rec_acct_attrs.array_char_value(2) := p_source_37;
35972 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
35973 l_rec_acct_attrs.array_num_value(3) := p_source_38;
35974 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
35975 l_rec_acct_attrs.array_char_value(4) := p_source_39;
35976 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
35977 l_rec_acct_attrs.array_date_value(5) := p_source_40;
35978 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
35979 l_rec_acct_attrs.array_num_value(6) := p_source_41;
35980 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
35981 l_rec_acct_attrs.array_char_value(7) := p_source_42;
35982 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
35983 l_rec_acct_attrs.array_num_value(8) := p_source_43;
35984 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
35985 l_rec_acct_attrs.array_num_value(9) := p_source_32;
35986 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
35987 l_rec_acct_attrs.array_num_value(10) := p_source_33;
35988 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
35989 l_rec_acct_attrs.array_char_value(11) := p_source_34;
35990 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
35991 l_rec_acct_attrs.array_num_value(12) := p_source_57;
35992
35993 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
35994 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
35995
35996 ---------------------------------------------------------------------------------------------------------------
35997 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
35998 ---------------------------------------------------------------------------------------------------------------
35999 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
36000
36001 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36002 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36003
36004 IF xla_accounting_cache_pkg.GetValueChar
36005 (p_source_code => 'LEDGER_CATEGORY_CODE'
36006 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
36007 AND l_bflow_method_code = 'PRIOR_ENTRY'
36008 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
36009 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
36010 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
36011 )
36012 THEN
36013 xla_ae_lines_pkg.BflowUpgEntry
36014 (p_business_method_code => l_bflow_method_code
36015 ,p_business_class_code => l_bflow_class_code
36016 ,p_balance_type => l_balance_type_code);
36017 ELSE
36018 NULL;
36019 -- No business flow processing for business flow method of NONE.
36020 END IF;
36021
36022 --
36023 -- call analytical criteria
36024 --
36025
36026 --
36027 -- call description
36028 --
36029 -- No description or it is inherited.
36030 --
36031 -- call ADRs
36032 -- Bug 4922099
36033 --
36034 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36035 (NVL(l_actual_upg_option, 'N') = 'O') OR
36036 (NVL(l_enc_upg_option, 'N') = 'O')
36037 )
36038 THEN
36039 NULL;
36040 --
36041 --
36042
36043 l_ccid := AcctDerRule_34(
36044 p_application_id => p_application_id
36045 , p_ae_header_id => l_ae_header_id
36046 , p_source_21 => p_source_21
36047 , x_transaction_coa_id => l_adr_transaction_coa_id
36048 , x_accounting_coa_id => l_adr_accounting_coa_id
36049 , x_value_type_code => l_adr_value_type_code
36050 , p_side => 'NA'
36051 );
36052
36053 xla_ae_lines_pkg.set_ccid(
36054 p_code_combination_id => l_ccid
36055 , p_value_type_code => l_adr_value_type_code
36056 , p_transaction_coa_id => l_adr_transaction_coa_id
36057 , p_accounting_coa_id => l_adr_accounting_coa_id
36058 , p_adr_code => 'TRX_DIST_CCID'
36059 , p_adr_type_code => 'S'
36060 , p_component_type => l_component_type
36061 , p_component_code => l_component_code
36062 , p_component_type_code => l_component_type_code
36066 );
36063 , p_component_appl_id => l_component_appl_id
36064 , p_amb_context_code => l_amb_context_code
36065 , p_side => 'NA'
36067
36068
36069 --
36070 --
36071 END IF;
36072 --
36073 -- Bug 4922099
36074 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
36075 (NVL(l_enc_upg_option, 'N') = 'O')
36076 ) AND
36077 (l_bflow_method_code = 'PRIOR_ENTRY')
36078 )
36079 THEN
36080 IF
36081 --
36082 1 = 2
36083 --
36084 THEN
36085 xla_accounting_err_pkg.build_message
36086 (p_appli_s_name => 'XLA'
36087 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
36088 ,p_token_1 => 'LINE_NUMBER'
36089 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
36090 ,p_token_2 => 'LINE_TYPE_NAME'
36091 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
36092 l_component_type
36093 ,l_component_code
36094 ,l_component_type_code
36095 ,l_component_appl_id
36096 ,l_amb_context_code
36097 ,l_entity_code
36098 ,l_event_class_code
36099 )
36100 ,p_token_3 => 'OWNER'
36101 ,p_value_3 => xla_lookups_pkg.get_meaning(
36102 p_lookup_type => 'XLA_OWNER_TYPE'
36103 ,p_lookup_code => l_component_type_code
36104 )
36105 ,p_token_4 => 'PRODUCT_NAME'
36106 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
36107 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
36108 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
36109 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
36110 ,p_ae_header_id => NULL
36111 );
36112
36113 IF (C_LEVEL_ERROR>= g_log_level) THEN
36114 trace
36115 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
36116 ,p_level => C_LEVEL_ERROR
36117 ,p_module => l_log_module);
36118 END IF;
36119 END IF;
36120 END IF;
36121 --
36122 --
36123 ------------------------------------------------------------------------------------------------
36124 -- 4219869 Business Flow
36125 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
36126 -- Prior Entry. Currently, the following code is always generated.
36127 ------------------------------------------------------------------------------------------------
36128 XLA_AE_LINES_PKG.ValidateCurrentLine;
36129
36130 ------------------------------------------------------------------------------------
36131 -- 4219869 Business Flow
36132 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
36133 ------------------------------------------------------------------------------------
36134 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
36135
36136 ----------------------------------------------------------------------------------
36137 -- 4219869 Business Flow
36138 -- Update journal entry status -- Need to generate this within IF <condition>
36139 ----------------------------------------------------------------------------------
36140 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36141 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
36142 ,p_balance_type_code => l_balance_type_code
36143 );
36144
36145 -------------------------------------------------------------------------------------------
36146 -- 4262811 - Generate the Accrual Reversal lines
36147 -------------------------------------------------------------------------------------------
36148 BEGIN
36149 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
36150 (g_array_event(p_event_id).array_value_num('header_index'));
36151 IF l_acc_rev_flag IS NULL THEN
36152 l_acc_rev_flag := 'N';
36153 END IF;
36154 EXCEPTION
36155 WHEN OTHERS THEN
36156 l_acc_rev_flag := 'N';
36157 END;
36158 --
36159 IF (l_acc_rev_flag = 'Y') THEN
36160
36161 -- 4645092 ------------------------------------------------------------------------------
36165
36162 -- To allow MPA report to determine if it should generate report process
36163 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
36164 ------------------------------------------------------------------------------------------
36166 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
36167 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
36168 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
36169 -- call ADRs
36170 -- Bug 4922099
36171 --
36172 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36173 (NVL(l_actual_upg_option, 'N') = 'O') OR
36174 (NVL(l_enc_upg_option, 'N') = 'O')
36175 )
36176 THEN
36177 NULL;
36178 --
36179 --
36180
36181 l_ccid := AcctDerRule_34(
36182 p_application_id => p_application_id
36183 , p_ae_header_id => l_ae_header_id
36184 , p_source_21 => p_source_21
36185 , x_transaction_coa_id => l_adr_transaction_coa_id
36186 , x_accounting_coa_id => l_adr_accounting_coa_id
36187 , x_value_type_code => l_adr_value_type_code
36188 , p_side => 'NA'
36189 );
36190
36191 xla_ae_lines_pkg.set_ccid(
36192 p_code_combination_id => l_ccid
36193 , p_value_type_code => l_adr_value_type_code
36194 , p_transaction_coa_id => l_adr_transaction_coa_id
36195 , p_accounting_coa_id => l_adr_accounting_coa_id
36196 , p_adr_code => 'TRX_DIST_CCID'
36197 , p_adr_type_code => 'S'
36198 , p_component_type => l_component_type
36199 , p_component_code => l_component_code
36200 , p_component_type_code => l_component_type_code
36201 , p_component_appl_id => l_component_appl_id
36202 , p_amb_context_code => l_amb_context_code
36203 , p_side => 'NA'
36204 );
36205
36206
36207 --
36208 --
36209 END IF;
36210
36211 --
36212 -- Update the line information that should be overwritten
36213 --
36214 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
36215 p_header_num => 1);
36216 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
36217
36218 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
36219
36220 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
36221 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
36222 END IF;
36223
36224 --
36225 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
36226 --
36227 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
36228 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
36229 ELSE
36230 ---------------------------------------------------------------------------------------------------
36231 -- 4262811a Switch Sign
36232 ---------------------------------------------------------------------------------------------------
36233 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
36234 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36235 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36236 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36237 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36238 -- 5132302
36239 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
36240 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36241
36242 END IF;
36243
36244 -- 4955764
36245 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36246 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
36247
36248
36249 XLA_AE_LINES_PKG.ValidateCurrentLine;
36250 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
36251
36252 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36253 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
36254 ,p_balance_type_code => l_balance_type_code);
36255
36256 END IF;
36257
36258 -----------------------------------------------------------------------------------------
36259 -- 4262811 Multiperiod Accounting
36260 -----------------------------------------------------------------------------------------
36261 -- No MPA option is assigned.
36262
36263
36264 END IF;
36265 END IF;
36266 --
36267
36268 --
36269 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
36270 trace
36271 (p_msg => 'END of AcctLineType_86'
36272 ,p_level => C_LEVEL_PROCEDURE
36273 ,p_module => l_log_module);
36274 END IF;
36275 --
36276 EXCEPTION
36277 WHEN xla_exceptions_pkg.application_exception THEN
36278 RAISE;
36282 END AcctLineType_86;
36279 WHEN OTHERS THEN
36280 xla_exceptions_pkg.raise_message
36281 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_86');
36283 --
36284
36285 ---------------------------------------
36286 --
36287 -- PRIVATE FUNCTION
36288 -- AcctLineType_87
36289 --
36290 ---------------------------------------
36291 PROCEDURE AcctLineType_87 (
36292 p_application_id IN NUMBER
36293 ,p_event_id IN NUMBER
36294 ,p_calculate_acctd_flag IN VARCHAR2
36295 ,p_calculate_g_l_flag IN VARCHAR2
36296 ,p_actual_flag IN OUT VARCHAR2
36297 ,p_balance_type_code OUT VARCHAR2
36298 ,p_gain_or_loss_ref OUT VARCHAR2
36299
36300 --Transaction Default Receivable Account
36301 , p_source_8 IN NUMBER
36302 --Distribution GL Account
36303 , p_source_10 IN NUMBER
36304 --Distribution Source Type
36305 , p_source_22 IN VARCHAR2
36306 --Receivable Activity Type
36307 , p_source_23 IN VARCHAR2
36308 --Distribution Line Identifier
36309 , p_source_24 IN NUMBER
36310 --Distribution Type
36311 , p_source_25 IN VARCHAR2
36312 --Entered Amount
36313 , p_source_26 IN NUMBER
36314 --Currency Code
36315 , p_source_27 IN VARCHAR2
36316 --Exchange Date
36317 , p_source_28 IN DATE
36318 --Exchange Rate
36319 , p_source_29 IN NUMBER
36320 --Exchange Rate Type
36321 , p_source_30 IN VARCHAR2
36322 --Applied To Document Accounting Amount
36323 , p_source_31 IN NUMBER
36324 --Bill To Customer Account Identifier
36325 , p_source_32 IN NUMBER
36326 --Bill To Customer Site Use Identifier
36327 , p_source_33 IN NUMBER
36328 --SLA Party Type
36329 , p_source_34 IN VARCHAR2
36330 )
36331 IS
36332
36333 l_component_type VARCHAR2(80);
36334 l_component_code VARCHAR2(30);
36335 l_component_type_code VARCHAR2(1);
36336 l_component_appl_id INTEGER;
36337 l_amb_context_code VARCHAR2(30);
36338 l_entity_code VARCHAR2(30);
36339 l_event_class_code VARCHAR2(30);
36340 l_ae_header_id NUMBER;
36341 l_event_type_code VARCHAR2(30);
36342 l_line_definition_code VARCHAR2(30);
36343 l_line_definition_owner_code VARCHAR2(1);
36344 --
36345 -- adr variables
36346 l_segment VARCHAR2(30);
36347 l_ccid NUMBER;
36348 l_adr_transaction_coa_id NUMBER;
36349 l_adr_accounting_coa_id NUMBER;
36350 l_adr_flexfield_segment_code VARCHAR2(30);
36351 l_adr_flex_value_set_id NUMBER;
36352 l_adr_value_type_code VARCHAR2(30);
36353 l_adr_value_combination_id NUMBER;
36354 l_adr_value_segment_code VARCHAR2(30);
36355
36356 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
36357 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
36358 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
36359 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
36360
36361 -- 4262811 Variables ------------------------------------------------------------------------------------------
36362 l_entered_amt_idx NUMBER;
36363 l_accted_amt_idx NUMBER;
36364 l_acc_rev_flag VARCHAR2(1);
36365 l_accrual_line_num NUMBER;
36366 l_tmp_amt NUMBER;
36367 l_acc_rev_natural_side_code VARCHAR2(1);
36368
36369 l_num_entries NUMBER;
36370 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
36371 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
36372 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
36373 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
36374 l_recog_line_1 NUMBER;
36375 l_recog_line_2 NUMBER;
36376
36377 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
36378 l_bflow_applied_to_amt NUMBER; -- 5132302
36379 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
36380
36381 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
36382
36383 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
36384 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
36385
36386 ---------------------------------------------------------------------------------------------------------------
36387
36388
36389 --
36390 -- bulk performance
36391 --
36392 l_balance_type_code VARCHAR2(1);
36393 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
36394 l_log_module VARCHAR2(240);
36395
36396 --
36397 -- Upgrade strategy
36398 --
36399 l_actual_upg_option VARCHAR2(1);
36400 l_enc_upg_option VARCHAR2(1);
36401
36402 --
36403 BEGIN
36404 --
36405 IF g_log_enabled THEN
36406 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_87';
36407 END IF;
36408 --
36409 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
36410
36411 trace
36412 (p_msg => 'BEGIN of AcctLineType_87'
36413 ,p_level => C_LEVEL_PROCEDURE
36414 ,p_module => l_log_module);
36415
36416 END IF;
36417 --
36421 l_component_appl_id := 222;
36418 l_component_type := 'AMB_JLT';
36419 l_component_code := 'MFAR_ADJ_REC';
36420 l_component_type_code := 'S';
36422 l_amb_context_code := 'DEFAULT';
36423 l_entity_code := 'ADJUSTMENTS';
36424 l_event_class_code := 'ADJUSTMENT';
36425 l_event_type_code := 'ADJUSTMENT_ALL';
36426 l_line_definition_owner_code := 'S';
36427 l_line_definition_code := 'MFAR_ADJ_ACCRUAL_ACCOUNT';
36428 --
36429 l_balance_type_code := 'A';
36430 l_segment := NULL;
36431 l_ccid := NULL;
36432 l_adr_transaction_coa_id := NULL;
36433 l_adr_accounting_coa_id := NULL;
36434 l_adr_flexfield_segment_code := NULL;
36435 l_adr_flex_value_set_id := NULL;
36436 l_adr_value_type_code := NULL;
36437 l_adr_value_combination_id := NULL;
36438 l_adr_value_segment_code := NULL;
36439
36440 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
36441 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
36442 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
36443 l_budgetary_control_flag := 'N';
36444
36445 l_bflow_applied_to_amt_idx := NULL; -- 5132302
36446 l_bflow_applied_to_amt := NULL; -- 5132302
36447 l_entered_amt_idx := NULL; -- 4262811
36448 l_accted_amt_idx := NULL; -- 4262811
36449 l_acc_rev_flag := NULL; -- 4262811
36450 l_accrual_line_num := NULL; -- 4262811
36451 l_tmp_amt := NULL; -- 4262811
36452 --
36453
36454 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
36455 l_balance_type_code <> 'B' THEN
36456 IF NVL(p_source_22,'
36457 ') = 'TAX' OR
36458 NVL(p_source_22,'
36459 ') = 'DEFERRED_TAX' OR
36460 NVL(p_source_22,'
36461 ') = 'FINCHRG' OR
36462 (NVL(p_source_22,'
36463 ') = 'ADJ' AND
36464 NVL(p_source_23,'
36465 ') = 'ENDORSEMENT') OR
36466 (NVL(p_source_22,'
36467 ') = 'ADJ' AND
36468 NVL(p_source_23,'
36469 ') <> 'ENDORSEMENT')
36470 THEN
36471
36472 --
36473 XLA_AE_LINES_PKG.SetNewLine;
36474
36475 p_balance_type_code := l_balance_type_code;
36476 -- set the flag so later we will know whether the gain loss line needs to be created
36477
36478 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
36479 p_actual_flag :='A';
36480 END IF;
36481
36482 --
36483 -- bulk performance
36484 --
36485 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
36486 p_header_num => 0); -- 4262811
36487 --
36488 -- set accounting line options
36489 --
36490 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
36491 p_natural_side_code => 'D'
36492 , p_gain_or_loss_flag => 'N'
36493 , p_gl_transfer_mode_code => 'S'
36494 , p_acct_entry_type_code => 'A'
36495 , p_switch_side_flag => 'Y'
36496 , p_merge_duplicate_code => 'A'
36497 );
36498 --
36499 l_acc_rev_natural_side_code := 'C'; -- 4262811
36500 --
36501 --
36502 -- set accounting line type info
36503 --
36504 xla_ae_lines_pkg.SetAcctLineType
36505 (p_component_type => l_component_type
36506 ,p_event_type_code => l_event_type_code
36507 ,p_line_definition_owner_code => l_line_definition_owner_code
36508 ,p_line_definition_code => l_line_definition_code
36509 ,p_accounting_line_code => l_component_code
36510 ,p_accounting_line_type_code => l_component_type_code
36511 ,p_accounting_line_appl_id => l_component_appl_id
36512 ,p_amb_context_code => l_amb_context_code
36513 ,p_entity_code => l_entity_code
36514 ,p_event_class_code => l_event_class_code);
36515 --
36516 -- set accounting class
36517 --
36518 xla_ae_lines_pkg.SetAcctClass(
36519 p_accounting_class_code => 'RECEIVABLE'
36520 , p_ae_header_id => l_ae_header_id
36521 );
36522
36523 --
36524 -- set rounding class
36525 --
36526 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
36527 'RECEIVABLE';
36528
36529 --
36530 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
36531 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
36532 --
36533 -- bulk performance
36534 --
36535 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
36536
36537 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
36538 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
36539
36540 -- 4955764
36541 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36542 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
36543
36544 -- 4458381 Public Sector Enh
36545
36546 --
36550 l_accted_amt_idx := 8;
36547 -- set accounting attributes for the line type
36548 --
36549 l_entered_amt_idx := 3;
36551 l_bflow_applied_to_amt_idx := NULL; -- 5132302
36552 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
36553 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
36554 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
36555 l_rec_acct_attrs.array_char_value(2) := p_source_25;
36556 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
36557 l_rec_acct_attrs.array_num_value(3) := p_source_26;
36558 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
36559 l_rec_acct_attrs.array_char_value(4) := p_source_27;
36560 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
36561 l_rec_acct_attrs.array_date_value(5) := p_source_28;
36562 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
36563 l_rec_acct_attrs.array_num_value(6) := p_source_29;
36564 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
36565 l_rec_acct_attrs.array_char_value(7) := p_source_30;
36566 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
36567 l_rec_acct_attrs.array_num_value(8) := p_source_31;
36568 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
36569 l_rec_acct_attrs.array_num_value(9) := p_source_32;
36570 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
36571 l_rec_acct_attrs.array_num_value(10) := p_source_33;
36572 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
36573 l_rec_acct_attrs.array_char_value(11) := p_source_34;
36574
36575 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
36576 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
36577
36578 ---------------------------------------------------------------------------------------------------------------
36579 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
36580 ---------------------------------------------------------------------------------------------------------------
36581 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
36582
36583 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36584 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36585
36586 IF xla_accounting_cache_pkg.GetValueChar
36587 (p_source_code => 'LEDGER_CATEGORY_CODE'
36588 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
36589 AND l_bflow_method_code = 'PRIOR_ENTRY'
36590 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
36591 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
36592 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
36593 )
36594 THEN
36595 xla_ae_lines_pkg.BflowUpgEntry
36596 (p_business_method_code => l_bflow_method_code
36597 ,p_business_class_code => l_bflow_class_code
36598 ,p_balance_type => l_balance_type_code);
36599 ELSE
36600 NULL;
36601 -- No business flow processing for business flow method of NONE.
36602 END IF;
36603
36604 --
36605 -- call analytical criteria
36606 --
36607
36608 --
36609 -- call description
36610 --
36611
36612 xla_ae_lines_pkg.SetLineDescription(
36613 p_ae_header_id => l_ae_header_id
36614 ,p_description => Description_1 (
36615 p_application_id => p_application_id
36616 , p_ae_header_id => l_ae_header_id
36617 )
36618 );
36619
36620
36621 --
36622 -- call ADRs
36623 -- Bug 4922099
36624 --
36625 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36626 (NVL(l_actual_upg_option, 'N') = 'O') OR
36627 (NVL(l_enc_upg_option, 'N') = 'O')
36628 )
36629 THEN
36630 NULL;
36631 --
36632 --
36633
36634 l_ccid := AcctDerRule_11(
36635 p_application_id => p_application_id
36636 , p_ae_header_id => l_ae_header_id
36637 , p_source_10 => p_source_10
36638 , x_transaction_coa_id => l_adr_transaction_coa_id
36639 , x_accounting_coa_id => l_adr_accounting_coa_id
36640 , x_value_type_code => l_adr_value_type_code
36641 , p_side => 'NA'
36642 );
36643
36644 xla_ae_lines_pkg.set_ccid(
36645 p_code_combination_id => l_ccid
36646 , p_value_type_code => l_adr_value_type_code
36647 , p_transaction_coa_id => l_adr_transaction_coa_id
36648 , p_accounting_coa_id => l_adr_accounting_coa_id
36649 , p_adr_code => 'DIST_CCID'
36650 , p_adr_type_code => 'S'
36651 , p_component_type => l_component_type
36652 , p_component_code => l_component_code
36653 , p_component_type_code => l_component_type_code
36654 , p_component_appl_id => l_component_appl_id
36655 , p_amb_context_code => l_amb_context_code
36656 , p_side => 'NA'
36657 );
36658
36659
36660 l_segment := AcctDerRule_9(
36661 p_application_id => p_application_id
36665 , x_accounting_coa_id => l_adr_accounting_coa_id
36662 , p_ae_header_id => l_ae_header_id
36663 , p_source_8 => p_source_8
36664 , x_transaction_coa_id => l_adr_transaction_coa_id
36666 , x_flexfield_segment_code => l_adr_flexfield_segment_code
36667 , x_flex_value_set_id => l_adr_flex_value_set_id
36668 , x_value_type_code => l_adr_value_type_code
36669 , x_value_combination_id => l_adr_value_combination_id
36670 , x_value_segment_code => l_adr_value_segment_code
36671 , p_side => 'NA'
36672 , p_override_seg_flag => 'Y'
36673 );
36674
36675 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
36676
36677 xla_ae_lines_pkg.set_segment(
36678 p_to_segment_code => 'GL_ACCOUNT'
36679 , p_segment_value => l_segment
36680 , p_from_segment_code => l_adr_value_segment_code
36681 , p_from_combination_id => l_adr_value_combination_id
36682 , p_value_type_code => l_adr_value_type_code
36683 , p_transaction_coa_id => l_adr_transaction_coa_id
36684 , p_accounting_coa_id => l_adr_accounting_coa_id
36685 , p_flexfield_segment_code => l_adr_flexfield_segment_code
36686 , p_flex_value_set_id => l_adr_flex_value_set_id
36687 , p_adr_code => 'MFAR_TRX_NATURAL_SEGMENT'
36688 , p_adr_type_code => 'S'
36689 , p_component_type => l_component_type
36690 , p_component_code => l_component_code
36691 , p_component_type_code => l_component_type_code
36692 , p_component_appl_id => l_component_appl_id
36693 , p_amb_context_code => l_amb_context_code
36694 , p_entity_code => 'ADJUSTMENTS'
36695 , p_event_class_code => 'ADJUSTMENT'
36696 , p_side => 'NA'
36697 );
36698
36699 END IF;
36700
36701 --
36702 --
36703 END IF;
36704 --
36705 -- Bug 4922099
36706 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
36707 (NVL(l_enc_upg_option, 'N') = 'O')
36708 ) AND
36709 (l_bflow_method_code = 'PRIOR_ENTRY')
36710 )
36711 THEN
36712 IF
36713 --
36714 1 = 2
36715 --
36716 THEN
36717 xla_accounting_err_pkg.build_message
36718 (p_appli_s_name => 'XLA'
36719 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
36720 ,p_token_1 => 'LINE_NUMBER'
36721 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
36722 ,p_token_2 => 'LINE_TYPE_NAME'
36723 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
36724 l_component_type
36725 ,l_component_code
36726 ,l_component_type_code
36727 ,l_component_appl_id
36728 ,l_amb_context_code
36729 ,l_entity_code
36730 ,l_event_class_code
36731 )
36732 ,p_token_3 => 'OWNER'
36733 ,p_value_3 => xla_lookups_pkg.get_meaning(
36734 p_lookup_type => 'XLA_OWNER_TYPE'
36735 ,p_lookup_code => l_component_type_code
36736 )
36737 ,p_token_4 => 'PRODUCT_NAME'
36738 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
36739 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
36740 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
36741 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
36742 ,p_ae_header_id => NULL
36743 );
36744
36745 IF (C_LEVEL_ERROR>= g_log_level) THEN
36746 trace
36747 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
36748 ,p_level => C_LEVEL_ERROR
36749 ,p_module => l_log_module);
36750 END IF;
36751 END IF;
36752 END IF;
36753 --
36754 --
36755 ------------------------------------------------------------------------------------------------
36756 -- 4219869 Business Flow
36757 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
36758 -- Prior Entry. Currently, the following code is always generated.
36762 ------------------------------------------------------------------------------------
36759 ------------------------------------------------------------------------------------------------
36760 XLA_AE_LINES_PKG.ValidateCurrentLine;
36761
36763 -- 4219869 Business Flow
36764 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
36765 ------------------------------------------------------------------------------------
36766 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
36767
36768 ----------------------------------------------------------------------------------
36769 -- 4219869 Business Flow
36770 -- Update journal entry status -- Need to generate this within IF <condition>
36771 ----------------------------------------------------------------------------------
36772 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36773 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
36774 ,p_balance_type_code => l_balance_type_code
36775 );
36776
36777 -------------------------------------------------------------------------------------------
36778 -- 4262811 - Generate the Accrual Reversal lines
36779 -------------------------------------------------------------------------------------------
36780 BEGIN
36781 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
36782 (g_array_event(p_event_id).array_value_num('header_index'));
36783 IF l_acc_rev_flag IS NULL THEN
36784 l_acc_rev_flag := 'N';
36785 END IF;
36786 EXCEPTION
36787 WHEN OTHERS THEN
36788 l_acc_rev_flag := 'N';
36789 END;
36790 --
36791 IF (l_acc_rev_flag = 'Y') THEN
36792
36793 -- 4645092 ------------------------------------------------------------------------------
36794 -- To allow MPA report to determine if it should generate report process
36795 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
36796 ------------------------------------------------------------------------------------------
36797
36798 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
36799 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
36800 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
36801 -- call ADRs
36802 -- Bug 4922099
36803 --
36804 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36805 (NVL(l_actual_upg_option, 'N') = 'O') OR
36806 (NVL(l_enc_upg_option, 'N') = 'O')
36807 )
36808 THEN
36809 NULL;
36810 --
36811 --
36812
36813 l_ccid := AcctDerRule_11(
36814 p_application_id => p_application_id
36815 , p_ae_header_id => l_ae_header_id
36816 , p_source_10 => p_source_10
36817 , x_transaction_coa_id => l_adr_transaction_coa_id
36818 , x_accounting_coa_id => l_adr_accounting_coa_id
36819 , x_value_type_code => l_adr_value_type_code
36820 , p_side => 'NA'
36821 );
36822
36823 xla_ae_lines_pkg.set_ccid(
36824 p_code_combination_id => l_ccid
36825 , p_value_type_code => l_adr_value_type_code
36826 , p_transaction_coa_id => l_adr_transaction_coa_id
36827 , p_accounting_coa_id => l_adr_accounting_coa_id
36828 , p_adr_code => 'DIST_CCID'
36829 , p_adr_type_code => 'S'
36830 , p_component_type => l_component_type
36831 , p_component_code => l_component_code
36832 , p_component_type_code => l_component_type_code
36833 , p_component_appl_id => l_component_appl_id
36834 , p_amb_context_code => l_amb_context_code
36835 , p_side => 'NA'
36836 );
36837
36838
36839 l_segment := AcctDerRule_9(
36840 p_application_id => p_application_id
36841 , p_ae_header_id => l_ae_header_id
36842 , p_source_8 => p_source_8
36843 , x_transaction_coa_id => l_adr_transaction_coa_id
36844 , x_accounting_coa_id => l_adr_accounting_coa_id
36845 , x_flexfield_segment_code => l_adr_flexfield_segment_code
36846 , x_flex_value_set_id => l_adr_flex_value_set_id
36847 , x_value_type_code => l_adr_value_type_code
36848 , x_value_combination_id => l_adr_value_combination_id
36849 , x_value_segment_code => l_adr_value_segment_code
36850 , p_side => 'NA'
36851 , p_override_seg_flag => 'Y'
36852 );
36853
36854 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
36855
36856 xla_ae_lines_pkg.set_segment(
36857 p_to_segment_code => 'GL_ACCOUNT'
36858 , p_segment_value => l_segment
36859 , p_from_segment_code => l_adr_value_segment_code
36860 , p_from_combination_id => l_adr_value_combination_id
36861 , p_value_type_code => l_adr_value_type_code
36862 , p_transaction_coa_id => l_adr_transaction_coa_id
36863 , p_accounting_coa_id => l_adr_accounting_coa_id
36864 , p_flexfield_segment_code => l_adr_flexfield_segment_code
36865 , p_flex_value_set_id => l_adr_flex_value_set_id
36866 , p_adr_code => 'MFAR_TRX_NATURAL_SEGMENT'
36867 , p_adr_type_code => 'S'
36868 , p_component_type => l_component_type
36872 , p_amb_context_code => l_amb_context_code
36869 , p_component_code => l_component_code
36870 , p_component_type_code => l_component_type_code
36871 , p_component_appl_id => l_component_appl_id
36873 , p_entity_code => 'ADJUSTMENTS'
36874 , p_event_class_code => 'ADJUSTMENT'
36875 , p_side => 'NA'
36876 );
36877
36878 END IF;
36879
36880 --
36881 --
36882 END IF;
36883
36884 --
36885 -- Update the line information that should be overwritten
36886 --
36887 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
36888 p_header_num => 1);
36889 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
36890
36891 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
36892
36893 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
36894 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
36895 END IF;
36896
36897 --
36898 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
36899 --
36900 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
36901 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
36902 ELSE
36903 ---------------------------------------------------------------------------------------------------
36904 -- 4262811a Switch Sign
36905 ---------------------------------------------------------------------------------------------------
36906 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
36907 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36908 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36909 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36910 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36911 -- 5132302
36912 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
36913 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36914
36915 END IF;
36916
36917 -- 4955764
36918 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36919 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
36920
36921
36922 XLA_AE_LINES_PKG.ValidateCurrentLine;
36923 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
36924
36925 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36926 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
36927 ,p_balance_type_code => l_balance_type_code);
36928
36929 END IF;
36930
36931 -----------------------------------------------------------------------------------------
36932 -- 4262811 Multiperiod Accounting
36933 -----------------------------------------------------------------------------------------
36934 -- No MPA option is assigned.
36935
36936
36937 END IF;
36938 END IF;
36939 --
36940
36941 --
36942 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
36943 trace
36944 (p_msg => 'END of AcctLineType_87'
36945 ,p_level => C_LEVEL_PROCEDURE
36946 ,p_module => l_log_module);
36947 END IF;
36948 --
36949 EXCEPTION
36950 WHEN xla_exceptions_pkg.application_exception THEN
36951 RAISE;
36952 WHEN OTHERS THEN
36953 xla_exceptions_pkg.raise_message
36954 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_87');
36955 END AcctLineType_87;
36956 --
36957
36958 ---------------------------------------
36959 --
36960 -- PRIVATE FUNCTION
36961 -- AcctLineType_88
36962 --
36963 ---------------------------------------
36964 PROCEDURE AcctLineType_88 (
36965 p_application_id IN NUMBER
36966 ,p_event_id IN NUMBER
36967 ,p_calculate_acctd_flag IN VARCHAR2
36968 ,p_calculate_g_l_flag IN VARCHAR2
36969 ,p_actual_flag IN OUT VARCHAR2
36970 ,p_balance_type_code OUT VARCHAR2
36971 ,p_gain_or_loss_ref OUT VARCHAR2
36972
36973 --Credit Memo Default Receivable Account
36974 , p_source_2 IN NUMBER
36975 --Credit Memo Distribution GL Account
36976 , p_source_9 IN NUMBER
36977 --SLA Party Type
36978 , p_source_34 IN VARCHAR2
36979 --Credit Memo Distribution Identifier
36980 , p_source_44 IN NUMBER
36981 --Credit memo distributions type
36982 , p_source_45 IN VARCHAR2
36983 --Credit Memo Currency Code
36984 , p_source_46 IN VARCHAR2
36985 --Credit Memo Exchange Date
36986 , p_source_47 IN DATE
36987 --Credit Memo Exchange Rate
36988 , p_source_48 IN NUMBER
36989 --Credit Memo Exchange Rate Type
36990 , p_source_49 IN VARCHAR2
36991 --Gain Loss Reference
36992 , p_source_50 IN VARCHAR2
36993 --Credit Memo Accounting Amount
36997 --Credit Memo Bill To Customer Site Use Identifier
36994 , p_source_51 IN NUMBER
36995 --Credit Memo Bill To Customer Account Identifier
36996 , p_source_52 IN NUMBER
36998 , p_source_53 IN NUMBER
36999 --Credit Memo Tax Line Identifier
37000 , p_source_54 IN NUMBER
37001 --Credit Memo Distribution Account Class
37002 , p_source_55 IN VARCHAR2
37003 --Credit Memo Distribution Entered Amount
37004 , p_source_56 IN NUMBER
37005 --Credit Memo Invoicing Rule
37006 , p_source_69 IN NUMBER
37007 )
37008 IS
37009
37010 l_component_type VARCHAR2(80);
37011 l_component_code VARCHAR2(30);
37012 l_component_type_code VARCHAR2(1);
37013 l_component_appl_id INTEGER;
37014 l_amb_context_code VARCHAR2(30);
37015 l_entity_code VARCHAR2(30);
37016 l_event_class_code VARCHAR2(30);
37017 l_ae_header_id NUMBER;
37018 l_event_type_code VARCHAR2(30);
37019 l_line_definition_code VARCHAR2(30);
37020 l_line_definition_owner_code VARCHAR2(1);
37021 --
37022 -- adr variables
37023 l_segment VARCHAR2(30);
37024 l_ccid NUMBER;
37025 l_adr_transaction_coa_id NUMBER;
37026 l_adr_accounting_coa_id NUMBER;
37027 l_adr_flexfield_segment_code VARCHAR2(30);
37028 l_adr_flex_value_set_id NUMBER;
37029 l_adr_value_type_code VARCHAR2(30);
37030 l_adr_value_combination_id NUMBER;
37031 l_adr_value_segment_code VARCHAR2(30);
37032
37033 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
37034 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
37035 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
37036 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
37037
37038 -- 4262811 Variables ------------------------------------------------------------------------------------------
37039 l_entered_amt_idx NUMBER;
37040 l_accted_amt_idx NUMBER;
37041 l_acc_rev_flag VARCHAR2(1);
37042 l_accrual_line_num NUMBER;
37043 l_tmp_amt NUMBER;
37044 l_acc_rev_natural_side_code VARCHAR2(1);
37045
37046 l_num_entries NUMBER;
37047 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
37048 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
37049 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
37050 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
37051 l_recog_line_1 NUMBER;
37052 l_recog_line_2 NUMBER;
37053
37054 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
37055 l_bflow_applied_to_amt NUMBER; -- 5132302
37056 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
37057
37058 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
37059
37060 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
37061 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
37062
37063 ---------------------------------------------------------------------------------------------------------------
37064
37065
37066 --
37067 -- bulk performance
37068 --
37069 l_balance_type_code VARCHAR2(1);
37070 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
37071 l_log_module VARCHAR2(240);
37072
37073 --
37074 -- Upgrade strategy
37075 --
37076 l_actual_upg_option VARCHAR2(1);
37077 l_enc_upg_option VARCHAR2(1);
37078
37079 --
37080 BEGIN
37081 --
37082 IF g_log_enabled THEN
37083 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_88';
37084 END IF;
37085 --
37086 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
37087
37088 trace
37089 (p_msg => 'BEGIN of AcctLineType_88'
37090 ,p_level => C_LEVEL_PROCEDURE
37091 ,p_module => l_log_module);
37092
37093 END IF;
37094 --
37095 l_component_type := 'AMB_JLT';
37096 l_component_code := 'MFAR_CM_REC';
37097 l_component_type_code := 'S';
37098 l_component_appl_id := 222;
37099 l_amb_context_code := 'DEFAULT';
37100 l_entity_code := 'TRANSACTIONS';
37101 l_event_class_code := 'CREDIT_MEMO';
37102 l_event_type_code := 'CREDIT_MEMO_ALL';
37103 l_line_definition_owner_code := 'S';
37104 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
37105 --
37106 l_balance_type_code := 'A';
37107 l_segment := NULL;
37108 l_ccid := NULL;
37109 l_adr_transaction_coa_id := NULL;
37110 l_adr_accounting_coa_id := NULL;
37111 l_adr_flexfield_segment_code := NULL;
37112 l_adr_flex_value_set_id := NULL;
37113 l_adr_value_type_code := NULL;
37114 l_adr_value_combination_id := NULL;
37115 l_adr_value_segment_code := NULL;
37116
37117 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
37118 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
37119 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
37120 l_budgetary_control_flag := 'N';
37124 l_entered_amt_idx := NULL; -- 4262811
37121
37122 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37123 l_bflow_applied_to_amt := NULL; -- 5132302
37125 l_accted_amt_idx := NULL; -- 4262811
37126 l_acc_rev_flag := NULL; -- 4262811
37127 l_accrual_line_num := NULL; -- 4262811
37128 l_tmp_amt := NULL; -- 4262811
37129 --
37130
37131 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
37132 l_balance_type_code <> 'B' THEN
37133 IF (p_source_69 IS NULL ) AND
37134 (NVL(p_source_55,'
37135 ') = 'REV' OR
37136 NVL(p_source_55,'
37137 ') = 'TAX' OR
37138 NVL(p_source_55,'
37139 ') = 'FREIGHT' OR
37140 NVL(p_source_55,'
37141 ') = 'ROUND' OR
37142 NVL(p_source_55,'
37143 ') = 'CHARGES')
37144 THEN
37145
37146 --
37147 XLA_AE_LINES_PKG.SetNewLine;
37148
37149 p_balance_type_code := l_balance_type_code;
37150 -- set the flag so later we will know whether the gain loss line needs to be created
37151
37152 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
37153 p_actual_flag :='A';
37154 END IF;
37155
37156 --
37157 -- bulk performance
37158 --
37159 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
37160 p_header_num => 0); -- 4262811
37161 --
37162 -- set accounting line options
37163 --
37164 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
37165 p_natural_side_code => 'D'
37166 , p_gain_or_loss_flag => 'N'
37167 , p_gl_transfer_mode_code => 'S'
37168 , p_acct_entry_type_code => 'A'
37169 , p_switch_side_flag => 'Y'
37170 , p_merge_duplicate_code => 'A'
37171 );
37172 --
37173 l_acc_rev_natural_side_code := 'C'; -- 4262811
37174 --
37175 --
37176 -- set accounting line type info
37177 --
37178 xla_ae_lines_pkg.SetAcctLineType
37179 (p_component_type => l_component_type
37180 ,p_event_type_code => l_event_type_code
37181 ,p_line_definition_owner_code => l_line_definition_owner_code
37182 ,p_line_definition_code => l_line_definition_code
37183 ,p_accounting_line_code => l_component_code
37184 ,p_accounting_line_type_code => l_component_type_code
37185 ,p_accounting_line_appl_id => l_component_appl_id
37186 ,p_amb_context_code => l_amb_context_code
37187 ,p_entity_code => l_entity_code
37188 ,p_event_class_code => l_event_class_code);
37189 --
37190 -- set accounting class
37191 --
37192 xla_ae_lines_pkg.SetAcctClass(
37193 p_accounting_class_code => 'RECEIVABLE'
37194 , p_ae_header_id => l_ae_header_id
37195 );
37196
37197 --
37198 -- set rounding class
37199 --
37200 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
37201 'RECEIVABLE';
37202
37203 --
37204 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
37205 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
37206 --
37207 -- bulk performance
37208 --
37209 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
37210
37211 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
37212 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
37213
37214 -- 4955764
37215 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
37216 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
37217
37218 -- 4458381 Public Sector Enh
37219
37220 --
37221 -- set accounting attributes for the line type
37222 --
37223 l_entered_amt_idx := 3;
37224 l_accted_amt_idx := 9;
37225 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37226 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
37227 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_44);
37228 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
37229 l_rec_acct_attrs.array_char_value(2) := p_source_45;
37230 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
37231 l_rec_acct_attrs.array_num_value(3) := p_source_56;
37232 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
37233 l_rec_acct_attrs.array_char_value(4) := p_source_46;
37234 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
37235 l_rec_acct_attrs.array_date_value(5) := p_source_47;
37236 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
37237 l_rec_acct_attrs.array_num_value(6) := p_source_48;
37238 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
37239 l_rec_acct_attrs.array_char_value(7) := p_source_49;
37240 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
37241 l_rec_acct_attrs.array_char_value(8) := p_source_50;
37242 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
37246 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
37243 l_rec_acct_attrs.array_num_value(9) := p_source_51;
37244 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
37245 l_rec_acct_attrs.array_num_value(10) := p_source_52;
37247 l_rec_acct_attrs.array_num_value(11) := p_source_53;
37248 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
37249 l_rec_acct_attrs.array_char_value(12) := p_source_34;
37250 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
37251 l_rec_acct_attrs.array_num_value(13) := p_source_54;
37252
37253 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
37254 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
37255
37256 ---------------------------------------------------------------------------------------------------------------
37257 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
37258 ---------------------------------------------------------------------------------------------------------------
37259 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
37260
37261 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37262 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37263
37264 IF xla_accounting_cache_pkg.GetValueChar
37265 (p_source_code => 'LEDGER_CATEGORY_CODE'
37266 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
37267 AND l_bflow_method_code = 'PRIOR_ENTRY'
37268 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
37269 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
37270 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
37271 )
37272 THEN
37273 xla_ae_lines_pkg.BflowUpgEntry
37274 (p_business_method_code => l_bflow_method_code
37275 ,p_business_class_code => l_bflow_class_code
37276 ,p_balance_type => l_balance_type_code);
37277 ELSE
37278 NULL;
37279 -- No business flow processing for business flow method of NONE.
37280 END IF;
37281
37282 --
37283 -- call analytical criteria
37284 --
37285
37286 --
37287 -- call description
37288 --
37289
37290 xla_ae_lines_pkg.SetLineDescription(
37291 p_ae_header_id => l_ae_header_id
37292 ,p_description => Description_1 (
37293 p_application_id => p_application_id
37294 , p_ae_header_id => l_ae_header_id
37295 )
37296 );
37297
37298
37299 --
37300 -- call ADRs
37301 -- Bug 4922099
37302 --
37303 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
37304 (NVL(l_actual_upg_option, 'N') = 'O') OR
37305 (NVL(l_enc_upg_option, 'N') = 'O')
37306 )
37307 THEN
37308 NULL;
37309 --
37310 --
37311
37312 l_ccid := AcctDerRule_10(
37313 p_application_id => p_application_id
37314 , p_ae_header_id => l_ae_header_id
37315 , p_source_9 => p_source_9
37316 , x_transaction_coa_id => l_adr_transaction_coa_id
37317 , x_accounting_coa_id => l_adr_accounting_coa_id
37318 , x_value_type_code => l_adr_value_type_code
37319 , p_side => 'NA'
37320 );
37321
37322 xla_ae_lines_pkg.set_ccid(
37323 p_code_combination_id => l_ccid
37324 , p_value_type_code => l_adr_value_type_code
37325 , p_transaction_coa_id => l_adr_transaction_coa_id
37326 , p_accounting_coa_id => l_adr_accounting_coa_id
37327 , p_adr_code => 'CM_DIST_CCID'
37328 , p_adr_type_code => 'S'
37329 , p_component_type => l_component_type
37330 , p_component_code => l_component_code
37331 , p_component_type_code => l_component_type_code
37332 , p_component_appl_id => l_component_appl_id
37333 , p_amb_context_code => l_amb_context_code
37334 , p_side => 'NA'
37335 );
37336
37337
37338 l_segment := AcctDerRule_3(
37339 p_application_id => p_application_id
37340 , p_ae_header_id => l_ae_header_id
37341 , p_source_2 => p_source_2
37342 , x_transaction_coa_id => l_adr_transaction_coa_id
37343 , x_accounting_coa_id => l_adr_accounting_coa_id
37344 , x_flexfield_segment_code => l_adr_flexfield_segment_code
37345 , x_flex_value_set_id => l_adr_flex_value_set_id
37346 , x_value_type_code => l_adr_value_type_code
37347 , x_value_combination_id => l_adr_value_combination_id
37348 , x_value_segment_code => l_adr_value_segment_code
37349 , p_side => 'NA'
37350 , p_override_seg_flag => 'Y'
37351 );
37352
37353 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
37354
37355 xla_ae_lines_pkg.set_segment(
37356 p_to_segment_code => 'GL_ACCOUNT'
37357 , p_segment_value => l_segment
37358 , p_from_segment_code => l_adr_value_segment_code
37359 , p_from_combination_id => l_adr_value_combination_id
37360 , p_value_type_code => l_adr_value_type_code
37364 , p_flex_value_set_id => l_adr_flex_value_set_id
37361 , p_transaction_coa_id => l_adr_transaction_coa_id
37362 , p_accounting_coa_id => l_adr_accounting_coa_id
37363 , p_flexfield_segment_code => l_adr_flexfield_segment_code
37365 , p_adr_code => 'MFAR_CM_NATURAL_SEGMENT'
37366 , p_adr_type_code => 'S'
37367 , p_component_type => l_component_type
37368 , p_component_code => l_component_code
37369 , p_component_type_code => l_component_type_code
37370 , p_component_appl_id => l_component_appl_id
37371 , p_amb_context_code => l_amb_context_code
37372 , p_entity_code => 'TRANSACTIONS'
37373 , p_event_class_code => 'CREDIT_MEMO'
37374 , p_side => 'NA'
37375 );
37376
37377 END IF;
37378
37379 --
37380 --
37381 END IF;
37382 --
37383 -- Bug 4922099
37384 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
37385 (NVL(l_enc_upg_option, 'N') = 'O')
37386 ) AND
37387 (l_bflow_method_code = 'PRIOR_ENTRY')
37388 )
37389 THEN
37390 IF
37391 --
37392 1 = 2
37393 --
37394 THEN
37395 xla_accounting_err_pkg.build_message
37396 (p_appli_s_name => 'XLA'
37397 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37398 ,p_token_1 => 'LINE_NUMBER'
37399 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
37400 ,p_token_2 => 'LINE_TYPE_NAME'
37401 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
37402 l_component_type
37403 ,l_component_code
37404 ,l_component_type_code
37405 ,l_component_appl_id
37406 ,l_amb_context_code
37407 ,l_entity_code
37408 ,l_event_class_code
37409 )
37410 ,p_token_3 => 'OWNER'
37411 ,p_value_3 => xla_lookups_pkg.get_meaning(
37412 p_lookup_type => 'XLA_OWNER_TYPE'
37413 ,p_lookup_code => l_component_type_code
37414 )
37415 ,p_token_4 => 'PRODUCT_NAME'
37416 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
37417 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
37418 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
37419 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
37420 ,p_ae_header_id => NULL
37421 );
37422
37423 IF (C_LEVEL_ERROR>= g_log_level) THEN
37424 trace
37425 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37426 ,p_level => C_LEVEL_ERROR
37427 ,p_module => l_log_module);
37428 END IF;
37429 END IF;
37430 END IF;
37431 --
37432 --
37433 ------------------------------------------------------------------------------------------------
37434 -- 4219869 Business Flow
37435 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
37436 -- Prior Entry. Currently, the following code is always generated.
37437 ------------------------------------------------------------------------------------------------
37438 XLA_AE_LINES_PKG.ValidateCurrentLine;
37439
37440 ------------------------------------------------------------------------------------
37441 -- 4219869 Business Flow
37442 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
37443 ------------------------------------------------------------------------------------
37444 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
37445
37446 ----------------------------------------------------------------------------------
37447 -- 4219869 Business Flow
37448 -- Update journal entry status -- Need to generate this within IF <condition>
37449 ----------------------------------------------------------------------------------
37450 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
37451 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
37452 ,p_balance_type_code => l_balance_type_code
37453 );
37454
37455 -------------------------------------------------------------------------------------------
37456 -- 4262811 - Generate the Accrual Reversal lines
37460 (g_array_event(p_event_id).array_value_num('header_index'));
37457 -------------------------------------------------------------------------------------------
37458 BEGIN
37459 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
37461 IF l_acc_rev_flag IS NULL THEN
37462 l_acc_rev_flag := 'N';
37463 END IF;
37464 EXCEPTION
37465 WHEN OTHERS THEN
37466 l_acc_rev_flag := 'N';
37467 END;
37468 --
37469 IF (l_acc_rev_flag = 'Y') THEN
37470
37471 -- 4645092 ------------------------------------------------------------------------------
37472 -- To allow MPA report to determine if it should generate report process
37473 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
37474 ------------------------------------------------------------------------------------------
37475
37476 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
37477 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
37478 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
37479 -- call ADRs
37480 -- Bug 4922099
37481 --
37482 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
37483 (NVL(l_actual_upg_option, 'N') = 'O') OR
37484 (NVL(l_enc_upg_option, 'N') = 'O')
37485 )
37486 THEN
37487 NULL;
37488 --
37489 --
37490
37491 l_ccid := AcctDerRule_10(
37492 p_application_id => p_application_id
37493 , p_ae_header_id => l_ae_header_id
37494 , p_source_9 => p_source_9
37495 , x_transaction_coa_id => l_adr_transaction_coa_id
37496 , x_accounting_coa_id => l_adr_accounting_coa_id
37497 , x_value_type_code => l_adr_value_type_code
37498 , p_side => 'NA'
37499 );
37500
37501 xla_ae_lines_pkg.set_ccid(
37502 p_code_combination_id => l_ccid
37503 , p_value_type_code => l_adr_value_type_code
37504 , p_transaction_coa_id => l_adr_transaction_coa_id
37505 , p_accounting_coa_id => l_adr_accounting_coa_id
37506 , p_adr_code => 'CM_DIST_CCID'
37507 , p_adr_type_code => 'S'
37508 , p_component_type => l_component_type
37509 , p_component_code => l_component_code
37510 , p_component_type_code => l_component_type_code
37511 , p_component_appl_id => l_component_appl_id
37512 , p_amb_context_code => l_amb_context_code
37513 , p_side => 'NA'
37514 );
37515
37516
37517 l_segment := AcctDerRule_3(
37518 p_application_id => p_application_id
37519 , p_ae_header_id => l_ae_header_id
37520 , p_source_2 => p_source_2
37521 , x_transaction_coa_id => l_adr_transaction_coa_id
37522 , x_accounting_coa_id => l_adr_accounting_coa_id
37523 , x_flexfield_segment_code => l_adr_flexfield_segment_code
37524 , x_flex_value_set_id => l_adr_flex_value_set_id
37525 , x_value_type_code => l_adr_value_type_code
37526 , x_value_combination_id => l_adr_value_combination_id
37527 , x_value_segment_code => l_adr_value_segment_code
37528 , p_side => 'NA'
37529 , p_override_seg_flag => 'Y'
37530 );
37531
37532 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
37533
37534 xla_ae_lines_pkg.set_segment(
37535 p_to_segment_code => 'GL_ACCOUNT'
37536 , p_segment_value => l_segment
37537 , p_from_segment_code => l_adr_value_segment_code
37538 , p_from_combination_id => l_adr_value_combination_id
37539 , p_value_type_code => l_adr_value_type_code
37540 , p_transaction_coa_id => l_adr_transaction_coa_id
37541 , p_accounting_coa_id => l_adr_accounting_coa_id
37542 , p_flexfield_segment_code => l_adr_flexfield_segment_code
37543 , p_flex_value_set_id => l_adr_flex_value_set_id
37544 , p_adr_code => 'MFAR_CM_NATURAL_SEGMENT'
37545 , p_adr_type_code => 'S'
37546 , p_component_type => l_component_type
37547 , p_component_code => l_component_code
37548 , p_component_type_code => l_component_type_code
37549 , p_component_appl_id => l_component_appl_id
37550 , p_amb_context_code => l_amb_context_code
37551 , p_entity_code => 'TRANSACTIONS'
37552 , p_event_class_code => 'CREDIT_MEMO'
37553 , p_side => 'NA'
37554 );
37555
37556 END IF;
37557
37558 --
37559 --
37560 END IF;
37561
37562 --
37563 -- Update the line information that should be overwritten
37564 --
37565 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
37566 p_header_num => 1);
37567 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
37568
37569 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
37570
37571 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
37572 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
37576 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
37573 END IF;
37574
37575 --
37577 --
37578 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
37579 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
37580 ELSE
37581 ---------------------------------------------------------------------------------------------------
37582 -- 4262811a Switch Sign
37583 ---------------------------------------------------------------------------------------------------
37584 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
37585 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
37586 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37587 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
37588 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37589 -- 5132302
37590 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
37591 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37592
37593 END IF;
37594
37595 -- 4955764
37596 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
37597 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
37598
37599
37600 XLA_AE_LINES_PKG.ValidateCurrentLine;
37601 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
37602
37603 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
37604 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
37605 ,p_balance_type_code => l_balance_type_code);
37606
37607 END IF;
37608
37609 -----------------------------------------------------------------------------------------
37610 -- 4262811 Multiperiod Accounting
37611 -----------------------------------------------------------------------------------------
37612 -- No MPA option is assigned.
37613
37614
37615 END IF;
37616 END IF;
37617 --
37618
37619 --
37620 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
37621 trace
37622 (p_msg => 'END of AcctLineType_88'
37623 ,p_level => C_LEVEL_PROCEDURE
37624 ,p_module => l_log_module);
37625 END IF;
37626 --
37627 EXCEPTION
37628 WHEN xla_exceptions_pkg.application_exception THEN
37629 RAISE;
37630 WHEN OTHERS THEN
37631 xla_exceptions_pkg.raise_message
37632 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_88');
37633 END AcctLineType_88;
37634 --
37635
37636 ---------------------------------------
37637 --
37638 -- PRIVATE FUNCTION
37639 -- AcctLineType_89
37640 --
37641 ---------------------------------------
37642 PROCEDURE AcctLineType_89 (
37643 p_application_id IN NUMBER
37644 ,p_event_id IN NUMBER
37645 ,p_calculate_acctd_flag IN VARCHAR2
37646 ,p_calculate_g_l_flag IN VARCHAR2
37647 ,p_actual_flag IN OUT VARCHAR2
37648 ,p_balance_type_code OUT VARCHAR2
37649 ,p_gain_or_loss_ref OUT VARCHAR2
37650
37651 --Transaction Default Receivable Account
37652 , p_source_8 IN NUMBER
37653 --Transaction Distribution GL Account
37654 , p_source_21 IN NUMBER
37655 --Bill To Customer Account Identifier
37656 , p_source_32 IN NUMBER
37657 --Bill To Customer Site Use Identifier
37658 , p_source_33 IN NUMBER
37659 --SLA Party Type
37660 , p_source_34 IN VARCHAR2
37661 --Transaction Distribution Account Class
37662 , p_source_35 IN VARCHAR2
37663 --Transaction Distribution Identifier
37664 , p_source_36 IN NUMBER
37665 --Transaction Distribution Type
37666 , p_source_37 IN VARCHAR2
37667 --Transaction Distribution Entered Amount
37668 , p_source_38 IN NUMBER
37669 --Transaction Currency Code
37670 , p_source_39 IN VARCHAR2
37671 --Transaction Exchange Date
37672 , p_source_40 IN DATE
37673 --Transaction Exchange Rate
37674 , p_source_41 IN NUMBER
37675 --Transaction Exchange Rate Type
37676 , p_source_42 IN VARCHAR2
37677 --Transaction Accounting Amount
37678 , p_source_43 IN NUMBER
37679 --Transaction Tax Line Identifier
37680 , p_source_57 IN NUMBER
37681 --Transaction Invoicing Rule
37682 , p_source_70 IN NUMBER
37683 )
37684 IS
37685
37686 l_component_type VARCHAR2(80);
37687 l_component_code VARCHAR2(30);
37688 l_component_type_code VARCHAR2(1);
37689 l_component_appl_id INTEGER;
37690 l_amb_context_code VARCHAR2(30);
37691 l_entity_code VARCHAR2(30);
37692 l_event_class_code VARCHAR2(30);
37693 l_ae_header_id NUMBER;
37694 l_event_type_code VARCHAR2(30);
37695 l_line_definition_code VARCHAR2(30);
37696 l_line_definition_owner_code VARCHAR2(1);
37697 --
37698 -- adr variables
37702 l_adr_accounting_coa_id NUMBER;
37699 l_segment VARCHAR2(30);
37700 l_ccid NUMBER;
37701 l_adr_transaction_coa_id NUMBER;
37703 l_adr_flexfield_segment_code VARCHAR2(30);
37704 l_adr_flex_value_set_id NUMBER;
37705 l_adr_value_type_code VARCHAR2(30);
37706 l_adr_value_combination_id NUMBER;
37707 l_adr_value_segment_code VARCHAR2(30);
37708
37709 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
37710 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
37711 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
37712 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
37713
37714 -- 4262811 Variables ------------------------------------------------------------------------------------------
37715 l_entered_amt_idx NUMBER;
37716 l_accted_amt_idx NUMBER;
37717 l_acc_rev_flag VARCHAR2(1);
37718 l_accrual_line_num NUMBER;
37719 l_tmp_amt NUMBER;
37720 l_acc_rev_natural_side_code VARCHAR2(1);
37721
37722 l_num_entries NUMBER;
37723 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
37724 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
37725 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
37726 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
37727 l_recog_line_1 NUMBER;
37728 l_recog_line_2 NUMBER;
37729
37730 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
37731 l_bflow_applied_to_amt NUMBER; -- 5132302
37732 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
37733
37734 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
37735
37736 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
37737 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
37738
37739 ---------------------------------------------------------------------------------------------------------------
37740
37741
37742 --
37743 -- bulk performance
37744 --
37745 l_balance_type_code VARCHAR2(1);
37746 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
37747 l_log_module VARCHAR2(240);
37748
37749 --
37750 -- Upgrade strategy
37751 --
37752 l_actual_upg_option VARCHAR2(1);
37753 l_enc_upg_option VARCHAR2(1);
37754
37755 --
37756 BEGIN
37757 --
37758 IF g_log_enabled THEN
37759 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_89';
37760 END IF;
37761 --
37762 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
37763
37764 trace
37765 (p_msg => 'BEGIN of AcctLineType_89'
37766 ,p_level => C_LEVEL_PROCEDURE
37767 ,p_module => l_log_module);
37768
37769 END IF;
37770 --
37771 l_component_type := 'AMB_JLT';
37772 l_component_code := 'MFAR_DM_REC';
37773 l_component_type_code := 'S';
37774 l_component_appl_id := 222;
37775 l_amb_context_code := 'DEFAULT';
37776 l_entity_code := 'TRANSACTIONS';
37777 l_event_class_code := 'DEBIT_MEMO';
37778 l_event_type_code := 'DEBIT_MEMO_ALL';
37779 l_line_definition_owner_code := 'S';
37780 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
37781 --
37782 l_balance_type_code := 'A';
37783 l_segment := NULL;
37784 l_ccid := NULL;
37785 l_adr_transaction_coa_id := NULL;
37786 l_adr_accounting_coa_id := NULL;
37787 l_adr_flexfield_segment_code := NULL;
37788 l_adr_flex_value_set_id := NULL;
37789 l_adr_value_type_code := NULL;
37790 l_adr_value_combination_id := NULL;
37791 l_adr_value_segment_code := NULL;
37792
37793 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
37794 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
37795 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
37796 l_budgetary_control_flag := 'N';
37797
37798 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37799 l_bflow_applied_to_amt := NULL; -- 5132302
37800 l_entered_amt_idx := NULL; -- 4262811
37801 l_accted_amt_idx := NULL; -- 4262811
37802 l_acc_rev_flag := NULL; -- 4262811
37803 l_accrual_line_num := NULL; -- 4262811
37804 l_tmp_amt := NULL; -- 4262811
37805 --
37806
37807 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
37808 l_balance_type_code <> 'B' THEN
37809 IF (p_source_70 IS NULL ) AND
37810 (NVL(p_source_35,'
37811 ') = 'REV' OR
37812 NVL(p_source_35,'
37813 ') = 'TAX' OR
37814 NVL(p_source_35,'
37815 ') = 'FREIGHT' OR
37816 NVL(p_source_35,'
37817 ') = 'ROUND' OR
37818 NVL(p_source_35,'
37819 ') = 'CHARGES')
37820 THEN
37821
37822 --
37823 XLA_AE_LINES_PKG.SetNewLine;
37824
37825 p_balance_type_code := l_balance_type_code;
37826 -- set the flag so later we will know whether the gain loss line needs to be created
37827
37831
37828 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
37829 p_actual_flag :='A';
37830 END IF;
37832 --
37833 -- bulk performance
37834 --
37835 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
37836 p_header_num => 0); -- 4262811
37837 --
37838 -- set accounting line options
37839 --
37840 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
37841 p_natural_side_code => 'D'
37842 , p_gain_or_loss_flag => 'N'
37843 , p_gl_transfer_mode_code => 'S'
37844 , p_acct_entry_type_code => 'A'
37845 , p_switch_side_flag => 'Y'
37846 , p_merge_duplicate_code => 'A'
37847 );
37848 --
37849 l_acc_rev_natural_side_code := 'C'; -- 4262811
37850 --
37851 --
37852 -- set accounting line type info
37853 --
37854 xla_ae_lines_pkg.SetAcctLineType
37855 (p_component_type => l_component_type
37856 ,p_event_type_code => l_event_type_code
37857 ,p_line_definition_owner_code => l_line_definition_owner_code
37858 ,p_line_definition_code => l_line_definition_code
37859 ,p_accounting_line_code => l_component_code
37860 ,p_accounting_line_type_code => l_component_type_code
37861 ,p_accounting_line_appl_id => l_component_appl_id
37862 ,p_amb_context_code => l_amb_context_code
37863 ,p_entity_code => l_entity_code
37864 ,p_event_class_code => l_event_class_code);
37865 --
37866 -- set accounting class
37867 --
37868 xla_ae_lines_pkg.SetAcctClass(
37869 p_accounting_class_code => 'RECEIVABLE'
37870 , p_ae_header_id => l_ae_header_id
37871 );
37872
37873 --
37874 -- set rounding class
37875 --
37876 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
37877 'RECEIVABLE';
37878
37879 --
37880 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
37881 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
37882 --
37883 -- bulk performance
37884 --
37885 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
37886
37887 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
37888 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
37889
37890 -- 4955764
37891 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
37892 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
37893
37894 -- 4458381 Public Sector Enh
37895
37896 --
37897 -- set accounting attributes for the line type
37898 --
37899 l_entered_amt_idx := 3;
37900 l_accted_amt_idx := 8;
37901 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37902 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
37903 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
37904 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
37905 l_rec_acct_attrs.array_char_value(2) := p_source_37;
37906 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
37907 l_rec_acct_attrs.array_num_value(3) := p_source_38;
37908 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
37909 l_rec_acct_attrs.array_char_value(4) := p_source_39;
37910 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
37911 l_rec_acct_attrs.array_date_value(5) := p_source_40;
37912 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
37913 l_rec_acct_attrs.array_num_value(6) := p_source_41;
37914 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
37915 l_rec_acct_attrs.array_char_value(7) := p_source_42;
37916 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
37917 l_rec_acct_attrs.array_num_value(8) := p_source_43;
37918 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
37919 l_rec_acct_attrs.array_num_value(9) := p_source_32;
37920 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
37921 l_rec_acct_attrs.array_num_value(10) := p_source_33;
37922 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
37923 l_rec_acct_attrs.array_char_value(11) := p_source_34;
37924 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
37925 l_rec_acct_attrs.array_num_value(12) := p_source_57;
37926
37927 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
37928 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
37929
37930 ---------------------------------------------------------------------------------------------------------------
37931 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
37932 ---------------------------------------------------------------------------------------------------------------
37933 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
37934
37935 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37936 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37937
37938 IF xla_accounting_cache_pkg.GetValueChar
37942 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
37939 (p_source_code => 'LEDGER_CATEGORY_CODE'
37940 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
37941 AND l_bflow_method_code = 'PRIOR_ENTRY'
37943 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
37944 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
37945 )
37946 THEN
37947 xla_ae_lines_pkg.BflowUpgEntry
37948 (p_business_method_code => l_bflow_method_code
37949 ,p_business_class_code => l_bflow_class_code
37950 ,p_balance_type => l_balance_type_code);
37951 ELSE
37952 NULL;
37953 -- No business flow processing for business flow method of NONE.
37954 END IF;
37955
37956 --
37957 -- call analytical criteria
37958 --
37959
37960 --
37961 -- call description
37962 --
37963
37964 xla_ae_lines_pkg.SetLineDescription(
37965 p_ae_header_id => l_ae_header_id
37966 ,p_description => Description_1 (
37967 p_application_id => p_application_id
37968 , p_ae_header_id => l_ae_header_id
37969 )
37970 );
37971
37972
37973 --
37974 -- call ADRs
37975 -- Bug 4922099
37976 --
37977 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
37978 (NVL(l_actual_upg_option, 'N') = 'O') OR
37979 (NVL(l_enc_upg_option, 'N') = 'O')
37980 )
37981 THEN
37982 NULL;
37983 --
37984 --
37985
37986 l_ccid := AcctDerRule_34(
37987 p_application_id => p_application_id
37988 , p_ae_header_id => l_ae_header_id
37989 , p_source_21 => p_source_21
37990 , x_transaction_coa_id => l_adr_transaction_coa_id
37991 , x_accounting_coa_id => l_adr_accounting_coa_id
37992 , x_value_type_code => l_adr_value_type_code
37993 , p_side => 'NA'
37994 );
37995
37996 xla_ae_lines_pkg.set_ccid(
37997 p_code_combination_id => l_ccid
37998 , p_value_type_code => l_adr_value_type_code
37999 , p_transaction_coa_id => l_adr_transaction_coa_id
38000 , p_accounting_coa_id => l_adr_accounting_coa_id
38001 , p_adr_code => 'TRX_DIST_CCID'
38002 , p_adr_type_code => 'S'
38003 , p_component_type => l_component_type
38004 , p_component_code => l_component_code
38005 , p_component_type_code => l_component_type_code
38006 , p_component_appl_id => l_component_appl_id
38007 , p_amb_context_code => l_amb_context_code
38008 , p_side => 'NA'
38009 );
38010
38011
38012 l_segment := AcctDerRule_9(
38013 p_application_id => p_application_id
38014 , p_ae_header_id => l_ae_header_id
38015 , p_source_8 => p_source_8
38016 , x_transaction_coa_id => l_adr_transaction_coa_id
38017 , x_accounting_coa_id => l_adr_accounting_coa_id
38018 , x_flexfield_segment_code => l_adr_flexfield_segment_code
38019 , x_flex_value_set_id => l_adr_flex_value_set_id
38020 , x_value_type_code => l_adr_value_type_code
38021 , x_value_combination_id => l_adr_value_combination_id
38022 , x_value_segment_code => l_adr_value_segment_code
38023 , p_side => 'NA'
38024 , p_override_seg_flag => 'Y'
38025 );
38026
38027 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
38028
38029 xla_ae_lines_pkg.set_segment(
38030 p_to_segment_code => 'GL_ACCOUNT'
38031 , p_segment_value => l_segment
38032 , p_from_segment_code => l_adr_value_segment_code
38033 , p_from_combination_id => l_adr_value_combination_id
38034 , p_value_type_code => l_adr_value_type_code
38035 , p_transaction_coa_id => l_adr_transaction_coa_id
38036 , p_accounting_coa_id => l_adr_accounting_coa_id
38037 , p_flexfield_segment_code => l_adr_flexfield_segment_code
38038 , p_flex_value_set_id => l_adr_flex_value_set_id
38039 , p_adr_code => 'MFAR_TRX_NATURAL_SEGMENT'
38040 , p_adr_type_code => 'S'
38041 , p_component_type => l_component_type
38042 , p_component_code => l_component_code
38043 , p_component_type_code => l_component_type_code
38044 , p_component_appl_id => l_component_appl_id
38045 , p_amb_context_code => l_amb_context_code
38046 , p_entity_code => 'TRANSACTIONS'
38047 , p_event_class_code => 'DEBIT_MEMO'
38048 , p_side => 'NA'
38049 );
38050
38051 END IF;
38052
38053 --
38054 --
38055 END IF;
38056 --
38057 -- Bug 4922099
38058 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
38059 (NVL(l_enc_upg_option, 'N') = 'O')
38060 ) AND
38061 (l_bflow_method_code = 'PRIOR_ENTRY')
38062 )
38063 THEN
38064 IF
38065 --
38066 1 = 2
38067 --
38068 THEN
38069 xla_accounting_err_pkg.build_message
38070 (p_appli_s_name => 'XLA'
38074 ,p_token_2 => 'LINE_TYPE_NAME'
38071 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38072 ,p_token_1 => 'LINE_NUMBER'
38073 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
38075 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
38076 l_component_type
38077 ,l_component_code
38078 ,l_component_type_code
38079 ,l_component_appl_id
38080 ,l_amb_context_code
38081 ,l_entity_code
38082 ,l_event_class_code
38083 )
38084 ,p_token_3 => 'OWNER'
38085 ,p_value_3 => xla_lookups_pkg.get_meaning(
38086 p_lookup_type => 'XLA_OWNER_TYPE'
38087 ,p_lookup_code => l_component_type_code
38088 )
38089 ,p_token_4 => 'PRODUCT_NAME'
38090 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
38091 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
38092 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
38093 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
38094 ,p_ae_header_id => NULL
38095 );
38096
38097 IF (C_LEVEL_ERROR>= g_log_level) THEN
38098 trace
38099 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38100 ,p_level => C_LEVEL_ERROR
38101 ,p_module => l_log_module);
38102 END IF;
38103 END IF;
38104 END IF;
38105 --
38106 --
38107 ------------------------------------------------------------------------------------------------
38108 -- 4219869 Business Flow
38109 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
38110 -- Prior Entry. Currently, the following code is always generated.
38111 ------------------------------------------------------------------------------------------------
38112 XLA_AE_LINES_PKG.ValidateCurrentLine;
38113
38114 ------------------------------------------------------------------------------------
38115 -- 4219869 Business Flow
38116 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
38117 ------------------------------------------------------------------------------------
38118 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38119
38120 ----------------------------------------------------------------------------------
38121 -- 4219869 Business Flow
38122 -- Update journal entry status -- Need to generate this within IF <condition>
38123 ----------------------------------------------------------------------------------
38124 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38125 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
38126 ,p_balance_type_code => l_balance_type_code
38127 );
38128
38129 -------------------------------------------------------------------------------------------
38130 -- 4262811 - Generate the Accrual Reversal lines
38131 -------------------------------------------------------------------------------------------
38132 BEGIN
38133 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
38134 (g_array_event(p_event_id).array_value_num('header_index'));
38135 IF l_acc_rev_flag IS NULL THEN
38136 l_acc_rev_flag := 'N';
38137 END IF;
38138 EXCEPTION
38139 WHEN OTHERS THEN
38140 l_acc_rev_flag := 'N';
38141 END;
38142 --
38143 IF (l_acc_rev_flag = 'Y') THEN
38144
38145 -- 4645092 ------------------------------------------------------------------------------
38146 -- To allow MPA report to determine if it should generate report process
38147 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
38148 ------------------------------------------------------------------------------------------
38149
38150 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
38151 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
38152 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
38153 -- call ADRs
38154 -- Bug 4922099
38155 --
38156 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38157 (NVL(l_actual_upg_option, 'N') = 'O') OR
38158 (NVL(l_enc_upg_option, 'N') = 'O')
38159 )
38160 THEN
38161 NULL;
38162 --
38163 --
38167 , p_ae_header_id => l_ae_header_id
38164
38165 l_ccid := AcctDerRule_34(
38166 p_application_id => p_application_id
38168 , p_source_21 => p_source_21
38169 , x_transaction_coa_id => l_adr_transaction_coa_id
38170 , x_accounting_coa_id => l_adr_accounting_coa_id
38171 , x_value_type_code => l_adr_value_type_code
38172 , p_side => 'NA'
38173 );
38174
38175 xla_ae_lines_pkg.set_ccid(
38176 p_code_combination_id => l_ccid
38177 , p_value_type_code => l_adr_value_type_code
38178 , p_transaction_coa_id => l_adr_transaction_coa_id
38179 , p_accounting_coa_id => l_adr_accounting_coa_id
38180 , p_adr_code => 'TRX_DIST_CCID'
38181 , p_adr_type_code => 'S'
38182 , p_component_type => l_component_type
38183 , p_component_code => l_component_code
38184 , p_component_type_code => l_component_type_code
38185 , p_component_appl_id => l_component_appl_id
38186 , p_amb_context_code => l_amb_context_code
38187 , p_side => 'NA'
38188 );
38189
38190
38191 l_segment := AcctDerRule_9(
38192 p_application_id => p_application_id
38193 , p_ae_header_id => l_ae_header_id
38194 , p_source_8 => p_source_8
38195 , x_transaction_coa_id => l_adr_transaction_coa_id
38196 , x_accounting_coa_id => l_adr_accounting_coa_id
38197 , x_flexfield_segment_code => l_adr_flexfield_segment_code
38198 , x_flex_value_set_id => l_adr_flex_value_set_id
38199 , x_value_type_code => l_adr_value_type_code
38200 , x_value_combination_id => l_adr_value_combination_id
38201 , x_value_segment_code => l_adr_value_segment_code
38202 , p_side => 'NA'
38203 , p_override_seg_flag => 'Y'
38204 );
38205
38206 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
38207
38208 xla_ae_lines_pkg.set_segment(
38209 p_to_segment_code => 'GL_ACCOUNT'
38210 , p_segment_value => l_segment
38211 , p_from_segment_code => l_adr_value_segment_code
38212 , p_from_combination_id => l_adr_value_combination_id
38213 , p_value_type_code => l_adr_value_type_code
38214 , p_transaction_coa_id => l_adr_transaction_coa_id
38215 , p_accounting_coa_id => l_adr_accounting_coa_id
38216 , p_flexfield_segment_code => l_adr_flexfield_segment_code
38217 , p_flex_value_set_id => l_adr_flex_value_set_id
38218 , p_adr_code => 'MFAR_TRX_NATURAL_SEGMENT'
38219 , p_adr_type_code => 'S'
38220 , p_component_type => l_component_type
38221 , p_component_code => l_component_code
38222 , p_component_type_code => l_component_type_code
38223 , p_component_appl_id => l_component_appl_id
38224 , p_amb_context_code => l_amb_context_code
38225 , p_entity_code => 'TRANSACTIONS'
38226 , p_event_class_code => 'DEBIT_MEMO'
38227 , p_side => 'NA'
38228 );
38229
38230 END IF;
38231
38232 --
38233 --
38234 END IF;
38235
38236 --
38237 -- Update the line information that should be overwritten
38238 --
38239 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
38240 p_header_num => 1);
38241 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
38242
38243 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
38244
38245 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
38246 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
38247 END IF;
38248
38249 --
38250 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
38251 --
38252 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
38253 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
38254 ELSE
38255 ---------------------------------------------------------------------------------------------------
38256 -- 4262811a Switch Sign
38257 ---------------------------------------------------------------------------------------------------
38258 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
38259 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38260 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38261 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38262 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38263 -- 5132302
38264 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
38268
38265 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38266
38267 END IF;
38269 -- 4955764
38270 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38271 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
38272
38273
38274 XLA_AE_LINES_PKG.ValidateCurrentLine;
38275 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38276
38277 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38278 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
38279 ,p_balance_type_code => l_balance_type_code);
38280
38281 END IF;
38282
38283 -----------------------------------------------------------------------------------------
38284 -- 4262811 Multiperiod Accounting
38285 -----------------------------------------------------------------------------------------
38286 -- No MPA option is assigned.
38287
38288
38289 END IF;
38290 END IF;
38291 --
38292
38293 --
38294 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
38295 trace
38296 (p_msg => 'END of AcctLineType_89'
38297 ,p_level => C_LEVEL_PROCEDURE
38298 ,p_module => l_log_module);
38299 END IF;
38300 --
38301 EXCEPTION
38302 WHEN xla_exceptions_pkg.application_exception THEN
38303 RAISE;
38304 WHEN OTHERS THEN
38305 xla_exceptions_pkg.raise_message
38306 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_89');
38307 END AcctLineType_89;
38308 --
38309
38310 ---------------------------------------
38311 --
38312 -- PRIVATE FUNCTION
38313 -- AcctLineType_90
38314 --
38315 ---------------------------------------
38316 PROCEDURE AcctLineType_90 (
38317 p_application_id IN NUMBER
38318 ,p_event_id IN NUMBER
38319 ,p_calculate_acctd_flag IN VARCHAR2
38320 ,p_calculate_g_l_flag IN VARCHAR2
38321 ,p_actual_flag IN OUT VARCHAR2
38322 ,p_balance_type_code OUT VARCHAR2
38323 ,p_gain_or_loss_ref OUT VARCHAR2
38324
38325 --Transaction Default Receivable Account
38326 , p_source_8 IN NUMBER
38327 --Transaction Distribution GL Account
38328 , p_source_21 IN NUMBER
38329 --Bill To Customer Account Identifier
38330 , p_source_32 IN NUMBER
38331 --Bill To Customer Site Use Identifier
38332 , p_source_33 IN NUMBER
38333 --SLA Party Type
38334 , p_source_34 IN VARCHAR2
38335 --Transaction Distribution Account Class
38336 , p_source_35 IN VARCHAR2
38337 --Transaction Distribution Identifier
38338 , p_source_36 IN NUMBER
38339 --Transaction Distribution Type
38340 , p_source_37 IN VARCHAR2
38341 --Transaction Distribution Entered Amount
38342 , p_source_38 IN NUMBER
38343 --Transaction Currency Code
38344 , p_source_39 IN VARCHAR2
38345 --Transaction Exchange Date
38346 , p_source_40 IN DATE
38347 --Transaction Exchange Rate
38348 , p_source_41 IN NUMBER
38349 --Transaction Exchange Rate Type
38350 , p_source_42 IN VARCHAR2
38351 --Transaction Accounting Amount
38352 , p_source_43 IN NUMBER
38353 --Transaction Tax Line Identifier
38354 , p_source_57 IN NUMBER
38355 --Transaction Invoicing Rule
38356 , p_source_70 IN NUMBER
38357 )
38358 IS
38359
38360 l_component_type VARCHAR2(80);
38361 l_component_code VARCHAR2(30);
38362 l_component_type_code VARCHAR2(1);
38363 l_component_appl_id INTEGER;
38364 l_amb_context_code VARCHAR2(30);
38365 l_entity_code VARCHAR2(30);
38366 l_event_class_code VARCHAR2(30);
38367 l_ae_header_id NUMBER;
38368 l_event_type_code VARCHAR2(30);
38369 l_line_definition_code VARCHAR2(30);
38370 l_line_definition_owner_code VARCHAR2(1);
38371 --
38372 -- adr variables
38373 l_segment VARCHAR2(30);
38374 l_ccid NUMBER;
38375 l_adr_transaction_coa_id NUMBER;
38376 l_adr_accounting_coa_id NUMBER;
38377 l_adr_flexfield_segment_code VARCHAR2(30);
38378 l_adr_flex_value_set_id NUMBER;
38379 l_adr_value_type_code VARCHAR2(30);
38380 l_adr_value_combination_id NUMBER;
38381 l_adr_value_segment_code VARCHAR2(30);
38382
38383 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
38384 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
38385 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
38386 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
38387
38388 -- 4262811 Variables ------------------------------------------------------------------------------------------
38389 l_entered_amt_idx NUMBER;
38390 l_accted_amt_idx NUMBER;
38391 l_acc_rev_flag VARCHAR2(1);
38392 l_accrual_line_num NUMBER;
38393 l_tmp_amt NUMBER;
38394 l_acc_rev_natural_side_code VARCHAR2(1);
38395
38396 l_num_entries NUMBER;
38397 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
38398 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
38402 l_recog_line_2 NUMBER;
38399 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
38400 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
38401 l_recog_line_1 NUMBER;
38403
38404 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
38405 l_bflow_applied_to_amt NUMBER; -- 5132302
38406 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
38407
38408 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
38409
38410 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
38411 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
38412
38413 ---------------------------------------------------------------------------------------------------------------
38414
38415
38416 --
38417 -- bulk performance
38418 --
38419 l_balance_type_code VARCHAR2(1);
38420 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
38421 l_log_module VARCHAR2(240);
38422
38423 --
38424 -- Upgrade strategy
38425 --
38426 l_actual_upg_option VARCHAR2(1);
38427 l_enc_upg_option VARCHAR2(1);
38428
38429 --
38430 BEGIN
38431 --
38432 IF g_log_enabled THEN
38433 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_90';
38434 END IF;
38435 --
38436 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
38437
38438 trace
38439 (p_msg => 'BEGIN of AcctLineType_90'
38440 ,p_level => C_LEVEL_PROCEDURE
38441 ,p_module => l_log_module);
38442
38443 END IF;
38444 --
38445 l_component_type := 'AMB_JLT';
38446 l_component_code := 'MFAR_INV_REC';
38447 l_component_type_code := 'S';
38448 l_component_appl_id := 222;
38449 l_amb_context_code := 'DEFAULT';
38450 l_entity_code := 'TRANSACTIONS';
38451 l_event_class_code := 'INVOICE';
38452 l_event_type_code := 'INVOICE_ALL';
38453 l_line_definition_owner_code := 'S';
38454 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
38455 --
38456 l_balance_type_code := 'A';
38457 l_segment := NULL;
38458 l_ccid := NULL;
38459 l_adr_transaction_coa_id := NULL;
38460 l_adr_accounting_coa_id := NULL;
38461 l_adr_flexfield_segment_code := NULL;
38462 l_adr_flex_value_set_id := NULL;
38463 l_adr_value_type_code := NULL;
38464 l_adr_value_combination_id := NULL;
38465 l_adr_value_segment_code := NULL;
38466
38467 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
38468 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
38469 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
38470 l_budgetary_control_flag := 'N';
38471
38472 l_bflow_applied_to_amt_idx := NULL; -- 5132302
38473 l_bflow_applied_to_amt := NULL; -- 5132302
38474 l_entered_amt_idx := NULL; -- 4262811
38475 l_accted_amt_idx := NULL; -- 4262811
38476 l_acc_rev_flag := NULL; -- 4262811
38477 l_accrual_line_num := NULL; -- 4262811
38478 l_tmp_amt := NULL; -- 4262811
38479 --
38480
38481 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
38482 l_balance_type_code <> 'B' THEN
38483 IF (p_source_70 IS NULL ) AND
38484 (NVL(p_source_35,'
38485 ') = 'REV' OR
38486 NVL(p_source_35,'
38487 ') = 'TAX' OR
38488 NVL(p_source_35,'
38489 ') = 'FREIGHT' OR
38490 NVL(p_source_35,'
38491 ') = 'ROUND' OR
38492 NVL(p_source_35,'
38493 ') = 'CHARGES')
38494 THEN
38495
38496 --
38497 XLA_AE_LINES_PKG.SetNewLine;
38498
38499 p_balance_type_code := l_balance_type_code;
38500 -- set the flag so later we will know whether the gain loss line needs to be created
38501
38502 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
38503 p_actual_flag :='A';
38504 END IF;
38505
38506 --
38507 -- bulk performance
38508 --
38509 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
38510 p_header_num => 0); -- 4262811
38511 --
38512 -- set accounting line options
38513 --
38514 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
38515 p_natural_side_code => 'D'
38516 , p_gain_or_loss_flag => 'N'
38517 , p_gl_transfer_mode_code => 'S'
38518 , p_acct_entry_type_code => 'A'
38519 , p_switch_side_flag => 'Y'
38520 , p_merge_duplicate_code => 'A'
38521 );
38522 --
38523 l_acc_rev_natural_side_code := 'C'; -- 4262811
38524 --
38525 --
38526 -- set accounting line type info
38527 --
38528 xla_ae_lines_pkg.SetAcctLineType
38529 (p_component_type => l_component_type
38530 ,p_event_type_code => l_event_type_code
38531 ,p_line_definition_owner_code => l_line_definition_owner_code
38532 ,p_line_definition_code => l_line_definition_code
38533 ,p_accounting_line_code => l_component_code
38534 ,p_accounting_line_type_code => l_component_type_code
38535 ,p_accounting_line_appl_id => l_component_appl_id
38539 --
38536 ,p_amb_context_code => l_amb_context_code
38537 ,p_entity_code => l_entity_code
38538 ,p_event_class_code => l_event_class_code);
38540 -- set accounting class
38541 --
38542 xla_ae_lines_pkg.SetAcctClass(
38543 p_accounting_class_code => 'RECEIVABLE'
38544 , p_ae_header_id => l_ae_header_id
38545 );
38546
38547 --
38548 -- set rounding class
38549 --
38550 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
38551 'RECEIVABLE';
38552
38553 --
38554 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
38555 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
38556 --
38557 -- bulk performance
38558 --
38559 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
38560
38561 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
38562 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
38563
38564 -- 4955764
38565 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38566 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
38567
38568 -- 4458381 Public Sector Enh
38569
38570 --
38571 -- set accounting attributes for the line type
38572 --
38573 l_entered_amt_idx := 3;
38574 l_accted_amt_idx := 8;
38575 l_bflow_applied_to_amt_idx := NULL; -- 5132302
38576 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
38577 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_36);
38578 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
38579 l_rec_acct_attrs.array_char_value(2) := p_source_37;
38580 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
38581 l_rec_acct_attrs.array_num_value(3) := p_source_38;
38582 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
38583 l_rec_acct_attrs.array_char_value(4) := p_source_39;
38584 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
38585 l_rec_acct_attrs.array_date_value(5) := p_source_40;
38586 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
38587 l_rec_acct_attrs.array_num_value(6) := p_source_41;
38588 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
38589 l_rec_acct_attrs.array_char_value(7) := p_source_42;
38590 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
38591 l_rec_acct_attrs.array_num_value(8) := p_source_43;
38592 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
38593 l_rec_acct_attrs.array_num_value(9) := p_source_32;
38594 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
38595 l_rec_acct_attrs.array_num_value(10) := p_source_33;
38596 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
38597 l_rec_acct_attrs.array_char_value(11) := p_source_34;
38598 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
38599 l_rec_acct_attrs.array_num_value(12) := p_source_57;
38600
38601 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
38602 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
38603
38604 ---------------------------------------------------------------------------------------------------------------
38605 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
38606 ---------------------------------------------------------------------------------------------------------------
38607 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
38608
38609 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
38610 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
38611
38612 IF xla_accounting_cache_pkg.GetValueChar
38613 (p_source_code => 'LEDGER_CATEGORY_CODE'
38614 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
38615 AND l_bflow_method_code = 'PRIOR_ENTRY'
38616 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
38617 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
38618 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
38619 )
38620 THEN
38621 xla_ae_lines_pkg.BflowUpgEntry
38622 (p_business_method_code => l_bflow_method_code
38623 ,p_business_class_code => l_bflow_class_code
38624 ,p_balance_type => l_balance_type_code);
38625 ELSE
38626 NULL;
38627 -- No business flow processing for business flow method of NONE.
38628 END IF;
38629
38630 --
38631 -- call analytical criteria
38632 --
38633
38634 --
38635 -- call description
38636 --
38637
38638 xla_ae_lines_pkg.SetLineDescription(
38639 p_ae_header_id => l_ae_header_id
38640 ,p_description => Description_1 (
38641 p_application_id => p_application_id
38642 , p_ae_header_id => l_ae_header_id
38643 )
38644 );
38645
38646
38647 --
38648 -- call ADRs
38649 -- Bug 4922099
38650 --
38654 )
38651 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38652 (NVL(l_actual_upg_option, 'N') = 'O') OR
38653 (NVL(l_enc_upg_option, 'N') = 'O')
38655 THEN
38656 NULL;
38657 --
38658 --
38659
38660 l_ccid := AcctDerRule_34(
38661 p_application_id => p_application_id
38662 , p_ae_header_id => l_ae_header_id
38663 , p_source_21 => p_source_21
38664 , x_transaction_coa_id => l_adr_transaction_coa_id
38665 , x_accounting_coa_id => l_adr_accounting_coa_id
38666 , x_value_type_code => l_adr_value_type_code
38667 , p_side => 'NA'
38668 );
38669
38670 xla_ae_lines_pkg.set_ccid(
38671 p_code_combination_id => l_ccid
38672 , p_value_type_code => l_adr_value_type_code
38673 , p_transaction_coa_id => l_adr_transaction_coa_id
38674 , p_accounting_coa_id => l_adr_accounting_coa_id
38675 , p_adr_code => 'TRX_DIST_CCID'
38676 , p_adr_type_code => 'S'
38677 , p_component_type => l_component_type
38678 , p_component_code => l_component_code
38679 , p_component_type_code => l_component_type_code
38680 , p_component_appl_id => l_component_appl_id
38681 , p_amb_context_code => l_amb_context_code
38682 , p_side => 'NA'
38683 );
38684
38685
38686 l_segment := AcctDerRule_9(
38687 p_application_id => p_application_id
38688 , p_ae_header_id => l_ae_header_id
38689 , p_source_8 => p_source_8
38690 , x_transaction_coa_id => l_adr_transaction_coa_id
38691 , x_accounting_coa_id => l_adr_accounting_coa_id
38692 , x_flexfield_segment_code => l_adr_flexfield_segment_code
38693 , x_flex_value_set_id => l_adr_flex_value_set_id
38694 , x_value_type_code => l_adr_value_type_code
38695 , x_value_combination_id => l_adr_value_combination_id
38696 , x_value_segment_code => l_adr_value_segment_code
38697 , p_side => 'NA'
38698 , p_override_seg_flag => 'Y'
38699 );
38700
38701 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
38702
38703 xla_ae_lines_pkg.set_segment(
38704 p_to_segment_code => 'GL_ACCOUNT'
38705 , p_segment_value => l_segment
38706 , p_from_segment_code => l_adr_value_segment_code
38707 , p_from_combination_id => l_adr_value_combination_id
38708 , p_value_type_code => l_adr_value_type_code
38709 , p_transaction_coa_id => l_adr_transaction_coa_id
38710 , p_accounting_coa_id => l_adr_accounting_coa_id
38711 , p_flexfield_segment_code => l_adr_flexfield_segment_code
38712 , p_flex_value_set_id => l_adr_flex_value_set_id
38713 , p_adr_code => 'MFAR_TRX_NATURAL_SEGMENT'
38714 , p_adr_type_code => 'S'
38715 , p_component_type => l_component_type
38716 , p_component_code => l_component_code
38717 , p_component_type_code => l_component_type_code
38718 , p_component_appl_id => l_component_appl_id
38719 , p_amb_context_code => l_amb_context_code
38720 , p_entity_code => 'TRANSACTIONS'
38721 , p_event_class_code => 'INVOICE'
38722 , p_side => 'NA'
38723 );
38724
38725 END IF;
38726
38727 --
38728 --
38729 END IF;
38730 --
38731 -- Bug 4922099
38732 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
38733 (NVL(l_enc_upg_option, 'N') = 'O')
38734 ) AND
38735 (l_bflow_method_code = 'PRIOR_ENTRY')
38736 )
38737 THEN
38738 IF
38739 --
38740 1 = 2
38741 --
38742 THEN
38743 xla_accounting_err_pkg.build_message
38744 (p_appli_s_name => 'XLA'
38745 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38746 ,p_token_1 => 'LINE_NUMBER'
38747 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
38748 ,p_token_2 => 'LINE_TYPE_NAME'
38749 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
38750 l_component_type
38751 ,l_component_code
38752 ,l_component_type_code
38753 ,l_component_appl_id
38754 ,l_amb_context_code
38755 ,l_entity_code
38756 ,l_event_class_code
38757 )
38758 ,p_token_3 => 'OWNER'
38759 ,p_value_3 => xla_lookups_pkg.get_meaning(
38763 ,p_token_4 => 'PRODUCT_NAME'
38760 p_lookup_type => 'XLA_OWNER_TYPE'
38761 ,p_lookup_code => l_component_type_code
38762 )
38764 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
38765 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
38766 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
38767 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
38768 ,p_ae_header_id => NULL
38769 );
38770
38771 IF (C_LEVEL_ERROR>= g_log_level) THEN
38772 trace
38773 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38774 ,p_level => C_LEVEL_ERROR
38775 ,p_module => l_log_module);
38776 END IF;
38777 END IF;
38778 END IF;
38779 --
38780 --
38781 ------------------------------------------------------------------------------------------------
38782 -- 4219869 Business Flow
38783 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
38784 -- Prior Entry. Currently, the following code is always generated.
38785 ------------------------------------------------------------------------------------------------
38786 XLA_AE_LINES_PKG.ValidateCurrentLine;
38787
38788 ------------------------------------------------------------------------------------
38789 -- 4219869 Business Flow
38790 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
38791 ------------------------------------------------------------------------------------
38792 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38793
38794 ----------------------------------------------------------------------------------
38795 -- 4219869 Business Flow
38796 -- Update journal entry status -- Need to generate this within IF <condition>
38797 ----------------------------------------------------------------------------------
38798 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38799 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
38800 ,p_balance_type_code => l_balance_type_code
38801 );
38802
38803 -------------------------------------------------------------------------------------------
38804 -- 4262811 - Generate the Accrual Reversal lines
38805 -------------------------------------------------------------------------------------------
38806 BEGIN
38807 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
38808 (g_array_event(p_event_id).array_value_num('header_index'));
38809 IF l_acc_rev_flag IS NULL THEN
38810 l_acc_rev_flag := 'N';
38811 END IF;
38812 EXCEPTION
38813 WHEN OTHERS THEN
38814 l_acc_rev_flag := 'N';
38815 END;
38816 --
38817 IF (l_acc_rev_flag = 'Y') THEN
38818
38819 -- 4645092 ------------------------------------------------------------------------------
38820 -- To allow MPA report to determine if it should generate report process
38821 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
38822 ------------------------------------------------------------------------------------------
38823
38824 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
38825 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
38826 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
38827 -- call ADRs
38828 -- Bug 4922099
38829 --
38830 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38831 (NVL(l_actual_upg_option, 'N') = 'O') OR
38832 (NVL(l_enc_upg_option, 'N') = 'O')
38833 )
38834 THEN
38835 NULL;
38836 --
38837 --
38838
38839 l_ccid := AcctDerRule_34(
38840 p_application_id => p_application_id
38841 , p_ae_header_id => l_ae_header_id
38842 , p_source_21 => p_source_21
38843 , x_transaction_coa_id => l_adr_transaction_coa_id
38844 , x_accounting_coa_id => l_adr_accounting_coa_id
38845 , x_value_type_code => l_adr_value_type_code
38846 , p_side => 'NA'
38847 );
38848
38849 xla_ae_lines_pkg.set_ccid(
38850 p_code_combination_id => l_ccid
38851 , p_value_type_code => l_adr_value_type_code
38852 , p_transaction_coa_id => l_adr_transaction_coa_id
38853 , p_accounting_coa_id => l_adr_accounting_coa_id
38854 , p_adr_code => 'TRX_DIST_CCID'
38855 , p_adr_type_code => 'S'
38856 , p_component_type => l_component_type
38857 , p_component_code => l_component_code
38858 , p_component_type_code => l_component_type_code
38859 , p_component_appl_id => l_component_appl_id
38860 , p_amb_context_code => l_amb_context_code
38861 , p_side => 'NA'
38862 );
38866 p_application_id => p_application_id
38863
38864
38865 l_segment := AcctDerRule_9(
38867 , p_ae_header_id => l_ae_header_id
38868 , p_source_8 => p_source_8
38869 , x_transaction_coa_id => l_adr_transaction_coa_id
38870 , x_accounting_coa_id => l_adr_accounting_coa_id
38871 , x_flexfield_segment_code => l_adr_flexfield_segment_code
38872 , x_flex_value_set_id => l_adr_flex_value_set_id
38873 , x_value_type_code => l_adr_value_type_code
38874 , x_value_combination_id => l_adr_value_combination_id
38875 , x_value_segment_code => l_adr_value_segment_code
38876 , p_side => 'NA'
38877 , p_override_seg_flag => 'Y'
38878 );
38879
38880 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
38881
38882 xla_ae_lines_pkg.set_segment(
38883 p_to_segment_code => 'GL_ACCOUNT'
38884 , p_segment_value => l_segment
38885 , p_from_segment_code => l_adr_value_segment_code
38886 , p_from_combination_id => l_adr_value_combination_id
38887 , p_value_type_code => l_adr_value_type_code
38888 , p_transaction_coa_id => l_adr_transaction_coa_id
38889 , p_accounting_coa_id => l_adr_accounting_coa_id
38890 , p_flexfield_segment_code => l_adr_flexfield_segment_code
38891 , p_flex_value_set_id => l_adr_flex_value_set_id
38892 , p_adr_code => 'MFAR_TRX_NATURAL_SEGMENT'
38893 , p_adr_type_code => 'S'
38894 , p_component_type => l_component_type
38895 , p_component_code => l_component_code
38896 , p_component_type_code => l_component_type_code
38897 , p_component_appl_id => l_component_appl_id
38898 , p_amb_context_code => l_amb_context_code
38899 , p_entity_code => 'TRANSACTIONS'
38900 , p_event_class_code => 'INVOICE'
38901 , p_side => 'NA'
38902 );
38903
38904 END IF;
38905
38906 --
38907 --
38908 END IF;
38909
38910 --
38911 -- Update the line information that should be overwritten
38912 --
38913 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
38914 p_header_num => 1);
38915 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
38916
38917 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
38918
38919 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
38920 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
38921 END IF;
38922
38923 --
38924 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
38925 --
38926 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
38927 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
38928 ELSE
38929 ---------------------------------------------------------------------------------------------------
38930 -- 4262811a Switch Sign
38931 ---------------------------------------------------------------------------------------------------
38932 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
38933 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38934 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38935 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38936 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38937 -- 5132302
38938 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
38939 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38940
38941 END IF;
38942
38943 -- 4955764
38944 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38945 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
38946
38947
38948 XLA_AE_LINES_PKG.ValidateCurrentLine;
38949 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38950
38951 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38952 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
38953 ,p_balance_type_code => l_balance_type_code);
38954
38955 END IF;
38956
38957 -----------------------------------------------------------------------------------------
38958 -- 4262811 Multiperiod Accounting
38959 -----------------------------------------------------------------------------------------
38960 -- No MPA option is assigned.
38961
38962
38963 END IF;
38964 END IF;
38965 --
38966
38967 --
38968 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
38969 trace
38970 (p_msg => 'END of AcctLineType_90'
38971 ,p_level => C_LEVEL_PROCEDURE
38972 ,p_module => l_log_module);
38976 WHEN xla_exceptions_pkg.application_exception THEN
38973 END IF;
38974 --
38975 EXCEPTION
38977 RAISE;
38978 WHEN OTHERS THEN
38979 xla_exceptions_pkg.raise_message
38980 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_90');
38981 END AcctLineType_90;
38982 --
38983
38984 ---------------------------------------
38985 --
38986 -- PRIVATE FUNCTION
38987 -- AcctLineType_91
38988 --
38989 ---------------------------------------
38990 PROCEDURE AcctLineType_91 (
38991 p_application_id IN NUMBER
38992 ,p_event_id IN NUMBER
38993 ,p_calculate_acctd_flag IN VARCHAR2
38994 ,p_calculate_g_l_flag IN VARCHAR2
38995 ,p_actual_flag IN OUT VARCHAR2
38996 ,p_balance_type_code OUT VARCHAR2
38997 ,p_gain_or_loss_ref OUT VARCHAR2
38998
38999 --Remittance Bank Account Bank Charges Acount
39000 , p_source_1 IN NUMBER
39001 --Remittance Bank Account Cash Account
39002 , p_source_5 IN NUMBER
39003 --Distribution Source Type
39004 , p_source_22 IN VARCHAR2
39005 --Distribution Line Identifier
39006 , p_source_24 IN NUMBER
39007 --Distribution Type
39008 , p_source_25 IN VARCHAR2
39009 --Entered Amount
39010 , p_source_26 IN NUMBER
39011 --Currency Code
39012 , p_source_27 IN VARCHAR2
39013 --Exchange Rate
39014 , p_source_29 IN NUMBER
39015 --Exchange Rate Type
39016 , p_source_30 IN VARCHAR2
39017 --Applied To Document Accounting Amount
39018 , p_source_31 IN NUMBER
39019 --Applied To Document Exchange Date
39020 , p_source_59 IN DATE
39021 --Distribution Multi Fund Additional Entry
39022 , p_source_71 IN VARCHAR2
39023 )
39024 IS
39025
39026 l_component_type VARCHAR2(80);
39027 l_component_code VARCHAR2(30);
39028 l_component_type_code VARCHAR2(1);
39029 l_component_appl_id INTEGER;
39030 l_amb_context_code VARCHAR2(30);
39031 l_entity_code VARCHAR2(30);
39032 l_event_class_code VARCHAR2(30);
39033 l_ae_header_id NUMBER;
39034 l_event_type_code VARCHAR2(30);
39035 l_line_definition_code VARCHAR2(30);
39036 l_line_definition_owner_code VARCHAR2(1);
39037 --
39038 -- adr variables
39039 l_segment VARCHAR2(30);
39040 l_ccid NUMBER;
39041 l_adr_transaction_coa_id NUMBER;
39042 l_adr_accounting_coa_id NUMBER;
39043 l_adr_flexfield_segment_code VARCHAR2(30);
39044 l_adr_flex_value_set_id NUMBER;
39045 l_adr_value_type_code VARCHAR2(30);
39046 l_adr_value_combination_id NUMBER;
39047 l_adr_value_segment_code VARCHAR2(30);
39048
39049 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
39050 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
39051 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
39052 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
39053
39054 -- 4262811 Variables ------------------------------------------------------------------------------------------
39055 l_entered_amt_idx NUMBER;
39056 l_accted_amt_idx NUMBER;
39057 l_acc_rev_flag VARCHAR2(1);
39058 l_accrual_line_num NUMBER;
39059 l_tmp_amt NUMBER;
39060 l_acc_rev_natural_side_code VARCHAR2(1);
39061
39062 l_num_entries NUMBER;
39063 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
39064 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
39065 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
39066 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
39067 l_recog_line_1 NUMBER;
39068 l_recog_line_2 NUMBER;
39069
39070 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
39071 l_bflow_applied_to_amt NUMBER; -- 5132302
39072 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
39073
39074 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
39075
39076 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
39077 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
39078
39079 ---------------------------------------------------------------------------------------------------------------
39080
39081
39082 --
39083 -- bulk performance
39084 --
39085 l_balance_type_code VARCHAR2(1);
39086 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
39087 l_log_module VARCHAR2(240);
39088
39089 --
39090 -- Upgrade strategy
39091 --
39092 l_actual_upg_option VARCHAR2(1);
39093 l_enc_upg_option VARCHAR2(1);
39094
39095 --
39096 BEGIN
39097 --
39098 IF g_log_enabled THEN
39099 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_91';
39100 END IF;
39101 --
39102 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39103
39104 trace
39105 (p_msg => 'BEGIN of AcctLineType_91'
39106 ,p_level => C_LEVEL_PROCEDURE
39107 ,p_module => l_log_module);
39108
39109 END IF;
39110 --
39111 l_component_type := 'AMB_JLT';
39112 l_component_code := 'MFAR_MISC_RCT_BNK_CHG_CASH';
39116 l_entity_code := 'RECEIPTS';
39113 l_component_type_code := 'S';
39114 l_component_appl_id := 222;
39115 l_amb_context_code := 'DEFAULT';
39117 l_event_class_code := 'MISC_RECEIPT';
39118 l_event_type_code := 'MISC_RECEIPT_ALL';
39119 l_line_definition_owner_code := 'S';
39120 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
39121 --
39122 l_balance_type_code := 'A';
39123 l_segment := NULL;
39124 l_ccid := NULL;
39125 l_adr_transaction_coa_id := NULL;
39126 l_adr_accounting_coa_id := NULL;
39127 l_adr_flexfield_segment_code := NULL;
39128 l_adr_flex_value_set_id := NULL;
39129 l_adr_value_type_code := NULL;
39130 l_adr_value_combination_id := NULL;
39131 l_adr_value_segment_code := NULL;
39132
39133 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
39134 l_bflow_class_code := ''; -- 4219869 Business Flow
39135 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
39136 l_budgetary_control_flag := 'N';
39137
39138 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39139 l_bflow_applied_to_amt := NULL; -- 5132302
39140 l_entered_amt_idx := NULL; -- 4262811
39141 l_accted_amt_idx := NULL; -- 4262811
39142 l_acc_rev_flag := NULL; -- 4262811
39143 l_accrual_line_num := NULL; -- 4262811
39144 l_tmp_amt := NULL; -- 4262811
39145 --
39146
39147 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
39148 l_balance_type_code <> 'B' THEN
39149 IF NVL(p_source_22,'
39150 ') = 'BANK_CHARGES' AND
39151 NVL(p_source_71,'
39152 ') = 'N'
39153 THEN
39154
39155 --
39156 XLA_AE_LINES_PKG.SetNewLine;
39157
39158 p_balance_type_code := l_balance_type_code;
39159 -- set the flag so later we will know whether the gain loss line needs to be created
39160
39161 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
39162 p_actual_flag :='A';
39163 END IF;
39164
39165 --
39166 -- bulk performance
39167 --
39168 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
39169 p_header_num => 0); -- 4262811
39170 --
39171 -- set accounting line options
39172 --
39173 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
39174 p_natural_side_code => 'D'
39175 , p_gain_or_loss_flag => 'N'
39176 , p_gl_transfer_mode_code => 'S'
39177 , p_acct_entry_type_code => 'A'
39178 , p_switch_side_flag => 'Y'
39179 , p_merge_duplicate_code => 'A'
39180 );
39181 --
39182 l_acc_rev_natural_side_code := 'C'; -- 4262811
39183 --
39184 --
39185 -- set accounting line type info
39186 --
39187 xla_ae_lines_pkg.SetAcctLineType
39188 (p_component_type => l_component_type
39189 ,p_event_type_code => l_event_type_code
39190 ,p_line_definition_owner_code => l_line_definition_owner_code
39191 ,p_line_definition_code => l_line_definition_code
39192 ,p_accounting_line_code => l_component_code
39193 ,p_accounting_line_type_code => l_component_type_code
39194 ,p_accounting_line_appl_id => l_component_appl_id
39195 ,p_amb_context_code => l_amb_context_code
39196 ,p_entity_code => l_entity_code
39197 ,p_event_class_code => l_event_class_code);
39198 --
39199 -- set accounting class
39200 --
39201 xla_ae_lines_pkg.SetAcctClass(
39202 p_accounting_class_code => 'BANK_CHG'
39203 , p_ae_header_id => l_ae_header_id
39204 );
39205
39206 --
39207 -- set rounding class
39208 --
39209 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
39210 'RECEIVABLE';
39211
39212 --
39213 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
39214 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
39215 --
39216 -- bulk performance
39217 --
39218 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
39219
39220 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
39221 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
39222
39223 -- 4955764
39224 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
39225 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
39226
39227 -- 4458381 Public Sector Enh
39228
39229 --
39230 -- set accounting attributes for the line type
39231 --
39232 l_entered_amt_idx := 3;
39233 l_accted_amt_idx := 8;
39234 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39235 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
39236 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
39237 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
39241 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
39238 l_rec_acct_attrs.array_char_value(2) := p_source_25;
39239 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
39240 l_rec_acct_attrs.array_num_value(3) := p_source_26;
39242 l_rec_acct_attrs.array_char_value(4) := p_source_27;
39243 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
39244 l_rec_acct_attrs.array_date_value(5) := p_source_59;
39245 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
39246 l_rec_acct_attrs.array_num_value(6) := p_source_29;
39247 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
39248 l_rec_acct_attrs.array_char_value(7) := p_source_30;
39249 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
39250 l_rec_acct_attrs.array_num_value(8) := p_source_31;
39251
39252 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
39253 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
39254
39255 ---------------------------------------------------------------------------------------------------------------
39256 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
39257 ---------------------------------------------------------------------------------------------------------------
39258 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
39259
39260 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39261 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39262
39263 IF xla_accounting_cache_pkg.GetValueChar
39264 (p_source_code => 'LEDGER_CATEGORY_CODE'
39265 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
39266 AND l_bflow_method_code = 'PRIOR_ENTRY'
39267 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
39268 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
39269 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
39270 )
39271 THEN
39272 xla_ae_lines_pkg.BflowUpgEntry
39273 (p_business_method_code => l_bflow_method_code
39274 ,p_business_class_code => l_bflow_class_code
39275 ,p_balance_type => l_balance_type_code);
39276 ELSE
39277 NULL;
39278 -- No business flow processing for business flow method of NONE.
39279 END IF;
39280
39281 --
39282 -- call analytical criteria
39283 --
39284
39285 --
39286 -- call description
39287 --
39288
39289 xla_ae_lines_pkg.SetLineDescription(
39290 p_ae_header_id => l_ae_header_id
39291 ,p_description => Description_1 (
39292 p_application_id => p_application_id
39293 , p_ae_header_id => l_ae_header_id
39294 )
39295 );
39296
39297
39298 --
39299 -- call ADRs
39300 -- Bug 4922099
39301 --
39302 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
39303 (NVL(l_actual_upg_option, 'N') = 'O') OR
39304 (NVL(l_enc_upg_option, 'N') = 'O')
39305 )
39306 THEN
39307 NULL;
39308 --
39309 --
39310
39311 l_ccid := AcctDerRule_28(
39312 p_application_id => p_application_id
39313 , p_ae_header_id => l_ae_header_id
39314 , p_source_5 => p_source_5
39315 , x_transaction_coa_id => l_adr_transaction_coa_id
39316 , x_accounting_coa_id => l_adr_accounting_coa_id
39317 , x_value_type_code => l_adr_value_type_code
39318 , p_side => 'NA'
39319 );
39320
39321 xla_ae_lines_pkg.set_ccid(
39322 p_code_combination_id => l_ccid
39323 , p_value_type_code => l_adr_value_type_code
39324 , p_transaction_coa_id => l_adr_transaction_coa_id
39325 , p_accounting_coa_id => l_adr_accounting_coa_id
39326 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
39327 , p_adr_type_code => 'S'
39328 , p_component_type => l_component_type
39329 , p_component_code => l_component_code
39330 , p_component_type_code => l_component_type_code
39331 , p_component_appl_id => l_component_appl_id
39332 , p_amb_context_code => l_amb_context_code
39333 , p_side => 'NA'
39334 );
39335
39336
39337 l_segment := AcctDerRule_2(
39338 p_application_id => p_application_id
39339 , p_ae_header_id => l_ae_header_id
39340 , p_source_1 => p_source_1
39341 , x_transaction_coa_id => l_adr_transaction_coa_id
39342 , x_accounting_coa_id => l_adr_accounting_coa_id
39343 , x_flexfield_segment_code => l_adr_flexfield_segment_code
39344 , x_flex_value_set_id => l_adr_flex_value_set_id
39345 , x_value_type_code => l_adr_value_type_code
39346 , x_value_combination_id => l_adr_value_combination_id
39347 , x_value_segment_code => l_adr_value_segment_code
39348 , p_side => 'NA'
39349 , p_override_seg_flag => 'Y'
39350 );
39351
39352 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
39353
39354 xla_ae_lines_pkg.set_segment(
39358 , p_from_combination_id => l_adr_value_combination_id
39355 p_to_segment_code => 'GL_ACCOUNT'
39356 , p_segment_value => l_segment
39357 , p_from_segment_code => l_adr_value_segment_code
39359 , p_value_type_code => l_adr_value_type_code
39360 , p_transaction_coa_id => l_adr_transaction_coa_id
39361 , p_accounting_coa_id => l_adr_accounting_coa_id
39362 , p_flexfield_segment_code => l_adr_flexfield_segment_code
39363 , p_flex_value_set_id => l_adr_flex_value_set_id
39364 , p_adr_code => 'MFAR_BNK_CHARGES_NATURAL_SEG'
39365 , p_adr_type_code => 'S'
39366 , p_component_type => l_component_type
39367 , p_component_code => l_component_code
39368 , p_component_type_code => l_component_type_code
39369 , p_component_appl_id => l_component_appl_id
39370 , p_amb_context_code => l_amb_context_code
39371 , p_entity_code => 'RECEIPTS'
39372 , p_event_class_code => 'MISC_RECEIPT'
39373 , p_side => 'NA'
39374 );
39375
39376 END IF;
39377
39378 --
39379 --
39380 END IF;
39381 --
39382 -- Bug 4922099
39383 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
39384 (NVL(l_enc_upg_option, 'N') = 'O')
39385 ) AND
39386 (l_bflow_method_code = 'PRIOR_ENTRY')
39387 )
39388 THEN
39389 IF
39390 --
39391 1 = 2
39392 --
39393 THEN
39394 xla_accounting_err_pkg.build_message
39395 (p_appli_s_name => 'XLA'
39396 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
39397 ,p_token_1 => 'LINE_NUMBER'
39398 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
39399 ,p_token_2 => 'LINE_TYPE_NAME'
39400 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
39401 l_component_type
39402 ,l_component_code
39403 ,l_component_type_code
39404 ,l_component_appl_id
39405 ,l_amb_context_code
39406 ,l_entity_code
39407 ,l_event_class_code
39408 )
39409 ,p_token_3 => 'OWNER'
39410 ,p_value_3 => xla_lookups_pkg.get_meaning(
39411 p_lookup_type => 'XLA_OWNER_TYPE'
39412 ,p_lookup_code => l_component_type_code
39413 )
39414 ,p_token_4 => 'PRODUCT_NAME'
39415 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
39416 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
39417 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
39418 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
39419 ,p_ae_header_id => NULL
39420 );
39421
39422 IF (C_LEVEL_ERROR>= g_log_level) THEN
39423 trace
39424 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
39425 ,p_level => C_LEVEL_ERROR
39426 ,p_module => l_log_module);
39427 END IF;
39428 END IF;
39429 END IF;
39430 --
39431 --
39432 ------------------------------------------------------------------------------------------------
39433 -- 4219869 Business Flow
39434 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
39435 -- Prior Entry. Currently, the following code is always generated.
39436 ------------------------------------------------------------------------------------------------
39437 XLA_AE_LINES_PKG.ValidateCurrentLine;
39438
39439 ------------------------------------------------------------------------------------
39440 -- 4219869 Business Flow
39441 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
39442 ------------------------------------------------------------------------------------
39443 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
39444
39445 ----------------------------------------------------------------------------------
39446 -- 4219869 Business Flow
39447 -- Update journal entry status -- Need to generate this within IF <condition>
39451 ,p_balance_type_code => l_balance_type_code
39448 ----------------------------------------------------------------------------------
39449 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
39450 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
39452 );
39453
39454 -------------------------------------------------------------------------------------------
39455 -- 4262811 - Generate the Accrual Reversal lines
39456 -------------------------------------------------------------------------------------------
39457 BEGIN
39458 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
39459 (g_array_event(p_event_id).array_value_num('header_index'));
39460 IF l_acc_rev_flag IS NULL THEN
39461 l_acc_rev_flag := 'N';
39462 END IF;
39463 EXCEPTION
39464 WHEN OTHERS THEN
39465 l_acc_rev_flag := 'N';
39466 END;
39467 --
39468 IF (l_acc_rev_flag = 'Y') THEN
39469
39470 -- 4645092 ------------------------------------------------------------------------------
39471 -- To allow MPA report to determine if it should generate report process
39472 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
39473 ------------------------------------------------------------------------------------------
39474
39475 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
39476 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
39477 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
39478 -- call ADRs
39479 -- Bug 4922099
39480 --
39481 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
39482 (NVL(l_actual_upg_option, 'N') = 'O') OR
39483 (NVL(l_enc_upg_option, 'N') = 'O')
39484 )
39485 THEN
39486 NULL;
39487 --
39488 --
39489
39490 l_ccid := AcctDerRule_28(
39491 p_application_id => p_application_id
39492 , p_ae_header_id => l_ae_header_id
39493 , p_source_5 => p_source_5
39494 , x_transaction_coa_id => l_adr_transaction_coa_id
39495 , x_accounting_coa_id => l_adr_accounting_coa_id
39496 , x_value_type_code => l_adr_value_type_code
39497 , p_side => 'NA'
39498 );
39499
39500 xla_ae_lines_pkg.set_ccid(
39501 p_code_combination_id => l_ccid
39502 , p_value_type_code => l_adr_value_type_code
39503 , p_transaction_coa_id => l_adr_transaction_coa_id
39504 , p_accounting_coa_id => l_adr_accounting_coa_id
39505 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
39506 , p_adr_type_code => 'S'
39507 , p_component_type => l_component_type
39508 , p_component_code => l_component_code
39509 , p_component_type_code => l_component_type_code
39510 , p_component_appl_id => l_component_appl_id
39511 , p_amb_context_code => l_amb_context_code
39512 , p_side => 'NA'
39513 );
39514
39515
39516 l_segment := AcctDerRule_2(
39517 p_application_id => p_application_id
39518 , p_ae_header_id => l_ae_header_id
39519 , p_source_1 => p_source_1
39520 , x_transaction_coa_id => l_adr_transaction_coa_id
39521 , x_accounting_coa_id => l_adr_accounting_coa_id
39522 , x_flexfield_segment_code => l_adr_flexfield_segment_code
39523 , x_flex_value_set_id => l_adr_flex_value_set_id
39524 , x_value_type_code => l_adr_value_type_code
39525 , x_value_combination_id => l_adr_value_combination_id
39526 , x_value_segment_code => l_adr_value_segment_code
39527 , p_side => 'NA'
39528 , p_override_seg_flag => 'Y'
39529 );
39530
39531 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
39532
39533 xla_ae_lines_pkg.set_segment(
39534 p_to_segment_code => 'GL_ACCOUNT'
39535 , p_segment_value => l_segment
39536 , p_from_segment_code => l_adr_value_segment_code
39537 , p_from_combination_id => l_adr_value_combination_id
39538 , p_value_type_code => l_adr_value_type_code
39539 , p_transaction_coa_id => l_adr_transaction_coa_id
39540 , p_accounting_coa_id => l_adr_accounting_coa_id
39541 , p_flexfield_segment_code => l_adr_flexfield_segment_code
39542 , p_flex_value_set_id => l_adr_flex_value_set_id
39543 , p_adr_code => 'MFAR_BNK_CHARGES_NATURAL_SEG'
39544 , p_adr_type_code => 'S'
39545 , p_component_type => l_component_type
39546 , p_component_code => l_component_code
39547 , p_component_type_code => l_component_type_code
39548 , p_component_appl_id => l_component_appl_id
39549 , p_amb_context_code => l_amb_context_code
39550 , p_entity_code => 'RECEIPTS'
39551 , p_event_class_code => 'MISC_RECEIPT'
39552 , p_side => 'NA'
39553 );
39554
39555 END IF;
39556
39557 --
39558 --
39559 END IF;
39560
39561 --
39562 -- Update the line information that should be overwritten
39563 --
39567
39564 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
39565 p_header_num => 1);
39566 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
39568 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
39569
39570 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
39571 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
39572 END IF;
39573
39574 --
39575 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
39576 --
39577 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
39578 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
39579 ELSE
39580 ---------------------------------------------------------------------------------------------------
39581 -- 4262811a Switch Sign
39582 ---------------------------------------------------------------------------------------------------
39583 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
39584 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
39585 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39586 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
39587 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39588 -- 5132302
39589 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
39590 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39591
39592 END IF;
39593
39594 -- 4955764
39595 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
39596 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
39597
39598
39599 XLA_AE_LINES_PKG.ValidateCurrentLine;
39600 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
39601
39602 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
39603 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
39604 ,p_balance_type_code => l_balance_type_code);
39605
39606 END IF;
39607
39608 -----------------------------------------------------------------------------------------
39609 -- 4262811 Multiperiod Accounting
39610 -----------------------------------------------------------------------------------------
39611 -- No MPA option is assigned.
39612
39613
39614 END IF;
39615 END IF;
39616 --
39617
39618 --
39619 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39620 trace
39621 (p_msg => 'END of AcctLineType_91'
39622 ,p_level => C_LEVEL_PROCEDURE
39623 ,p_module => l_log_module);
39624 END IF;
39625 --
39626 EXCEPTION
39627 WHEN xla_exceptions_pkg.application_exception THEN
39628 RAISE;
39629 WHEN OTHERS THEN
39630 xla_exceptions_pkg.raise_message
39631 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_91');
39632 END AcctLineType_91;
39633 --
39634
39635 ---------------------------------------
39636 --
39637 -- PRIVATE FUNCTION
39638 -- AcctLineType_92
39639 --
39640 ---------------------------------------
39641 PROCEDURE AcctLineType_92 (
39642 p_application_id IN NUMBER
39643 ,p_event_id IN NUMBER
39644 ,p_calculate_acctd_flag IN VARCHAR2
39645 ,p_calculate_g_l_flag IN VARCHAR2
39646 ,p_actual_flag IN OUT VARCHAR2
39647 ,p_balance_type_code OUT VARCHAR2
39648 ,p_gain_or_loss_ref OUT VARCHAR2
39649
39650 --Remittance Bank Account Cash Account
39651 , p_source_5 IN NUMBER
39652 --Distribution GL Account
39653 , p_source_10 IN NUMBER
39654 --Distribution Source Type
39655 , p_source_22 IN VARCHAR2
39656 --Distribution Line Identifier
39657 , p_source_24 IN NUMBER
39658 --Distribution Type
39659 , p_source_25 IN VARCHAR2
39660 --Entered Amount
39661 , p_source_26 IN NUMBER
39662 --Currency Code
39663 , p_source_27 IN VARCHAR2
39664 --Exchange Rate
39665 , p_source_29 IN NUMBER
39666 --Exchange Rate Type
39667 , p_source_30 IN VARCHAR2
39668 --Applied To Document Accounting Amount
39669 , p_source_31 IN NUMBER
39670 --Applied To Document Exchange Date
39671 , p_source_59 IN DATE
39672 --Distribution Multi Fund Additional Entry
39673 , p_source_71 IN VARCHAR2
39674 --Receipt Class Require Remittance Flag
39675 , p_source_72 IN VARCHAR2
39676 --Receipt Class Confirm Flag
39677 , p_source_73 IN VARCHAR2
39678 )
39679 IS
39680
39681 l_component_type VARCHAR2(80);
39682 l_component_code VARCHAR2(30);
39683 l_component_type_code VARCHAR2(1);
39684 l_component_appl_id INTEGER;
39685 l_amb_context_code VARCHAR2(30);
39686 l_entity_code VARCHAR2(30);
39687 l_event_class_code VARCHAR2(30);
39688 l_ae_header_id NUMBER;
39692 --
39689 l_event_type_code VARCHAR2(30);
39690 l_line_definition_code VARCHAR2(30);
39691 l_line_definition_owner_code VARCHAR2(1);
39693 -- adr variables
39694 l_segment VARCHAR2(30);
39695 l_ccid NUMBER;
39696 l_adr_transaction_coa_id NUMBER;
39697 l_adr_accounting_coa_id NUMBER;
39698 l_adr_flexfield_segment_code VARCHAR2(30);
39699 l_adr_flex_value_set_id NUMBER;
39700 l_adr_value_type_code VARCHAR2(30);
39701 l_adr_value_combination_id NUMBER;
39702 l_adr_value_segment_code VARCHAR2(30);
39703
39704 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
39705 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
39706 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
39707 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
39708
39709 -- 4262811 Variables ------------------------------------------------------------------------------------------
39710 l_entered_amt_idx NUMBER;
39711 l_accted_amt_idx NUMBER;
39712 l_acc_rev_flag VARCHAR2(1);
39713 l_accrual_line_num NUMBER;
39714 l_tmp_amt NUMBER;
39715 l_acc_rev_natural_side_code VARCHAR2(1);
39716
39717 l_num_entries NUMBER;
39718 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
39719 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
39720 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
39721 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
39722 l_recog_line_1 NUMBER;
39723 l_recog_line_2 NUMBER;
39724
39725 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
39726 l_bflow_applied_to_amt NUMBER; -- 5132302
39727 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
39728
39729 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
39730
39731 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
39732 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
39733
39734 ---------------------------------------------------------------------------------------------------------------
39735
39736
39737 --
39738 -- bulk performance
39739 --
39740 l_balance_type_code VARCHAR2(1);
39741 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
39742 l_log_module VARCHAR2(240);
39743
39744 --
39745 -- Upgrade strategy
39746 --
39747 l_actual_upg_option VARCHAR2(1);
39748 l_enc_upg_option VARCHAR2(1);
39749
39750 --
39751 BEGIN
39752 --
39753 IF g_log_enabled THEN
39754 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_92';
39755 END IF;
39756 --
39757 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39758
39759 trace
39760 (p_msg => 'BEGIN of AcctLineType_92'
39761 ,p_level => C_LEVEL_PROCEDURE
39762 ,p_module => l_log_module);
39763
39764 END IF;
39765 --
39766 l_component_type := 'AMB_JLT';
39767 l_component_code := 'MFAR_MISC_RCT_CASH';
39768 l_component_type_code := 'S';
39769 l_component_appl_id := 222;
39770 l_amb_context_code := 'DEFAULT';
39771 l_entity_code := 'RECEIPTS';
39772 l_event_class_code := 'MISC_RECEIPT';
39773 l_event_type_code := 'MISC_RECEIPT_ALL';
39774 l_line_definition_owner_code := 'S';
39775 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
39776 --
39777 l_balance_type_code := 'A';
39778 l_segment := NULL;
39779 l_ccid := NULL;
39780 l_adr_transaction_coa_id := NULL;
39781 l_adr_accounting_coa_id := NULL;
39782 l_adr_flexfield_segment_code := NULL;
39783 l_adr_flex_value_set_id := NULL;
39784 l_adr_value_type_code := NULL;
39785 l_adr_value_combination_id := NULL;
39786 l_adr_value_segment_code := NULL;
39787
39788 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
39789 l_bflow_class_code := ''; -- 4219869 Business Flow
39790 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
39791 l_budgetary_control_flag := 'N';
39792
39793 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39794 l_bflow_applied_to_amt := NULL; -- 5132302
39795 l_entered_amt_idx := NULL; -- 4262811
39796 l_accted_amt_idx := NULL; -- 4262811
39797 l_acc_rev_flag := NULL; -- 4262811
39798 l_accrual_line_num := NULL; -- 4262811
39799 l_tmp_amt := NULL; -- 4262811
39800 --
39801
39802 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
39803 l_balance_type_code <> 'B' THEN
39804 IF (NVL(p_source_22,'
39805 ') = 'CASH' OR
39806 NVL(p_source_22,'
39807 ') = 'TAX') AND
39808 NVL(p_source_71,'
39809 ') = 'N' AND
39810 NVL(p_source_72,'
39811 ') = 'N' AND
39812 NVL(p_source_73,'
39813 ') = 'N'
39814 THEN
39815
39816 --
39817 XLA_AE_LINES_PKG.SetNewLine;
39818
39819 p_balance_type_code := l_balance_type_code;
39823 p_actual_flag :='A';
39820 -- set the flag so later we will know whether the gain loss line needs to be created
39821
39822 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
39824 END IF;
39825
39826 --
39827 -- bulk performance
39828 --
39829 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
39830 p_header_num => 0); -- 4262811
39831 --
39832 -- set accounting line options
39833 --
39834 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
39835 p_natural_side_code => 'C'
39836 , p_gain_or_loss_flag => 'N'
39837 , p_gl_transfer_mode_code => 'S'
39838 , p_acct_entry_type_code => 'A'
39839 , p_switch_side_flag => 'Y'
39840 , p_merge_duplicate_code => 'A'
39841 );
39842 --
39843 l_acc_rev_natural_side_code := 'D'; -- 4262811
39844 --
39845 --
39846 -- set accounting line type info
39847 --
39848 xla_ae_lines_pkg.SetAcctLineType
39849 (p_component_type => l_component_type
39850 ,p_event_type_code => l_event_type_code
39851 ,p_line_definition_owner_code => l_line_definition_owner_code
39852 ,p_line_definition_code => l_line_definition_code
39853 ,p_accounting_line_code => l_component_code
39854 ,p_accounting_line_type_code => l_component_type_code
39855 ,p_accounting_line_appl_id => l_component_appl_id
39856 ,p_amb_context_code => l_amb_context_code
39857 ,p_entity_code => l_entity_code
39858 ,p_event_class_code => l_event_class_code);
39859 --
39860 -- set accounting class
39861 --
39862 xla_ae_lines_pkg.SetAcctClass(
39863 p_accounting_class_code => 'CASH'
39864 , p_ae_header_id => l_ae_header_id
39865 );
39866
39867 --
39868 -- set rounding class
39869 --
39870 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
39871 'RECEIVABLE';
39872
39873 --
39874 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
39875 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
39876 --
39877 -- bulk performance
39878 --
39879 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
39880
39881 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
39882 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
39883
39884 -- 4955764
39885 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
39886 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
39887
39888 -- 4458381 Public Sector Enh
39889
39890 --
39891 -- set accounting attributes for the line type
39892 --
39893 l_entered_amt_idx := 3;
39894 l_accted_amt_idx := 8;
39895 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39896 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
39897 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
39898 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
39899 l_rec_acct_attrs.array_char_value(2) := p_source_25;
39900 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
39901 l_rec_acct_attrs.array_num_value(3) := p_source_26;
39902 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
39903 l_rec_acct_attrs.array_char_value(4) := p_source_27;
39904 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
39905 l_rec_acct_attrs.array_date_value(5) := p_source_59;
39906 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
39907 l_rec_acct_attrs.array_num_value(6) := p_source_29;
39908 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
39909 l_rec_acct_attrs.array_char_value(7) := p_source_30;
39910 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
39911 l_rec_acct_attrs.array_num_value(8) := p_source_31;
39912
39913 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
39914 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
39915
39916 ---------------------------------------------------------------------------------------------------------------
39917 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
39918 ---------------------------------------------------------------------------------------------------------------
39919 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
39920
39921 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39922 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39923
39924 IF xla_accounting_cache_pkg.GetValueChar
39925 (p_source_code => 'LEDGER_CATEGORY_CODE'
39926 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
39927 AND l_bflow_method_code = 'PRIOR_ENTRY'
39928 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
39932 THEN
39929 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
39930 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
39931 )
39933 xla_ae_lines_pkg.BflowUpgEntry
39934 (p_business_method_code => l_bflow_method_code
39935 ,p_business_class_code => l_bflow_class_code
39936 ,p_balance_type => l_balance_type_code);
39937 ELSE
39938 NULL;
39939 -- No business flow processing for business flow method of NONE.
39940 END IF;
39941
39942 --
39943 -- call analytical criteria
39944 --
39945
39946 --
39947 -- call description
39948 --
39949
39950 xla_ae_lines_pkg.SetLineDescription(
39951 p_ae_header_id => l_ae_header_id
39952 ,p_description => Description_1 (
39953 p_application_id => p_application_id
39954 , p_ae_header_id => l_ae_header_id
39955 )
39956 );
39957
39958
39959 --
39960 -- call ADRs
39961 -- Bug 4922099
39962 --
39963 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
39964 (NVL(l_actual_upg_option, 'N') = 'O') OR
39965 (NVL(l_enc_upg_option, 'N') = 'O')
39966 )
39967 THEN
39968 NULL;
39969 --
39970 --
39971
39972 l_ccid := AcctDerRule_11(
39973 p_application_id => p_application_id
39974 , p_ae_header_id => l_ae_header_id
39975 , p_source_10 => p_source_10
39976 , x_transaction_coa_id => l_adr_transaction_coa_id
39977 , x_accounting_coa_id => l_adr_accounting_coa_id
39978 , x_value_type_code => l_adr_value_type_code
39979 , p_side => 'NA'
39980 );
39981
39982 xla_ae_lines_pkg.set_ccid(
39983 p_code_combination_id => l_ccid
39984 , p_value_type_code => l_adr_value_type_code
39985 , p_transaction_coa_id => l_adr_transaction_coa_id
39986 , p_accounting_coa_id => l_adr_accounting_coa_id
39987 , p_adr_code => 'DIST_CCID'
39988 , p_adr_type_code => 'S'
39989 , p_component_type => l_component_type
39990 , p_component_code => l_component_code
39991 , p_component_type_code => l_component_type_code
39992 , p_component_appl_id => l_component_appl_id
39993 , p_amb_context_code => l_amb_context_code
39994 , p_side => 'NA'
39995 );
39996
39997
39998 l_segment := AcctDerRule_6(
39999 p_application_id => p_application_id
40000 , p_ae_header_id => l_ae_header_id
40001 , p_source_5 => p_source_5
40002 , x_transaction_coa_id => l_adr_transaction_coa_id
40003 , x_accounting_coa_id => l_adr_accounting_coa_id
40004 , x_flexfield_segment_code => l_adr_flexfield_segment_code
40005 , x_flex_value_set_id => l_adr_flex_value_set_id
40006 , x_value_type_code => l_adr_value_type_code
40007 , x_value_combination_id => l_adr_value_combination_id
40008 , x_value_segment_code => l_adr_value_segment_code
40009 , p_side => 'NA'
40010 , p_override_seg_flag => 'Y'
40011 );
40012
40013 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
40014
40015 xla_ae_lines_pkg.set_segment(
40016 p_to_segment_code => 'GL_ACCOUNT'
40017 , p_segment_value => l_segment
40018 , p_from_segment_code => l_adr_value_segment_code
40019 , p_from_combination_id => l_adr_value_combination_id
40020 , p_value_type_code => l_adr_value_type_code
40021 , p_transaction_coa_id => l_adr_transaction_coa_id
40022 , p_accounting_coa_id => l_adr_accounting_coa_id
40023 , p_flexfield_segment_code => l_adr_flexfield_segment_code
40024 , p_flex_value_set_id => l_adr_flex_value_set_id
40025 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
40026 , p_adr_type_code => 'S'
40027 , p_component_type => l_component_type
40028 , p_component_code => l_component_code
40029 , p_component_type_code => l_component_type_code
40030 , p_component_appl_id => l_component_appl_id
40031 , p_amb_context_code => l_amb_context_code
40032 , p_entity_code => 'RECEIPTS'
40033 , p_event_class_code => 'MISC_RECEIPT'
40034 , p_side => 'NA'
40035 );
40036
40037 END IF;
40038
40039 --
40040 --
40041 END IF;
40042 --
40043 -- Bug 4922099
40044 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
40045 (NVL(l_enc_upg_option, 'N') = 'O')
40046 ) AND
40047 (l_bflow_method_code = 'PRIOR_ENTRY')
40048 )
40049 THEN
40050 IF
40051 --
40052 1 = 2
40053 --
40054 THEN
40055 xla_accounting_err_pkg.build_message
40056 (p_appli_s_name => 'XLA'
40057 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40058 ,p_token_1 => 'LINE_NUMBER'
40062 l_component_type
40059 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
40060 ,p_token_2 => 'LINE_TYPE_NAME'
40061 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
40063 ,l_component_code
40064 ,l_component_type_code
40065 ,l_component_appl_id
40066 ,l_amb_context_code
40067 ,l_entity_code
40068 ,l_event_class_code
40069 )
40070 ,p_token_3 => 'OWNER'
40071 ,p_value_3 => xla_lookups_pkg.get_meaning(
40072 p_lookup_type => 'XLA_OWNER_TYPE'
40073 ,p_lookup_code => l_component_type_code
40074 )
40075 ,p_token_4 => 'PRODUCT_NAME'
40076 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
40077 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
40078 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
40079 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
40080 ,p_ae_header_id => NULL
40081 );
40082
40083 IF (C_LEVEL_ERROR>= g_log_level) THEN
40084 trace
40085 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40086 ,p_level => C_LEVEL_ERROR
40087 ,p_module => l_log_module);
40088 END IF;
40089 END IF;
40090 END IF;
40091 --
40092 --
40093 ------------------------------------------------------------------------------------------------
40094 -- 4219869 Business Flow
40095 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
40096 -- Prior Entry. Currently, the following code is always generated.
40097 ------------------------------------------------------------------------------------------------
40098 XLA_AE_LINES_PKG.ValidateCurrentLine;
40099
40100 ------------------------------------------------------------------------------------
40101 -- 4219869 Business Flow
40102 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
40103 ------------------------------------------------------------------------------------
40104 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40105
40106 ----------------------------------------------------------------------------------
40107 -- 4219869 Business Flow
40108 -- Update journal entry status -- Need to generate this within IF <condition>
40109 ----------------------------------------------------------------------------------
40110 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40111 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
40112 ,p_balance_type_code => l_balance_type_code
40113 );
40114
40115 -------------------------------------------------------------------------------------------
40116 -- 4262811 - Generate the Accrual Reversal lines
40117 -------------------------------------------------------------------------------------------
40118 BEGIN
40119 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
40120 (g_array_event(p_event_id).array_value_num('header_index'));
40121 IF l_acc_rev_flag IS NULL THEN
40122 l_acc_rev_flag := 'N';
40123 END IF;
40124 EXCEPTION
40125 WHEN OTHERS THEN
40126 l_acc_rev_flag := 'N';
40127 END;
40128 --
40129 IF (l_acc_rev_flag = 'Y') THEN
40130
40131 -- 4645092 ------------------------------------------------------------------------------
40132 -- To allow MPA report to determine if it should generate report process
40133 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
40134 ------------------------------------------------------------------------------------------
40135
40136 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
40137 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
40138 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
40139 -- call ADRs
40140 -- Bug 4922099
40141 --
40142 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
40143 (NVL(l_actual_upg_option, 'N') = 'O') OR
40144 (NVL(l_enc_upg_option, 'N') = 'O')
40145 )
40146 THEN
40147 NULL;
40148 --
40149 --
40150
40151 l_ccid := AcctDerRule_11(
40152 p_application_id => p_application_id
40156 , x_accounting_coa_id => l_adr_accounting_coa_id
40153 , p_ae_header_id => l_ae_header_id
40154 , p_source_10 => p_source_10
40155 , x_transaction_coa_id => l_adr_transaction_coa_id
40157 , x_value_type_code => l_adr_value_type_code
40158 , p_side => 'NA'
40159 );
40160
40161 xla_ae_lines_pkg.set_ccid(
40162 p_code_combination_id => l_ccid
40163 , p_value_type_code => l_adr_value_type_code
40164 , p_transaction_coa_id => l_adr_transaction_coa_id
40165 , p_accounting_coa_id => l_adr_accounting_coa_id
40166 , p_adr_code => 'DIST_CCID'
40167 , p_adr_type_code => 'S'
40168 , p_component_type => l_component_type
40169 , p_component_code => l_component_code
40170 , p_component_type_code => l_component_type_code
40171 , p_component_appl_id => l_component_appl_id
40172 , p_amb_context_code => l_amb_context_code
40173 , p_side => 'NA'
40174 );
40175
40176
40177 l_segment := AcctDerRule_6(
40178 p_application_id => p_application_id
40179 , p_ae_header_id => l_ae_header_id
40180 , p_source_5 => p_source_5
40181 , x_transaction_coa_id => l_adr_transaction_coa_id
40182 , x_accounting_coa_id => l_adr_accounting_coa_id
40183 , x_flexfield_segment_code => l_adr_flexfield_segment_code
40184 , x_flex_value_set_id => l_adr_flex_value_set_id
40185 , x_value_type_code => l_adr_value_type_code
40186 , x_value_combination_id => l_adr_value_combination_id
40187 , x_value_segment_code => l_adr_value_segment_code
40188 , p_side => 'NA'
40189 , p_override_seg_flag => 'Y'
40190 );
40191
40192 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
40193
40194 xla_ae_lines_pkg.set_segment(
40195 p_to_segment_code => 'GL_ACCOUNT'
40196 , p_segment_value => l_segment
40197 , p_from_segment_code => l_adr_value_segment_code
40198 , p_from_combination_id => l_adr_value_combination_id
40199 , p_value_type_code => l_adr_value_type_code
40200 , p_transaction_coa_id => l_adr_transaction_coa_id
40201 , p_accounting_coa_id => l_adr_accounting_coa_id
40202 , p_flexfield_segment_code => l_adr_flexfield_segment_code
40203 , p_flex_value_set_id => l_adr_flex_value_set_id
40204 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
40205 , p_adr_type_code => 'S'
40206 , p_component_type => l_component_type
40207 , p_component_code => l_component_code
40208 , p_component_type_code => l_component_type_code
40209 , p_component_appl_id => l_component_appl_id
40210 , p_amb_context_code => l_amb_context_code
40211 , p_entity_code => 'RECEIPTS'
40212 , p_event_class_code => 'MISC_RECEIPT'
40213 , p_side => 'NA'
40214 );
40215
40216 END IF;
40217
40218 --
40219 --
40220 END IF;
40221
40222 --
40223 -- Update the line information that should be overwritten
40224 --
40225 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
40226 p_header_num => 1);
40227 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
40228
40229 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
40230
40231 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
40232 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
40233 END IF;
40234
40235 --
40236 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
40237 --
40238 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
40239 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
40240 ELSE
40241 ---------------------------------------------------------------------------------------------------
40242 -- 4262811a Switch Sign
40243 ---------------------------------------------------------------------------------------------------
40244 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
40245 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40246 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40247 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40248 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40249 -- 5132302
40250 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
40251 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40252
40253 END IF;
40254
40255 -- 4955764
40256 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40260 XLA_AE_LINES_PKG.ValidateCurrentLine;
40257 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
40258
40259
40261 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40262
40263 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40264 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
40265 ,p_balance_type_code => l_balance_type_code);
40266
40267 END IF;
40268
40269 -----------------------------------------------------------------------------------------
40270 -- 4262811 Multiperiod Accounting
40271 -----------------------------------------------------------------------------------------
40272 -- No MPA option is assigned.
40273
40274
40275 END IF;
40276 END IF;
40277 --
40278
40279 --
40280 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40281 trace
40282 (p_msg => 'END of AcctLineType_92'
40283 ,p_level => C_LEVEL_PROCEDURE
40284 ,p_module => l_log_module);
40285 END IF;
40286 --
40287 EXCEPTION
40288 WHEN xla_exceptions_pkg.application_exception THEN
40289 RAISE;
40290 WHEN OTHERS THEN
40291 xla_exceptions_pkg.raise_message
40292 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_92');
40293 END AcctLineType_92;
40294 --
40295
40296 ---------------------------------------
40297 --
40298 -- PRIVATE FUNCTION
40299 -- AcctLineType_93
40300 --
40301 ---------------------------------------
40302 PROCEDURE AcctLineType_93 (
40303 p_application_id IN NUMBER
40304 ,p_event_id IN NUMBER
40305 ,p_calculate_acctd_flag IN VARCHAR2
40306 ,p_calculate_g_l_flag IN VARCHAR2
40307 ,p_actual_flag IN OUT VARCHAR2
40308 ,p_balance_type_code OUT VARCHAR2
40309 ,p_gain_or_loss_ref OUT VARCHAR2
40310
40311 --Remittance Bank Account Cash Account
40312 , p_source_5 IN NUMBER
40313 --Distribution GL Account
40314 , p_source_10 IN NUMBER
40315 --Distribution Source Type
40316 , p_source_22 IN VARCHAR2
40317 --Distribution Line Identifier
40318 , p_source_24 IN NUMBER
40319 --Distribution Type
40320 , p_source_25 IN VARCHAR2
40321 --Entered Amount
40322 , p_source_26 IN NUMBER
40323 --Currency Code
40324 , p_source_27 IN VARCHAR2
40325 --Exchange Rate
40326 , p_source_29 IN NUMBER
40327 --Exchange Rate Type
40328 , p_source_30 IN VARCHAR2
40329 --Applied To Document Accounting Amount
40330 , p_source_31 IN NUMBER
40331 --Applied To Document Exchange Date
40332 , p_source_59 IN DATE
40333 --Distribution Multi Fund Additional Entry
40334 , p_source_71 IN VARCHAR2
40335 --Receipt Class Require Remittance Flag
40336 , p_source_72 IN VARCHAR2
40337 )
40338 IS
40339
40340 l_component_type VARCHAR2(80);
40341 l_component_code VARCHAR2(30);
40342 l_component_type_code VARCHAR2(1);
40343 l_component_appl_id INTEGER;
40344 l_amb_context_code VARCHAR2(30);
40345 l_entity_code VARCHAR2(30);
40346 l_event_class_code VARCHAR2(30);
40347 l_ae_header_id NUMBER;
40348 l_event_type_code VARCHAR2(30);
40349 l_line_definition_code VARCHAR2(30);
40350 l_line_definition_owner_code VARCHAR2(1);
40351 --
40352 -- adr variables
40353 l_segment VARCHAR2(30);
40354 l_ccid NUMBER;
40355 l_adr_transaction_coa_id NUMBER;
40356 l_adr_accounting_coa_id NUMBER;
40357 l_adr_flexfield_segment_code VARCHAR2(30);
40358 l_adr_flex_value_set_id NUMBER;
40359 l_adr_value_type_code VARCHAR2(30);
40360 l_adr_value_combination_id NUMBER;
40361 l_adr_value_segment_code VARCHAR2(30);
40362
40363 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
40364 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
40365 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
40366 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
40367
40368 -- 4262811 Variables ------------------------------------------------------------------------------------------
40369 l_entered_amt_idx NUMBER;
40370 l_accted_amt_idx NUMBER;
40371 l_acc_rev_flag VARCHAR2(1);
40372 l_accrual_line_num NUMBER;
40373 l_tmp_amt NUMBER;
40374 l_acc_rev_natural_side_code VARCHAR2(1);
40375
40376 l_num_entries NUMBER;
40377 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
40378 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
40379 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
40380 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
40381 l_recog_line_1 NUMBER;
40382 l_recog_line_2 NUMBER;
40383
40384 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
40385 l_bflow_applied_to_amt NUMBER; -- 5132302
40386 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
40387
40388 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
40389
40393 ---------------------------------------------------------------------------------------------------------------
40390 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
40391 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
40392
40394
40395
40396 --
40397 -- bulk performance
40398 --
40399 l_balance_type_code VARCHAR2(1);
40400 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
40401 l_log_module VARCHAR2(240);
40402
40403 --
40404 -- Upgrade strategy
40405 --
40406 l_actual_upg_option VARCHAR2(1);
40407 l_enc_upg_option VARCHAR2(1);
40408
40409 --
40410 BEGIN
40411 --
40412 IF g_log_enabled THEN
40413 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_93';
40414 END IF;
40415 --
40416 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40417
40418 trace
40419 (p_msg => 'BEGIN of AcctLineType_93'
40420 ,p_level => C_LEVEL_PROCEDURE
40421 ,p_module => l_log_module);
40422
40423 END IF;
40424 --
40425 l_component_type := 'AMB_JLT';
40426 l_component_code := 'MFAR_MISC_RCT_CM_CASH';
40427 l_component_type_code := 'S';
40428 l_component_appl_id := 222;
40429 l_amb_context_code := 'DEFAULT';
40430 l_entity_code := 'RECEIPTS';
40431 l_event_class_code := 'MISC_RECEIPT';
40432 l_event_type_code := 'MISC_RECEIPT_ALL';
40433 l_line_definition_owner_code := 'S';
40434 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
40435 --
40436 l_balance_type_code := 'A';
40437 l_segment := NULL;
40438 l_ccid := NULL;
40439 l_adr_transaction_coa_id := NULL;
40440 l_adr_accounting_coa_id := NULL;
40441 l_adr_flexfield_segment_code := NULL;
40442 l_adr_flex_value_set_id := NULL;
40443 l_adr_value_type_code := NULL;
40444 l_adr_value_combination_id := NULL;
40445 l_adr_value_segment_code := NULL;
40446
40447 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
40448 l_bflow_class_code := ''; -- 4219869 Business Flow
40449 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
40450 l_budgetary_control_flag := 'N';
40451
40452 l_bflow_applied_to_amt_idx := NULL; -- 5132302
40453 l_bflow_applied_to_amt := NULL; -- 5132302
40454 l_entered_amt_idx := NULL; -- 4262811
40455 l_accted_amt_idx := NULL; -- 4262811
40456 l_acc_rev_flag := NULL; -- 4262811
40457 l_accrual_line_num := NULL; -- 4262811
40458 l_tmp_amt := NULL; -- 4262811
40459 --
40460
40461 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
40462 l_balance_type_code <> 'B' THEN
40463 IF NVL(p_source_22,'
40464 ') = 'MISCCASH' AND
40465 NVL(p_source_71,'
40466 ') = 'Y' AND
40467 NVL(p_source_72,'
40468 ') = 'Y'
40469 THEN
40470
40471 --
40472 XLA_AE_LINES_PKG.SetNewLine;
40473
40474 p_balance_type_code := l_balance_type_code;
40475 -- set the flag so later we will know whether the gain loss line needs to be created
40476
40477 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
40478 p_actual_flag :='A';
40479 END IF;
40480
40481 --
40482 -- bulk performance
40483 --
40484 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
40485 p_header_num => 0); -- 4262811
40486 --
40487 -- set accounting line options
40488 --
40489 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
40490 p_natural_side_code => 'C'
40491 , p_gain_or_loss_flag => 'N'
40492 , p_gl_transfer_mode_code => 'S'
40493 , p_acct_entry_type_code => 'A'
40494 , p_switch_side_flag => 'Y'
40495 , p_merge_duplicate_code => 'A'
40496 );
40497 --
40498 l_acc_rev_natural_side_code := 'D'; -- 4262811
40499 --
40500 --
40501 -- set accounting line type info
40502 --
40503 xla_ae_lines_pkg.SetAcctLineType
40504 (p_component_type => l_component_type
40505 ,p_event_type_code => l_event_type_code
40506 ,p_line_definition_owner_code => l_line_definition_owner_code
40507 ,p_line_definition_code => l_line_definition_code
40508 ,p_accounting_line_code => l_component_code
40509 ,p_accounting_line_type_code => l_component_type_code
40510 ,p_accounting_line_appl_id => l_component_appl_id
40511 ,p_amb_context_code => l_amb_context_code
40512 ,p_entity_code => l_entity_code
40513 ,p_event_class_code => l_event_class_code);
40514 --
40515 -- set accounting class
40516 --
40517 xla_ae_lines_pkg.SetAcctClass(
40518 p_accounting_class_code => 'CASH'
40519 , p_ae_header_id => l_ae_header_id
40520 );
40521
40522 --
40523 -- set rounding class
40524 --
40525 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
40526 'RECEIVABLE';
40527
40528 --
40532 -- bulk performance
40529 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
40530 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
40531 --
40533 --
40534 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
40535
40536 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
40537 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
40538
40539 -- 4955764
40540 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40541 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
40542
40543 -- 4458381 Public Sector Enh
40544
40545 --
40546 -- set accounting attributes for the line type
40547 --
40548 l_entered_amt_idx := 3;
40549 l_accted_amt_idx := 8;
40550 l_bflow_applied_to_amt_idx := NULL; -- 5132302
40551 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
40552 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
40553 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
40554 l_rec_acct_attrs.array_char_value(2) := p_source_25;
40555 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
40556 l_rec_acct_attrs.array_num_value(3) := p_source_26;
40557 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
40558 l_rec_acct_attrs.array_char_value(4) := p_source_27;
40559 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
40560 l_rec_acct_attrs.array_date_value(5) := p_source_59;
40561 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
40562 l_rec_acct_attrs.array_num_value(6) := p_source_29;
40563 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
40564 l_rec_acct_attrs.array_char_value(7) := p_source_30;
40565 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
40566 l_rec_acct_attrs.array_num_value(8) := p_source_31;
40567
40568 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
40569 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
40570
40571 ---------------------------------------------------------------------------------------------------------------
40572 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
40573 ---------------------------------------------------------------------------------------------------------------
40574 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
40575
40576 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
40577 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
40578
40579 IF xla_accounting_cache_pkg.GetValueChar
40580 (p_source_code => 'LEDGER_CATEGORY_CODE'
40581 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
40582 AND l_bflow_method_code = 'PRIOR_ENTRY'
40583 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
40584 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
40585 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
40586 )
40587 THEN
40588 xla_ae_lines_pkg.BflowUpgEntry
40589 (p_business_method_code => l_bflow_method_code
40590 ,p_business_class_code => l_bflow_class_code
40591 ,p_balance_type => l_balance_type_code);
40592 ELSE
40593 NULL;
40594 -- No business flow processing for business flow method of NONE.
40595 END IF;
40596
40597 --
40598 -- call analytical criteria
40599 --
40600
40601 --
40602 -- call description
40603 --
40604
40605 xla_ae_lines_pkg.SetLineDescription(
40606 p_ae_header_id => l_ae_header_id
40607 ,p_description => Description_1 (
40608 p_application_id => p_application_id
40609 , p_ae_header_id => l_ae_header_id
40610 )
40611 );
40612
40613
40614 --
40615 -- call ADRs
40616 -- Bug 4922099
40617 --
40618 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
40619 (NVL(l_actual_upg_option, 'N') = 'O') OR
40620 (NVL(l_enc_upg_option, 'N') = 'O')
40621 )
40622 THEN
40623 NULL;
40624 --
40625 --
40626
40627 l_ccid := AcctDerRule_11(
40628 p_application_id => p_application_id
40629 , p_ae_header_id => l_ae_header_id
40630 , p_source_10 => p_source_10
40631 , x_transaction_coa_id => l_adr_transaction_coa_id
40632 , x_accounting_coa_id => l_adr_accounting_coa_id
40633 , x_value_type_code => l_adr_value_type_code
40634 , p_side => 'NA'
40635 );
40636
40637 xla_ae_lines_pkg.set_ccid(
40638 p_code_combination_id => l_ccid
40639 , p_value_type_code => l_adr_value_type_code
40640 , p_transaction_coa_id => l_adr_transaction_coa_id
40641 , p_accounting_coa_id => l_adr_accounting_coa_id
40642 , p_adr_code => 'DIST_CCID'
40643 , p_adr_type_code => 'S'
40647 , p_component_appl_id => l_component_appl_id
40644 , p_component_type => l_component_type
40645 , p_component_code => l_component_code
40646 , p_component_type_code => l_component_type_code
40648 , p_amb_context_code => l_amb_context_code
40649 , p_side => 'NA'
40650 );
40651
40652
40653 l_segment := AcctDerRule_6(
40654 p_application_id => p_application_id
40655 , p_ae_header_id => l_ae_header_id
40656 , p_source_5 => p_source_5
40657 , x_transaction_coa_id => l_adr_transaction_coa_id
40658 , x_accounting_coa_id => l_adr_accounting_coa_id
40659 , x_flexfield_segment_code => l_adr_flexfield_segment_code
40660 , x_flex_value_set_id => l_adr_flex_value_set_id
40661 , x_value_type_code => l_adr_value_type_code
40662 , x_value_combination_id => l_adr_value_combination_id
40663 , x_value_segment_code => l_adr_value_segment_code
40664 , p_side => 'NA'
40665 , p_override_seg_flag => 'Y'
40666 );
40667
40668 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
40669
40670 xla_ae_lines_pkg.set_segment(
40671 p_to_segment_code => 'GL_ACCOUNT'
40672 , p_segment_value => l_segment
40673 , p_from_segment_code => l_adr_value_segment_code
40674 , p_from_combination_id => l_adr_value_combination_id
40675 , p_value_type_code => l_adr_value_type_code
40676 , p_transaction_coa_id => l_adr_transaction_coa_id
40677 , p_accounting_coa_id => l_adr_accounting_coa_id
40678 , p_flexfield_segment_code => l_adr_flexfield_segment_code
40679 , p_flex_value_set_id => l_adr_flex_value_set_id
40680 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
40681 , p_adr_type_code => 'S'
40682 , p_component_type => l_component_type
40683 , p_component_code => l_component_code
40684 , p_component_type_code => l_component_type_code
40685 , p_component_appl_id => l_component_appl_id
40686 , p_amb_context_code => l_amb_context_code
40687 , p_entity_code => 'RECEIPTS'
40688 , p_event_class_code => 'MISC_RECEIPT'
40689 , p_side => 'NA'
40690 );
40691
40692 END IF;
40693
40694 --
40695 --
40696 END IF;
40697 --
40698 -- Bug 4922099
40699 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
40700 (NVL(l_enc_upg_option, 'N') = 'O')
40701 ) AND
40702 (l_bflow_method_code = 'PRIOR_ENTRY')
40703 )
40704 THEN
40705 IF
40706 --
40707 1 = 2
40708 --
40709 THEN
40710 xla_accounting_err_pkg.build_message
40711 (p_appli_s_name => 'XLA'
40712 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40713 ,p_token_1 => 'LINE_NUMBER'
40714 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
40715 ,p_token_2 => 'LINE_TYPE_NAME'
40716 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
40717 l_component_type
40718 ,l_component_code
40719 ,l_component_type_code
40720 ,l_component_appl_id
40721 ,l_amb_context_code
40722 ,l_entity_code
40723 ,l_event_class_code
40724 )
40725 ,p_token_3 => 'OWNER'
40726 ,p_value_3 => xla_lookups_pkg.get_meaning(
40727 p_lookup_type => 'XLA_OWNER_TYPE'
40728 ,p_lookup_code => l_component_type_code
40729 )
40730 ,p_token_4 => 'PRODUCT_NAME'
40731 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
40732 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
40733 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
40734 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
40735 ,p_ae_header_id => NULL
40736 );
40737
40738 IF (C_LEVEL_ERROR>= g_log_level) THEN
40739 trace
40740 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40744 END IF;
40741 ,p_level => C_LEVEL_ERROR
40742 ,p_module => l_log_module);
40743 END IF;
40745 END IF;
40746 --
40747 --
40748 ------------------------------------------------------------------------------------------------
40749 -- 4219869 Business Flow
40750 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
40751 -- Prior Entry. Currently, the following code is always generated.
40752 ------------------------------------------------------------------------------------------------
40753 XLA_AE_LINES_PKG.ValidateCurrentLine;
40754
40755 ------------------------------------------------------------------------------------
40756 -- 4219869 Business Flow
40757 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
40758 ------------------------------------------------------------------------------------
40759 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40760
40761 ----------------------------------------------------------------------------------
40762 -- 4219869 Business Flow
40763 -- Update journal entry status -- Need to generate this within IF <condition>
40764 ----------------------------------------------------------------------------------
40765 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40766 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
40767 ,p_balance_type_code => l_balance_type_code
40768 );
40769
40770 -------------------------------------------------------------------------------------------
40771 -- 4262811 - Generate the Accrual Reversal lines
40772 -------------------------------------------------------------------------------------------
40773 BEGIN
40774 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
40775 (g_array_event(p_event_id).array_value_num('header_index'));
40776 IF l_acc_rev_flag IS NULL THEN
40777 l_acc_rev_flag := 'N';
40778 END IF;
40779 EXCEPTION
40780 WHEN OTHERS THEN
40781 l_acc_rev_flag := 'N';
40782 END;
40783 --
40784 IF (l_acc_rev_flag = 'Y') THEN
40785
40786 -- 4645092 ------------------------------------------------------------------------------
40787 -- To allow MPA report to determine if it should generate report process
40788 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
40789 ------------------------------------------------------------------------------------------
40790
40791 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
40792 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
40793 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
40794 -- call ADRs
40795 -- Bug 4922099
40796 --
40797 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
40798 (NVL(l_actual_upg_option, 'N') = 'O') OR
40799 (NVL(l_enc_upg_option, 'N') = 'O')
40800 )
40801 THEN
40802 NULL;
40803 --
40804 --
40805
40806 l_ccid := AcctDerRule_11(
40807 p_application_id => p_application_id
40808 , p_ae_header_id => l_ae_header_id
40809 , p_source_10 => p_source_10
40810 , x_transaction_coa_id => l_adr_transaction_coa_id
40811 , x_accounting_coa_id => l_adr_accounting_coa_id
40812 , x_value_type_code => l_adr_value_type_code
40813 , p_side => 'NA'
40814 );
40815
40816 xla_ae_lines_pkg.set_ccid(
40817 p_code_combination_id => l_ccid
40818 , p_value_type_code => l_adr_value_type_code
40819 , p_transaction_coa_id => l_adr_transaction_coa_id
40820 , p_accounting_coa_id => l_adr_accounting_coa_id
40821 , p_adr_code => 'DIST_CCID'
40822 , p_adr_type_code => 'S'
40823 , p_component_type => l_component_type
40824 , p_component_code => l_component_code
40825 , p_component_type_code => l_component_type_code
40826 , p_component_appl_id => l_component_appl_id
40827 , p_amb_context_code => l_amb_context_code
40828 , p_side => 'NA'
40829 );
40830
40831
40832 l_segment := AcctDerRule_6(
40833 p_application_id => p_application_id
40834 , p_ae_header_id => l_ae_header_id
40835 , p_source_5 => p_source_5
40836 , x_transaction_coa_id => l_adr_transaction_coa_id
40837 , x_accounting_coa_id => l_adr_accounting_coa_id
40838 , x_flexfield_segment_code => l_adr_flexfield_segment_code
40839 , x_flex_value_set_id => l_adr_flex_value_set_id
40840 , x_value_type_code => l_adr_value_type_code
40841 , x_value_combination_id => l_adr_value_combination_id
40842 , x_value_segment_code => l_adr_value_segment_code
40843 , p_side => 'NA'
40844 , p_override_seg_flag => 'Y'
40845 );
40846
40847 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
40848
40849 xla_ae_lines_pkg.set_segment(
40850 p_to_segment_code => 'GL_ACCOUNT'
40851 , p_segment_value => l_segment
40852 , p_from_segment_code => l_adr_value_segment_code
40853 , p_from_combination_id => l_adr_value_combination_id
40854 , p_value_type_code => l_adr_value_type_code
40858 , p_flex_value_set_id => l_adr_flex_value_set_id
40855 , p_transaction_coa_id => l_adr_transaction_coa_id
40856 , p_accounting_coa_id => l_adr_accounting_coa_id
40857 , p_flexfield_segment_code => l_adr_flexfield_segment_code
40859 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
40860 , p_adr_type_code => 'S'
40861 , p_component_type => l_component_type
40862 , p_component_code => l_component_code
40863 , p_component_type_code => l_component_type_code
40864 , p_component_appl_id => l_component_appl_id
40865 , p_amb_context_code => l_amb_context_code
40866 , p_entity_code => 'RECEIPTS'
40867 , p_event_class_code => 'MISC_RECEIPT'
40868 , p_side => 'NA'
40869 );
40870
40871 END IF;
40872
40873 --
40874 --
40875 END IF;
40876
40877 --
40878 -- Update the line information that should be overwritten
40879 --
40880 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
40881 p_header_num => 1);
40882 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
40883
40884 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
40885
40886 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
40887 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
40888 END IF;
40889
40890 --
40891 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
40892 --
40893 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
40894 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
40895 ELSE
40896 ---------------------------------------------------------------------------------------------------
40897 -- 4262811a Switch Sign
40898 ---------------------------------------------------------------------------------------------------
40899 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
40900 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40901 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40902 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40903 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40904 -- 5132302
40905 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
40906 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40907
40908 END IF;
40909
40910 -- 4955764
40911 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40912 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
40913
40914
40915 XLA_AE_LINES_PKG.ValidateCurrentLine;
40916 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40917
40918 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40919 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
40920 ,p_balance_type_code => l_balance_type_code);
40921
40922 END IF;
40923
40924 -----------------------------------------------------------------------------------------
40925 -- 4262811 Multiperiod Accounting
40926 -----------------------------------------------------------------------------------------
40927 -- No MPA option is assigned.
40928
40929
40930 END IF;
40931 END IF;
40932 --
40933
40934 --
40935 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40936 trace
40937 (p_msg => 'END of AcctLineType_93'
40938 ,p_level => C_LEVEL_PROCEDURE
40939 ,p_module => l_log_module);
40940 END IF;
40941 --
40942 EXCEPTION
40943 WHEN xla_exceptions_pkg.application_exception THEN
40944 RAISE;
40945 WHEN OTHERS THEN
40946 xla_exceptions_pkg.raise_message
40947 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_93');
40948 END AcctLineType_93;
40949 --
40950
40951 ---------------------------------------
40952 --
40953 -- PRIVATE FUNCTION
40954 -- AcctLineType_94
40955 --
40956 ---------------------------------------
40957 PROCEDURE AcctLineType_94 (
40958 p_application_id IN NUMBER
40959 ,p_event_id IN NUMBER
40960 ,p_calculate_acctd_flag IN VARCHAR2
40961 ,p_calculate_g_l_flag IN VARCHAR2
40962 ,p_actual_flag IN OUT VARCHAR2
40963 ,p_balance_type_code OUT VARCHAR2
40964 ,p_gain_or_loss_ref OUT VARCHAR2
40965
40966 --Remittance Bank Account Confirmation Account
40967 , p_source_3 IN NUMBER
40968 --Distribution GL Account
40969 , p_source_10 IN NUMBER
40970 --Distribution Source Type
40971 , p_source_22 IN VARCHAR2
40972 --Distribution Line Identifier
40973 , p_source_24 IN NUMBER
40974 --Distribution Type
40978 --Currency Code
40975 , p_source_25 IN VARCHAR2
40976 --Entered Amount
40977 , p_source_26 IN NUMBER
40979 , p_source_27 IN VARCHAR2
40980 --Exchange Rate
40981 , p_source_29 IN NUMBER
40982 --Exchange Rate Type
40983 , p_source_30 IN VARCHAR2
40984 --Applied To Document Accounting Amount
40985 , p_source_31 IN NUMBER
40986 --Applied To Document Exchange Date
40987 , p_source_59 IN DATE
40988 --Distribution Multi Fund Additional Entry
40989 , p_source_71 IN VARCHAR2
40990 )
40991 IS
40992
40993 l_component_type VARCHAR2(80);
40994 l_component_code VARCHAR2(30);
40995 l_component_type_code VARCHAR2(1);
40996 l_component_appl_id INTEGER;
40997 l_amb_context_code VARCHAR2(30);
40998 l_entity_code VARCHAR2(30);
40999 l_event_class_code VARCHAR2(30);
41000 l_ae_header_id NUMBER;
41001 l_event_type_code VARCHAR2(30);
41002 l_line_definition_code VARCHAR2(30);
41003 l_line_definition_owner_code VARCHAR2(1);
41004 --
41005 -- adr variables
41006 l_segment VARCHAR2(30);
41007 l_ccid NUMBER;
41008 l_adr_transaction_coa_id NUMBER;
41009 l_adr_accounting_coa_id NUMBER;
41010 l_adr_flexfield_segment_code VARCHAR2(30);
41011 l_adr_flex_value_set_id NUMBER;
41012 l_adr_value_type_code VARCHAR2(30);
41013 l_adr_value_combination_id NUMBER;
41014 l_adr_value_segment_code VARCHAR2(30);
41015
41016 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
41017 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
41018 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
41019 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
41020
41021 -- 4262811 Variables ------------------------------------------------------------------------------------------
41022 l_entered_amt_idx NUMBER;
41023 l_accted_amt_idx NUMBER;
41024 l_acc_rev_flag VARCHAR2(1);
41025 l_accrual_line_num NUMBER;
41026 l_tmp_amt NUMBER;
41027 l_acc_rev_natural_side_code VARCHAR2(1);
41028
41029 l_num_entries NUMBER;
41030 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
41031 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
41032 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
41033 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
41034 l_recog_line_1 NUMBER;
41035 l_recog_line_2 NUMBER;
41036
41037 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
41038 l_bflow_applied_to_amt NUMBER; -- 5132302
41039 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
41040
41041 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
41042
41043 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
41044 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
41045
41046 ---------------------------------------------------------------------------------------------------------------
41047
41048
41049 --
41050 -- bulk performance
41051 --
41052 l_balance_type_code VARCHAR2(1);
41053 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
41054 l_log_module VARCHAR2(240);
41055
41056 --
41057 -- Upgrade strategy
41058 --
41059 l_actual_upg_option VARCHAR2(1);
41060 l_enc_upg_option VARCHAR2(1);
41061
41062 --
41063 BEGIN
41064 --
41065 IF g_log_enabled THEN
41066 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_94';
41067 END IF;
41068 --
41069 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
41070
41071 trace
41072 (p_msg => 'BEGIN of AcctLineType_94'
41073 ,p_level => C_LEVEL_PROCEDURE
41074 ,p_module => l_log_module);
41075
41076 END IF;
41077 --
41078 l_component_type := 'AMB_JLT';
41079 l_component_code := 'MFAR_MISC_RCT_CONFIRMATION';
41080 l_component_type_code := 'S';
41081 l_component_appl_id := 222;
41082 l_amb_context_code := 'DEFAULT';
41083 l_entity_code := 'RECEIPTS';
41084 l_event_class_code := 'MISC_RECEIPT';
41085 l_event_type_code := 'MISC_RECEIPT_ALL';
41086 l_line_definition_owner_code := 'S';
41087 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
41088 --
41089 l_balance_type_code := 'A';
41090 l_segment := NULL;
41091 l_ccid := NULL;
41092 l_adr_transaction_coa_id := NULL;
41093 l_adr_accounting_coa_id := NULL;
41094 l_adr_flexfield_segment_code := NULL;
41095 l_adr_flex_value_set_id := NULL;
41096 l_adr_value_type_code := NULL;
41097 l_adr_value_combination_id := NULL;
41098 l_adr_value_segment_code := NULL;
41099
41100 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
41101 l_bflow_class_code := ''; -- 4219869 Business Flow
41102 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
41103 l_budgetary_control_flag := 'N';
41104
41108 l_accted_amt_idx := NULL; -- 4262811
41105 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41106 l_bflow_applied_to_amt := NULL; -- 5132302
41107 l_entered_amt_idx := NULL; -- 4262811
41109 l_acc_rev_flag := NULL; -- 4262811
41110 l_accrual_line_num := NULL; -- 4262811
41111 l_tmp_amt := NULL; -- 4262811
41112 --
41113
41114 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
41115 l_balance_type_code <> 'B' THEN
41116 IF NVL(p_source_22,'
41117 ') = 'CONFIRMATION' AND
41118 NVL(p_source_71,'
41119 ') = 'Y'
41120 THEN
41121
41122 --
41123 XLA_AE_LINES_PKG.SetNewLine;
41124
41125 p_balance_type_code := l_balance_type_code;
41126 -- set the flag so later we will know whether the gain loss line needs to be created
41127
41128 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
41129 p_actual_flag :='A';
41130 END IF;
41131
41132 --
41133 -- bulk performance
41134 --
41135 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
41136 p_header_num => 0); -- 4262811
41137 --
41138 -- set accounting line options
41139 --
41140 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
41141 p_natural_side_code => 'C'
41142 , p_gain_or_loss_flag => 'N'
41143 , p_gl_transfer_mode_code => 'S'
41144 , p_acct_entry_type_code => 'A'
41145 , p_switch_side_flag => 'Y'
41146 , p_merge_duplicate_code => 'A'
41147 );
41148 --
41149 l_acc_rev_natural_side_code := 'D'; -- 4262811
41150 --
41151 --
41152 -- set accounting line type info
41153 --
41154 xla_ae_lines_pkg.SetAcctLineType
41155 (p_component_type => l_component_type
41156 ,p_event_type_code => l_event_type_code
41157 ,p_line_definition_owner_code => l_line_definition_owner_code
41158 ,p_line_definition_code => l_line_definition_code
41159 ,p_accounting_line_code => l_component_code
41160 ,p_accounting_line_type_code => l_component_type_code
41161 ,p_accounting_line_appl_id => l_component_appl_id
41162 ,p_amb_context_code => l_amb_context_code
41163 ,p_entity_code => l_entity_code
41164 ,p_event_class_code => l_event_class_code);
41165 --
41166 -- set accounting class
41167 --
41168 xla_ae_lines_pkg.SetAcctClass(
41169 p_accounting_class_code => 'CONFIRMATION'
41170 , p_ae_header_id => l_ae_header_id
41171 );
41172
41173 --
41174 -- set rounding class
41175 --
41176 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
41177 'RECEIVABLE';
41178
41179 --
41180 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
41181 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
41182 --
41183 -- bulk performance
41184 --
41185 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
41186
41187 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
41188 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
41189
41190 -- 4955764
41191 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
41192 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
41193
41194 -- 4458381 Public Sector Enh
41195
41196 --
41197 -- set accounting attributes for the line type
41198 --
41199 l_entered_amt_idx := 3;
41200 l_accted_amt_idx := 8;
41201 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41202 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
41203 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
41204 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
41205 l_rec_acct_attrs.array_char_value(2) := p_source_25;
41206 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
41207 l_rec_acct_attrs.array_num_value(3) := p_source_26;
41208 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
41209 l_rec_acct_attrs.array_char_value(4) := p_source_27;
41210 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
41211 l_rec_acct_attrs.array_date_value(5) := p_source_59;
41212 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
41213 l_rec_acct_attrs.array_num_value(6) := p_source_29;
41214 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
41215 l_rec_acct_attrs.array_char_value(7) := p_source_30;
41216 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
41217 l_rec_acct_attrs.array_num_value(8) := p_source_31;
41218
41219 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
41220 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
41221
41222 ---------------------------------------------------------------------------------------------------------------
41226
41223 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
41224 ---------------------------------------------------------------------------------------------------------------
41225 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
41227 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41228 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41229
41230 IF xla_accounting_cache_pkg.GetValueChar
41231 (p_source_code => 'LEDGER_CATEGORY_CODE'
41232 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
41233 AND l_bflow_method_code = 'PRIOR_ENTRY'
41234 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
41235 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
41236 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
41237 )
41238 THEN
41239 xla_ae_lines_pkg.BflowUpgEntry
41240 (p_business_method_code => l_bflow_method_code
41241 ,p_business_class_code => l_bflow_class_code
41242 ,p_balance_type => l_balance_type_code);
41243 ELSE
41244 NULL;
41245 -- No business flow processing for business flow method of NONE.
41246 END IF;
41247
41248 --
41249 -- call analytical criteria
41250 --
41251
41252 --
41253 -- call description
41254 --
41255
41256 xla_ae_lines_pkg.SetLineDescription(
41257 p_ae_header_id => l_ae_header_id
41258 ,p_description => Description_1 (
41259 p_application_id => p_application_id
41260 , p_ae_header_id => l_ae_header_id
41261 )
41262 );
41263
41264
41265 --
41266 -- call ADRs
41267 -- Bug 4922099
41268 --
41269 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41270 (NVL(l_actual_upg_option, 'N') = 'O') OR
41271 (NVL(l_enc_upg_option, 'N') = 'O')
41272 )
41273 THEN
41274 NULL;
41275 --
41276 --
41277
41278 l_ccid := AcctDerRule_11(
41279 p_application_id => p_application_id
41280 , p_ae_header_id => l_ae_header_id
41281 , p_source_10 => p_source_10
41282 , x_transaction_coa_id => l_adr_transaction_coa_id
41283 , x_accounting_coa_id => l_adr_accounting_coa_id
41284 , x_value_type_code => l_adr_value_type_code
41285 , p_side => 'NA'
41286 );
41287
41288 xla_ae_lines_pkg.set_ccid(
41289 p_code_combination_id => l_ccid
41290 , p_value_type_code => l_adr_value_type_code
41291 , p_transaction_coa_id => l_adr_transaction_coa_id
41292 , p_accounting_coa_id => l_adr_accounting_coa_id
41293 , p_adr_code => 'DIST_CCID'
41294 , p_adr_type_code => 'S'
41295 , p_component_type => l_component_type
41296 , p_component_code => l_component_code
41297 , p_component_type_code => l_component_type_code
41298 , p_component_appl_id => l_component_appl_id
41299 , p_amb_context_code => l_amb_context_code
41300 , p_side => 'NA'
41301 );
41302
41303
41304 l_segment := AcctDerRule_4(
41305 p_application_id => p_application_id
41306 , p_ae_header_id => l_ae_header_id
41307 , p_source_3 => p_source_3
41308 , x_transaction_coa_id => l_adr_transaction_coa_id
41309 , x_accounting_coa_id => l_adr_accounting_coa_id
41310 , x_flexfield_segment_code => l_adr_flexfield_segment_code
41311 , x_flex_value_set_id => l_adr_flex_value_set_id
41312 , x_value_type_code => l_adr_value_type_code
41313 , x_value_combination_id => l_adr_value_combination_id
41314 , x_value_segment_code => l_adr_value_segment_code
41315 , p_side => 'NA'
41316 , p_override_seg_flag => 'Y'
41317 );
41318
41319 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
41320
41321 xla_ae_lines_pkg.set_segment(
41322 p_to_segment_code => 'GL_ACCOUNT'
41323 , p_segment_value => l_segment
41324 , p_from_segment_code => l_adr_value_segment_code
41325 , p_from_combination_id => l_adr_value_combination_id
41326 , p_value_type_code => l_adr_value_type_code
41327 , p_transaction_coa_id => l_adr_transaction_coa_id
41328 , p_accounting_coa_id => l_adr_accounting_coa_id
41329 , p_flexfield_segment_code => l_adr_flexfield_segment_code
41330 , p_flex_value_set_id => l_adr_flex_value_set_id
41331 , p_adr_code => 'MFAR_RCT_CONFIRMATION_NATSEG'
41332 , p_adr_type_code => 'S'
41333 , p_component_type => l_component_type
41334 , p_component_code => l_component_code
41335 , p_component_type_code => l_component_type_code
41336 , p_component_appl_id => l_component_appl_id
41337 , p_amb_context_code => l_amb_context_code
41338 , p_entity_code => 'RECEIPTS'
41339 , p_event_class_code => 'MISC_RECEIPT'
41340 , p_side => 'NA'
41344
41341 );
41342
41343 END IF;
41345 --
41346 --
41347 END IF;
41348 --
41349 -- Bug 4922099
41350 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
41351 (NVL(l_enc_upg_option, 'N') = 'O')
41352 ) AND
41353 (l_bflow_method_code = 'PRIOR_ENTRY')
41354 )
41355 THEN
41356 IF
41357 --
41358 1 = 2
41359 --
41360 THEN
41361 xla_accounting_err_pkg.build_message
41362 (p_appli_s_name => 'XLA'
41363 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
41364 ,p_token_1 => 'LINE_NUMBER'
41365 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
41366 ,p_token_2 => 'LINE_TYPE_NAME'
41367 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
41368 l_component_type
41369 ,l_component_code
41370 ,l_component_type_code
41371 ,l_component_appl_id
41372 ,l_amb_context_code
41373 ,l_entity_code
41374 ,l_event_class_code
41375 )
41376 ,p_token_3 => 'OWNER'
41377 ,p_value_3 => xla_lookups_pkg.get_meaning(
41378 p_lookup_type => 'XLA_OWNER_TYPE'
41379 ,p_lookup_code => l_component_type_code
41380 )
41381 ,p_token_4 => 'PRODUCT_NAME'
41382 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
41383 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
41384 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
41385 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
41386 ,p_ae_header_id => NULL
41387 );
41388
41389 IF (C_LEVEL_ERROR>= g_log_level) THEN
41390 trace
41391 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
41392 ,p_level => C_LEVEL_ERROR
41393 ,p_module => l_log_module);
41394 END IF;
41395 END IF;
41396 END IF;
41397 --
41398 --
41399 ------------------------------------------------------------------------------------------------
41400 -- 4219869 Business Flow
41401 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
41402 -- Prior Entry. Currently, the following code is always generated.
41403 ------------------------------------------------------------------------------------------------
41404 XLA_AE_LINES_PKG.ValidateCurrentLine;
41405
41406 ------------------------------------------------------------------------------------
41407 -- 4219869 Business Flow
41408 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
41409 ------------------------------------------------------------------------------------
41410 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
41411
41412 ----------------------------------------------------------------------------------
41413 -- 4219869 Business Flow
41414 -- Update journal entry status -- Need to generate this within IF <condition>
41415 ----------------------------------------------------------------------------------
41416 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
41417 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
41418 ,p_balance_type_code => l_balance_type_code
41419 );
41420
41421 -------------------------------------------------------------------------------------------
41422 -- 4262811 - Generate the Accrual Reversal lines
41423 -------------------------------------------------------------------------------------------
41424 BEGIN
41425 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
41426 (g_array_event(p_event_id).array_value_num('header_index'));
41427 IF l_acc_rev_flag IS NULL THEN
41428 l_acc_rev_flag := 'N';
41429 END IF;
41430 EXCEPTION
41431 WHEN OTHERS THEN
41432 l_acc_rev_flag := 'N';
41433 END;
41434 --
41435 IF (l_acc_rev_flag = 'Y') THEN
41436
41437 -- 4645092 ------------------------------------------------------------------------------
41438 -- To allow MPA report to determine if it should generate report process
41439 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
41443 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
41440 ------------------------------------------------------------------------------------------
41441
41442 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
41444 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
41445 -- call ADRs
41446 -- Bug 4922099
41447 --
41448 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41449 (NVL(l_actual_upg_option, 'N') = 'O') OR
41450 (NVL(l_enc_upg_option, 'N') = 'O')
41451 )
41452 THEN
41453 NULL;
41454 --
41455 --
41456
41457 l_ccid := AcctDerRule_11(
41458 p_application_id => p_application_id
41459 , p_ae_header_id => l_ae_header_id
41460 , p_source_10 => p_source_10
41461 , x_transaction_coa_id => l_adr_transaction_coa_id
41462 , x_accounting_coa_id => l_adr_accounting_coa_id
41463 , x_value_type_code => l_adr_value_type_code
41464 , p_side => 'NA'
41465 );
41466
41467 xla_ae_lines_pkg.set_ccid(
41468 p_code_combination_id => l_ccid
41469 , p_value_type_code => l_adr_value_type_code
41470 , p_transaction_coa_id => l_adr_transaction_coa_id
41471 , p_accounting_coa_id => l_adr_accounting_coa_id
41472 , p_adr_code => 'DIST_CCID'
41473 , p_adr_type_code => 'S'
41474 , p_component_type => l_component_type
41475 , p_component_code => l_component_code
41476 , p_component_type_code => l_component_type_code
41477 , p_component_appl_id => l_component_appl_id
41478 , p_amb_context_code => l_amb_context_code
41479 , p_side => 'NA'
41480 );
41481
41482
41483 l_segment := AcctDerRule_4(
41484 p_application_id => p_application_id
41485 , p_ae_header_id => l_ae_header_id
41486 , p_source_3 => p_source_3
41487 , x_transaction_coa_id => l_adr_transaction_coa_id
41488 , x_accounting_coa_id => l_adr_accounting_coa_id
41489 , x_flexfield_segment_code => l_adr_flexfield_segment_code
41490 , x_flex_value_set_id => l_adr_flex_value_set_id
41491 , x_value_type_code => l_adr_value_type_code
41492 , x_value_combination_id => l_adr_value_combination_id
41493 , x_value_segment_code => l_adr_value_segment_code
41494 , p_side => 'NA'
41495 , p_override_seg_flag => 'Y'
41496 );
41497
41498 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
41499
41500 xla_ae_lines_pkg.set_segment(
41501 p_to_segment_code => 'GL_ACCOUNT'
41502 , p_segment_value => l_segment
41503 , p_from_segment_code => l_adr_value_segment_code
41504 , p_from_combination_id => l_adr_value_combination_id
41505 , p_value_type_code => l_adr_value_type_code
41506 , p_transaction_coa_id => l_adr_transaction_coa_id
41507 , p_accounting_coa_id => l_adr_accounting_coa_id
41508 , p_flexfield_segment_code => l_adr_flexfield_segment_code
41509 , p_flex_value_set_id => l_adr_flex_value_set_id
41510 , p_adr_code => 'MFAR_RCT_CONFIRMATION_NATSEG'
41511 , p_adr_type_code => 'S'
41512 , p_component_type => l_component_type
41513 , p_component_code => l_component_code
41514 , p_component_type_code => l_component_type_code
41515 , p_component_appl_id => l_component_appl_id
41516 , p_amb_context_code => l_amb_context_code
41517 , p_entity_code => 'RECEIPTS'
41518 , p_event_class_code => 'MISC_RECEIPT'
41519 , p_side => 'NA'
41520 );
41521
41522 END IF;
41523
41524 --
41525 --
41526 END IF;
41527
41528 --
41529 -- Update the line information that should be overwritten
41530 --
41531 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
41532 p_header_num => 1);
41533 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
41534
41535 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
41536
41537 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
41538 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
41539 END IF;
41540
41541 --
41542 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
41543 --
41544 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
41545 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
41546 ELSE
41547 ---------------------------------------------------------------------------------------------------
41548 -- 4262811a Switch Sign
41549 ---------------------------------------------------------------------------------------------------
41553 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
41550 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
41551 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
41552 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41554 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41555 -- 5132302
41556 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
41557 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41558
41559 END IF;
41560
41561 -- 4955764
41562 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
41563 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
41564
41565
41566 XLA_AE_LINES_PKG.ValidateCurrentLine;
41567 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
41568
41569 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
41570 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
41571 ,p_balance_type_code => l_balance_type_code);
41572
41573 END IF;
41574
41575 -----------------------------------------------------------------------------------------
41576 -- 4262811 Multiperiod Accounting
41577 -----------------------------------------------------------------------------------------
41578 -- No MPA option is assigned.
41579
41580
41581 END IF;
41582 END IF;
41583 --
41584
41585 --
41586 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
41587 trace
41588 (p_msg => 'END of AcctLineType_94'
41589 ,p_level => C_LEVEL_PROCEDURE
41590 ,p_module => l_log_module);
41591 END IF;
41592 --
41593 EXCEPTION
41594 WHEN xla_exceptions_pkg.application_exception THEN
41595 RAISE;
41596 WHEN OTHERS THEN
41597 xla_exceptions_pkg.raise_message
41598 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_94');
41599 END AcctLineType_94;
41600 --
41601
41602 ---------------------------------------
41603 --
41604 -- PRIVATE FUNCTION
41605 -- AcctLineType_95
41606 --
41607 ---------------------------------------
41608 PROCEDURE AcctLineType_95 (
41609 p_application_id IN NUMBER
41610 ,p_event_id IN NUMBER
41611 ,p_calculate_acctd_flag IN VARCHAR2
41612 ,p_calculate_g_l_flag IN VARCHAR2
41613 ,p_actual_flag IN OUT VARCHAR2
41614 ,p_balance_type_code OUT VARCHAR2
41615 ,p_gain_or_loss_ref OUT VARCHAR2
41616
41617 --Remittance Bank Account Remittance Account
41618 , p_source_6 IN NUMBER
41619 --Distribution GL Account
41620 , p_source_10 IN NUMBER
41621 --Distribution Source Type
41622 , p_source_22 IN VARCHAR2
41623 --Distribution Line Identifier
41624 , p_source_24 IN NUMBER
41625 --Distribution Type
41626 , p_source_25 IN VARCHAR2
41627 --Entered Amount
41628 , p_source_26 IN NUMBER
41629 --Currency Code
41630 , p_source_27 IN VARCHAR2
41631 --Exchange Rate
41632 , p_source_29 IN NUMBER
41633 --Exchange Rate Type
41634 , p_source_30 IN VARCHAR2
41635 --Applied To Document Accounting Amount
41636 , p_source_31 IN NUMBER
41637 --Applied To Document Exchange Date
41638 , p_source_59 IN DATE
41639 --Distribution Multi Fund Additional Entry
41640 , p_source_71 IN VARCHAR2
41641 )
41642 IS
41643
41644 l_component_type VARCHAR2(80);
41645 l_component_code VARCHAR2(30);
41646 l_component_type_code VARCHAR2(1);
41647 l_component_appl_id INTEGER;
41648 l_amb_context_code VARCHAR2(30);
41649 l_entity_code VARCHAR2(30);
41650 l_event_class_code VARCHAR2(30);
41651 l_ae_header_id NUMBER;
41652 l_event_type_code VARCHAR2(30);
41653 l_line_definition_code VARCHAR2(30);
41654 l_line_definition_owner_code VARCHAR2(1);
41655 --
41656 -- adr variables
41657 l_segment VARCHAR2(30);
41658 l_ccid NUMBER;
41659 l_adr_transaction_coa_id NUMBER;
41660 l_adr_accounting_coa_id NUMBER;
41661 l_adr_flexfield_segment_code VARCHAR2(30);
41662 l_adr_flex_value_set_id NUMBER;
41663 l_adr_value_type_code VARCHAR2(30);
41664 l_adr_value_combination_id NUMBER;
41665 l_adr_value_segment_code VARCHAR2(30);
41666
41667 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
41668 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
41669 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
41670 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
41671
41672 -- 4262811 Variables ------------------------------------------------------------------------------------------
41673 l_entered_amt_idx NUMBER;
41674 l_accted_amt_idx NUMBER;
41675 l_acc_rev_flag VARCHAR2(1);
41676 l_accrual_line_num NUMBER;
41677 l_tmp_amt NUMBER;
41678 l_acc_rev_natural_side_code VARCHAR2(1);
41679
41683 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
41680 l_num_entries NUMBER;
41681 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
41682 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
41684 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
41685 l_recog_line_1 NUMBER;
41686 l_recog_line_2 NUMBER;
41687
41688 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
41689 l_bflow_applied_to_amt NUMBER; -- 5132302
41690 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
41691
41692 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
41693
41694 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
41695 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
41696
41697 ---------------------------------------------------------------------------------------------------------------
41698
41699
41700 --
41701 -- bulk performance
41702 --
41703 l_balance_type_code VARCHAR2(1);
41704 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
41705 l_log_module VARCHAR2(240);
41706
41707 --
41708 -- Upgrade strategy
41709 --
41710 l_actual_upg_option VARCHAR2(1);
41711 l_enc_upg_option VARCHAR2(1);
41712
41713 --
41714 BEGIN
41715 --
41716 IF g_log_enabled THEN
41717 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_95';
41718 END IF;
41719 --
41720 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
41721
41722 trace
41723 (p_msg => 'BEGIN of AcctLineType_95'
41724 ,p_level => C_LEVEL_PROCEDURE
41725 ,p_module => l_log_module);
41726
41727 END IF;
41728 --
41729 l_component_type := 'AMB_JLT';
41730 l_component_code := 'MFAR_MISC_RCT_REMITTANCE';
41731 l_component_type_code := 'S';
41732 l_component_appl_id := 222;
41733 l_amb_context_code := 'DEFAULT';
41734 l_entity_code := 'RECEIPTS';
41735 l_event_class_code := 'MISC_RECEIPT';
41736 l_event_type_code := 'MISC_RECEIPT_ALL';
41737 l_line_definition_owner_code := 'S';
41738 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
41739 --
41740 l_balance_type_code := 'A';
41741 l_segment := NULL;
41742 l_ccid := NULL;
41743 l_adr_transaction_coa_id := NULL;
41744 l_adr_accounting_coa_id := NULL;
41745 l_adr_flexfield_segment_code := NULL;
41746 l_adr_flex_value_set_id := NULL;
41747 l_adr_value_type_code := NULL;
41748 l_adr_value_combination_id := NULL;
41749 l_adr_value_segment_code := NULL;
41750
41751 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
41752 l_bflow_class_code := ''; -- 4219869 Business Flow
41753 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
41754 l_budgetary_control_flag := 'N';
41755
41756 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41757 l_bflow_applied_to_amt := NULL; -- 5132302
41758 l_entered_amt_idx := NULL; -- 4262811
41759 l_accted_amt_idx := NULL; -- 4262811
41760 l_acc_rev_flag := NULL; -- 4262811
41761 l_accrual_line_num := NULL; -- 4262811
41762 l_tmp_amt := NULL; -- 4262811
41763 --
41764
41765 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
41766 l_balance_type_code <> 'B' THEN
41767 IF NVL(p_source_22,'
41768 ') = 'REMITTANCE' AND
41769 NVL(p_source_71,'
41770 ') = 'Y'
41771 THEN
41772
41773 --
41774 XLA_AE_LINES_PKG.SetNewLine;
41775
41776 p_balance_type_code := l_balance_type_code;
41777 -- set the flag so later we will know whether the gain loss line needs to be created
41778
41779 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
41780 p_actual_flag :='A';
41781 END IF;
41782
41783 --
41784 -- bulk performance
41785 --
41786 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
41787 p_header_num => 0); -- 4262811
41788 --
41789 -- set accounting line options
41790 --
41791 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
41792 p_natural_side_code => 'C'
41793 , p_gain_or_loss_flag => 'N'
41794 , p_gl_transfer_mode_code => 'S'
41795 , p_acct_entry_type_code => 'A'
41796 , p_switch_side_flag => 'Y'
41797 , p_merge_duplicate_code => 'A'
41798 );
41799 --
41800 l_acc_rev_natural_side_code := 'D'; -- 4262811
41801 --
41802 --
41803 -- set accounting line type info
41804 --
41805 xla_ae_lines_pkg.SetAcctLineType
41806 (p_component_type => l_component_type
41807 ,p_event_type_code => l_event_type_code
41808 ,p_line_definition_owner_code => l_line_definition_owner_code
41809 ,p_line_definition_code => l_line_definition_code
41810 ,p_accounting_line_code => l_component_code
41814 ,p_entity_code => l_entity_code
41811 ,p_accounting_line_type_code => l_component_type_code
41812 ,p_accounting_line_appl_id => l_component_appl_id
41813 ,p_amb_context_code => l_amb_context_code
41815 ,p_event_class_code => l_event_class_code);
41816 --
41817 -- set accounting class
41818 --
41819 xla_ae_lines_pkg.SetAcctClass(
41820 p_accounting_class_code => 'REMITTANCE'
41821 , p_ae_header_id => l_ae_header_id
41822 );
41823
41824 --
41825 -- set rounding class
41826 --
41827 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
41828 'RECEIVABLE';
41829
41830 --
41831 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
41832 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
41833 --
41834 -- bulk performance
41835 --
41836 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
41837
41838 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
41839 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
41840
41841 -- 4955764
41842 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
41843 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
41844
41845 -- 4458381 Public Sector Enh
41846
41847 --
41848 -- set accounting attributes for the line type
41849 --
41850 l_entered_amt_idx := 3;
41851 l_accted_amt_idx := 8;
41852 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41853 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
41854 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
41855 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
41856 l_rec_acct_attrs.array_char_value(2) := p_source_25;
41857 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
41858 l_rec_acct_attrs.array_num_value(3) := p_source_26;
41859 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
41860 l_rec_acct_attrs.array_char_value(4) := p_source_27;
41861 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
41862 l_rec_acct_attrs.array_date_value(5) := p_source_59;
41863 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
41864 l_rec_acct_attrs.array_num_value(6) := p_source_29;
41865 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
41866 l_rec_acct_attrs.array_char_value(7) := p_source_30;
41867 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
41868 l_rec_acct_attrs.array_num_value(8) := p_source_31;
41869
41870 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
41871 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
41872
41873 ---------------------------------------------------------------------------------------------------------------
41874 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
41875 ---------------------------------------------------------------------------------------------------------------
41876 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
41877
41878 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41879 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41880
41881 IF xla_accounting_cache_pkg.GetValueChar
41882 (p_source_code => 'LEDGER_CATEGORY_CODE'
41883 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
41884 AND l_bflow_method_code = 'PRIOR_ENTRY'
41885 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
41886 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
41887 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
41888 )
41889 THEN
41890 xla_ae_lines_pkg.BflowUpgEntry
41891 (p_business_method_code => l_bflow_method_code
41892 ,p_business_class_code => l_bflow_class_code
41893 ,p_balance_type => l_balance_type_code);
41894 ELSE
41895 NULL;
41896 -- No business flow processing for business flow method of NONE.
41897 END IF;
41898
41899 --
41900 -- call analytical criteria
41901 --
41902
41903 --
41904 -- call description
41905 --
41906
41907 xla_ae_lines_pkg.SetLineDescription(
41908 p_ae_header_id => l_ae_header_id
41909 ,p_description => Description_1 (
41910 p_application_id => p_application_id
41911 , p_ae_header_id => l_ae_header_id
41912 )
41913 );
41914
41915
41916 --
41917 -- call ADRs
41918 -- Bug 4922099
41919 --
41920 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41921 (NVL(l_actual_upg_option, 'N') = 'O') OR
41922 (NVL(l_enc_upg_option, 'N') = 'O')
41923 )
41924 THEN
41925 NULL;
41926 --
41927 --
41928
41929 l_ccid := AcctDerRule_11(
41930 p_application_id => p_application_id
41934 , x_accounting_coa_id => l_adr_accounting_coa_id
41931 , p_ae_header_id => l_ae_header_id
41932 , p_source_10 => p_source_10
41933 , x_transaction_coa_id => l_adr_transaction_coa_id
41935 , x_value_type_code => l_adr_value_type_code
41936 , p_side => 'NA'
41937 );
41938
41939 xla_ae_lines_pkg.set_ccid(
41940 p_code_combination_id => l_ccid
41941 , p_value_type_code => l_adr_value_type_code
41942 , p_transaction_coa_id => l_adr_transaction_coa_id
41943 , p_accounting_coa_id => l_adr_accounting_coa_id
41944 , p_adr_code => 'DIST_CCID'
41945 , p_adr_type_code => 'S'
41946 , p_component_type => l_component_type
41947 , p_component_code => l_component_code
41948 , p_component_type_code => l_component_type_code
41949 , p_component_appl_id => l_component_appl_id
41950 , p_amb_context_code => l_amb_context_code
41951 , p_side => 'NA'
41952 );
41953
41954
41955 l_segment := AcctDerRule_7(
41956 p_application_id => p_application_id
41957 , p_ae_header_id => l_ae_header_id
41958 , p_source_6 => p_source_6
41959 , x_transaction_coa_id => l_adr_transaction_coa_id
41960 , x_accounting_coa_id => l_adr_accounting_coa_id
41961 , x_flexfield_segment_code => l_adr_flexfield_segment_code
41962 , x_flex_value_set_id => l_adr_flex_value_set_id
41963 , x_value_type_code => l_adr_value_type_code
41964 , x_value_combination_id => l_adr_value_combination_id
41965 , x_value_segment_code => l_adr_value_segment_code
41966 , p_side => 'NA'
41967 , p_override_seg_flag => 'Y'
41968 );
41969
41970 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
41971
41972 xla_ae_lines_pkg.set_segment(
41973 p_to_segment_code => 'GL_ACCOUNT'
41974 , p_segment_value => l_segment
41975 , p_from_segment_code => l_adr_value_segment_code
41976 , p_from_combination_id => l_adr_value_combination_id
41977 , p_value_type_code => l_adr_value_type_code
41978 , p_transaction_coa_id => l_adr_transaction_coa_id
41979 , p_accounting_coa_id => l_adr_accounting_coa_id
41980 , p_flexfield_segment_code => l_adr_flexfield_segment_code
41981 , p_flex_value_set_id => l_adr_flex_value_set_id
41982 , p_adr_code => 'MFAR_RCT_REMITTANCE_NATSEG'
41983 , p_adr_type_code => 'S'
41984 , p_component_type => l_component_type
41985 , p_component_code => l_component_code
41986 , p_component_type_code => l_component_type_code
41987 , p_component_appl_id => l_component_appl_id
41988 , p_amb_context_code => l_amb_context_code
41989 , p_entity_code => 'RECEIPTS'
41990 , p_event_class_code => 'MISC_RECEIPT'
41991 , p_side => 'NA'
41992 );
41993
41994 END IF;
41995
41996 --
41997 --
41998 END IF;
41999 --
42000 -- Bug 4922099
42001 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
42002 (NVL(l_enc_upg_option, 'N') = 'O')
42003 ) AND
42004 (l_bflow_method_code = 'PRIOR_ENTRY')
42005 )
42006 THEN
42007 IF
42008 --
42009 1 = 2
42010 --
42011 THEN
42012 xla_accounting_err_pkg.build_message
42013 (p_appli_s_name => 'XLA'
42014 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42015 ,p_token_1 => 'LINE_NUMBER'
42016 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
42017 ,p_token_2 => 'LINE_TYPE_NAME'
42018 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
42019 l_component_type
42020 ,l_component_code
42021 ,l_component_type_code
42022 ,l_component_appl_id
42023 ,l_amb_context_code
42024 ,l_entity_code
42025 ,l_event_class_code
42026 )
42027 ,p_token_3 => 'OWNER'
42028 ,p_value_3 => xla_lookups_pkg.get_meaning(
42029 p_lookup_type => 'XLA_OWNER_TYPE'
42030 ,p_lookup_code => l_component_type_code
42031 )
42032 ,p_token_4 => 'PRODUCT_NAME'
42036 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
42033 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
42034 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
42035 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
42037 ,p_ae_header_id => NULL
42038 );
42039
42040 IF (C_LEVEL_ERROR>= g_log_level) THEN
42041 trace
42042 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42043 ,p_level => C_LEVEL_ERROR
42044 ,p_module => l_log_module);
42045 END IF;
42046 END IF;
42047 END IF;
42048 --
42049 --
42050 ------------------------------------------------------------------------------------------------
42051 -- 4219869 Business Flow
42052 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
42053 -- Prior Entry. Currently, the following code is always generated.
42054 ------------------------------------------------------------------------------------------------
42055 XLA_AE_LINES_PKG.ValidateCurrentLine;
42056
42057 ------------------------------------------------------------------------------------
42058 -- 4219869 Business Flow
42059 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
42060 ------------------------------------------------------------------------------------
42061 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
42062
42063 ----------------------------------------------------------------------------------
42064 -- 4219869 Business Flow
42065 -- Update journal entry status -- Need to generate this within IF <condition>
42066 ----------------------------------------------------------------------------------
42067 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
42068 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
42069 ,p_balance_type_code => l_balance_type_code
42070 );
42071
42072 -------------------------------------------------------------------------------------------
42073 -- 4262811 - Generate the Accrual Reversal lines
42074 -------------------------------------------------------------------------------------------
42075 BEGIN
42076 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
42077 (g_array_event(p_event_id).array_value_num('header_index'));
42078 IF l_acc_rev_flag IS NULL THEN
42079 l_acc_rev_flag := 'N';
42080 END IF;
42081 EXCEPTION
42082 WHEN OTHERS THEN
42083 l_acc_rev_flag := 'N';
42084 END;
42085 --
42086 IF (l_acc_rev_flag = 'Y') THEN
42087
42088 -- 4645092 ------------------------------------------------------------------------------
42089 -- To allow MPA report to determine if it should generate report process
42090 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
42091 ------------------------------------------------------------------------------------------
42092
42093 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
42094 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
42095 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
42096 -- call ADRs
42097 -- Bug 4922099
42098 --
42099 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
42100 (NVL(l_actual_upg_option, 'N') = 'O') OR
42101 (NVL(l_enc_upg_option, 'N') = 'O')
42102 )
42103 THEN
42104 NULL;
42105 --
42106 --
42107
42108 l_ccid := AcctDerRule_11(
42109 p_application_id => p_application_id
42110 , p_ae_header_id => l_ae_header_id
42111 , p_source_10 => p_source_10
42112 , x_transaction_coa_id => l_adr_transaction_coa_id
42113 , x_accounting_coa_id => l_adr_accounting_coa_id
42114 , x_value_type_code => l_adr_value_type_code
42115 , p_side => 'NA'
42116 );
42117
42118 xla_ae_lines_pkg.set_ccid(
42119 p_code_combination_id => l_ccid
42120 , p_value_type_code => l_adr_value_type_code
42121 , p_transaction_coa_id => l_adr_transaction_coa_id
42122 , p_accounting_coa_id => l_adr_accounting_coa_id
42123 , p_adr_code => 'DIST_CCID'
42124 , p_adr_type_code => 'S'
42125 , p_component_type => l_component_type
42126 , p_component_code => l_component_code
42127 , p_component_type_code => l_component_type_code
42128 , p_component_appl_id => l_component_appl_id
42129 , p_amb_context_code => l_amb_context_code
42130 , p_side => 'NA'
42131 );
42132
42133
42134 l_segment := AcctDerRule_7(
42135 p_application_id => p_application_id
42136 , p_ae_header_id => l_ae_header_id
42137 , p_source_6 => p_source_6
42138 , x_transaction_coa_id => l_adr_transaction_coa_id
42139 , x_accounting_coa_id => l_adr_accounting_coa_id
42143 , x_value_combination_id => l_adr_value_combination_id
42140 , x_flexfield_segment_code => l_adr_flexfield_segment_code
42141 , x_flex_value_set_id => l_adr_flex_value_set_id
42142 , x_value_type_code => l_adr_value_type_code
42144 , x_value_segment_code => l_adr_value_segment_code
42145 , p_side => 'NA'
42146 , p_override_seg_flag => 'Y'
42147 );
42148
42149 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
42150
42151 xla_ae_lines_pkg.set_segment(
42152 p_to_segment_code => 'GL_ACCOUNT'
42153 , p_segment_value => l_segment
42154 , p_from_segment_code => l_adr_value_segment_code
42155 , p_from_combination_id => l_adr_value_combination_id
42156 , p_value_type_code => l_adr_value_type_code
42157 , p_transaction_coa_id => l_adr_transaction_coa_id
42158 , p_accounting_coa_id => l_adr_accounting_coa_id
42159 , p_flexfield_segment_code => l_adr_flexfield_segment_code
42160 , p_flex_value_set_id => l_adr_flex_value_set_id
42161 , p_adr_code => 'MFAR_RCT_REMITTANCE_NATSEG'
42162 , p_adr_type_code => 'S'
42163 , p_component_type => l_component_type
42164 , p_component_code => l_component_code
42165 , p_component_type_code => l_component_type_code
42166 , p_component_appl_id => l_component_appl_id
42167 , p_amb_context_code => l_amb_context_code
42168 , p_entity_code => 'RECEIPTS'
42169 , p_event_class_code => 'MISC_RECEIPT'
42170 , p_side => 'NA'
42171 );
42172
42173 END IF;
42174
42175 --
42176 --
42177 END IF;
42178
42179 --
42180 -- Update the line information that should be overwritten
42181 --
42182 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
42183 p_header_num => 1);
42184 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
42185
42186 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
42187
42188 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
42189 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
42190 END IF;
42191
42192 --
42193 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
42194 --
42195 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
42196 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
42197 ELSE
42198 ---------------------------------------------------------------------------------------------------
42199 -- 4262811a Switch Sign
42200 ---------------------------------------------------------------------------------------------------
42201 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
42202 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42203 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42204 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42205 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42206 -- 5132302
42207 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
42208 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42209
42210 END IF;
42211
42212 -- 4955764
42213 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
42214 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
42215
42216
42217 XLA_AE_LINES_PKG.ValidateCurrentLine;
42218 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
42219
42220 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
42221 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
42222 ,p_balance_type_code => l_balance_type_code);
42223
42224 END IF;
42225
42226 -----------------------------------------------------------------------------------------
42227 -- 4262811 Multiperiod Accounting
42228 -----------------------------------------------------------------------------------------
42229 -- No MPA option is assigned.
42230
42231
42232 END IF;
42233 END IF;
42234 --
42235
42236 --
42237 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
42238 trace
42239 (p_msg => 'END of AcctLineType_95'
42240 ,p_level => C_LEVEL_PROCEDURE
42241 ,p_module => l_log_module);
42242 END IF;
42243 --
42244 EXCEPTION
42245 WHEN xla_exceptions_pkg.application_exception THEN
42246 RAISE;
42247 WHEN OTHERS THEN
42248 xla_exceptions_pkg.raise_message
42249 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_95');
42250 END AcctLineType_95;
42251 --
42252
42253 ---------------------------------------
42254 --
42255 -- PRIVATE FUNCTION
42259 PROCEDURE AcctLineType_96 (
42256 -- AcctLineType_96
42257 --
42258 ---------------------------------------
42260 p_application_id IN NUMBER
42261 ,p_event_id IN NUMBER
42262 ,p_calculate_acctd_flag IN VARCHAR2
42263 ,p_calculate_g_l_flag IN VARCHAR2
42264 ,p_actual_flag IN OUT VARCHAR2
42265 ,p_balance_type_code OUT VARCHAR2
42266 ,p_gain_or_loss_ref OUT VARCHAR2
42267
42268 --Remittance Bank Account Bank Charges Acount
42269 , p_source_1 IN NUMBER
42270 --Remittance Bank Account Cash Account
42271 , p_source_5 IN NUMBER
42272 --Distribution Source Type
42273 , p_source_22 IN VARCHAR2
42274 --Distribution Line Identifier
42275 , p_source_24 IN NUMBER
42276 --Distribution Type
42277 , p_source_25 IN VARCHAR2
42278 --Exchange Date
42279 , p_source_28 IN DATE
42280 --Exchange Rate
42281 , p_source_29 IN NUMBER
42282 --Exchange Rate Type
42283 , p_source_30 IN VARCHAR2
42284 --Transaction Distribution Identifier
42285 , p_source_36 IN NUMBER
42286 --Transaction Distribution Type
42287 , p_source_37 IN VARCHAR2
42288 --Receipt Applied To Application Identifier
42289 , p_source_60 IN NUMBER
42290 --Transaction Entity Code
42291 , p_source_61 IN VARCHAR2
42292 --Transaction Identifier
42293 , p_source_62 IN NUMBER
42294 --Applying Document Currency Code
42295 , p_source_63 IN VARCHAR2
42296 --Distribution Party Identifier
42297 , p_source_65 IN NUMBER
42298 --Distribution Party Site Id
42299 , p_source_66 IN NUMBER
42300 --Distribution Party Type
42301 , p_source_67 IN VARCHAR2
42302 --Distribution Multi Fund Additional Entry
42303 , p_source_71 IN VARCHAR2
42304 --DIST_ENT_AMT_FROM
42305 , p_source_74 IN NUMBER
42306 --Accounting Amount
42307 , p_source_75 IN NUMBER
42308 )
42309 IS
42310
42311 l_component_type VARCHAR2(80);
42312 l_component_code VARCHAR2(30);
42313 l_component_type_code VARCHAR2(1);
42314 l_component_appl_id INTEGER;
42315 l_amb_context_code VARCHAR2(30);
42316 l_entity_code VARCHAR2(30);
42317 l_event_class_code VARCHAR2(30);
42318 l_ae_header_id NUMBER;
42319 l_event_type_code VARCHAR2(30);
42320 l_line_definition_code VARCHAR2(30);
42321 l_line_definition_owner_code VARCHAR2(1);
42322 --
42323 -- adr variables
42324 l_segment VARCHAR2(30);
42325 l_ccid NUMBER;
42326 l_adr_transaction_coa_id NUMBER;
42327 l_adr_accounting_coa_id NUMBER;
42328 l_adr_flexfield_segment_code VARCHAR2(30);
42329 l_adr_flex_value_set_id NUMBER;
42330 l_adr_value_type_code VARCHAR2(30);
42331 l_adr_value_combination_id NUMBER;
42332 l_adr_value_segment_code VARCHAR2(30);
42333
42334 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
42335 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
42336 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
42337 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
42338
42339 -- 4262811 Variables ------------------------------------------------------------------------------------------
42340 l_entered_amt_idx NUMBER;
42341 l_accted_amt_idx NUMBER;
42342 l_acc_rev_flag VARCHAR2(1);
42343 l_accrual_line_num NUMBER;
42344 l_tmp_amt NUMBER;
42345 l_acc_rev_natural_side_code VARCHAR2(1);
42346
42347 l_num_entries NUMBER;
42348 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
42349 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
42350 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
42351 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
42352 l_recog_line_1 NUMBER;
42353 l_recog_line_2 NUMBER;
42354
42355 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
42356 l_bflow_applied_to_amt NUMBER; -- 5132302
42357 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
42358
42359 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
42360
42361 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
42362 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
42363
42364 ---------------------------------------------------------------------------------------------------------------
42365
42366
42367 --
42368 -- bulk performance
42369 --
42370 l_balance_type_code VARCHAR2(1);
42371 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
42372 l_log_module VARCHAR2(240);
42373
42374 --
42375 -- Upgrade strategy
42376 --
42377 l_actual_upg_option VARCHAR2(1);
42378 l_enc_upg_option VARCHAR2(1);
42379
42380 --
42381 BEGIN
42382 --
42383 IF g_log_enabled THEN
42384 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_96';
42385 END IF;
42386 --
42387 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
42391 ,p_level => C_LEVEL_PROCEDURE
42388
42389 trace
42390 (p_msg => 'BEGIN of AcctLineType_96'
42392 ,p_module => l_log_module);
42393
42394 END IF;
42395 --
42396 l_component_type := 'AMB_JLT';
42397 l_component_code := 'MFAR_RCT_BNK_CHG_CASH';
42398 l_component_type_code := 'S';
42399 l_component_appl_id := 222;
42400 l_amb_context_code := 'DEFAULT';
42401 l_entity_code := 'RECEIPTS';
42402 l_event_class_code := 'RECEIPT';
42403 l_event_type_code := 'RECEIPT_ALL';
42404 l_line_definition_owner_code := 'S';
42405 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
42406 --
42407 l_balance_type_code := 'A';
42408 l_segment := NULL;
42409 l_ccid := NULL;
42410 l_adr_transaction_coa_id := NULL;
42411 l_adr_accounting_coa_id := NULL;
42412 l_adr_flexfield_segment_code := NULL;
42413 l_adr_flex_value_set_id := NULL;
42414 l_adr_value_type_code := NULL;
42415 l_adr_value_combination_id := NULL;
42416 l_adr_value_segment_code := NULL;
42417
42418 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
42419 l_bflow_class_code := ''; -- 4219869 Business Flow
42420 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
42421 l_budgetary_control_flag := 'N';
42422
42423 l_bflow_applied_to_amt_idx := NULL; -- 5132302
42424 l_bflow_applied_to_amt := NULL; -- 5132302
42425 l_entered_amt_idx := NULL; -- 4262811
42426 l_accted_amt_idx := NULL; -- 4262811
42427 l_acc_rev_flag := NULL; -- 4262811
42428 l_accrual_line_num := NULL; -- 4262811
42429 l_tmp_amt := NULL; -- 4262811
42430 --
42431
42432 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
42433 l_balance_type_code <> 'B' THEN
42434 IF NVL(p_source_22,'
42435 ') = 'BANK_CHARGES' AND
42436 NVL(p_source_71,'
42437 ') = 'N'
42438 THEN
42439
42440 --
42441 XLA_AE_LINES_PKG.SetNewLine;
42442
42443 p_balance_type_code := l_balance_type_code;
42444 -- set the flag so later we will know whether the gain loss line needs to be created
42445
42446 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
42447 p_actual_flag :='A';
42448 END IF;
42449
42450 --
42451 -- bulk performance
42452 --
42453 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
42454 p_header_num => 0); -- 4262811
42455 --
42456 -- set accounting line options
42457 --
42458 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
42459 p_natural_side_code => 'D'
42460 , p_gain_or_loss_flag => 'N'
42461 , p_gl_transfer_mode_code => 'S'
42462 , p_acct_entry_type_code => 'A'
42463 , p_switch_side_flag => 'Y'
42464 , p_merge_duplicate_code => 'A'
42465 );
42466 --
42467 l_acc_rev_natural_side_code := 'C'; -- 4262811
42468 --
42469 --
42470 -- set accounting line type info
42471 --
42472 xla_ae_lines_pkg.SetAcctLineType
42473 (p_component_type => l_component_type
42474 ,p_event_type_code => l_event_type_code
42475 ,p_line_definition_owner_code => l_line_definition_owner_code
42476 ,p_line_definition_code => l_line_definition_code
42477 ,p_accounting_line_code => l_component_code
42478 ,p_accounting_line_type_code => l_component_type_code
42479 ,p_accounting_line_appl_id => l_component_appl_id
42480 ,p_amb_context_code => l_amb_context_code
42481 ,p_entity_code => l_entity_code
42482 ,p_event_class_code => l_event_class_code);
42483 --
42484 -- set accounting class
42485 --
42486 xla_ae_lines_pkg.SetAcctClass(
42487 p_accounting_class_code => 'CASH'
42488 , p_ae_header_id => l_ae_header_id
42489 );
42490
42491 --
42492 -- set rounding class
42493 --
42494 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
42495 'RECEIVABLE';
42496
42497 --
42498 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
42499 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
42500 --
42501 -- bulk performance
42502 --
42503 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
42504
42505 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
42506 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
42507
42508 -- 4955764
42509 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
42510 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
42511
42512 -- 4458381 Public Sector Enh
42513
42514 --
42515 -- set accounting attributes for the line type
42516 --
42517 l_entered_amt_idx := 8;
42521 l_rec_acct_attrs.array_num_value(1) := p_source_60;
42518 l_accted_amt_idx := 13;
42519 l_bflow_applied_to_amt_idx := NULL; -- 5132302
42520 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
42522 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
42523 l_rec_acct_attrs.array_char_value(2) := p_source_37;
42524 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
42525 l_rec_acct_attrs.array_char_value(3) := p_source_61;
42526 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
42527 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
42528 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
42529 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
42530 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
42531 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
42532 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
42533 l_rec_acct_attrs.array_char_value(7) := p_source_25;
42534 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
42535 l_rec_acct_attrs.array_num_value(8) := p_source_74;
42536 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
42537 l_rec_acct_attrs.array_char_value(9) := p_source_63;
42538 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
42539 l_rec_acct_attrs.array_date_value(10) := p_source_28;
42540 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
42541 l_rec_acct_attrs.array_num_value(11) := p_source_29;
42542 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
42543 l_rec_acct_attrs.array_char_value(12) := p_source_30;
42544 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
42545 l_rec_acct_attrs.array_num_value(13) := p_source_75;
42546 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
42547 l_rec_acct_attrs.array_num_value(14) := p_source_65;
42548 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
42549 l_rec_acct_attrs.array_num_value(15) := p_source_66;
42550 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
42551 l_rec_acct_attrs.array_char_value(16) := p_source_67;
42552
42553 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
42554 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
42555
42556 ---------------------------------------------------------------------------------------------------------------
42557 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
42558 ---------------------------------------------------------------------------------------------------------------
42559 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
42560
42561 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
42562 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
42563
42564 IF xla_accounting_cache_pkg.GetValueChar
42565 (p_source_code => 'LEDGER_CATEGORY_CODE'
42566 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
42567 AND l_bflow_method_code = 'PRIOR_ENTRY'
42568 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
42569 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
42570 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
42571 )
42572 THEN
42573 xla_ae_lines_pkg.BflowUpgEntry
42574 (p_business_method_code => l_bflow_method_code
42575 ,p_business_class_code => l_bflow_class_code
42576 ,p_balance_type => l_balance_type_code);
42577 ELSE
42578 NULL;
42579 -- No business flow processing for business flow method of NONE.
42580 END IF;
42581
42582 --
42583 -- call analytical criteria
42584 --
42585
42586 --
42587 -- call description
42588 --
42589
42590 xla_ae_lines_pkg.SetLineDescription(
42591 p_ae_header_id => l_ae_header_id
42592 ,p_description => Description_1 (
42593 p_application_id => p_application_id
42594 , p_ae_header_id => l_ae_header_id
42595 )
42596 );
42597
42598
42599 --
42600 -- call ADRs
42601 -- Bug 4922099
42602 --
42603 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
42604 (NVL(l_actual_upg_option, 'N') = 'O') OR
42605 (NVL(l_enc_upg_option, 'N') = 'O')
42606 )
42607 THEN
42608 NULL;
42609 --
42610 --
42611
42612 l_ccid := AcctDerRule_28(
42613 p_application_id => p_application_id
42614 , p_ae_header_id => l_ae_header_id
42615 , p_source_5 => p_source_5
42616 , x_transaction_coa_id => l_adr_transaction_coa_id
42617 , x_accounting_coa_id => l_adr_accounting_coa_id
42618 , x_value_type_code => l_adr_value_type_code
42619 , p_side => 'NA'
42620 );
42621
42622 xla_ae_lines_pkg.set_ccid(
42623 p_code_combination_id => l_ccid
42624 , p_value_type_code => l_adr_value_type_code
42625 , p_transaction_coa_id => l_adr_transaction_coa_id
42626 , p_accounting_coa_id => l_adr_accounting_coa_id
42627 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
42628 , p_adr_type_code => 'S'
42632 , p_component_appl_id => l_component_appl_id
42629 , p_component_type => l_component_type
42630 , p_component_code => l_component_code
42631 , p_component_type_code => l_component_type_code
42633 , p_amb_context_code => l_amb_context_code
42634 , p_side => 'NA'
42635 );
42636
42637
42638 l_segment := AcctDerRule_2(
42639 p_application_id => p_application_id
42640 , p_ae_header_id => l_ae_header_id
42641 , p_source_1 => p_source_1
42642 , x_transaction_coa_id => l_adr_transaction_coa_id
42643 , x_accounting_coa_id => l_adr_accounting_coa_id
42644 , x_flexfield_segment_code => l_adr_flexfield_segment_code
42645 , x_flex_value_set_id => l_adr_flex_value_set_id
42646 , x_value_type_code => l_adr_value_type_code
42647 , x_value_combination_id => l_adr_value_combination_id
42648 , x_value_segment_code => l_adr_value_segment_code
42649 , p_side => 'NA'
42650 , p_override_seg_flag => 'Y'
42651 );
42652
42653 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
42654
42655 xla_ae_lines_pkg.set_segment(
42656 p_to_segment_code => 'GL_ACCOUNT'
42657 , p_segment_value => l_segment
42658 , p_from_segment_code => l_adr_value_segment_code
42659 , p_from_combination_id => l_adr_value_combination_id
42660 , p_value_type_code => l_adr_value_type_code
42661 , p_transaction_coa_id => l_adr_transaction_coa_id
42662 , p_accounting_coa_id => l_adr_accounting_coa_id
42663 , p_flexfield_segment_code => l_adr_flexfield_segment_code
42664 , p_flex_value_set_id => l_adr_flex_value_set_id
42665 , p_adr_code => 'MFAR_BNK_CHARGES_NATURAL_SEG'
42666 , p_adr_type_code => 'S'
42667 , p_component_type => l_component_type
42668 , p_component_code => l_component_code
42669 , p_component_type_code => l_component_type_code
42670 , p_component_appl_id => l_component_appl_id
42671 , p_amb_context_code => l_amb_context_code
42672 , p_entity_code => 'RECEIPTS'
42673 , p_event_class_code => 'RECEIPT'
42674 , p_side => 'NA'
42675 );
42676
42677 END IF;
42678
42679 --
42680 --
42681 END IF;
42682 --
42683 -- Bug 4922099
42684 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
42685 (NVL(l_enc_upg_option, 'N') = 'O')
42686 ) AND
42687 (l_bflow_method_code = 'PRIOR_ENTRY')
42688 )
42689 THEN
42690 IF
42691 --
42692 1 = 2
42693 --
42694 THEN
42695 xla_accounting_err_pkg.build_message
42696 (p_appli_s_name => 'XLA'
42697 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42698 ,p_token_1 => 'LINE_NUMBER'
42699 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
42700 ,p_token_2 => 'LINE_TYPE_NAME'
42701 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
42702 l_component_type
42703 ,l_component_code
42704 ,l_component_type_code
42705 ,l_component_appl_id
42706 ,l_amb_context_code
42707 ,l_entity_code
42708 ,l_event_class_code
42709 )
42710 ,p_token_3 => 'OWNER'
42711 ,p_value_3 => xla_lookups_pkg.get_meaning(
42712 p_lookup_type => 'XLA_OWNER_TYPE'
42713 ,p_lookup_code => l_component_type_code
42714 )
42715 ,p_token_4 => 'PRODUCT_NAME'
42716 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
42717 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
42718 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
42719 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
42720 ,p_ae_header_id => NULL
42721 );
42722
42723 IF (C_LEVEL_ERROR>= g_log_level) THEN
42724 trace
42725 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42726 ,p_level => C_LEVEL_ERROR
42730 END IF;
42727 ,p_module => l_log_module);
42728 END IF;
42729 END IF;
42731 --
42732 --
42733 ------------------------------------------------------------------------------------------------
42734 -- 4219869 Business Flow
42735 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
42736 -- Prior Entry. Currently, the following code is always generated.
42737 ------------------------------------------------------------------------------------------------
42738 XLA_AE_LINES_PKG.ValidateCurrentLine;
42739
42740 ------------------------------------------------------------------------------------
42741 -- 4219869 Business Flow
42742 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
42743 ------------------------------------------------------------------------------------
42744 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
42745
42746 ----------------------------------------------------------------------------------
42747 -- 4219869 Business Flow
42748 -- Update journal entry status -- Need to generate this within IF <condition>
42749 ----------------------------------------------------------------------------------
42750 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
42751 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
42752 ,p_balance_type_code => l_balance_type_code
42753 );
42754
42755 -------------------------------------------------------------------------------------------
42756 -- 4262811 - Generate the Accrual Reversal lines
42757 -------------------------------------------------------------------------------------------
42758 BEGIN
42759 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
42760 (g_array_event(p_event_id).array_value_num('header_index'));
42761 IF l_acc_rev_flag IS NULL THEN
42762 l_acc_rev_flag := 'N';
42763 END IF;
42764 EXCEPTION
42765 WHEN OTHERS THEN
42766 l_acc_rev_flag := 'N';
42767 END;
42768 --
42769 IF (l_acc_rev_flag = 'Y') THEN
42770
42771 -- 4645092 ------------------------------------------------------------------------------
42772 -- To allow MPA report to determine if it should generate report process
42773 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
42774 ------------------------------------------------------------------------------------------
42775
42776 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
42777 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
42778 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
42779 -- call ADRs
42780 -- Bug 4922099
42781 --
42782 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
42783 (NVL(l_actual_upg_option, 'N') = 'O') OR
42784 (NVL(l_enc_upg_option, 'N') = 'O')
42785 )
42786 THEN
42787 NULL;
42788 --
42789 --
42790
42791 l_ccid := AcctDerRule_28(
42792 p_application_id => p_application_id
42793 , p_ae_header_id => l_ae_header_id
42794 , p_source_5 => p_source_5
42795 , x_transaction_coa_id => l_adr_transaction_coa_id
42796 , x_accounting_coa_id => l_adr_accounting_coa_id
42797 , x_value_type_code => l_adr_value_type_code
42798 , p_side => 'NA'
42799 );
42800
42801 xla_ae_lines_pkg.set_ccid(
42802 p_code_combination_id => l_ccid
42803 , p_value_type_code => l_adr_value_type_code
42804 , p_transaction_coa_id => l_adr_transaction_coa_id
42805 , p_accounting_coa_id => l_adr_accounting_coa_id
42806 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
42807 , p_adr_type_code => 'S'
42808 , p_component_type => l_component_type
42809 , p_component_code => l_component_code
42810 , p_component_type_code => l_component_type_code
42811 , p_component_appl_id => l_component_appl_id
42812 , p_amb_context_code => l_amb_context_code
42813 , p_side => 'NA'
42814 );
42815
42816
42817 l_segment := AcctDerRule_2(
42818 p_application_id => p_application_id
42819 , p_ae_header_id => l_ae_header_id
42820 , p_source_1 => p_source_1
42821 , x_transaction_coa_id => l_adr_transaction_coa_id
42822 , x_accounting_coa_id => l_adr_accounting_coa_id
42823 , x_flexfield_segment_code => l_adr_flexfield_segment_code
42824 , x_flex_value_set_id => l_adr_flex_value_set_id
42825 , x_value_type_code => l_adr_value_type_code
42826 , x_value_combination_id => l_adr_value_combination_id
42827 , x_value_segment_code => l_adr_value_segment_code
42828 , p_side => 'NA'
42829 , p_override_seg_flag => 'Y'
42830 );
42831
42832 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
42833
42834 xla_ae_lines_pkg.set_segment(
42835 p_to_segment_code => 'GL_ACCOUNT'
42836 , p_segment_value => l_segment
42837 , p_from_segment_code => l_adr_value_segment_code
42838 , p_from_combination_id => l_adr_value_combination_id
42842 , p_flexfield_segment_code => l_adr_flexfield_segment_code
42839 , p_value_type_code => l_adr_value_type_code
42840 , p_transaction_coa_id => l_adr_transaction_coa_id
42841 , p_accounting_coa_id => l_adr_accounting_coa_id
42843 , p_flex_value_set_id => l_adr_flex_value_set_id
42844 , p_adr_code => 'MFAR_BNK_CHARGES_NATURAL_SEG'
42845 , p_adr_type_code => 'S'
42846 , p_component_type => l_component_type
42847 , p_component_code => l_component_code
42848 , p_component_type_code => l_component_type_code
42849 , p_component_appl_id => l_component_appl_id
42850 , p_amb_context_code => l_amb_context_code
42851 , p_entity_code => 'RECEIPTS'
42852 , p_event_class_code => 'RECEIPT'
42853 , p_side => 'NA'
42854 );
42855
42856 END IF;
42857
42858 --
42859 --
42860 END IF;
42861
42862 --
42863 -- Update the line information that should be overwritten
42864 --
42865 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
42866 p_header_num => 1);
42867 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
42868
42869 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
42870
42871 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
42872 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
42873 END IF;
42874
42875 --
42876 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
42877 --
42878 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
42879 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
42880 ELSE
42881 ---------------------------------------------------------------------------------------------------
42882 -- 4262811a Switch Sign
42883 ---------------------------------------------------------------------------------------------------
42884 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
42885 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42886 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42887 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42888 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42889 -- 5132302
42890 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
42891 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42892
42893 END IF;
42894
42895 -- 4955764
42896 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
42897 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
42898
42899
42900 XLA_AE_LINES_PKG.ValidateCurrentLine;
42901 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
42902
42903 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
42904 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
42905 ,p_balance_type_code => l_balance_type_code);
42906
42907 END IF;
42908
42909 -----------------------------------------------------------------------------------------
42910 -- 4262811 Multiperiod Accounting
42911 -----------------------------------------------------------------------------------------
42912 -- No MPA option is assigned.
42913
42914
42915 END IF;
42916 END IF;
42917 --
42918
42919 --
42920 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
42921 trace
42922 (p_msg => 'END of AcctLineType_96'
42923 ,p_level => C_LEVEL_PROCEDURE
42924 ,p_module => l_log_module);
42925 END IF;
42926 --
42927 EXCEPTION
42928 WHEN xla_exceptions_pkg.application_exception THEN
42929 RAISE;
42930 WHEN OTHERS THEN
42931 xla_exceptions_pkg.raise_message
42932 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_96');
42933 END AcctLineType_96;
42934 --
42935
42936 ---------------------------------------
42937 --
42938 -- PRIVATE FUNCTION
42939 -- AcctLineType_97
42940 --
42941 ---------------------------------------
42942 PROCEDURE AcctLineType_97 (
42943 p_application_id IN NUMBER
42944 ,p_event_id IN NUMBER
42945 ,p_calculate_acctd_flag IN VARCHAR2
42946 ,p_calculate_g_l_flag IN VARCHAR2
42947 ,p_actual_flag IN OUT VARCHAR2
42948 ,p_balance_type_code OUT VARCHAR2
42949 ,p_gain_or_loss_ref OUT VARCHAR2
42950
42951 --Remittance Bank Account Cash Account
42952 , p_source_5 IN NUMBER
42953 --Distribution Source Type
42954 , p_source_22 IN VARCHAR2
42955 --Distribution Line Identifier
42956 , p_source_24 IN NUMBER
42960 , p_source_28 IN DATE
42957 --Distribution Type
42958 , p_source_25 IN VARCHAR2
42959 --Exchange Date
42961 --Exchange Rate
42962 , p_source_29 IN NUMBER
42963 --Exchange Rate Type
42964 , p_source_30 IN VARCHAR2
42965 --Transaction Distribution Account Class
42966 , p_source_35 IN VARCHAR2
42967 --Transaction Distribution Identifier
42968 , p_source_36 IN NUMBER
42969 --Transaction Distribution Type
42970 , p_source_37 IN VARCHAR2
42971 --Receipt Applied To Application Identifier
42972 , p_source_60 IN NUMBER
42973 --Transaction Entity Code
42974 , p_source_61 IN VARCHAR2
42975 --Transaction Identifier
42976 , p_source_62 IN NUMBER
42977 --Applying Document Currency Code
42978 , p_source_63 IN VARCHAR2
42979 --Distribution Party Identifier
42980 , p_source_65 IN NUMBER
42981 --Distribution Party Site Id
42982 , p_source_66 IN NUMBER
42983 --Distribution Party Type
42984 , p_source_67 IN VARCHAR2
42985 --Distribution Multi Fund Additional Entry
42986 , p_source_71 IN VARCHAR2
42987 --Receipt Class Require Remittance Flag
42988 , p_source_72 IN VARCHAR2
42989 --Receipt Class Confirm Flag
42990 , p_source_73 IN VARCHAR2
42991 --DIST_ENT_AMT_FROM
42992 , p_source_74 IN NUMBER
42993 --Accounting Amount
42994 , p_source_75 IN NUMBER
42995 )
42996 IS
42997
42998 l_component_type VARCHAR2(80);
42999 l_component_code VARCHAR2(30);
43000 l_component_type_code VARCHAR2(1);
43001 l_component_appl_id INTEGER;
43002 l_amb_context_code VARCHAR2(30);
43003 l_entity_code VARCHAR2(30);
43004 l_event_class_code VARCHAR2(30);
43005 l_ae_header_id NUMBER;
43006 l_event_type_code VARCHAR2(30);
43007 l_line_definition_code VARCHAR2(30);
43008 l_line_definition_owner_code VARCHAR2(1);
43009 --
43010 -- adr variables
43011 l_segment VARCHAR2(30);
43012 l_ccid NUMBER;
43013 l_adr_transaction_coa_id NUMBER;
43014 l_adr_accounting_coa_id NUMBER;
43015 l_adr_flexfield_segment_code VARCHAR2(30);
43016 l_adr_flex_value_set_id NUMBER;
43017 l_adr_value_type_code VARCHAR2(30);
43018 l_adr_value_combination_id NUMBER;
43019 l_adr_value_segment_code VARCHAR2(30);
43020
43021 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
43022 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
43023 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
43024 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
43025
43026 -- 4262811 Variables ------------------------------------------------------------------------------------------
43027 l_entered_amt_idx NUMBER;
43028 l_accted_amt_idx NUMBER;
43029 l_acc_rev_flag VARCHAR2(1);
43030 l_accrual_line_num NUMBER;
43031 l_tmp_amt NUMBER;
43032 l_acc_rev_natural_side_code VARCHAR2(1);
43033
43034 l_num_entries NUMBER;
43035 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
43036 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
43037 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
43038 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
43039 l_recog_line_1 NUMBER;
43040 l_recog_line_2 NUMBER;
43041
43042 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
43043 l_bflow_applied_to_amt NUMBER; -- 5132302
43044 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
43045
43046 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
43047
43048 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
43049 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
43050
43051 ---------------------------------------------------------------------------------------------------------------
43052
43053
43054 --
43055 -- bulk performance
43056 --
43057 l_balance_type_code VARCHAR2(1);
43058 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
43059 l_log_module VARCHAR2(240);
43060
43061 --
43062 -- Upgrade strategy
43063 --
43064 l_actual_upg_option VARCHAR2(1);
43065 l_enc_upg_option VARCHAR2(1);
43066
43067 --
43068 BEGIN
43069 --
43070 IF g_log_enabled THEN
43071 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_97';
43072 END IF;
43073 --
43074 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
43075
43076 trace
43077 (p_msg => 'BEGIN of AcctLineType_97'
43078 ,p_level => C_LEVEL_PROCEDURE
43079 ,p_module => l_log_module);
43080
43081 END IF;
43082 --
43083 l_component_type := 'AMB_JLT';
43084 l_component_code := 'MFAR_RCT_CASH_REVERSE';
43085 l_component_type_code := 'S';
43086 l_component_appl_id := 222;
43087 l_amb_context_code := 'DEFAULT';
43088 l_entity_code := 'RECEIPTS';
43089 l_event_class_code := 'RECEIPT';
43093 --
43090 l_event_type_code := 'RECEIPT_ALL';
43091 l_line_definition_owner_code := 'S';
43092 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
43094 l_balance_type_code := 'A';
43095 l_segment := NULL;
43096 l_ccid := NULL;
43097 l_adr_transaction_coa_id := NULL;
43098 l_adr_accounting_coa_id := NULL;
43099 l_adr_flexfield_segment_code := NULL;
43100 l_adr_flex_value_set_id := NULL;
43101 l_adr_value_type_code := NULL;
43102 l_adr_value_combination_id := NULL;
43103 l_adr_value_segment_code := NULL;
43104
43105 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
43106 l_bflow_class_code := ''; -- 4219869 Business Flow
43107 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
43108 l_budgetary_control_flag := 'N';
43109
43110 l_bflow_applied_to_amt_idx := NULL; -- 5132302
43111 l_bflow_applied_to_amt := NULL; -- 5132302
43112 l_entered_amt_idx := NULL; -- 4262811
43113 l_accted_amt_idx := NULL; -- 4262811
43114 l_acc_rev_flag := NULL; -- 4262811
43115 l_accrual_line_num := NULL; -- 4262811
43116 l_tmp_amt := NULL; -- 4262811
43117 --
43118
43119 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
43120 l_balance_type_code <> 'B' THEN
43121 IF (NVL(p_source_35,'
43122 ') = 'REV' OR
43123 NVL(p_source_35,'
43124 ') = 'TAX' OR
43125 NVL(p_source_35,'
43126 ') = 'FREIGHT' OR
43127 NVL(p_source_35,'
43128 ') = 'CHARGES' OR
43129 NVL(p_source_35,'
43130 ') = 'ROUND') AND
43131 NVL(p_source_22,'
43132 ') = 'REC' AND
43133 NVL(p_source_71,'
43134 ') = 'N' AND
43135 NVL(p_source_72,'
43136 ') = 'N' AND
43137 NVL(p_source_73,'
43138 ') = 'N'
43139 THEN
43140
43141 --
43142 XLA_AE_LINES_PKG.SetNewLine;
43143
43144 p_balance_type_code := l_balance_type_code;
43145 -- set the flag so later we will know whether the gain loss line needs to be created
43146
43147 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
43148 p_actual_flag :='A';
43149 END IF;
43150
43151 --
43152 -- bulk performance
43153 --
43154 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
43155 p_header_num => 0); -- 4262811
43156 --
43157 -- set accounting line options
43158 --
43159 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
43160 p_natural_side_code => 'C'
43161 , p_gain_or_loss_flag => 'N'
43162 , p_gl_transfer_mode_code => 'S'
43163 , p_acct_entry_type_code => 'A'
43164 , p_switch_side_flag => 'Y'
43165 , p_merge_duplicate_code => 'A'
43166 );
43167 --
43168 l_acc_rev_natural_side_code := 'D'; -- 4262811
43169 --
43170 --
43171 -- set accounting line type info
43172 --
43173 xla_ae_lines_pkg.SetAcctLineType
43174 (p_component_type => l_component_type
43175 ,p_event_type_code => l_event_type_code
43176 ,p_line_definition_owner_code => l_line_definition_owner_code
43177 ,p_line_definition_code => l_line_definition_code
43178 ,p_accounting_line_code => l_component_code
43179 ,p_accounting_line_type_code => l_component_type_code
43180 ,p_accounting_line_appl_id => l_component_appl_id
43181 ,p_amb_context_code => l_amb_context_code
43182 ,p_entity_code => l_entity_code
43183 ,p_event_class_code => l_event_class_code);
43184 --
43185 -- set accounting class
43186 --
43187 xla_ae_lines_pkg.SetAcctClass(
43188 p_accounting_class_code => 'CASH'
43189 , p_ae_header_id => l_ae_header_id
43190 );
43191
43192 --
43193 -- set rounding class
43194 --
43195 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
43196 'RECEIVABLE';
43197
43198 --
43199 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
43200 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
43201 --
43202 -- bulk performance
43203 --
43204 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
43205
43206 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
43207 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
43208
43209 -- 4955764
43210 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
43211 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
43212
43213 -- 4458381 Public Sector Enh
43214
43215 --
43216 -- set accounting attributes for the line type
43217 --
43218 l_entered_amt_idx := 8;
43219 l_accted_amt_idx := 13;
43220 l_bflow_applied_to_amt_idx := NULL; -- 5132302
43221 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
43222 l_rec_acct_attrs.array_num_value(1) := p_source_60;
43226 l_rec_acct_attrs.array_char_value(3) := p_source_61;
43223 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
43224 l_rec_acct_attrs.array_char_value(2) := p_source_37;
43225 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
43227 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
43228 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
43229 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
43230 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
43231 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
43232 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
43233 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
43234 l_rec_acct_attrs.array_char_value(7) := p_source_25;
43235 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
43236 l_rec_acct_attrs.array_num_value(8) := p_source_74;
43237 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
43238 l_rec_acct_attrs.array_char_value(9) := p_source_63;
43239 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
43240 l_rec_acct_attrs.array_date_value(10) := p_source_28;
43241 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
43242 l_rec_acct_attrs.array_num_value(11) := p_source_29;
43243 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
43244 l_rec_acct_attrs.array_char_value(12) := p_source_30;
43245 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
43246 l_rec_acct_attrs.array_num_value(13) := p_source_75;
43247 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
43248 l_rec_acct_attrs.array_num_value(14) := p_source_65;
43249 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
43250 l_rec_acct_attrs.array_num_value(15) := p_source_66;
43251 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
43252 l_rec_acct_attrs.array_char_value(16) := p_source_67;
43253
43254 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
43255 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
43256
43257 ---------------------------------------------------------------------------------------------------------------
43258 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
43259 ---------------------------------------------------------------------------------------------------------------
43260 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
43261
43262 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43263 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43264
43265 IF xla_accounting_cache_pkg.GetValueChar
43266 (p_source_code => 'LEDGER_CATEGORY_CODE'
43267 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
43268 AND l_bflow_method_code = 'PRIOR_ENTRY'
43269 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
43270 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
43271 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
43272 )
43273 THEN
43274 xla_ae_lines_pkg.BflowUpgEntry
43275 (p_business_method_code => l_bflow_method_code
43276 ,p_business_class_code => l_bflow_class_code
43277 ,p_balance_type => l_balance_type_code);
43278 ELSE
43279 NULL;
43280 -- No business flow processing for business flow method of NONE.
43281 END IF;
43282
43283 --
43284 -- call analytical criteria
43285 --
43286
43287 --
43288 -- call description
43289 --
43290
43291 xla_ae_lines_pkg.SetLineDescription(
43292 p_ae_header_id => l_ae_header_id
43293 ,p_description => Description_1 (
43294 p_application_id => p_application_id
43295 , p_ae_header_id => l_ae_header_id
43296 )
43297 );
43298
43299
43300 --
43301 -- call ADRs
43302 -- Bug 4922099
43303 --
43304 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
43305 (NVL(l_actual_upg_option, 'N') = 'O') OR
43306 (NVL(l_enc_upg_option, 'N') = 'O')
43307 )
43308 THEN
43309 NULL;
43310 --
43311 --
43312
43313 l_ccid := AcctDerRule_28(
43314 p_application_id => p_application_id
43315 , p_ae_header_id => l_ae_header_id
43316 , p_source_5 => p_source_5
43317 , x_transaction_coa_id => l_adr_transaction_coa_id
43318 , x_accounting_coa_id => l_adr_accounting_coa_id
43319 , x_value_type_code => l_adr_value_type_code
43320 , p_side => 'NA'
43321 );
43322
43323 xla_ae_lines_pkg.set_ccid(
43324 p_code_combination_id => l_ccid
43325 , p_value_type_code => l_adr_value_type_code
43326 , p_transaction_coa_id => l_adr_transaction_coa_id
43327 , p_accounting_coa_id => l_adr_accounting_coa_id
43328 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
43329 , p_adr_type_code => 'S'
43330 , p_component_type => l_component_type
43331 , p_component_code => l_component_code
43332 , p_component_type_code => l_component_type_code
43336 );
43333 , p_component_appl_id => l_component_appl_id
43334 , p_amb_context_code => l_amb_context_code
43335 , p_side => 'NA'
43337
43338
43339 --
43340 --
43341 END IF;
43342 --
43343 -- Bug 4922099
43344 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
43345 (NVL(l_enc_upg_option, 'N') = 'O')
43346 ) AND
43347 (l_bflow_method_code = 'PRIOR_ENTRY')
43348 )
43349 THEN
43350 IF
43351 --
43352 1 = 2
43353 --
43354 THEN
43355 xla_accounting_err_pkg.build_message
43356 (p_appli_s_name => 'XLA'
43357 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43358 ,p_token_1 => 'LINE_NUMBER'
43359 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
43360 ,p_token_2 => 'LINE_TYPE_NAME'
43361 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
43362 l_component_type
43363 ,l_component_code
43364 ,l_component_type_code
43365 ,l_component_appl_id
43366 ,l_amb_context_code
43367 ,l_entity_code
43368 ,l_event_class_code
43369 )
43370 ,p_token_3 => 'OWNER'
43371 ,p_value_3 => xla_lookups_pkg.get_meaning(
43372 p_lookup_type => 'XLA_OWNER_TYPE'
43373 ,p_lookup_code => l_component_type_code
43374 )
43375 ,p_token_4 => 'PRODUCT_NAME'
43376 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
43377 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
43378 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
43379 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
43380 ,p_ae_header_id => NULL
43381 );
43382
43383 IF (C_LEVEL_ERROR>= g_log_level) THEN
43384 trace
43385 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43386 ,p_level => C_LEVEL_ERROR
43387 ,p_module => l_log_module);
43388 END IF;
43389 END IF;
43390 END IF;
43391 --
43392 --
43393 ------------------------------------------------------------------------------------------------
43394 -- 4219869 Business Flow
43395 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
43396 -- Prior Entry. Currently, the following code is always generated.
43397 ------------------------------------------------------------------------------------------------
43398 XLA_AE_LINES_PKG.ValidateCurrentLine;
43399
43400 ------------------------------------------------------------------------------------
43401 -- 4219869 Business Flow
43402 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
43403 ------------------------------------------------------------------------------------
43404 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
43405
43406 ----------------------------------------------------------------------------------
43407 -- 4219869 Business Flow
43408 -- Update journal entry status -- Need to generate this within IF <condition>
43409 ----------------------------------------------------------------------------------
43410 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
43411 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
43412 ,p_balance_type_code => l_balance_type_code
43413 );
43414
43415 -------------------------------------------------------------------------------------------
43416 -- 4262811 - Generate the Accrual Reversal lines
43417 -------------------------------------------------------------------------------------------
43418 BEGIN
43419 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
43420 (g_array_event(p_event_id).array_value_num('header_index'));
43421 IF l_acc_rev_flag IS NULL THEN
43422 l_acc_rev_flag := 'N';
43423 END IF;
43424 EXCEPTION
43425 WHEN OTHERS THEN
43426 l_acc_rev_flag := 'N';
43427 END;
43428 --
43429 IF (l_acc_rev_flag = 'Y') THEN
43430
43434 ------------------------------------------------------------------------------------------
43431 -- 4645092 ------------------------------------------------------------------------------
43432 -- To allow MPA report to determine if it should generate report process
43433 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
43435
43436 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
43437 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
43438 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
43439 -- call ADRs
43440 -- Bug 4922099
43441 --
43442 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
43443 (NVL(l_actual_upg_option, 'N') = 'O') OR
43444 (NVL(l_enc_upg_option, 'N') = 'O')
43445 )
43446 THEN
43447 NULL;
43448 --
43449 --
43450
43451 l_ccid := AcctDerRule_28(
43452 p_application_id => p_application_id
43453 , p_ae_header_id => l_ae_header_id
43454 , p_source_5 => p_source_5
43455 , x_transaction_coa_id => l_adr_transaction_coa_id
43456 , x_accounting_coa_id => l_adr_accounting_coa_id
43457 , x_value_type_code => l_adr_value_type_code
43458 , p_side => 'NA'
43459 );
43460
43461 xla_ae_lines_pkg.set_ccid(
43462 p_code_combination_id => l_ccid
43463 , p_value_type_code => l_adr_value_type_code
43464 , p_transaction_coa_id => l_adr_transaction_coa_id
43465 , p_accounting_coa_id => l_adr_accounting_coa_id
43466 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
43467 , p_adr_type_code => 'S'
43468 , p_component_type => l_component_type
43469 , p_component_code => l_component_code
43470 , p_component_type_code => l_component_type_code
43471 , p_component_appl_id => l_component_appl_id
43472 , p_amb_context_code => l_amb_context_code
43473 , p_side => 'NA'
43474 );
43475
43476
43477 --
43478 --
43479 END IF;
43480
43481 --
43482 -- Update the line information that should be overwritten
43483 --
43484 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
43485 p_header_num => 1);
43486 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
43487
43488 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
43489
43490 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
43491 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
43492 END IF;
43493
43494 --
43495 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
43496 --
43497 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
43498 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
43499 ELSE
43500 ---------------------------------------------------------------------------------------------------
43501 -- 4262811a Switch Sign
43502 ---------------------------------------------------------------------------------------------------
43503 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
43504 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
43505 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43506 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
43507 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43508 -- 5132302
43509 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
43510 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43511
43512 END IF;
43513
43514 -- 4955764
43515 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
43516 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
43517
43518
43519 XLA_AE_LINES_PKG.ValidateCurrentLine;
43520 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
43521
43522 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
43523 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
43524 ,p_balance_type_code => l_balance_type_code);
43525
43526 END IF;
43527
43528 -----------------------------------------------------------------------------------------
43529 -- 4262811 Multiperiod Accounting
43530 -----------------------------------------------------------------------------------------
43531 -- No MPA option is assigned.
43532
43533
43534 END IF;
43535 END IF;
43536 --
43537
43538 --
43539 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
43540 trace
43541 (p_msg => 'END of AcctLineType_97'
43542 ,p_level => C_LEVEL_PROCEDURE
43546 EXCEPTION
43543 ,p_module => l_log_module);
43544 END IF;
43545 --
43547 WHEN xla_exceptions_pkg.application_exception THEN
43548 RAISE;
43549 WHEN OTHERS THEN
43550 xla_exceptions_pkg.raise_message
43551 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_97');
43552 END AcctLineType_97;
43553 --
43554
43555 ---------------------------------------
43556 --
43557 -- PRIVATE FUNCTION
43558 -- AcctLineType_98
43559 --
43560 ---------------------------------------
43561 PROCEDURE AcctLineType_98 (
43562 p_application_id IN NUMBER
43563 ,p_event_id IN NUMBER
43564 ,p_calculate_acctd_flag IN VARCHAR2
43565 ,p_calculate_g_l_flag IN VARCHAR2
43566 ,p_actual_flag IN OUT VARCHAR2
43567 ,p_balance_type_code OUT VARCHAR2
43568 ,p_gain_or_loss_ref OUT VARCHAR2
43569
43570 --Remittance Bank Account Cash Account
43571 , p_source_5 IN NUMBER
43572 --Distribution Source Type
43573 , p_source_22 IN VARCHAR2
43574 --Distribution Line Identifier
43575 , p_source_24 IN NUMBER
43576 --Distribution Type
43577 , p_source_25 IN VARCHAR2
43578 --Exchange Date
43579 , p_source_28 IN DATE
43580 --Exchange Rate
43581 , p_source_29 IN NUMBER
43582 --Exchange Rate Type
43583 , p_source_30 IN VARCHAR2
43584 --Transaction Distribution Identifier
43585 , p_source_36 IN NUMBER
43586 --Transaction Distribution Type
43587 , p_source_37 IN VARCHAR2
43588 --Receipt Applied To Application Identifier
43589 , p_source_60 IN NUMBER
43590 --Transaction Entity Code
43591 , p_source_61 IN VARCHAR2
43592 --Transaction Identifier
43593 , p_source_62 IN NUMBER
43594 --Applying Document Currency Code
43595 , p_source_63 IN VARCHAR2
43596 --Distribution Party Identifier
43597 , p_source_65 IN NUMBER
43598 --Distribution Party Site Id
43599 , p_source_66 IN NUMBER
43600 --Distribution Party Type
43601 , p_source_67 IN VARCHAR2
43602 --Distribution Multi Fund Additional Entry
43603 , p_source_71 IN VARCHAR2
43604 --Receipt Class Require Remittance Flag
43605 , p_source_72 IN VARCHAR2
43606 --DIST_ENT_AMT_FROM
43607 , p_source_74 IN NUMBER
43608 --Accounting Amount
43609 , p_source_75 IN NUMBER
43610 )
43611 IS
43612
43613 l_component_type VARCHAR2(80);
43614 l_component_code VARCHAR2(30);
43615 l_component_type_code VARCHAR2(1);
43616 l_component_appl_id INTEGER;
43617 l_amb_context_code VARCHAR2(30);
43618 l_entity_code VARCHAR2(30);
43619 l_event_class_code VARCHAR2(30);
43620 l_ae_header_id NUMBER;
43621 l_event_type_code VARCHAR2(30);
43622 l_line_definition_code VARCHAR2(30);
43623 l_line_definition_owner_code VARCHAR2(1);
43624 --
43625 -- adr variables
43626 l_segment VARCHAR2(30);
43627 l_ccid NUMBER;
43628 l_adr_transaction_coa_id NUMBER;
43629 l_adr_accounting_coa_id NUMBER;
43630 l_adr_flexfield_segment_code VARCHAR2(30);
43631 l_adr_flex_value_set_id NUMBER;
43632 l_adr_value_type_code VARCHAR2(30);
43633 l_adr_value_combination_id NUMBER;
43634 l_adr_value_segment_code VARCHAR2(30);
43635
43636 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
43637 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
43638 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
43639 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
43640
43641 -- 4262811 Variables ------------------------------------------------------------------------------------------
43642 l_entered_amt_idx NUMBER;
43643 l_accted_amt_idx NUMBER;
43644 l_acc_rev_flag VARCHAR2(1);
43645 l_accrual_line_num NUMBER;
43646 l_tmp_amt NUMBER;
43647 l_acc_rev_natural_side_code VARCHAR2(1);
43648
43649 l_num_entries NUMBER;
43650 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
43651 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
43652 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
43653 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
43654 l_recog_line_1 NUMBER;
43655 l_recog_line_2 NUMBER;
43656
43657 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
43658 l_bflow_applied_to_amt NUMBER; -- 5132302
43659 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
43660
43661 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
43662
43663 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
43664 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
43665
43666 ---------------------------------------------------------------------------------------------------------------
43667
43668
43669 --
43670 -- bulk performance
43671 --
43672 l_balance_type_code VARCHAR2(1);
43673 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
43674 l_log_module VARCHAR2(240);
43675
43676 --
43677 -- Upgrade strategy
43681
43678 --
43679 l_actual_upg_option VARCHAR2(1);
43680 l_enc_upg_option VARCHAR2(1);
43682 --
43683 BEGIN
43684 --
43685 IF g_log_enabled THEN
43686 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_98';
43687 END IF;
43688 --
43689 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
43690
43691 trace
43692 (p_msg => 'BEGIN of AcctLineType_98'
43693 ,p_level => C_LEVEL_PROCEDURE
43694 ,p_module => l_log_module);
43695
43696 END IF;
43697 --
43698 l_component_type := 'AMB_JLT';
43699 l_component_code := 'MFAR_RCT_CM_CASH_REVERSAL';
43700 l_component_type_code := 'S';
43701 l_component_appl_id := 222;
43702 l_amb_context_code := 'DEFAULT';
43703 l_entity_code := 'RECEIPTS';
43704 l_event_class_code := 'RECEIPT';
43705 l_event_type_code := 'RECEIPT_ALL';
43706 l_line_definition_owner_code := 'S';
43707 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
43708 --
43709 l_balance_type_code := 'A';
43710 l_segment := NULL;
43711 l_ccid := NULL;
43712 l_adr_transaction_coa_id := NULL;
43713 l_adr_accounting_coa_id := NULL;
43714 l_adr_flexfield_segment_code := NULL;
43715 l_adr_flex_value_set_id := NULL;
43716 l_adr_value_type_code := NULL;
43717 l_adr_value_combination_id := NULL;
43718 l_adr_value_segment_code := NULL;
43719
43720 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
43721 l_bflow_class_code := ''; -- 4219869 Business Flow
43722 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
43723 l_budgetary_control_flag := 'N';
43724
43725 l_bflow_applied_to_amt_idx := NULL; -- 5132302
43726 l_bflow_applied_to_amt := NULL; -- 5132302
43727 l_entered_amt_idx := NULL; -- 4262811
43728 l_accted_amt_idx := NULL; -- 4262811
43729 l_acc_rev_flag := NULL; -- 4262811
43730 l_accrual_line_num := NULL; -- 4262811
43731 l_tmp_amt := NULL; -- 4262811
43732 --
43733
43734 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
43735 l_balance_type_code <> 'B' THEN
43736 IF NVL(p_source_22,'
43737 ') = 'CASH' AND
43738 NVL(p_source_71,'
43739 ') = 'Y' AND
43740 NVL(p_source_72,'
43741 ') = 'Y'
43742 THEN
43743
43744 --
43745 XLA_AE_LINES_PKG.SetNewLine;
43746
43747 p_balance_type_code := l_balance_type_code;
43748 -- set the flag so later we will know whether the gain loss line needs to be created
43749
43750 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
43751 p_actual_flag :='A';
43752 END IF;
43753
43754 --
43755 -- bulk performance
43756 --
43757 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
43758 p_header_num => 0); -- 4262811
43759 --
43760 -- set accounting line options
43761 --
43762 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
43763 p_natural_side_code => 'D'
43764 , p_gain_or_loss_flag => 'N'
43765 , p_gl_transfer_mode_code => 'S'
43766 , p_acct_entry_type_code => 'A'
43767 , p_switch_side_flag => 'Y'
43768 , p_merge_duplicate_code => 'A'
43769 );
43770 --
43771 l_acc_rev_natural_side_code := 'C'; -- 4262811
43772 --
43773 --
43774 -- set accounting line type info
43775 --
43776 xla_ae_lines_pkg.SetAcctLineType
43777 (p_component_type => l_component_type
43778 ,p_event_type_code => l_event_type_code
43779 ,p_line_definition_owner_code => l_line_definition_owner_code
43780 ,p_line_definition_code => l_line_definition_code
43781 ,p_accounting_line_code => l_component_code
43782 ,p_accounting_line_type_code => l_component_type_code
43783 ,p_accounting_line_appl_id => l_component_appl_id
43784 ,p_amb_context_code => l_amb_context_code
43785 ,p_entity_code => l_entity_code
43786 ,p_event_class_code => l_event_class_code);
43787 --
43788 -- set accounting class
43789 --
43790 xla_ae_lines_pkg.SetAcctClass(
43791 p_accounting_class_code => 'CASH'
43792 , p_ae_header_id => l_ae_header_id
43793 );
43794
43795 --
43796 -- set rounding class
43797 --
43798 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
43799 'RECEIVABLE';
43800
43801 --
43802 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
43803 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
43804 --
43805 -- bulk performance
43806 --
43807 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
43808
43809 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
43810 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
43811
43812 -- 4955764
43816 -- 4458381 Public Sector Enh
43813 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
43814 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
43815
43817
43818 --
43819 -- set accounting attributes for the line type
43820 --
43821 l_entered_amt_idx := 8;
43822 l_accted_amt_idx := 13;
43823 l_bflow_applied_to_amt_idx := NULL; -- 5132302
43824 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
43825 l_rec_acct_attrs.array_num_value(1) := p_source_60;
43826 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
43827 l_rec_acct_attrs.array_char_value(2) := p_source_37;
43828 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
43829 l_rec_acct_attrs.array_char_value(3) := p_source_61;
43830 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
43831 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
43832 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
43833 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
43834 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
43835 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
43836 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
43837 l_rec_acct_attrs.array_char_value(7) := p_source_25;
43838 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
43839 l_rec_acct_attrs.array_num_value(8) := p_source_74;
43840 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
43841 l_rec_acct_attrs.array_char_value(9) := p_source_63;
43842 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
43843 l_rec_acct_attrs.array_date_value(10) := p_source_28;
43844 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
43845 l_rec_acct_attrs.array_num_value(11) := p_source_29;
43846 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
43847 l_rec_acct_attrs.array_char_value(12) := p_source_30;
43848 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
43849 l_rec_acct_attrs.array_num_value(13) := p_source_75;
43850 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
43851 l_rec_acct_attrs.array_num_value(14) := p_source_65;
43852 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
43853 l_rec_acct_attrs.array_num_value(15) := p_source_66;
43854 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
43855 l_rec_acct_attrs.array_char_value(16) := p_source_67;
43856
43857 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
43858 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
43859
43860 ---------------------------------------------------------------------------------------------------------------
43861 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
43862 ---------------------------------------------------------------------------------------------------------------
43863 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
43864
43865 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43866 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43867
43868 IF xla_accounting_cache_pkg.GetValueChar
43869 (p_source_code => 'LEDGER_CATEGORY_CODE'
43870 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
43871 AND l_bflow_method_code = 'PRIOR_ENTRY'
43872 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
43873 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
43874 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
43875 )
43876 THEN
43877 xla_ae_lines_pkg.BflowUpgEntry
43878 (p_business_method_code => l_bflow_method_code
43879 ,p_business_class_code => l_bflow_class_code
43880 ,p_balance_type => l_balance_type_code);
43881 ELSE
43882 NULL;
43883 -- No business flow processing for business flow method of NONE.
43884 END IF;
43885
43886 --
43887 -- call analytical criteria
43888 --
43889
43890 --
43891 -- call description
43892 --
43893
43894 xla_ae_lines_pkg.SetLineDescription(
43895 p_ae_header_id => l_ae_header_id
43896 ,p_description => Description_1 (
43897 p_application_id => p_application_id
43898 , p_ae_header_id => l_ae_header_id
43899 )
43900 );
43901
43902
43903 --
43904 -- call ADRs
43905 -- Bug 4922099
43906 --
43907 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
43908 (NVL(l_actual_upg_option, 'N') = 'O') OR
43909 (NVL(l_enc_upg_option, 'N') = 'O')
43910 )
43911 THEN
43912 NULL;
43913 --
43914 --
43915
43916 l_ccid := AcctDerRule_28(
43917 p_application_id => p_application_id
43918 , p_ae_header_id => l_ae_header_id
43919 , p_source_5 => p_source_5
43920 , x_transaction_coa_id => l_adr_transaction_coa_id
43921 , x_accounting_coa_id => l_adr_accounting_coa_id
43922 , x_value_type_code => l_adr_value_type_code
43926 xla_ae_lines_pkg.set_ccid(
43923 , p_side => 'NA'
43924 );
43925
43927 p_code_combination_id => l_ccid
43928 , p_value_type_code => l_adr_value_type_code
43929 , p_transaction_coa_id => l_adr_transaction_coa_id
43930 , p_accounting_coa_id => l_adr_accounting_coa_id
43931 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
43932 , p_adr_type_code => 'S'
43933 , p_component_type => l_component_type
43934 , p_component_code => l_component_code
43935 , p_component_type_code => l_component_type_code
43936 , p_component_appl_id => l_component_appl_id
43937 , p_amb_context_code => l_amb_context_code
43938 , p_side => 'NA'
43939 );
43940
43941
43942 --
43943 --
43944 END IF;
43945 --
43946 -- Bug 4922099
43947 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
43948 (NVL(l_enc_upg_option, 'N') = 'O')
43949 ) AND
43950 (l_bflow_method_code = 'PRIOR_ENTRY')
43951 )
43952 THEN
43953 IF
43954 --
43955 1 = 2
43956 --
43957 THEN
43958 xla_accounting_err_pkg.build_message
43959 (p_appli_s_name => 'XLA'
43960 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43961 ,p_token_1 => 'LINE_NUMBER'
43962 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
43963 ,p_token_2 => 'LINE_TYPE_NAME'
43964 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
43965 l_component_type
43966 ,l_component_code
43967 ,l_component_type_code
43968 ,l_component_appl_id
43969 ,l_amb_context_code
43970 ,l_entity_code
43971 ,l_event_class_code
43972 )
43973 ,p_token_3 => 'OWNER'
43974 ,p_value_3 => xla_lookups_pkg.get_meaning(
43975 p_lookup_type => 'XLA_OWNER_TYPE'
43976 ,p_lookup_code => l_component_type_code
43977 )
43978 ,p_token_4 => 'PRODUCT_NAME'
43979 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
43980 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
43981 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
43982 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
43983 ,p_ae_header_id => NULL
43984 );
43985
43986 IF (C_LEVEL_ERROR>= g_log_level) THEN
43987 trace
43988 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43989 ,p_level => C_LEVEL_ERROR
43990 ,p_module => l_log_module);
43991 END IF;
43992 END IF;
43993 END IF;
43994 --
43995 --
43996 ------------------------------------------------------------------------------------------------
43997 -- 4219869 Business Flow
43998 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
43999 -- Prior Entry. Currently, the following code is always generated.
44000 ------------------------------------------------------------------------------------------------
44001 XLA_AE_LINES_PKG.ValidateCurrentLine;
44002
44003 ------------------------------------------------------------------------------------
44004 -- 4219869 Business Flow
44005 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
44006 ------------------------------------------------------------------------------------
44007 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
44008
44009 ----------------------------------------------------------------------------------
44010 -- 4219869 Business Flow
44011 -- Update journal entry status -- Need to generate this within IF <condition>
44012 ----------------------------------------------------------------------------------
44013 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
44014 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
44015 ,p_balance_type_code => l_balance_type_code
44016 );
44017
44018 -------------------------------------------------------------------------------------------
44022 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
44019 -- 4262811 - Generate the Accrual Reversal lines
44020 -------------------------------------------------------------------------------------------
44021 BEGIN
44023 (g_array_event(p_event_id).array_value_num('header_index'));
44024 IF l_acc_rev_flag IS NULL THEN
44025 l_acc_rev_flag := 'N';
44026 END IF;
44027 EXCEPTION
44028 WHEN OTHERS THEN
44029 l_acc_rev_flag := 'N';
44030 END;
44031 --
44032 IF (l_acc_rev_flag = 'Y') THEN
44033
44034 -- 4645092 ------------------------------------------------------------------------------
44035 -- To allow MPA report to determine if it should generate report process
44036 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
44037 ------------------------------------------------------------------------------------------
44038
44039 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
44040 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
44041 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
44042 -- call ADRs
44043 -- Bug 4922099
44044 --
44045 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
44046 (NVL(l_actual_upg_option, 'N') = 'O') OR
44047 (NVL(l_enc_upg_option, 'N') = 'O')
44048 )
44049 THEN
44050 NULL;
44051 --
44052 --
44053
44054 l_ccid := AcctDerRule_28(
44055 p_application_id => p_application_id
44056 , p_ae_header_id => l_ae_header_id
44057 , p_source_5 => p_source_5
44058 , x_transaction_coa_id => l_adr_transaction_coa_id
44059 , x_accounting_coa_id => l_adr_accounting_coa_id
44060 , x_value_type_code => l_adr_value_type_code
44061 , p_side => 'NA'
44062 );
44063
44064 xla_ae_lines_pkg.set_ccid(
44065 p_code_combination_id => l_ccid
44066 , p_value_type_code => l_adr_value_type_code
44067 , p_transaction_coa_id => l_adr_transaction_coa_id
44068 , p_accounting_coa_id => l_adr_accounting_coa_id
44069 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
44070 , p_adr_type_code => 'S'
44071 , p_component_type => l_component_type
44072 , p_component_code => l_component_code
44073 , p_component_type_code => l_component_type_code
44074 , p_component_appl_id => l_component_appl_id
44075 , p_amb_context_code => l_amb_context_code
44076 , p_side => 'NA'
44077 );
44078
44079
44080 --
44081 --
44082 END IF;
44083
44084 --
44085 -- Update the line information that should be overwritten
44086 --
44087 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
44088 p_header_num => 1);
44089 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
44090
44091 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
44092
44093 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
44094 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
44095 END IF;
44096
44097 --
44098 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
44099 --
44100 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
44101 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
44102 ELSE
44103 ---------------------------------------------------------------------------------------------------
44104 -- 4262811a Switch Sign
44105 ---------------------------------------------------------------------------------------------------
44106 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
44107 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
44108 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44109 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
44110 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44111 -- 5132302
44112 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
44113 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44114
44115 END IF;
44116
44117 -- 4955764
44118 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
44119 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
44120
44121
44122 XLA_AE_LINES_PKG.ValidateCurrentLine;
44123 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
44124
44125 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
44126 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
44127 ,p_balance_type_code => l_balance_type_code);
44128
44129 END IF;
44130
44134 -- No MPA option is assigned.
44131 -----------------------------------------------------------------------------------------
44132 -- 4262811 Multiperiod Accounting
44133 -----------------------------------------------------------------------------------------
44135
44136
44137 END IF;
44138 END IF;
44139 --
44140
44141 --
44142 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44143 trace
44144 (p_msg => 'END of AcctLineType_98'
44145 ,p_level => C_LEVEL_PROCEDURE
44146 ,p_module => l_log_module);
44147 END IF;
44148 --
44149 EXCEPTION
44150 WHEN xla_exceptions_pkg.application_exception THEN
44151 RAISE;
44152 WHEN OTHERS THEN
44153 xla_exceptions_pkg.raise_message
44154 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_98');
44155 END AcctLineType_98;
44156 --
44157
44158 ---------------------------------------
44159 --
44160 -- PRIVATE FUNCTION
44161 -- AcctLineType_99
44162 --
44163 ---------------------------------------
44164 PROCEDURE AcctLineType_99 (
44165 p_application_id IN NUMBER
44166 ,p_event_id IN NUMBER
44167 ,p_calculate_acctd_flag IN VARCHAR2
44168 ,p_calculate_g_l_flag IN VARCHAR2
44169 ,p_actual_flag IN OUT VARCHAR2
44170 ,p_balance_type_code OUT VARCHAR2
44171 ,p_gain_or_loss_ref OUT VARCHAR2
44172
44173 --Remittance Bank Account Confirmation Account
44174 , p_source_3 IN NUMBER
44175 --Distribution Source Type
44176 , p_source_22 IN VARCHAR2
44177 --Distribution Line Identifier
44178 , p_source_24 IN NUMBER
44179 --Distribution Type
44180 , p_source_25 IN VARCHAR2
44181 --Exchange Date
44182 , p_source_28 IN DATE
44183 --Exchange Rate
44184 , p_source_29 IN NUMBER
44185 --Exchange Rate Type
44186 , p_source_30 IN VARCHAR2
44187 --Transaction Distribution Identifier
44188 , p_source_36 IN NUMBER
44189 --Transaction Distribution Type
44190 , p_source_37 IN VARCHAR2
44191 --Receipt Applied To Application Identifier
44192 , p_source_60 IN NUMBER
44193 --Transaction Entity Code
44194 , p_source_61 IN VARCHAR2
44195 --Transaction Identifier
44196 , p_source_62 IN NUMBER
44197 --Applying Document Currency Code
44198 , p_source_63 IN VARCHAR2
44199 --Distribution Party Identifier
44200 , p_source_65 IN NUMBER
44201 --Distribution Party Site Id
44202 , p_source_66 IN NUMBER
44203 --Distribution Party Type
44204 , p_source_67 IN VARCHAR2
44205 --Distribution Multi Fund Additional Entry
44206 , p_source_71 IN VARCHAR2
44207 --DIST_ENT_AMT_FROM
44208 , p_source_74 IN NUMBER
44209 --Accounting Amount
44210 , p_source_75 IN NUMBER
44211 )
44212 IS
44213
44214 l_component_type VARCHAR2(80);
44215 l_component_code VARCHAR2(30);
44216 l_component_type_code VARCHAR2(1);
44217 l_component_appl_id INTEGER;
44218 l_amb_context_code VARCHAR2(30);
44219 l_entity_code VARCHAR2(30);
44220 l_event_class_code VARCHAR2(30);
44221 l_ae_header_id NUMBER;
44222 l_event_type_code VARCHAR2(30);
44223 l_line_definition_code VARCHAR2(30);
44224 l_line_definition_owner_code VARCHAR2(1);
44225 --
44226 -- adr variables
44227 l_segment VARCHAR2(30);
44228 l_ccid NUMBER;
44229 l_adr_transaction_coa_id NUMBER;
44230 l_adr_accounting_coa_id NUMBER;
44231 l_adr_flexfield_segment_code VARCHAR2(30);
44232 l_adr_flex_value_set_id NUMBER;
44233 l_adr_value_type_code VARCHAR2(30);
44234 l_adr_value_combination_id NUMBER;
44235 l_adr_value_segment_code VARCHAR2(30);
44236
44237 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
44238 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
44239 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
44240 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
44241
44242 -- 4262811 Variables ------------------------------------------------------------------------------------------
44243 l_entered_amt_idx NUMBER;
44244 l_accted_amt_idx NUMBER;
44245 l_acc_rev_flag VARCHAR2(1);
44246 l_accrual_line_num NUMBER;
44247 l_tmp_amt NUMBER;
44248 l_acc_rev_natural_side_code VARCHAR2(1);
44249
44250 l_num_entries NUMBER;
44251 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
44252 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
44253 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
44254 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
44255 l_recog_line_1 NUMBER;
44256 l_recog_line_2 NUMBER;
44257
44258 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
44259 l_bflow_applied_to_amt NUMBER; -- 5132302
44260 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
44261
44262 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
44263
44264 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
44268
44265 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
44266
44267 ---------------------------------------------------------------------------------------------------------------
44269
44270 --
44271 -- bulk performance
44272 --
44273 l_balance_type_code VARCHAR2(1);
44274 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
44275 l_log_module VARCHAR2(240);
44276
44277 --
44278 -- Upgrade strategy
44279 --
44280 l_actual_upg_option VARCHAR2(1);
44281 l_enc_upg_option VARCHAR2(1);
44282
44283 --
44284 BEGIN
44285 --
44286 IF g_log_enabled THEN
44287 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_99';
44288 END IF;
44289 --
44290 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44291
44292 trace
44293 (p_msg => 'BEGIN of AcctLineType_99'
44294 ,p_level => C_LEVEL_PROCEDURE
44295 ,p_module => l_log_module);
44296
44297 END IF;
44298 --
44299 l_component_type := 'AMB_JLT';
44300 l_component_code := 'MFAR_RCT_CONFIRM_REVERSAL';
44301 l_component_type_code := 'S';
44302 l_component_appl_id := 222;
44303 l_amb_context_code := 'DEFAULT';
44304 l_entity_code := 'RECEIPTS';
44305 l_event_class_code := 'RECEIPT';
44306 l_event_type_code := 'RECEIPT_ALL';
44307 l_line_definition_owner_code := 'S';
44308 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
44309 --
44310 l_balance_type_code := 'A';
44311 l_segment := NULL;
44312 l_ccid := NULL;
44313 l_adr_transaction_coa_id := NULL;
44314 l_adr_accounting_coa_id := NULL;
44315 l_adr_flexfield_segment_code := NULL;
44316 l_adr_flex_value_set_id := NULL;
44317 l_adr_value_type_code := NULL;
44318 l_adr_value_combination_id := NULL;
44319 l_adr_value_segment_code := NULL;
44320
44321 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
44322 l_bflow_class_code := ''; -- 4219869 Business Flow
44323 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
44324 l_budgetary_control_flag := 'N';
44325
44326 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44327 l_bflow_applied_to_amt := NULL; -- 5132302
44328 l_entered_amt_idx := NULL; -- 4262811
44329 l_accted_amt_idx := NULL; -- 4262811
44330 l_acc_rev_flag := NULL; -- 4262811
44331 l_accrual_line_num := NULL; -- 4262811
44332 l_tmp_amt := NULL; -- 4262811
44333 --
44334
44335 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
44336 l_balance_type_code <> 'B' THEN
44337 IF NVL(p_source_22,'
44338 ') = 'CONFIRMATION' AND
44339 NVL(p_source_71,'
44340 ') = 'Y'
44341 THEN
44342
44343 --
44344 XLA_AE_LINES_PKG.SetNewLine;
44345
44346 p_balance_type_code := l_balance_type_code;
44347 -- set the flag so later we will know whether the gain loss line needs to be created
44348
44349 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
44350 p_actual_flag :='A';
44351 END IF;
44352
44353 --
44354 -- bulk performance
44355 --
44356 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
44357 p_header_num => 0); -- 4262811
44358 --
44359 -- set accounting line options
44360 --
44361 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
44362 p_natural_side_code => 'D'
44363 , p_gain_or_loss_flag => 'N'
44364 , p_gl_transfer_mode_code => 'S'
44365 , p_acct_entry_type_code => 'A'
44366 , p_switch_side_flag => 'Y'
44367 , p_merge_duplicate_code => 'A'
44368 );
44369 --
44370 l_acc_rev_natural_side_code := 'C'; -- 4262811
44371 --
44372 --
44373 -- set accounting line type info
44374 --
44375 xla_ae_lines_pkg.SetAcctLineType
44376 (p_component_type => l_component_type
44377 ,p_event_type_code => l_event_type_code
44378 ,p_line_definition_owner_code => l_line_definition_owner_code
44379 ,p_line_definition_code => l_line_definition_code
44380 ,p_accounting_line_code => l_component_code
44381 ,p_accounting_line_type_code => l_component_type_code
44382 ,p_accounting_line_appl_id => l_component_appl_id
44383 ,p_amb_context_code => l_amb_context_code
44384 ,p_entity_code => l_entity_code
44385 ,p_event_class_code => l_event_class_code);
44386 --
44387 -- set accounting class
44388 --
44389 xla_ae_lines_pkg.SetAcctClass(
44390 p_accounting_class_code => 'CONFIRMATION'
44391 , p_ae_header_id => l_ae_header_id
44392 );
44393
44394 --
44395 -- set rounding class
44396 --
44397 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
44398 'RECEIVABLE';
44399
44400 --
44401 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
44405 --
44402 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
44403 --
44404 -- bulk performance
44406 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
44407
44408 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
44409 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
44410
44411 -- 4955764
44412 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
44413 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
44414
44415 -- 4458381 Public Sector Enh
44416
44417 --
44418 -- set accounting attributes for the line type
44419 --
44420 l_entered_amt_idx := 8;
44421 l_accted_amt_idx := 13;
44422 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44423 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
44424 l_rec_acct_attrs.array_num_value(1) := p_source_60;
44425 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
44426 l_rec_acct_attrs.array_char_value(2) := p_source_37;
44427 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
44428 l_rec_acct_attrs.array_char_value(3) := p_source_61;
44429 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
44430 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
44431 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
44432 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
44433 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
44434 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
44435 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
44436 l_rec_acct_attrs.array_char_value(7) := p_source_25;
44437 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
44438 l_rec_acct_attrs.array_num_value(8) := p_source_74;
44439 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
44440 l_rec_acct_attrs.array_char_value(9) := p_source_63;
44441 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
44442 l_rec_acct_attrs.array_date_value(10) := p_source_28;
44443 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
44444 l_rec_acct_attrs.array_num_value(11) := p_source_29;
44445 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
44446 l_rec_acct_attrs.array_char_value(12) := p_source_30;
44447 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
44448 l_rec_acct_attrs.array_num_value(13) := p_source_75;
44449 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
44450 l_rec_acct_attrs.array_num_value(14) := p_source_65;
44451 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
44452 l_rec_acct_attrs.array_num_value(15) := p_source_66;
44453 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
44454 l_rec_acct_attrs.array_char_value(16) := p_source_67;
44455
44456 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
44457 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
44458
44459 ---------------------------------------------------------------------------------------------------------------
44460 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
44461 ---------------------------------------------------------------------------------------------------------------
44462 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
44463
44464 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
44465 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
44466
44467 IF xla_accounting_cache_pkg.GetValueChar
44468 (p_source_code => 'LEDGER_CATEGORY_CODE'
44469 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
44470 AND l_bflow_method_code = 'PRIOR_ENTRY'
44471 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
44472 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
44473 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
44474 )
44475 THEN
44476 xla_ae_lines_pkg.BflowUpgEntry
44477 (p_business_method_code => l_bflow_method_code
44478 ,p_business_class_code => l_bflow_class_code
44479 ,p_balance_type => l_balance_type_code);
44480 ELSE
44481 NULL;
44482 -- No business flow processing for business flow method of NONE.
44483 END IF;
44484
44485 --
44486 -- call analytical criteria
44487 --
44488
44489 --
44490 -- call description
44491 --
44492
44493 xla_ae_lines_pkg.SetLineDescription(
44494 p_ae_header_id => l_ae_header_id
44495 ,p_description => Description_1 (
44496 p_application_id => p_application_id
44497 , p_ae_header_id => l_ae_header_id
44498 )
44499 );
44500
44501
44502 --
44503 -- call ADRs
44504 -- Bug 4922099
44505 --
44506 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
44507 (NVL(l_actual_upg_option, 'N') = 'O') OR
44511 NULL;
44508 (NVL(l_enc_upg_option, 'N') = 'O')
44509 )
44510 THEN
44512 --
44513 --
44514
44515 l_ccid := AcctDerRule_29(
44516 p_application_id => p_application_id
44517 , p_ae_header_id => l_ae_header_id
44518 , p_source_3 => p_source_3
44519 , x_transaction_coa_id => l_adr_transaction_coa_id
44520 , x_accounting_coa_id => l_adr_accounting_coa_id
44521 , x_value_type_code => l_adr_value_type_code
44522 , p_side => 'NA'
44523 );
44524
44525 xla_ae_lines_pkg.set_ccid(
44526 p_code_combination_id => l_ccid
44527 , p_value_type_code => l_adr_value_type_code
44528 , p_transaction_coa_id => l_adr_transaction_coa_id
44529 , p_accounting_coa_id => l_adr_accounting_coa_id
44530 , p_adr_code => 'MFAR_RCT_DEF_CONFIRMATION_CCID'
44531 , p_adr_type_code => 'S'
44532 , p_component_type => l_component_type
44533 , p_component_code => l_component_code
44534 , p_component_type_code => l_component_type_code
44535 , p_component_appl_id => l_component_appl_id
44536 , p_amb_context_code => l_amb_context_code
44537 , p_side => 'NA'
44538 );
44539
44540
44541 --
44542 --
44543 END IF;
44544 --
44545 -- Bug 4922099
44546 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
44547 (NVL(l_enc_upg_option, 'N') = 'O')
44548 ) AND
44549 (l_bflow_method_code = 'PRIOR_ENTRY')
44550 )
44551 THEN
44552 IF
44553 --
44554 1 = 2
44555 --
44556 THEN
44557 xla_accounting_err_pkg.build_message
44558 (p_appli_s_name => 'XLA'
44559 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
44560 ,p_token_1 => 'LINE_NUMBER'
44561 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
44562 ,p_token_2 => 'LINE_TYPE_NAME'
44563 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
44564 l_component_type
44565 ,l_component_code
44566 ,l_component_type_code
44567 ,l_component_appl_id
44568 ,l_amb_context_code
44569 ,l_entity_code
44570 ,l_event_class_code
44571 )
44572 ,p_token_3 => 'OWNER'
44573 ,p_value_3 => xla_lookups_pkg.get_meaning(
44574 p_lookup_type => 'XLA_OWNER_TYPE'
44575 ,p_lookup_code => l_component_type_code
44576 )
44577 ,p_token_4 => 'PRODUCT_NAME'
44578 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
44579 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
44580 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
44581 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
44582 ,p_ae_header_id => NULL
44583 );
44584
44585 IF (C_LEVEL_ERROR>= g_log_level) THEN
44586 trace
44587 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
44588 ,p_level => C_LEVEL_ERROR
44589 ,p_module => l_log_module);
44590 END IF;
44591 END IF;
44592 END IF;
44593 --
44594 --
44595 ------------------------------------------------------------------------------------------------
44596 -- 4219869 Business Flow
44597 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
44598 -- Prior Entry. Currently, the following code is always generated.
44599 ------------------------------------------------------------------------------------------------
44600 XLA_AE_LINES_PKG.ValidateCurrentLine;
44601
44602 ------------------------------------------------------------------------------------
44603 -- 4219869 Business Flow
44604 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
44605 ------------------------------------------------------------------------------------
44606 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
44607
44608 ----------------------------------------------------------------------------------
44612 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
44609 -- 4219869 Business Flow
44610 -- Update journal entry status -- Need to generate this within IF <condition>
44611 ----------------------------------------------------------------------------------
44613 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
44614 ,p_balance_type_code => l_balance_type_code
44615 );
44616
44617 -------------------------------------------------------------------------------------------
44618 -- 4262811 - Generate the Accrual Reversal lines
44619 -------------------------------------------------------------------------------------------
44620 BEGIN
44621 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
44622 (g_array_event(p_event_id).array_value_num('header_index'));
44623 IF l_acc_rev_flag IS NULL THEN
44624 l_acc_rev_flag := 'N';
44625 END IF;
44626 EXCEPTION
44627 WHEN OTHERS THEN
44628 l_acc_rev_flag := 'N';
44629 END;
44630 --
44631 IF (l_acc_rev_flag = 'Y') THEN
44632
44633 -- 4645092 ------------------------------------------------------------------------------
44634 -- To allow MPA report to determine if it should generate report process
44635 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
44636 ------------------------------------------------------------------------------------------
44637
44638 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
44639 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
44640 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
44641 -- call ADRs
44642 -- Bug 4922099
44643 --
44644 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
44645 (NVL(l_actual_upg_option, 'N') = 'O') OR
44646 (NVL(l_enc_upg_option, 'N') = 'O')
44647 )
44648 THEN
44649 NULL;
44650 --
44651 --
44652
44653 l_ccid := AcctDerRule_29(
44654 p_application_id => p_application_id
44655 , p_ae_header_id => l_ae_header_id
44656 , p_source_3 => p_source_3
44657 , x_transaction_coa_id => l_adr_transaction_coa_id
44658 , x_accounting_coa_id => l_adr_accounting_coa_id
44659 , x_value_type_code => l_adr_value_type_code
44660 , p_side => 'NA'
44661 );
44662
44663 xla_ae_lines_pkg.set_ccid(
44664 p_code_combination_id => l_ccid
44665 , p_value_type_code => l_adr_value_type_code
44666 , p_transaction_coa_id => l_adr_transaction_coa_id
44667 , p_accounting_coa_id => l_adr_accounting_coa_id
44668 , p_adr_code => 'MFAR_RCT_DEF_CONFIRMATION_CCID'
44669 , p_adr_type_code => 'S'
44670 , p_component_type => l_component_type
44671 , p_component_code => l_component_code
44672 , p_component_type_code => l_component_type_code
44673 , p_component_appl_id => l_component_appl_id
44674 , p_amb_context_code => l_amb_context_code
44675 , p_side => 'NA'
44676 );
44677
44678
44679 --
44680 --
44681 END IF;
44682
44683 --
44684 -- Update the line information that should be overwritten
44685 --
44686 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
44687 p_header_num => 1);
44688 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
44689
44690 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
44691
44692 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
44693 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
44694 END IF;
44695
44696 --
44697 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
44698 --
44699 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
44700 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
44701 ELSE
44702 ---------------------------------------------------------------------------------------------------
44703 -- 4262811a Switch Sign
44704 ---------------------------------------------------------------------------------------------------
44705 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
44706 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
44707 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44708 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
44709 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44710 -- 5132302
44711 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
44712 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44713
44714 END IF;
44715
44716 -- 4955764
44717 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
44721 XLA_AE_LINES_PKG.ValidateCurrentLine;
44718 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
44719
44720
44722 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
44723
44724 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
44725 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
44726 ,p_balance_type_code => l_balance_type_code);
44727
44728 END IF;
44729
44730 -----------------------------------------------------------------------------------------
44731 -- 4262811 Multiperiod Accounting
44732 -----------------------------------------------------------------------------------------
44733 -- No MPA option is assigned.
44734
44735
44736 END IF;
44737 END IF;
44738 --
44739
44740 --
44741 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44742 trace
44743 (p_msg => 'END of AcctLineType_99'
44744 ,p_level => C_LEVEL_PROCEDURE
44745 ,p_module => l_log_module);
44746 END IF;
44747 --
44748 EXCEPTION
44749 WHEN xla_exceptions_pkg.application_exception THEN
44750 RAISE;
44751 WHEN OTHERS THEN
44752 xla_exceptions_pkg.raise_message
44753 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_99');
44754 END AcctLineType_99;
44755 --
44756
44757 ---------------------------------------
44758 --
44759 -- PRIVATE FUNCTION
44760 -- AcctLineType_100
44761 --
44762 ---------------------------------------
44763 PROCEDURE AcctLineType_100 (
44764 p_application_id IN NUMBER
44765 ,p_event_id IN NUMBER
44766 ,p_calculate_acctd_flag IN VARCHAR2
44767 ,p_calculate_g_l_flag IN VARCHAR2
44768 ,p_actual_flag IN OUT VARCHAR2
44769 ,p_balance_type_code OUT VARCHAR2
44770 ,p_gain_or_loss_ref OUT VARCHAR2
44771
44772 --Distribution Source Type
44773 , p_source_22 IN VARCHAR2
44774 --Distribution Line Identifier
44775 , p_source_24 IN NUMBER
44776 --Distribution Type
44777 , p_source_25 IN VARCHAR2
44778 --Entered Amount
44779 , p_source_26 IN NUMBER
44780 --Currency Code
44781 , p_source_27 IN VARCHAR2
44782 --Applied To Document Accounting Amount
44783 , p_source_31 IN NUMBER
44784 --Transaction Distribution Identifier
44785 , p_source_36 IN NUMBER
44786 --Transaction Distribution Type
44787 , p_source_37 IN VARCHAR2
44788 --Receipt Applied To Application Identifier
44789 , p_source_60 IN NUMBER
44790 --Transaction Entity Code
44791 , p_source_61 IN VARCHAR2
44792 --Transaction Identifier
44793 , p_source_62 IN NUMBER
44794 --Distribution Party Type
44795 , p_source_67 IN VARCHAR2
44796 --Distribution Multi Fund Additional Entry
44797 , p_source_71 IN VARCHAR2
44798 )
44799 IS
44800
44801 l_component_type VARCHAR2(80);
44802 l_component_code VARCHAR2(30);
44803 l_component_type_code VARCHAR2(1);
44804 l_component_appl_id INTEGER;
44805 l_amb_context_code VARCHAR2(30);
44806 l_entity_code VARCHAR2(30);
44807 l_event_class_code VARCHAR2(30);
44808 l_ae_header_id NUMBER;
44809 l_event_type_code VARCHAR2(30);
44810 l_line_definition_code VARCHAR2(30);
44811 l_line_definition_owner_code VARCHAR2(1);
44812 --
44813 -- adr variables
44814 l_segment VARCHAR2(30);
44815 l_ccid NUMBER;
44816 l_adr_transaction_coa_id NUMBER;
44817 l_adr_accounting_coa_id NUMBER;
44818 l_adr_flexfield_segment_code VARCHAR2(30);
44819 l_adr_flex_value_set_id NUMBER;
44820 l_adr_value_type_code VARCHAR2(30);
44821 l_adr_value_combination_id NUMBER;
44822 l_adr_value_segment_code VARCHAR2(30);
44823
44824 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
44825 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
44826 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
44827 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
44828
44829 -- 4262811 Variables ------------------------------------------------------------------------------------------
44830 l_entered_amt_idx NUMBER;
44831 l_accted_amt_idx NUMBER;
44832 l_acc_rev_flag VARCHAR2(1);
44833 l_accrual_line_num NUMBER;
44834 l_tmp_amt NUMBER;
44835 l_acc_rev_natural_side_code VARCHAR2(1);
44836
44837 l_num_entries NUMBER;
44838 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
44839 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
44840 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
44841 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
44842 l_recog_line_1 NUMBER;
44843 l_recog_line_2 NUMBER;
44844
44845 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
44846 l_bflow_applied_to_amt NUMBER; -- 5132302
44847 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
44848
44849 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
44850
44854 ---------------------------------------------------------------------------------------------------------------
44851 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
44852 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
44853
44855
44856
44857 --
44858 -- bulk performance
44859 --
44860 l_balance_type_code VARCHAR2(1);
44861 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
44862 l_log_module VARCHAR2(240);
44863
44864 --
44865 -- Upgrade strategy
44866 --
44867 l_actual_upg_option VARCHAR2(1);
44868 l_enc_upg_option VARCHAR2(1);
44869
44870 --
44871 BEGIN
44872 --
44873 IF g_log_enabled THEN
44874 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_100';
44875 END IF;
44876 --
44877 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44878
44879 trace
44880 (p_msg => 'BEGIN of AcctLineType_100'
44881 ,p_level => C_LEVEL_PROCEDURE
44882 ,p_module => l_log_module);
44883
44884 END IF;
44885 --
44886 l_component_type := 'AMB_JLT';
44887 l_component_code := 'MFAR_RCT_EDISC_REC';
44888 l_component_type_code := 'S';
44889 l_component_appl_id := 222;
44890 l_amb_context_code := 'DEFAULT';
44891 l_entity_code := 'RECEIPTS';
44892 l_event_class_code := 'RECEIPT';
44893 l_event_type_code := 'RECEIPT_ALL';
44894 l_line_definition_owner_code := 'S';
44895 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
44896 --
44897 l_balance_type_code := 'A';
44898 l_segment := NULL;
44899 l_ccid := NULL;
44900 l_adr_transaction_coa_id := NULL;
44901 l_adr_accounting_coa_id := NULL;
44902 l_adr_flexfield_segment_code := NULL;
44903 l_adr_flex_value_set_id := NULL;
44904 l_adr_value_type_code := NULL;
44905 l_adr_value_combination_id := NULL;
44906 l_adr_value_segment_code := NULL;
44907
44908 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
44909 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
44910 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
44911 l_budgetary_control_flag := 'N';
44912
44913 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44914 l_bflow_applied_to_amt := NULL; -- 5132302
44915 l_entered_amt_idx := NULL; -- 4262811
44916 l_accted_amt_idx := NULL; -- 4262811
44917 l_acc_rev_flag := NULL; -- 4262811
44918 l_accrual_line_num := NULL; -- 4262811
44919 l_tmp_amt := NULL; -- 4262811
44920 --
44921
44922 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
44923 l_balance_type_code <> 'B' THEN
44924 IF NVL(p_source_22,'
44925 ') = 'EDISC' AND
44926 NVL(p_source_71,'
44927 ') = 'N'
44928 THEN
44929
44930 --
44931 XLA_AE_LINES_PKG.SetNewLine;
44932
44933 p_balance_type_code := l_balance_type_code;
44934 -- set the flag so later we will know whether the gain loss line needs to be created
44935
44936 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
44937 p_actual_flag :='A';
44938 END IF;
44939
44940 --
44941 -- bulk performance
44942 --
44943 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
44944 p_header_num => 0); -- 4262811
44945 --
44946 -- set accounting line options
44947 --
44948 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
44949 p_natural_side_code => 'D'
44950 , p_gain_or_loss_flag => 'N'
44951 , p_gl_transfer_mode_code => 'S'
44952 , p_acct_entry_type_code => 'A'
44953 , p_switch_side_flag => 'Y'
44954 , p_merge_duplicate_code => 'A'
44955 );
44956 --
44957 l_acc_rev_natural_side_code := 'C'; -- 4262811
44958 --
44959 --
44960 -- set accounting line type info
44961 --
44962 xla_ae_lines_pkg.SetAcctLineType
44963 (p_component_type => l_component_type
44964 ,p_event_type_code => l_event_type_code
44965 ,p_line_definition_owner_code => l_line_definition_owner_code
44966 ,p_line_definition_code => l_line_definition_code
44967 ,p_accounting_line_code => l_component_code
44968 ,p_accounting_line_type_code => l_component_type_code
44969 ,p_accounting_line_appl_id => l_component_appl_id
44970 ,p_amb_context_code => l_amb_context_code
44971 ,p_entity_code => l_entity_code
44972 ,p_event_class_code => l_event_class_code);
44973 --
44974 -- set accounting class
44975 --
44976 xla_ae_lines_pkg.SetAcctClass(
44977 p_accounting_class_code => 'RECEIVABLE'
44978 , p_ae_header_id => l_ae_header_id
44979 );
44980
44981 --
44982 -- set rounding class
44983 --
44984 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
44985 'RECEIVABLE';
44986
44987 --
44991 -- bulk performance
44988 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
44989 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
44990 --
44992 --
44993 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
44994
44995 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
44996 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
44997
44998 -- 4955764
44999 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45000 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
45001
45002 -- 4458381 Public Sector Enh
45003
45004 --
45005 -- set accounting attributes for the line type
45006 --
45007 l_entered_amt_idx := 8;
45008 l_accted_amt_idx := 10;
45009 l_bflow_applied_to_amt_idx := NULL; -- 5132302
45010 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
45011 l_rec_acct_attrs.array_num_value(1) := p_source_60;
45012 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
45013 l_rec_acct_attrs.array_char_value(2) := p_source_37;
45014 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
45015 l_rec_acct_attrs.array_char_value(3) := p_source_61;
45016 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
45017 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
45018 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
45019 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
45020 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
45021 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
45022 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
45023 l_rec_acct_attrs.array_char_value(7) := p_source_25;
45024 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
45025 l_rec_acct_attrs.array_num_value(8) := p_source_26;
45026 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
45027 l_rec_acct_attrs.array_char_value(9) := p_source_27;
45028 l_rec_acct_attrs.array_acct_attr_code(10) := 'LEDGER_AMOUNT';
45029 l_rec_acct_attrs.array_num_value(10) := p_source_31;
45030 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
45031 l_rec_acct_attrs.array_char_value(11) := p_source_67;
45032
45033 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
45034 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
45035
45036 ---------------------------------------------------------------------------------------------------------------
45037 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
45038 ---------------------------------------------------------------------------------------------------------------
45039 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
45040
45041 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45042 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45043
45044 IF xla_accounting_cache_pkg.GetValueChar
45045 (p_source_code => 'LEDGER_CATEGORY_CODE'
45046 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
45047 AND l_bflow_method_code = 'PRIOR_ENTRY'
45048 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
45049 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
45050 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
45051 )
45052 THEN
45053 xla_ae_lines_pkg.BflowUpgEntry
45054 (p_business_method_code => l_bflow_method_code
45055 ,p_business_class_code => l_bflow_class_code
45056 ,p_balance_type => l_balance_type_code);
45057 ELSE
45058 NULL;
45059 XLA_AE_LINES_PKG.business_flow_validation(
45060 p_business_method_code => l_bflow_method_code
45061 ,p_business_class_code => l_bflow_class_code
45062 ,p_inherit_description_flag => l_inherit_desc_flag);
45063 END IF;
45064
45065 --
45066 -- call analytical criteria
45067 --
45068 -- Inherited Analytical Criteria for business flow method of Prior Entry.
45069 --
45070 -- call description
45071 --
45072
45073 xla_ae_lines_pkg.SetLineDescription(
45074 p_ae_header_id => l_ae_header_id
45075 ,p_description => Description_1 (
45076 p_application_id => p_application_id
45077 , p_ae_header_id => l_ae_header_id
45078 )
45079 );
45080
45081
45082 --
45083 -- call ADRs
45084 -- Bug 4922099
45085 --
45086 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45087 (NVL(l_actual_upg_option, 'N') = 'O') OR
45088 (NVL(l_enc_upg_option, 'N') = 'O')
45089 )
45090 THEN
45091 NULL;
45092 --
45093 --
45094
45095 --
45096 --
45097 END IF;
45098 --
45099 -- Bug 4922099
45100 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
45104 )
45101 (NVL(l_enc_upg_option, 'N') = 'O')
45102 ) AND
45103 (l_bflow_method_code = 'PRIOR_ENTRY')
45105 THEN
45106 IF
45107 --
45108 1 = 1
45109 --
45110 THEN
45111 xla_accounting_err_pkg.build_message
45112 (p_appli_s_name => 'XLA'
45113 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
45114 ,p_token_1 => 'LINE_NUMBER'
45115 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
45116 ,p_token_2 => 'LINE_TYPE_NAME'
45117 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
45118 l_component_type
45119 ,l_component_code
45120 ,l_component_type_code
45121 ,l_component_appl_id
45122 ,l_amb_context_code
45123 ,l_entity_code
45124 ,l_event_class_code
45125 )
45126 ,p_token_3 => 'OWNER'
45127 ,p_value_3 => xla_lookups_pkg.get_meaning(
45128 p_lookup_type => 'XLA_OWNER_TYPE'
45129 ,p_lookup_code => l_component_type_code
45130 )
45131 ,p_token_4 => 'PRODUCT_NAME'
45132 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
45133 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
45134 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
45135 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
45136 ,p_ae_header_id => NULL
45137 );
45138
45139 IF (C_LEVEL_ERROR>= g_log_level) THEN
45140 trace
45141 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
45142 ,p_level => C_LEVEL_ERROR
45143 ,p_module => l_log_module);
45144 END IF;
45145 END IF;
45146 END IF;
45147 --
45148 --
45149 ------------------------------------------------------------------------------------------------
45150 -- 4219869 Business Flow
45151 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
45152 -- Prior Entry. Currently, the following code is always generated.
45153 ------------------------------------------------------------------------------------------------
45154 -- No ValidateCurrentLine for business flow method of Prior Entry
45155
45156 ------------------------------------------------------------------------------------
45157 -- 4219869 Business Flow
45158 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
45159 ------------------------------------------------------------------------------------
45160 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45161
45162 ----------------------------------------------------------------------------------
45163 -- 4219869 Business Flow
45164 -- Update journal entry status -- Need to generate this within IF <condition>
45165 ----------------------------------------------------------------------------------
45166 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45167 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
45168 ,p_balance_type_code => l_balance_type_code
45169 );
45170
45171 -------------------------------------------------------------------------------------------
45172 -- 4262811 - Generate the Accrual Reversal lines
45173 -------------------------------------------------------------------------------------------
45174 BEGIN
45175 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
45176 (g_array_event(p_event_id).array_value_num('header_index'));
45177 IF l_acc_rev_flag IS NULL THEN
45178 l_acc_rev_flag := 'N';
45179 END IF;
45180 EXCEPTION
45181 WHEN OTHERS THEN
45182 l_acc_rev_flag := 'N';
45183 END;
45184 --
45185 IF (l_acc_rev_flag = 'Y') THEN
45186
45187 -- 4645092 ------------------------------------------------------------------------------
45188 -- To allow MPA report to determine if it should generate report process
45189 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
45190 ------------------------------------------------------------------------------------------
45191
45192 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
45196 -- Bug 4922099
45193 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
45194 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
45195 -- call ADRs
45197 --
45198 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45199 (NVL(l_actual_upg_option, 'N') = 'O') OR
45200 (NVL(l_enc_upg_option, 'N') = 'O')
45201 )
45202 THEN
45203 NULL;
45204 --
45205 --
45206
45207 --
45208 --
45209 END IF;
45210
45211 --
45212 -- Update the line information that should be overwritten
45213 --
45214 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
45215 p_header_num => 1);
45216 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
45217
45218 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
45219
45220 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
45221 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
45222 END IF;
45223
45224 --
45225 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
45226 --
45227 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
45228 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
45229 ELSE
45230 ---------------------------------------------------------------------------------------------------
45231 -- 4262811a Switch Sign
45232 ---------------------------------------------------------------------------------------------------
45233 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
45234 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45235 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45236 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45237 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45238 -- 5132302
45239 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
45240 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45241
45242 END IF;
45243
45244 -- 4955764
45245 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45246 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
45247
45248
45249 XLA_AE_LINES_PKG.ValidateCurrentLine;
45250 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45251
45252 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45253 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
45254 ,p_balance_type_code => l_balance_type_code);
45255
45256 END IF;
45257
45258 -----------------------------------------------------------------------------------------
45259 -- 4262811 Multiperiod Accounting
45260 -----------------------------------------------------------------------------------------
45261 -- No MPA option is assigned.
45262
45263
45264 END IF;
45265 END IF;
45266 --
45267
45268 --
45269 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45270 trace
45271 (p_msg => 'END of AcctLineType_100'
45272 ,p_level => C_LEVEL_PROCEDURE
45273 ,p_module => l_log_module);
45274 END IF;
45275 --
45276 EXCEPTION
45277 WHEN xla_exceptions_pkg.application_exception THEN
45278 RAISE;
45279 WHEN OTHERS THEN
45280 xla_exceptions_pkg.raise_message
45281 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_100');
45282 END AcctLineType_100;
45283 --
45284
45285 ---------------------------------------
45286 --
45287 -- PRIVATE FUNCTION
45288 -- AcctLineType_101
45289 --
45290 ---------------------------------------
45291 PROCEDURE AcctLineType_101 (
45292 p_application_id IN NUMBER
45293 ,p_event_id IN NUMBER
45294 ,p_calculate_acctd_flag IN VARCHAR2
45295 ,p_calculate_g_l_flag IN VARCHAR2
45296 ,p_actual_flag IN OUT VARCHAR2
45297 ,p_balance_type_code OUT VARCHAR2
45298 ,p_gain_or_loss_ref OUT VARCHAR2
45299
45300 --Remittance Bank Account Remittance Account
45301 , p_source_6 IN NUMBER
45302 --Distribution Source Type
45303 , p_source_22 IN VARCHAR2
45304 --Distribution Line Identifier
45305 , p_source_24 IN NUMBER
45306 --Distribution Type
45307 , p_source_25 IN VARCHAR2
45308 --Exchange Date
45309 , p_source_28 IN DATE
45310 --Exchange Rate
45311 , p_source_29 IN NUMBER
45312 --Exchange Rate Type
45313 , p_source_30 IN VARCHAR2
45314 --Transaction Distribution Identifier
45315 , p_source_36 IN NUMBER
45316 --Transaction Distribution Type
45317 , p_source_37 IN VARCHAR2
45318 --Receipt Applied To Application Identifier
45319 , p_source_60 IN NUMBER
45320 --Transaction Entity Code
45321 , p_source_61 IN VARCHAR2
45322 --Transaction Identifier
45326 --Distribution Party Identifier
45323 , p_source_62 IN NUMBER
45324 --Applying Document Currency Code
45325 , p_source_63 IN VARCHAR2
45327 , p_source_65 IN NUMBER
45328 --Distribution Party Site Id
45329 , p_source_66 IN NUMBER
45330 --Distribution Party Type
45331 , p_source_67 IN VARCHAR2
45332 --Distribution Multi Fund Additional Entry
45333 , p_source_71 IN VARCHAR2
45334 --DIST_ENT_AMT_FROM
45335 , p_source_74 IN NUMBER
45336 --Accounting Amount
45337 , p_source_75 IN NUMBER
45338 )
45339 IS
45340
45341 l_component_type VARCHAR2(80);
45342 l_component_code VARCHAR2(30);
45343 l_component_type_code VARCHAR2(1);
45344 l_component_appl_id INTEGER;
45345 l_amb_context_code VARCHAR2(30);
45346 l_entity_code VARCHAR2(30);
45347 l_event_class_code VARCHAR2(30);
45348 l_ae_header_id NUMBER;
45349 l_event_type_code VARCHAR2(30);
45350 l_line_definition_code VARCHAR2(30);
45351 l_line_definition_owner_code VARCHAR2(1);
45352 --
45353 -- adr variables
45354 l_segment VARCHAR2(30);
45355 l_ccid NUMBER;
45356 l_adr_transaction_coa_id NUMBER;
45357 l_adr_accounting_coa_id NUMBER;
45358 l_adr_flexfield_segment_code VARCHAR2(30);
45359 l_adr_flex_value_set_id NUMBER;
45360 l_adr_value_type_code VARCHAR2(30);
45361 l_adr_value_combination_id NUMBER;
45362 l_adr_value_segment_code VARCHAR2(30);
45363
45364 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
45365 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
45366 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
45367 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
45368
45369 -- 4262811 Variables ------------------------------------------------------------------------------------------
45370 l_entered_amt_idx NUMBER;
45371 l_accted_amt_idx NUMBER;
45372 l_acc_rev_flag VARCHAR2(1);
45373 l_accrual_line_num NUMBER;
45374 l_tmp_amt NUMBER;
45375 l_acc_rev_natural_side_code VARCHAR2(1);
45376
45377 l_num_entries NUMBER;
45378 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
45379 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
45380 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
45381 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
45382 l_recog_line_1 NUMBER;
45383 l_recog_line_2 NUMBER;
45384
45385 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
45386 l_bflow_applied_to_amt NUMBER; -- 5132302
45387 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
45388
45389 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
45390
45391 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
45392 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
45393
45394 ---------------------------------------------------------------------------------------------------------------
45395
45396
45397 --
45398 -- bulk performance
45399 --
45400 l_balance_type_code VARCHAR2(1);
45401 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
45402 l_log_module VARCHAR2(240);
45403
45404 --
45405 -- Upgrade strategy
45406 --
45407 l_actual_upg_option VARCHAR2(1);
45408 l_enc_upg_option VARCHAR2(1);
45409
45410 --
45411 BEGIN
45412 --
45413 IF g_log_enabled THEN
45414 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_101';
45415 END IF;
45416 --
45417 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45418
45419 trace
45420 (p_msg => 'BEGIN of AcctLineType_101'
45421 ,p_level => C_LEVEL_PROCEDURE
45422 ,p_module => l_log_module);
45423
45424 END IF;
45425 --
45426 l_component_type := 'AMB_JLT';
45427 l_component_code := 'MFAR_RCT_REMIT_REVERSAL';
45428 l_component_type_code := 'S';
45429 l_component_appl_id := 222;
45430 l_amb_context_code := 'DEFAULT';
45431 l_entity_code := 'RECEIPTS';
45432 l_event_class_code := 'RECEIPT';
45433 l_event_type_code := 'RECEIPT_ALL';
45434 l_line_definition_owner_code := 'S';
45435 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
45436 --
45437 l_balance_type_code := 'A';
45438 l_segment := NULL;
45439 l_ccid := NULL;
45440 l_adr_transaction_coa_id := NULL;
45441 l_adr_accounting_coa_id := NULL;
45442 l_adr_flexfield_segment_code := NULL;
45443 l_adr_flex_value_set_id := NULL;
45444 l_adr_value_type_code := NULL;
45445 l_adr_value_combination_id := NULL;
45446 l_adr_value_segment_code := NULL;
45447
45448 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
45449 l_bflow_class_code := ''; -- 4219869 Business Flow
45450 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
45451 l_budgetary_control_flag := 'N';
45452
45456 l_accted_amt_idx := NULL; -- 4262811
45453 l_bflow_applied_to_amt_idx := NULL; -- 5132302
45454 l_bflow_applied_to_amt := NULL; -- 5132302
45455 l_entered_amt_idx := NULL; -- 4262811
45457 l_acc_rev_flag := NULL; -- 4262811
45458 l_accrual_line_num := NULL; -- 4262811
45459 l_tmp_amt := NULL; -- 4262811
45460 --
45461
45462 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
45463 l_balance_type_code <> 'B' THEN
45464 IF NVL(p_source_22,'
45465 ') = 'REMITTANCE' AND
45466 NVL(p_source_71,'
45467 ') = 'Y'
45468 THEN
45469
45470 --
45471 XLA_AE_LINES_PKG.SetNewLine;
45472
45473 p_balance_type_code := l_balance_type_code;
45474 -- set the flag so later we will know whether the gain loss line needs to be created
45475
45476 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
45477 p_actual_flag :='A';
45478 END IF;
45479
45480 --
45481 -- bulk performance
45482 --
45483 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
45484 p_header_num => 0); -- 4262811
45485 --
45486 -- set accounting line options
45487 --
45488 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
45489 p_natural_side_code => 'D'
45490 , p_gain_or_loss_flag => 'N'
45491 , p_gl_transfer_mode_code => 'S'
45492 , p_acct_entry_type_code => 'A'
45493 , p_switch_side_flag => 'Y'
45494 , p_merge_duplicate_code => 'A'
45495 );
45496 --
45497 l_acc_rev_natural_side_code := 'C'; -- 4262811
45498 --
45499 --
45500 -- set accounting line type info
45501 --
45502 xla_ae_lines_pkg.SetAcctLineType
45503 (p_component_type => l_component_type
45504 ,p_event_type_code => l_event_type_code
45505 ,p_line_definition_owner_code => l_line_definition_owner_code
45506 ,p_line_definition_code => l_line_definition_code
45507 ,p_accounting_line_code => l_component_code
45508 ,p_accounting_line_type_code => l_component_type_code
45509 ,p_accounting_line_appl_id => l_component_appl_id
45510 ,p_amb_context_code => l_amb_context_code
45511 ,p_entity_code => l_entity_code
45512 ,p_event_class_code => l_event_class_code);
45513 --
45514 -- set accounting class
45515 --
45516 xla_ae_lines_pkg.SetAcctClass(
45517 p_accounting_class_code => 'REMITTANCE'
45518 , p_ae_header_id => l_ae_header_id
45519 );
45520
45521 --
45522 -- set rounding class
45523 --
45524 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
45525 'RECEIVABLE';
45526
45527 --
45528 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
45529 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
45530 --
45531 -- bulk performance
45532 --
45533 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
45534
45535 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
45536 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
45537
45538 -- 4955764
45539 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45540 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
45541
45542 -- 4458381 Public Sector Enh
45543
45544 --
45545 -- set accounting attributes for the line type
45546 --
45547 l_entered_amt_idx := 8;
45548 l_accted_amt_idx := 13;
45549 l_bflow_applied_to_amt_idx := NULL; -- 5132302
45550 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
45551 l_rec_acct_attrs.array_num_value(1) := p_source_60;
45552 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
45553 l_rec_acct_attrs.array_char_value(2) := p_source_37;
45554 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
45555 l_rec_acct_attrs.array_char_value(3) := p_source_61;
45556 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
45557 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
45558 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
45559 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
45560 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
45561 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
45562 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
45563 l_rec_acct_attrs.array_char_value(7) := p_source_25;
45564 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
45565 l_rec_acct_attrs.array_num_value(8) := p_source_74;
45566 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
45567 l_rec_acct_attrs.array_char_value(9) := p_source_63;
45568 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
45569 l_rec_acct_attrs.array_date_value(10) := p_source_28;
45573 l_rec_acct_attrs.array_char_value(12) := p_source_30;
45570 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
45571 l_rec_acct_attrs.array_num_value(11) := p_source_29;
45572 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
45574 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
45575 l_rec_acct_attrs.array_num_value(13) := p_source_75;
45576 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
45577 l_rec_acct_attrs.array_num_value(14) := p_source_65;
45578 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
45579 l_rec_acct_attrs.array_num_value(15) := p_source_66;
45580 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
45581 l_rec_acct_attrs.array_char_value(16) := p_source_67;
45582
45583 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
45584 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
45585
45586 ---------------------------------------------------------------------------------------------------------------
45587 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
45588 ---------------------------------------------------------------------------------------------------------------
45589 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
45590
45591 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45592 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45593
45594 IF xla_accounting_cache_pkg.GetValueChar
45595 (p_source_code => 'LEDGER_CATEGORY_CODE'
45596 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
45597 AND l_bflow_method_code = 'PRIOR_ENTRY'
45598 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
45599 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
45600 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
45601 )
45602 THEN
45603 xla_ae_lines_pkg.BflowUpgEntry
45604 (p_business_method_code => l_bflow_method_code
45605 ,p_business_class_code => l_bflow_class_code
45606 ,p_balance_type => l_balance_type_code);
45607 ELSE
45608 NULL;
45609 -- No business flow processing for business flow method of NONE.
45610 END IF;
45611
45612 --
45613 -- call analytical criteria
45614 --
45615
45616 --
45617 -- call description
45618 --
45619
45620 xla_ae_lines_pkg.SetLineDescription(
45621 p_ae_header_id => l_ae_header_id
45622 ,p_description => Description_1 (
45623 p_application_id => p_application_id
45624 , p_ae_header_id => l_ae_header_id
45625 )
45626 );
45627
45628
45629 --
45630 -- call ADRs
45631 -- Bug 4922099
45632 --
45633 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45634 (NVL(l_actual_upg_option, 'N') = 'O') OR
45635 (NVL(l_enc_upg_option, 'N') = 'O')
45636 )
45637 THEN
45638 NULL;
45639 --
45640 --
45641
45642 l_ccid := AcctDerRule_30(
45643 p_application_id => p_application_id
45644 , p_ae_header_id => l_ae_header_id
45645 , p_source_6 => p_source_6
45646 , x_transaction_coa_id => l_adr_transaction_coa_id
45647 , x_accounting_coa_id => l_adr_accounting_coa_id
45648 , x_value_type_code => l_adr_value_type_code
45649 , p_side => 'NA'
45650 );
45651
45652 xla_ae_lines_pkg.set_ccid(
45653 p_code_combination_id => l_ccid
45654 , p_value_type_code => l_adr_value_type_code
45655 , p_transaction_coa_id => l_adr_transaction_coa_id
45656 , p_accounting_coa_id => l_adr_accounting_coa_id
45657 , p_adr_code => 'MFAR_RCT_DEF_REMITTANCE_CCID'
45658 , p_adr_type_code => 'S'
45659 , p_component_type => l_component_type
45660 , p_component_code => l_component_code
45661 , p_component_type_code => l_component_type_code
45662 , p_component_appl_id => l_component_appl_id
45663 , p_amb_context_code => l_amb_context_code
45664 , p_side => 'NA'
45665 );
45666
45667
45668 --
45669 --
45670 END IF;
45671 --
45672 -- Bug 4922099
45673 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
45674 (NVL(l_enc_upg_option, 'N') = 'O')
45675 ) AND
45676 (l_bflow_method_code = 'PRIOR_ENTRY')
45677 )
45678 THEN
45679 IF
45680 --
45681 1 = 2
45682 --
45683 THEN
45684 xla_accounting_err_pkg.build_message
45685 (p_appli_s_name => 'XLA'
45686 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
45687 ,p_token_1 => 'LINE_NUMBER'
45688 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
45689 ,p_token_2 => 'LINE_TYPE_NAME'
45693 ,l_component_type_code
45690 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
45691 l_component_type
45692 ,l_component_code
45694 ,l_component_appl_id
45695 ,l_amb_context_code
45696 ,l_entity_code
45697 ,l_event_class_code
45698 )
45699 ,p_token_3 => 'OWNER'
45700 ,p_value_3 => xla_lookups_pkg.get_meaning(
45701 p_lookup_type => 'XLA_OWNER_TYPE'
45702 ,p_lookup_code => l_component_type_code
45703 )
45704 ,p_token_4 => 'PRODUCT_NAME'
45705 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
45706 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
45707 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
45708 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
45709 ,p_ae_header_id => NULL
45710 );
45711
45712 IF (C_LEVEL_ERROR>= g_log_level) THEN
45713 trace
45714 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
45715 ,p_level => C_LEVEL_ERROR
45716 ,p_module => l_log_module);
45717 END IF;
45718 END IF;
45719 END IF;
45720 --
45721 --
45722 ------------------------------------------------------------------------------------------------
45723 -- 4219869 Business Flow
45724 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
45725 -- Prior Entry. Currently, the following code is always generated.
45726 ------------------------------------------------------------------------------------------------
45727 XLA_AE_LINES_PKG.ValidateCurrentLine;
45728
45729 ------------------------------------------------------------------------------------
45730 -- 4219869 Business Flow
45731 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
45732 ------------------------------------------------------------------------------------
45733 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45734
45735 ----------------------------------------------------------------------------------
45736 -- 4219869 Business Flow
45737 -- Update journal entry status -- Need to generate this within IF <condition>
45738 ----------------------------------------------------------------------------------
45739 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45740 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
45741 ,p_balance_type_code => l_balance_type_code
45742 );
45743
45744 -------------------------------------------------------------------------------------------
45745 -- 4262811 - Generate the Accrual Reversal lines
45746 -------------------------------------------------------------------------------------------
45747 BEGIN
45748 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
45749 (g_array_event(p_event_id).array_value_num('header_index'));
45750 IF l_acc_rev_flag IS NULL THEN
45751 l_acc_rev_flag := 'N';
45752 END IF;
45753 EXCEPTION
45754 WHEN OTHERS THEN
45755 l_acc_rev_flag := 'N';
45756 END;
45757 --
45758 IF (l_acc_rev_flag = 'Y') THEN
45759
45760 -- 4645092 ------------------------------------------------------------------------------
45761 -- To allow MPA report to determine if it should generate report process
45762 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
45763 ------------------------------------------------------------------------------------------
45764
45765 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
45766 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
45767 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
45768 -- call ADRs
45769 -- Bug 4922099
45770 --
45771 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45772 (NVL(l_actual_upg_option, 'N') = 'O') OR
45773 (NVL(l_enc_upg_option, 'N') = 'O')
45774 )
45775 THEN
45776 NULL;
45777 --
45778 --
45779
45780 l_ccid := AcctDerRule_30(
45781 p_application_id => p_application_id
45782 , p_ae_header_id => l_ae_header_id
45783 , p_source_6 => p_source_6
45784 , x_transaction_coa_id => l_adr_transaction_coa_id
45785 , x_accounting_coa_id => l_adr_accounting_coa_id
45786 , x_value_type_code => l_adr_value_type_code
45790 xla_ae_lines_pkg.set_ccid(
45787 , p_side => 'NA'
45788 );
45789
45791 p_code_combination_id => l_ccid
45792 , p_value_type_code => l_adr_value_type_code
45793 , p_transaction_coa_id => l_adr_transaction_coa_id
45794 , p_accounting_coa_id => l_adr_accounting_coa_id
45795 , p_adr_code => 'MFAR_RCT_DEF_REMITTANCE_CCID'
45796 , p_adr_type_code => 'S'
45797 , p_component_type => l_component_type
45798 , p_component_code => l_component_code
45799 , p_component_type_code => l_component_type_code
45800 , p_component_appl_id => l_component_appl_id
45801 , p_amb_context_code => l_amb_context_code
45802 , p_side => 'NA'
45803 );
45804
45805
45806 --
45807 --
45808 END IF;
45809
45810 --
45811 -- Update the line information that should be overwritten
45812 --
45813 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
45814 p_header_num => 1);
45815 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
45816
45817 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
45818
45819 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
45820 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
45821 END IF;
45822
45823 --
45824 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
45825 --
45826 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
45827 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
45828 ELSE
45829 ---------------------------------------------------------------------------------------------------
45830 -- 4262811a Switch Sign
45831 ---------------------------------------------------------------------------------------------------
45832 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
45833 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45834 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45835 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45836 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45837 -- 5132302
45838 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
45839 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45840
45841 END IF;
45842
45843 -- 4955764
45844 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45845 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
45846
45847
45848 XLA_AE_LINES_PKG.ValidateCurrentLine;
45849 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45850
45851 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45852 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
45853 ,p_balance_type_code => l_balance_type_code);
45854
45855 END IF;
45856
45857 -----------------------------------------------------------------------------------------
45858 -- 4262811 Multiperiod Accounting
45859 -----------------------------------------------------------------------------------------
45860 -- No MPA option is assigned.
45861
45862
45863 END IF;
45864 END IF;
45865 --
45866
45867 --
45868 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45869 trace
45870 (p_msg => 'END of AcctLineType_101'
45871 ,p_level => C_LEVEL_PROCEDURE
45872 ,p_module => l_log_module);
45873 END IF;
45874 --
45875 EXCEPTION
45876 WHEN xla_exceptions_pkg.application_exception THEN
45877 RAISE;
45878 WHEN OTHERS THEN
45879 xla_exceptions_pkg.raise_message
45880 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_101');
45881 END AcctLineType_101;
45882 --
45883
45884 ---------------------------------------
45885 --
45886 -- PRIVATE FUNCTION
45887 -- AcctLineType_102
45888 --
45889 ---------------------------------------
45890 PROCEDURE AcctLineType_102 (
45891 p_application_id IN NUMBER
45892 ,p_event_id IN NUMBER
45893 ,p_calculate_acctd_flag IN VARCHAR2
45894 ,p_calculate_g_l_flag IN VARCHAR2
45895 ,p_actual_flag IN OUT VARCHAR2
45896 ,p_balance_type_code OUT VARCHAR2
45897 ,p_gain_or_loss_ref OUT VARCHAR2
45898
45899 --Distribution Source Type
45900 , p_source_22 IN VARCHAR2
45901 --Distribution Line Identifier
45902 , p_source_24 IN NUMBER
45903 --Distribution Type
45904 , p_source_25 IN VARCHAR2
45905 --Entered Amount
45906 , p_source_26 IN NUMBER
45907 --Currency Code
45908 , p_source_27 IN VARCHAR2
45909 --Applied To Document Accounting Amount
45913 --Transaction Distribution Type
45910 , p_source_31 IN NUMBER
45911 --Transaction Distribution Identifier
45912 , p_source_36 IN NUMBER
45914 , p_source_37 IN VARCHAR2
45915 --Receipt Applied To Application Identifier
45916 , p_source_60 IN NUMBER
45917 --Transaction Entity Code
45918 , p_source_61 IN VARCHAR2
45919 --Transaction Identifier
45920 , p_source_62 IN NUMBER
45921 --Distribution Party Type
45922 , p_source_67 IN VARCHAR2
45923 --Distribution Multi Fund Additional Entry
45924 , p_source_71 IN VARCHAR2
45925 )
45926 IS
45927
45928 l_component_type VARCHAR2(80);
45929 l_component_code VARCHAR2(30);
45930 l_component_type_code VARCHAR2(1);
45931 l_component_appl_id INTEGER;
45932 l_amb_context_code VARCHAR2(30);
45933 l_entity_code VARCHAR2(30);
45934 l_event_class_code VARCHAR2(30);
45935 l_ae_header_id NUMBER;
45936 l_event_type_code VARCHAR2(30);
45937 l_line_definition_code VARCHAR2(30);
45938 l_line_definition_owner_code VARCHAR2(1);
45939 --
45940 -- adr variables
45941 l_segment VARCHAR2(30);
45942 l_ccid NUMBER;
45943 l_adr_transaction_coa_id NUMBER;
45944 l_adr_accounting_coa_id NUMBER;
45945 l_adr_flexfield_segment_code VARCHAR2(30);
45946 l_adr_flex_value_set_id NUMBER;
45947 l_adr_value_type_code VARCHAR2(30);
45948 l_adr_value_combination_id NUMBER;
45949 l_adr_value_segment_code VARCHAR2(30);
45950
45951 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
45952 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
45953 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
45954 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
45955
45956 -- 4262811 Variables ------------------------------------------------------------------------------------------
45957 l_entered_amt_idx NUMBER;
45958 l_accted_amt_idx NUMBER;
45959 l_acc_rev_flag VARCHAR2(1);
45960 l_accrual_line_num NUMBER;
45961 l_tmp_amt NUMBER;
45962 l_acc_rev_natural_side_code VARCHAR2(1);
45963
45964 l_num_entries NUMBER;
45965 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
45966 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
45967 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
45968 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
45969 l_recog_line_1 NUMBER;
45970 l_recog_line_2 NUMBER;
45971
45972 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
45973 l_bflow_applied_to_amt NUMBER; -- 5132302
45974 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
45975
45976 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
45977
45978 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
45979 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
45980
45981 ---------------------------------------------------------------------------------------------------------------
45982
45983
45984 --
45985 -- bulk performance
45986 --
45987 l_balance_type_code VARCHAR2(1);
45988 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
45989 l_log_module VARCHAR2(240);
45990
45991 --
45992 -- Upgrade strategy
45993 --
45994 l_actual_upg_option VARCHAR2(1);
45995 l_enc_upg_option VARCHAR2(1);
45996
45997 --
45998 BEGIN
45999 --
46000 IF g_log_enabled THEN
46001 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_102';
46002 END IF;
46003 --
46004 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46005
46006 trace
46007 (p_msg => 'BEGIN of AcctLineType_102'
46008 ,p_level => C_LEVEL_PROCEDURE
46009 ,p_module => l_log_module);
46010
46011 END IF;
46012 --
46013 l_component_type := 'AMB_JLT';
46014 l_component_code := 'MFAR_RCT_UNDISC_REC';
46015 l_component_type_code := 'S';
46016 l_component_appl_id := 222;
46017 l_amb_context_code := 'DEFAULT';
46018 l_entity_code := 'RECEIPTS';
46019 l_event_class_code := 'RECEIPT';
46020 l_event_type_code := 'RECEIPT_ALL';
46021 l_line_definition_owner_code := 'S';
46022 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
46023 --
46024 l_balance_type_code := 'A';
46025 l_segment := NULL;
46026 l_ccid := NULL;
46027 l_adr_transaction_coa_id := NULL;
46028 l_adr_accounting_coa_id := NULL;
46029 l_adr_flexfield_segment_code := NULL;
46030 l_adr_flex_value_set_id := NULL;
46031 l_adr_value_type_code := NULL;
46032 l_adr_value_combination_id := NULL;
46033 l_adr_value_segment_code := NULL;
46034
46035 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
46036 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
46037 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
46041 l_bflow_applied_to_amt := NULL; -- 5132302
46038 l_budgetary_control_flag := 'N';
46039
46040 l_bflow_applied_to_amt_idx := NULL; -- 5132302
46042 l_entered_amt_idx := NULL; -- 4262811
46043 l_accted_amt_idx := NULL; -- 4262811
46044 l_acc_rev_flag := NULL; -- 4262811
46045 l_accrual_line_num := NULL; -- 4262811
46046 l_tmp_amt := NULL; -- 4262811
46047 --
46048
46049 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
46050 l_balance_type_code <> 'B' THEN
46051 IF NVL(p_source_22,'
46052 ') = 'UNEDISC' AND
46053 NVL(p_source_71,'
46054 ') = 'N'
46055 THEN
46056
46057 --
46058 XLA_AE_LINES_PKG.SetNewLine;
46059
46060 p_balance_type_code := l_balance_type_code;
46061 -- set the flag so later we will know whether the gain loss line needs to be created
46062
46063 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
46064 p_actual_flag :='A';
46065 END IF;
46066
46067 --
46068 -- bulk performance
46069 --
46070 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
46071 p_header_num => 0); -- 4262811
46072 --
46073 -- set accounting line options
46074 --
46075 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
46076 p_natural_side_code => 'D'
46077 , p_gain_or_loss_flag => 'N'
46078 , p_gl_transfer_mode_code => 'S'
46079 , p_acct_entry_type_code => 'A'
46080 , p_switch_side_flag => 'Y'
46081 , p_merge_duplicate_code => 'A'
46082 );
46083 --
46084 l_acc_rev_natural_side_code := 'C'; -- 4262811
46085 --
46086 --
46087 -- set accounting line type info
46088 --
46089 xla_ae_lines_pkg.SetAcctLineType
46090 (p_component_type => l_component_type
46091 ,p_event_type_code => l_event_type_code
46092 ,p_line_definition_owner_code => l_line_definition_owner_code
46093 ,p_line_definition_code => l_line_definition_code
46094 ,p_accounting_line_code => l_component_code
46095 ,p_accounting_line_type_code => l_component_type_code
46096 ,p_accounting_line_appl_id => l_component_appl_id
46097 ,p_amb_context_code => l_amb_context_code
46098 ,p_entity_code => l_entity_code
46099 ,p_event_class_code => l_event_class_code);
46100 --
46101 -- set accounting class
46102 --
46103 xla_ae_lines_pkg.SetAcctClass(
46104 p_accounting_class_code => 'RECEIVABLE'
46105 , p_ae_header_id => l_ae_header_id
46106 );
46107
46108 --
46109 -- set rounding class
46110 --
46111 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
46112 'RECEIVABLE';
46113
46114 --
46115 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
46116 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
46117 --
46118 -- bulk performance
46119 --
46120 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
46121
46122 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
46123 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
46124
46125 -- 4955764
46126 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46127 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
46128
46129 -- 4458381 Public Sector Enh
46130
46131 --
46132 -- set accounting attributes for the line type
46133 --
46134 l_entered_amt_idx := 8;
46135 l_accted_amt_idx := 10;
46136 l_bflow_applied_to_amt_idx := NULL; -- 5132302
46137 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
46138 l_rec_acct_attrs.array_num_value(1) := p_source_60;
46139 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
46140 l_rec_acct_attrs.array_char_value(2) := p_source_37;
46141 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
46142 l_rec_acct_attrs.array_char_value(3) := p_source_61;
46143 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
46144 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
46145 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
46146 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
46147 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
46148 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
46149 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
46150 l_rec_acct_attrs.array_char_value(7) := p_source_25;
46151 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
46152 l_rec_acct_attrs.array_num_value(8) := p_source_26;
46153 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
46154 l_rec_acct_attrs.array_char_value(9) := p_source_27;
46155 l_rec_acct_attrs.array_acct_attr_code(10) := 'LEDGER_AMOUNT';
46159
46156 l_rec_acct_attrs.array_num_value(10) := p_source_31;
46157 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
46158 l_rec_acct_attrs.array_char_value(11) := p_source_67;
46160 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
46161 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
46162
46163 ---------------------------------------------------------------------------------------------------------------
46164 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
46165 ---------------------------------------------------------------------------------------------------------------
46166 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
46167
46168 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46169 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46170
46171 IF xla_accounting_cache_pkg.GetValueChar
46172 (p_source_code => 'LEDGER_CATEGORY_CODE'
46173 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
46174 AND l_bflow_method_code = 'PRIOR_ENTRY'
46175 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
46176 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
46177 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
46178 )
46179 THEN
46180 xla_ae_lines_pkg.BflowUpgEntry
46181 (p_business_method_code => l_bflow_method_code
46182 ,p_business_class_code => l_bflow_class_code
46183 ,p_balance_type => l_balance_type_code);
46184 ELSE
46185 NULL;
46186 XLA_AE_LINES_PKG.business_flow_validation(
46187 p_business_method_code => l_bflow_method_code
46188 ,p_business_class_code => l_bflow_class_code
46189 ,p_inherit_description_flag => l_inherit_desc_flag);
46190 END IF;
46191
46192 --
46193 -- call analytical criteria
46194 --
46195 -- Inherited Analytical Criteria for business flow method of Prior Entry.
46196 --
46197 -- call description
46198 --
46199
46200 xla_ae_lines_pkg.SetLineDescription(
46201 p_ae_header_id => l_ae_header_id
46202 ,p_description => Description_1 (
46203 p_application_id => p_application_id
46204 , p_ae_header_id => l_ae_header_id
46205 )
46206 );
46207
46208
46209 --
46210 -- call ADRs
46211 -- Bug 4922099
46212 --
46213 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46214 (NVL(l_actual_upg_option, 'N') = 'O') OR
46215 (NVL(l_enc_upg_option, 'N') = 'O')
46216 )
46217 THEN
46218 NULL;
46219 --
46220 --
46221
46222 --
46223 --
46224 END IF;
46225 --
46226 -- Bug 4922099
46227 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
46228 (NVL(l_enc_upg_option, 'N') = 'O')
46229 ) AND
46230 (l_bflow_method_code = 'PRIOR_ENTRY')
46231 )
46232 THEN
46233 IF
46234 --
46235 1 = 1
46236 --
46237 THEN
46238 xla_accounting_err_pkg.build_message
46239 (p_appli_s_name => 'XLA'
46240 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46241 ,p_token_1 => 'LINE_NUMBER'
46242 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
46243 ,p_token_2 => 'LINE_TYPE_NAME'
46244 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
46245 l_component_type
46246 ,l_component_code
46247 ,l_component_type_code
46248 ,l_component_appl_id
46249 ,l_amb_context_code
46250 ,l_entity_code
46251 ,l_event_class_code
46252 )
46253 ,p_token_3 => 'OWNER'
46254 ,p_value_3 => xla_lookups_pkg.get_meaning(
46255 p_lookup_type => 'XLA_OWNER_TYPE'
46256 ,p_lookup_code => l_component_type_code
46257 )
46258 ,p_token_4 => 'PRODUCT_NAME'
46259 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
46260 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
46264 );
46261 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
46262 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
46263 ,p_ae_header_id => NULL
46265
46266 IF (C_LEVEL_ERROR>= g_log_level) THEN
46267 trace
46268 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46269 ,p_level => C_LEVEL_ERROR
46270 ,p_module => l_log_module);
46271 END IF;
46272 END IF;
46273 END IF;
46274 --
46275 --
46276 ------------------------------------------------------------------------------------------------
46277 -- 4219869 Business Flow
46278 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
46279 -- Prior Entry. Currently, the following code is always generated.
46280 ------------------------------------------------------------------------------------------------
46281 -- No ValidateCurrentLine for business flow method of Prior Entry
46282
46283 ------------------------------------------------------------------------------------
46284 -- 4219869 Business Flow
46285 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
46286 ------------------------------------------------------------------------------------
46287 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46288
46289 ----------------------------------------------------------------------------------
46290 -- 4219869 Business Flow
46291 -- Update journal entry status -- Need to generate this within IF <condition>
46292 ----------------------------------------------------------------------------------
46293 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46294 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
46295 ,p_balance_type_code => l_balance_type_code
46296 );
46297
46298 -------------------------------------------------------------------------------------------
46299 -- 4262811 - Generate the Accrual Reversal lines
46300 -------------------------------------------------------------------------------------------
46301 BEGIN
46302 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
46303 (g_array_event(p_event_id).array_value_num('header_index'));
46304 IF l_acc_rev_flag IS NULL THEN
46305 l_acc_rev_flag := 'N';
46306 END IF;
46307 EXCEPTION
46308 WHEN OTHERS THEN
46309 l_acc_rev_flag := 'N';
46310 END;
46311 --
46312 IF (l_acc_rev_flag = 'Y') THEN
46313
46314 -- 4645092 ------------------------------------------------------------------------------
46315 -- To allow MPA report to determine if it should generate report process
46316 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
46317 ------------------------------------------------------------------------------------------
46318
46319 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
46320 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
46321 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
46322 -- call ADRs
46323 -- Bug 4922099
46324 --
46325 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46326 (NVL(l_actual_upg_option, 'N') = 'O') OR
46327 (NVL(l_enc_upg_option, 'N') = 'O')
46328 )
46329 THEN
46330 NULL;
46331 --
46332 --
46333
46334 --
46335 --
46336 END IF;
46337
46338 --
46339 -- Update the line information that should be overwritten
46340 --
46341 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
46342 p_header_num => 1);
46343 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
46344
46345 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
46346
46347 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
46348 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
46349 END IF;
46350
46351 --
46352 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
46353 --
46354 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
46355 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
46356 ELSE
46357 ---------------------------------------------------------------------------------------------------
46358 -- 4262811a Switch Sign
46359 ---------------------------------------------------------------------------------------------------
46360 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
46361 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46362 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46363 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46364 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46365 -- 5132302
46369 END IF;
46366 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
46367 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46368
46370
46371 -- 4955764
46372 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46373 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
46374
46375
46376 XLA_AE_LINES_PKG.ValidateCurrentLine;
46377 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46378
46379 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46380 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
46381 ,p_balance_type_code => l_balance_type_code);
46382
46383 END IF;
46384
46385 -----------------------------------------------------------------------------------------
46386 -- 4262811 Multiperiod Accounting
46387 -----------------------------------------------------------------------------------------
46388 -- No MPA option is assigned.
46389
46390
46391 END IF;
46392 END IF;
46393 --
46394
46395 --
46396 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46397 trace
46398 (p_msg => 'END of AcctLineType_102'
46399 ,p_level => C_LEVEL_PROCEDURE
46400 ,p_module => l_log_module);
46401 END IF;
46402 --
46403 EXCEPTION
46404 WHEN xla_exceptions_pkg.application_exception THEN
46405 RAISE;
46406 WHEN OTHERS THEN
46407 xla_exceptions_pkg.raise_message
46408 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_102');
46409 END AcctLineType_102;
46410 --
46411
46412 ---------------------------------------
46413 --
46414 -- PRIVATE FUNCTION
46415 -- AcctLineType_103
46416 --
46417 ---------------------------------------
46418 PROCEDURE AcctLineType_103 (
46419 p_application_id IN NUMBER
46420 ,p_event_id IN NUMBER
46421 ,p_calculate_acctd_flag IN VARCHAR2
46422 ,p_calculate_g_l_flag IN VARCHAR2
46423 ,p_actual_flag IN OUT VARCHAR2
46424 ,p_balance_type_code OUT VARCHAR2
46425 ,p_gain_or_loss_ref OUT VARCHAR2
46426
46427 --Distribution GL Account
46428 , p_source_10 IN NUMBER
46429 --Distribution Source Type
46430 , p_source_22 IN VARCHAR2
46431 --Distribution Line Identifier
46432 , p_source_24 IN NUMBER
46433 --Distribution Type
46434 , p_source_25 IN VARCHAR2
46435 --Entered Amount
46436 , p_source_26 IN NUMBER
46437 --Currency Code
46438 , p_source_27 IN VARCHAR2
46439 --Exchange Rate
46440 , p_source_29 IN NUMBER
46441 --Exchange Rate Type
46442 , p_source_30 IN VARCHAR2
46443 --Applied To Document Accounting Amount
46444 , p_source_31 IN NUMBER
46445 --Applied To Document Exchange Date
46446 , p_source_59 IN DATE
46447 --Distribution Multi Fund Additional Entry
46448 , p_source_71 IN VARCHAR2
46449 )
46450 IS
46451
46452 l_component_type VARCHAR2(80);
46453 l_component_code VARCHAR2(30);
46454 l_component_type_code VARCHAR2(1);
46455 l_component_appl_id INTEGER;
46456 l_amb_context_code VARCHAR2(30);
46457 l_entity_code VARCHAR2(30);
46458 l_event_class_code VARCHAR2(30);
46459 l_ae_header_id NUMBER;
46460 l_event_type_code VARCHAR2(30);
46461 l_line_definition_code VARCHAR2(30);
46462 l_line_definition_owner_code VARCHAR2(1);
46463 --
46464 -- adr variables
46465 l_segment VARCHAR2(30);
46466 l_ccid NUMBER;
46467 l_adr_transaction_coa_id NUMBER;
46468 l_adr_accounting_coa_id NUMBER;
46469 l_adr_flexfield_segment_code VARCHAR2(30);
46470 l_adr_flex_value_set_id NUMBER;
46471 l_adr_value_type_code VARCHAR2(30);
46472 l_adr_value_combination_id NUMBER;
46473 l_adr_value_segment_code VARCHAR2(30);
46474
46475 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
46476 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
46477 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
46478 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
46479
46480 -- 4262811 Variables ------------------------------------------------------------------------------------------
46481 l_entered_amt_idx NUMBER;
46482 l_accted_amt_idx NUMBER;
46483 l_acc_rev_flag VARCHAR2(1);
46484 l_accrual_line_num NUMBER;
46485 l_tmp_amt NUMBER;
46486 l_acc_rev_natural_side_code VARCHAR2(1);
46487
46488 l_num_entries NUMBER;
46489 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
46490 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
46491 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
46492 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
46493 l_recog_line_1 NUMBER;
46494 l_recog_line_2 NUMBER;
46495
46496 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
46497 l_bflow_applied_to_amt NUMBER; -- 5132302
46501
46498 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
46499
46500 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
46502 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
46503 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
46504
46505 ---------------------------------------------------------------------------------------------------------------
46506
46507
46508 --
46509 -- bulk performance
46510 --
46511 l_balance_type_code VARCHAR2(1);
46512 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
46513 l_log_module VARCHAR2(240);
46514
46515 --
46516 -- Upgrade strategy
46517 --
46518 l_actual_upg_option VARCHAR2(1);
46519 l_enc_upg_option VARCHAR2(1);
46520
46521 --
46522 BEGIN
46523 --
46524 IF g_log_enabled THEN
46525 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_103';
46526 END IF;
46527 --
46528 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46529
46530 trace
46531 (p_msg => 'BEGIN of AcctLineType_103'
46532 ,p_level => C_LEVEL_PROCEDURE
46533 ,p_module => l_log_module);
46534
46535 END IF;
46536 --
46537 l_component_type := 'AMB_JLT';
46538 l_component_code := 'MISC_RCT_BNK_CHG';
46539 l_component_type_code := 'S';
46540 l_component_appl_id := 222;
46541 l_amb_context_code := 'DEFAULT';
46542 l_entity_code := 'RECEIPTS';
46543 l_event_class_code := 'MISC_RECEIPT';
46544 l_event_type_code := 'MISC_RECEIPT_ALL';
46545 l_line_definition_owner_code := 'S';
46546 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
46547 --
46548 l_balance_type_code := 'A';
46549 l_segment := NULL;
46550 l_ccid := NULL;
46551 l_adr_transaction_coa_id := NULL;
46552 l_adr_accounting_coa_id := NULL;
46553 l_adr_flexfield_segment_code := NULL;
46554 l_adr_flex_value_set_id := NULL;
46555 l_adr_value_type_code := NULL;
46556 l_adr_value_combination_id := NULL;
46557 l_adr_value_segment_code := NULL;
46558
46559 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
46560 l_bflow_class_code := ''; -- 4219869 Business Flow
46561 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
46562 l_budgetary_control_flag := 'N';
46563
46564 l_bflow_applied_to_amt_idx := NULL; -- 5132302
46565 l_bflow_applied_to_amt := NULL; -- 5132302
46566 l_entered_amt_idx := NULL; -- 4262811
46567 l_accted_amt_idx := NULL; -- 4262811
46568 l_acc_rev_flag := NULL; -- 4262811
46569 l_accrual_line_num := NULL; -- 4262811
46570 l_tmp_amt := NULL; -- 4262811
46571 --
46572
46573 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
46574 l_balance_type_code <> 'B' THEN
46575 IF NVL(p_source_22,'
46576 ') = 'BANK_CHARGES' AND
46577 NVL(p_source_71,'
46578 ') = 'N'
46579 THEN
46580
46581 --
46582 XLA_AE_LINES_PKG.SetNewLine;
46583
46584 p_balance_type_code := l_balance_type_code;
46585 -- set the flag so later we will know whether the gain loss line needs to be created
46586
46587 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
46588 p_actual_flag :='A';
46589 END IF;
46590
46591 --
46592 -- bulk performance
46593 --
46594 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
46595 p_header_num => 0); -- 4262811
46596 --
46597 -- set accounting line options
46598 --
46599 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
46600 p_natural_side_code => 'C'
46601 , p_gain_or_loss_flag => 'N'
46602 , p_gl_transfer_mode_code => 'S'
46603 , p_acct_entry_type_code => 'A'
46604 , p_switch_side_flag => 'Y'
46605 , p_merge_duplicate_code => 'A'
46606 );
46607 --
46608 l_acc_rev_natural_side_code := 'D'; -- 4262811
46609 --
46610 --
46611 -- set accounting line type info
46612 --
46613 xla_ae_lines_pkg.SetAcctLineType
46614 (p_component_type => l_component_type
46615 ,p_event_type_code => l_event_type_code
46616 ,p_line_definition_owner_code => l_line_definition_owner_code
46617 ,p_line_definition_code => l_line_definition_code
46618 ,p_accounting_line_code => l_component_code
46619 ,p_accounting_line_type_code => l_component_type_code
46620 ,p_accounting_line_appl_id => l_component_appl_id
46621 ,p_amb_context_code => l_amb_context_code
46622 ,p_entity_code => l_entity_code
46623 ,p_event_class_code => l_event_class_code);
46624 --
46625 -- set accounting class
46626 --
46627 xla_ae_lines_pkg.SetAcctClass(
46628 p_accounting_class_code => 'BANK_CHG'
46629 , p_ae_header_id => l_ae_header_id
46630 );
46631
46632 --
46636 'RECEIVABLE';
46633 -- set rounding class
46634 --
46635 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
46637
46638 --
46639 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
46640 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
46641 --
46642 -- bulk performance
46643 --
46644 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
46645
46646 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
46647 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
46648
46649 -- 4955764
46650 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46651 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
46652
46653 -- 4458381 Public Sector Enh
46654
46655 --
46656 -- set accounting attributes for the line type
46657 --
46658 l_entered_amt_idx := 3;
46659 l_accted_amt_idx := 8;
46660 l_bflow_applied_to_amt_idx := NULL; -- 5132302
46661 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
46662 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
46663 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
46664 l_rec_acct_attrs.array_char_value(2) := p_source_25;
46665 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
46666 l_rec_acct_attrs.array_num_value(3) := p_source_26;
46667 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
46668 l_rec_acct_attrs.array_char_value(4) := p_source_27;
46669 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
46670 l_rec_acct_attrs.array_date_value(5) := p_source_59;
46671 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
46672 l_rec_acct_attrs.array_num_value(6) := p_source_29;
46673 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
46674 l_rec_acct_attrs.array_char_value(7) := p_source_30;
46675 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
46676 l_rec_acct_attrs.array_num_value(8) := p_source_31;
46677
46678 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
46679 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
46680
46681 ---------------------------------------------------------------------------------------------------------------
46682 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
46683 ---------------------------------------------------------------------------------------------------------------
46684 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
46685
46686 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46687 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46688
46689 IF xla_accounting_cache_pkg.GetValueChar
46690 (p_source_code => 'LEDGER_CATEGORY_CODE'
46691 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
46692 AND l_bflow_method_code = 'PRIOR_ENTRY'
46693 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
46694 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
46695 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
46696 )
46697 THEN
46698 xla_ae_lines_pkg.BflowUpgEntry
46699 (p_business_method_code => l_bflow_method_code
46700 ,p_business_class_code => l_bflow_class_code
46701 ,p_balance_type => l_balance_type_code);
46702 ELSE
46703 NULL;
46704 -- No business flow processing for business flow method of NONE.
46705 END IF;
46706
46707 --
46708 -- call analytical criteria
46709 --
46710
46711 --
46712 -- call description
46713 --
46714 -- No description or it is inherited.
46715 --
46716 -- call ADRs
46717 -- Bug 4922099
46718 --
46719 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46720 (NVL(l_actual_upg_option, 'N') = 'O') OR
46721 (NVL(l_enc_upg_option, 'N') = 'O')
46722 )
46723 THEN
46724 NULL;
46725 --
46726 --
46727
46728 l_ccid := AcctDerRule_11(
46729 p_application_id => p_application_id
46730 , p_ae_header_id => l_ae_header_id
46731 , p_source_10 => p_source_10
46732 , x_transaction_coa_id => l_adr_transaction_coa_id
46733 , x_accounting_coa_id => l_adr_accounting_coa_id
46734 , x_value_type_code => l_adr_value_type_code
46735 , p_side => 'NA'
46736 );
46737
46738 xla_ae_lines_pkg.set_ccid(
46739 p_code_combination_id => l_ccid
46740 , p_value_type_code => l_adr_value_type_code
46741 , p_transaction_coa_id => l_adr_transaction_coa_id
46742 , p_accounting_coa_id => l_adr_accounting_coa_id
46743 , p_adr_code => 'DIST_CCID'
46744 , p_adr_type_code => 'S'
46745 , p_component_type => l_component_type
46749 , p_amb_context_code => l_amb_context_code
46746 , p_component_code => l_component_code
46747 , p_component_type_code => l_component_type_code
46748 , p_component_appl_id => l_component_appl_id
46750 , p_side => 'NA'
46751 );
46752
46753
46754 --
46755 --
46756 END IF;
46757 --
46758 -- Bug 4922099
46759 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
46760 (NVL(l_enc_upg_option, 'N') = 'O')
46761 ) AND
46762 (l_bflow_method_code = 'PRIOR_ENTRY')
46763 )
46764 THEN
46765 IF
46766 --
46767 1 = 2
46768 --
46769 THEN
46770 xla_accounting_err_pkg.build_message
46771 (p_appli_s_name => 'XLA'
46772 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46773 ,p_token_1 => 'LINE_NUMBER'
46774 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
46775 ,p_token_2 => 'LINE_TYPE_NAME'
46776 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
46777 l_component_type
46778 ,l_component_code
46779 ,l_component_type_code
46780 ,l_component_appl_id
46781 ,l_amb_context_code
46782 ,l_entity_code
46783 ,l_event_class_code
46784 )
46785 ,p_token_3 => 'OWNER'
46786 ,p_value_3 => xla_lookups_pkg.get_meaning(
46787 p_lookup_type => 'XLA_OWNER_TYPE'
46788 ,p_lookup_code => l_component_type_code
46789 )
46790 ,p_token_4 => 'PRODUCT_NAME'
46791 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
46792 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
46793 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
46794 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
46795 ,p_ae_header_id => NULL
46796 );
46797
46798 IF (C_LEVEL_ERROR>= g_log_level) THEN
46799 trace
46800 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46801 ,p_level => C_LEVEL_ERROR
46802 ,p_module => l_log_module);
46803 END IF;
46804 END IF;
46805 END IF;
46806 --
46807 --
46808 ------------------------------------------------------------------------------------------------
46809 -- 4219869 Business Flow
46810 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
46811 -- Prior Entry. Currently, the following code is always generated.
46812 ------------------------------------------------------------------------------------------------
46813 XLA_AE_LINES_PKG.ValidateCurrentLine;
46814
46815 ------------------------------------------------------------------------------------
46816 -- 4219869 Business Flow
46817 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
46818 ------------------------------------------------------------------------------------
46819 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46820
46821 ----------------------------------------------------------------------------------
46822 -- 4219869 Business Flow
46823 -- Update journal entry status -- Need to generate this within IF <condition>
46824 ----------------------------------------------------------------------------------
46825 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46826 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
46827 ,p_balance_type_code => l_balance_type_code
46828 );
46829
46830 -------------------------------------------------------------------------------------------
46831 -- 4262811 - Generate the Accrual Reversal lines
46832 -------------------------------------------------------------------------------------------
46833 BEGIN
46834 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
46835 (g_array_event(p_event_id).array_value_num('header_index'));
46836 IF l_acc_rev_flag IS NULL THEN
46837 l_acc_rev_flag := 'N';
46838 END IF;
46839 EXCEPTION
46840 WHEN OTHERS THEN
46841 l_acc_rev_flag := 'N';
46842 END;
46843 --
46844 IF (l_acc_rev_flag = 'Y') THEN
46845
46849 ------------------------------------------------------------------------------------------
46846 -- 4645092 ------------------------------------------------------------------------------
46847 -- To allow MPA report to determine if it should generate report process
46848 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
46850
46851 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
46852 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
46853 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
46854 -- call ADRs
46855 -- Bug 4922099
46856 --
46857 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46858 (NVL(l_actual_upg_option, 'N') = 'O') OR
46859 (NVL(l_enc_upg_option, 'N') = 'O')
46860 )
46861 THEN
46862 NULL;
46863 --
46864 --
46865
46866 l_ccid := AcctDerRule_11(
46867 p_application_id => p_application_id
46868 , p_ae_header_id => l_ae_header_id
46869 , p_source_10 => p_source_10
46870 , x_transaction_coa_id => l_adr_transaction_coa_id
46871 , x_accounting_coa_id => l_adr_accounting_coa_id
46872 , x_value_type_code => l_adr_value_type_code
46873 , p_side => 'NA'
46874 );
46875
46876 xla_ae_lines_pkg.set_ccid(
46877 p_code_combination_id => l_ccid
46878 , p_value_type_code => l_adr_value_type_code
46879 , p_transaction_coa_id => l_adr_transaction_coa_id
46880 , p_accounting_coa_id => l_adr_accounting_coa_id
46881 , p_adr_code => 'DIST_CCID'
46882 , p_adr_type_code => 'S'
46883 , p_component_type => l_component_type
46884 , p_component_code => l_component_code
46885 , p_component_type_code => l_component_type_code
46886 , p_component_appl_id => l_component_appl_id
46887 , p_amb_context_code => l_amb_context_code
46888 , p_side => 'NA'
46889 );
46890
46891
46892 --
46893 --
46894 END IF;
46895
46896 --
46897 -- Update the line information that should be overwritten
46898 --
46899 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
46900 p_header_num => 1);
46901 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
46902
46903 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
46904
46905 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
46906 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
46907 END IF;
46908
46909 --
46910 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
46911 --
46912 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
46913 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
46914 ELSE
46915 ---------------------------------------------------------------------------------------------------
46916 -- 4262811a Switch Sign
46917 ---------------------------------------------------------------------------------------------------
46918 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
46919 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46920 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46921 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46922 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46923 -- 5132302
46924 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
46925 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46926
46927 END IF;
46928
46929 -- 4955764
46930 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46931 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
46932
46933
46934 XLA_AE_LINES_PKG.ValidateCurrentLine;
46935 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46936
46937 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46938 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
46939 ,p_balance_type_code => l_balance_type_code);
46940
46941 END IF;
46942
46943 -----------------------------------------------------------------------------------------
46944 -- 4262811 Multiperiod Accounting
46945 -----------------------------------------------------------------------------------------
46946 -- No MPA option is assigned.
46947
46948
46949 END IF;
46950 END IF;
46951 --
46952
46953 --
46954 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46955 trace
46956 (p_msg => 'END of AcctLineType_103'
46957 ,p_level => C_LEVEL_PROCEDURE
46958 ,p_module => l_log_module);
46959 END IF;
46960 --
46961 EXCEPTION
46965 xla_exceptions_pkg.raise_message
46962 WHEN xla_exceptions_pkg.application_exception THEN
46963 RAISE;
46964 WHEN OTHERS THEN
46966 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_103');
46967 END AcctLineType_103;
46968 --
46969
46970 ---------------------------------------
46971 --
46972 -- PRIVATE FUNCTION
46973 -- AcctLineType_104
46974 --
46975 ---------------------------------------
46976 PROCEDURE AcctLineType_104 (
46977 p_application_id IN NUMBER
46978 ,p_event_id IN NUMBER
46979 ,p_calculate_acctd_flag IN VARCHAR2
46980 ,p_calculate_g_l_flag IN VARCHAR2
46981 ,p_actual_flag IN OUT VARCHAR2
46982 ,p_balance_type_code OUT VARCHAR2
46983 ,p_gain_or_loss_ref OUT VARCHAR2
46984
46985 --Distribution GL Account
46986 , p_source_10 IN NUMBER
46987 --Distribution Source Type
46988 , p_source_22 IN VARCHAR2
46989 --Distribution Line Identifier
46990 , p_source_24 IN NUMBER
46991 --Distribution Type
46992 , p_source_25 IN VARCHAR2
46993 --Entered Amount
46994 , p_source_26 IN NUMBER
46995 --Currency Code
46996 , p_source_27 IN VARCHAR2
46997 --Exchange Rate
46998 , p_source_29 IN NUMBER
46999 --Exchange Rate Type
47000 , p_source_30 IN VARCHAR2
47001 --Applied To Document Accounting Amount
47002 , p_source_31 IN NUMBER
47003 --Applied To Document Exchange Date
47004 , p_source_59 IN DATE
47005 --Distribution Multi Fund Additional Entry
47006 , p_source_71 IN VARCHAR2
47007 )
47008 IS
47009
47010 l_component_type VARCHAR2(80);
47011 l_component_code VARCHAR2(30);
47012 l_component_type_code VARCHAR2(1);
47013 l_component_appl_id INTEGER;
47014 l_amb_context_code VARCHAR2(30);
47015 l_entity_code VARCHAR2(30);
47016 l_event_class_code VARCHAR2(30);
47017 l_ae_header_id NUMBER;
47018 l_event_type_code VARCHAR2(30);
47019 l_line_definition_code VARCHAR2(30);
47020 l_line_definition_owner_code VARCHAR2(1);
47021 --
47022 -- adr variables
47023 l_segment VARCHAR2(30);
47024 l_ccid NUMBER;
47025 l_adr_transaction_coa_id NUMBER;
47026 l_adr_accounting_coa_id NUMBER;
47027 l_adr_flexfield_segment_code VARCHAR2(30);
47028 l_adr_flex_value_set_id NUMBER;
47029 l_adr_value_type_code VARCHAR2(30);
47030 l_adr_value_combination_id NUMBER;
47031 l_adr_value_segment_code VARCHAR2(30);
47032
47033 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
47034 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
47035 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
47036 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
47037
47038 -- 4262811 Variables ------------------------------------------------------------------------------------------
47039 l_entered_amt_idx NUMBER;
47040 l_accted_amt_idx NUMBER;
47041 l_acc_rev_flag VARCHAR2(1);
47042 l_accrual_line_num NUMBER;
47043 l_tmp_amt NUMBER;
47044 l_acc_rev_natural_side_code VARCHAR2(1);
47045
47046 l_num_entries NUMBER;
47047 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
47048 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
47049 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
47050 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
47051 l_recog_line_1 NUMBER;
47052 l_recog_line_2 NUMBER;
47053
47054 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
47055 l_bflow_applied_to_amt NUMBER; -- 5132302
47056 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
47057
47058 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
47059
47060 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
47061 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
47062
47063 ---------------------------------------------------------------------------------------------------------------
47064
47065
47066 --
47067 -- bulk performance
47068 --
47069 l_balance_type_code VARCHAR2(1);
47070 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
47071 l_log_module VARCHAR2(240);
47072
47073 --
47074 -- Upgrade strategy
47075 --
47076 l_actual_upg_option VARCHAR2(1);
47077 l_enc_upg_option VARCHAR2(1);
47078
47079 --
47080 BEGIN
47081 --
47082 IF g_log_enabled THEN
47083 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_104';
47084 END IF;
47085 --
47086 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
47087
47088 trace
47089 (p_msg => 'BEGIN of AcctLineType_104'
47090 ,p_level => C_LEVEL_PROCEDURE
47091 ,p_module => l_log_module);
47092
47093 END IF;
47094 --
47095 l_component_type := 'AMB_JLT';
47096 l_component_code := 'MISC_RCT_DEBT';
47097 l_component_type_code := 'S';
47098 l_component_appl_id := 222;
47102 l_event_type_code := 'MISC_RECEIPT_ALL';
47099 l_amb_context_code := 'DEFAULT';
47100 l_entity_code := 'RECEIPTS';
47101 l_event_class_code := 'MISC_RECEIPT';
47103 l_line_definition_owner_code := 'S';
47104 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
47105 --
47106 l_balance_type_code := 'A';
47107 l_segment := NULL;
47108 l_ccid := NULL;
47109 l_adr_transaction_coa_id := NULL;
47110 l_adr_accounting_coa_id := NULL;
47111 l_adr_flexfield_segment_code := NULL;
47112 l_adr_flex_value_set_id := NULL;
47113 l_adr_value_type_code := NULL;
47114 l_adr_value_combination_id := NULL;
47115 l_adr_value_segment_code := NULL;
47116
47117 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
47118 l_bflow_class_code := ''; -- 4219869 Business Flow
47119 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
47120 l_budgetary_control_flag := 'N';
47121
47122 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47123 l_bflow_applied_to_amt := NULL; -- 5132302
47124 l_entered_amt_idx := NULL; -- 4262811
47125 l_accted_amt_idx := NULL; -- 4262811
47126 l_acc_rev_flag := NULL; -- 4262811
47127 l_accrual_line_num := NULL; -- 4262811
47128 l_tmp_amt := NULL; -- 4262811
47129 --
47130
47131 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
47132 l_balance_type_code <> 'B' THEN
47133 IF NVL(p_source_22,'
47134 ') = 'SHORT_TERM_DEBT' AND
47135 NVL(p_source_71,'
47136 ') = 'N'
47137 THEN
47138
47139 --
47140 XLA_AE_LINES_PKG.SetNewLine;
47141
47142 p_balance_type_code := l_balance_type_code;
47143 -- set the flag so later we will know whether the gain loss line needs to be created
47144
47145 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
47146 p_actual_flag :='A';
47147 END IF;
47148
47149 --
47150 -- bulk performance
47151 --
47152 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
47153 p_header_num => 0); -- 4262811
47154 --
47155 -- set accounting line options
47156 --
47157 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
47158 p_natural_side_code => 'C'
47159 , p_gain_or_loss_flag => 'N'
47160 , p_gl_transfer_mode_code => 'S'
47161 , p_acct_entry_type_code => 'A'
47162 , p_switch_side_flag => 'Y'
47163 , p_merge_duplicate_code => 'A'
47164 );
47165 --
47166 l_acc_rev_natural_side_code := 'D'; -- 4262811
47167 --
47168 --
47169 -- set accounting line type info
47170 --
47171 xla_ae_lines_pkg.SetAcctLineType
47172 (p_component_type => l_component_type
47173 ,p_event_type_code => l_event_type_code
47174 ,p_line_definition_owner_code => l_line_definition_owner_code
47175 ,p_line_definition_code => l_line_definition_code
47176 ,p_accounting_line_code => l_component_code
47177 ,p_accounting_line_type_code => l_component_type_code
47178 ,p_accounting_line_appl_id => l_component_appl_id
47179 ,p_amb_context_code => l_amb_context_code
47180 ,p_entity_code => l_entity_code
47181 ,p_event_class_code => l_event_class_code);
47182 --
47183 -- set accounting class
47184 --
47185 xla_ae_lines_pkg.SetAcctClass(
47186 p_accounting_class_code => 'SHORT_TERM_DEBT'
47187 , p_ae_header_id => l_ae_header_id
47188 );
47189
47190 --
47191 -- set rounding class
47192 --
47193 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
47194 'RECEIVABLE';
47195
47196 --
47197 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
47198 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
47199 --
47200 -- bulk performance
47201 --
47202 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
47203
47204 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
47205 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
47206
47207 -- 4955764
47208 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
47209 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
47210
47211 -- 4458381 Public Sector Enh
47212
47213 --
47214 -- set accounting attributes for the line type
47215 --
47216 l_entered_amt_idx := 3;
47217 l_accted_amt_idx := 8;
47218 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47219 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
47220 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
47221 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
47222 l_rec_acct_attrs.array_char_value(2) := p_source_25;
47223 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
47227 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
47224 l_rec_acct_attrs.array_num_value(3) := p_source_26;
47225 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
47226 l_rec_acct_attrs.array_char_value(4) := p_source_27;
47228 l_rec_acct_attrs.array_date_value(5) := p_source_59;
47229 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
47230 l_rec_acct_attrs.array_num_value(6) := p_source_29;
47231 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
47232 l_rec_acct_attrs.array_char_value(7) := p_source_30;
47233 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
47234 l_rec_acct_attrs.array_num_value(8) := p_source_31;
47235
47236 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
47237 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
47238
47239 ---------------------------------------------------------------------------------------------------------------
47240 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
47241 ---------------------------------------------------------------------------------------------------------------
47242 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
47243
47244 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47245 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47246
47247 IF xla_accounting_cache_pkg.GetValueChar
47248 (p_source_code => 'LEDGER_CATEGORY_CODE'
47249 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
47250 AND l_bflow_method_code = 'PRIOR_ENTRY'
47251 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
47252 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
47253 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
47254 )
47255 THEN
47256 xla_ae_lines_pkg.BflowUpgEntry
47257 (p_business_method_code => l_bflow_method_code
47258 ,p_business_class_code => l_bflow_class_code
47259 ,p_balance_type => l_balance_type_code);
47260 ELSE
47261 NULL;
47262 -- No business flow processing for business flow method of NONE.
47263 END IF;
47264
47265 --
47266 -- call analytical criteria
47267 --
47268
47269 --
47270 -- call description
47271 --
47272 -- No description or it is inherited.
47273 --
47274 -- call ADRs
47275 -- Bug 4922099
47276 --
47277 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47278 (NVL(l_actual_upg_option, 'N') = 'O') OR
47279 (NVL(l_enc_upg_option, 'N') = 'O')
47280 )
47281 THEN
47282 NULL;
47283 --
47284 --
47285
47286 l_ccid := AcctDerRule_11(
47287 p_application_id => p_application_id
47288 , p_ae_header_id => l_ae_header_id
47289 , p_source_10 => p_source_10
47290 , x_transaction_coa_id => l_adr_transaction_coa_id
47291 , x_accounting_coa_id => l_adr_accounting_coa_id
47292 , x_value_type_code => l_adr_value_type_code
47293 , p_side => 'NA'
47294 );
47295
47296 xla_ae_lines_pkg.set_ccid(
47297 p_code_combination_id => l_ccid
47298 , p_value_type_code => l_adr_value_type_code
47299 , p_transaction_coa_id => l_adr_transaction_coa_id
47300 , p_accounting_coa_id => l_adr_accounting_coa_id
47301 , p_adr_code => 'DIST_CCID'
47302 , p_adr_type_code => 'S'
47303 , p_component_type => l_component_type
47304 , p_component_code => l_component_code
47305 , p_component_type_code => l_component_type_code
47306 , p_component_appl_id => l_component_appl_id
47307 , p_amb_context_code => l_amb_context_code
47308 , p_side => 'NA'
47309 );
47310
47311
47312 --
47313 --
47314 END IF;
47315 --
47316 -- Bug 4922099
47317 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
47318 (NVL(l_enc_upg_option, 'N') = 'O')
47319 ) AND
47320 (l_bflow_method_code = 'PRIOR_ENTRY')
47321 )
47322 THEN
47323 IF
47324 --
47325 1 = 2
47326 --
47327 THEN
47328 xla_accounting_err_pkg.build_message
47329 (p_appli_s_name => 'XLA'
47330 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47331 ,p_token_1 => 'LINE_NUMBER'
47332 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
47333 ,p_token_2 => 'LINE_TYPE_NAME'
47334 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
47335 l_component_type
47336 ,l_component_code
47337 ,l_component_type_code
47341 ,l_event_class_code
47338 ,l_component_appl_id
47339 ,l_amb_context_code
47340 ,l_entity_code
47342 )
47343 ,p_token_3 => 'OWNER'
47344 ,p_value_3 => xla_lookups_pkg.get_meaning(
47345 p_lookup_type => 'XLA_OWNER_TYPE'
47346 ,p_lookup_code => l_component_type_code
47347 )
47348 ,p_token_4 => 'PRODUCT_NAME'
47349 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
47350 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
47351 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
47352 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
47353 ,p_ae_header_id => NULL
47354 );
47355
47356 IF (C_LEVEL_ERROR>= g_log_level) THEN
47357 trace
47358 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47359 ,p_level => C_LEVEL_ERROR
47360 ,p_module => l_log_module);
47361 END IF;
47362 END IF;
47363 END IF;
47364 --
47365 --
47366 ------------------------------------------------------------------------------------------------
47367 -- 4219869 Business Flow
47368 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
47369 -- Prior Entry. Currently, the following code is always generated.
47370 ------------------------------------------------------------------------------------------------
47371 XLA_AE_LINES_PKG.ValidateCurrentLine;
47372
47373 ------------------------------------------------------------------------------------
47374 -- 4219869 Business Flow
47375 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
47376 ------------------------------------------------------------------------------------
47377 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
47378
47379 ----------------------------------------------------------------------------------
47380 -- 4219869 Business Flow
47381 -- Update journal entry status -- Need to generate this within IF <condition>
47382 ----------------------------------------------------------------------------------
47383 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
47384 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
47385 ,p_balance_type_code => l_balance_type_code
47386 );
47387
47388 -------------------------------------------------------------------------------------------
47389 -- 4262811 - Generate the Accrual Reversal lines
47390 -------------------------------------------------------------------------------------------
47391 BEGIN
47392 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
47393 (g_array_event(p_event_id).array_value_num('header_index'));
47394 IF l_acc_rev_flag IS NULL THEN
47395 l_acc_rev_flag := 'N';
47396 END IF;
47397 EXCEPTION
47398 WHEN OTHERS THEN
47399 l_acc_rev_flag := 'N';
47400 END;
47401 --
47402 IF (l_acc_rev_flag = 'Y') THEN
47403
47404 -- 4645092 ------------------------------------------------------------------------------
47405 -- To allow MPA report to determine if it should generate report process
47406 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
47407 ------------------------------------------------------------------------------------------
47408
47409 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
47410 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
47411 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
47412 -- call ADRs
47413 -- Bug 4922099
47414 --
47415 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47416 (NVL(l_actual_upg_option, 'N') = 'O') OR
47417 (NVL(l_enc_upg_option, 'N') = 'O')
47418 )
47419 THEN
47420 NULL;
47421 --
47422 --
47423
47424 l_ccid := AcctDerRule_11(
47425 p_application_id => p_application_id
47426 , p_ae_header_id => l_ae_header_id
47427 , p_source_10 => p_source_10
47428 , x_transaction_coa_id => l_adr_transaction_coa_id
47429 , x_accounting_coa_id => l_adr_accounting_coa_id
47430 , x_value_type_code => l_adr_value_type_code
47431 , p_side => 'NA'
47432 );
47433
47434 xla_ae_lines_pkg.set_ccid(
47435 p_code_combination_id => l_ccid
47436 , p_value_type_code => l_adr_value_type_code
47437 , p_transaction_coa_id => l_adr_transaction_coa_id
47438 , p_accounting_coa_id => l_adr_accounting_coa_id
47442 , p_component_code => l_component_code
47439 , p_adr_code => 'DIST_CCID'
47440 , p_adr_type_code => 'S'
47441 , p_component_type => l_component_type
47443 , p_component_type_code => l_component_type_code
47444 , p_component_appl_id => l_component_appl_id
47445 , p_amb_context_code => l_amb_context_code
47446 , p_side => 'NA'
47447 );
47448
47449
47450 --
47451 --
47452 END IF;
47453
47454 --
47455 -- Update the line information that should be overwritten
47456 --
47457 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
47458 p_header_num => 1);
47459 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
47460
47461 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
47462
47463 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
47464 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
47465 END IF;
47466
47467 --
47468 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
47469 --
47470 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
47471 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
47472 ELSE
47473 ---------------------------------------------------------------------------------------------------
47474 -- 4262811a Switch Sign
47475 ---------------------------------------------------------------------------------------------------
47476 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
47477 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
47478 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47479 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
47480 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47481 -- 5132302
47482 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
47483 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47484
47485 END IF;
47486
47487 -- 4955764
47488 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
47489 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
47490
47491
47492 XLA_AE_LINES_PKG.ValidateCurrentLine;
47493 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
47494
47495 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
47496 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
47497 ,p_balance_type_code => l_balance_type_code);
47498
47499 END IF;
47500
47501 -----------------------------------------------------------------------------------------
47502 -- 4262811 Multiperiod Accounting
47503 -----------------------------------------------------------------------------------------
47504 -- No MPA option is assigned.
47505
47506
47507 END IF;
47508 END IF;
47509 --
47510
47511 --
47512 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
47513 trace
47514 (p_msg => 'END of AcctLineType_104'
47515 ,p_level => C_LEVEL_PROCEDURE
47516 ,p_module => l_log_module);
47517 END IF;
47518 --
47519 EXCEPTION
47520 WHEN xla_exceptions_pkg.application_exception THEN
47521 RAISE;
47522 WHEN OTHERS THEN
47523 xla_exceptions_pkg.raise_message
47524 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_104');
47525 END AcctLineType_104;
47526 --
47527
47528 ---------------------------------------
47529 --
47530 -- PRIVATE FUNCTION
47531 -- AcctLineType_105
47532 --
47533 ---------------------------------------
47534 PROCEDURE AcctLineType_105 (
47535 p_application_id IN NUMBER
47536 ,p_event_id IN NUMBER
47537 ,p_calculate_acctd_flag IN VARCHAR2
47538 ,p_calculate_g_l_flag IN VARCHAR2
47539 ,p_actual_flag IN OUT VARCHAR2
47540 ,p_balance_type_code OUT VARCHAR2
47541 ,p_gain_or_loss_ref OUT VARCHAR2
47542
47543 --Distribution GL Account
47544 , p_source_10 IN NUMBER
47545 --Distribution Source Type
47546 , p_source_22 IN VARCHAR2
47547 --Distribution Line Identifier
47548 , p_source_24 IN NUMBER
47549 --Distribution Type
47550 , p_source_25 IN VARCHAR2
47551 --Entered Amount
47552 , p_source_26 IN NUMBER
47553 --Currency Code
47554 , p_source_27 IN VARCHAR2
47555 --Exchange Rate
47556 , p_source_29 IN NUMBER
47557 --Exchange Rate Type
47558 , p_source_30 IN VARCHAR2
47559 --Applied To Document Accounting Amount
47560 , p_source_31 IN NUMBER
47561 --Applied To Document Exchange Date
47562 , p_source_59 IN DATE
47563 --Distribution Multi Fund Additional Entry
47567
47564 , p_source_71 IN VARCHAR2
47565 )
47566 IS
47568 l_component_type VARCHAR2(80);
47569 l_component_code VARCHAR2(30);
47570 l_component_type_code VARCHAR2(1);
47571 l_component_appl_id INTEGER;
47572 l_amb_context_code VARCHAR2(30);
47573 l_entity_code VARCHAR2(30);
47574 l_event_class_code VARCHAR2(30);
47575 l_ae_header_id NUMBER;
47576 l_event_type_code VARCHAR2(30);
47577 l_line_definition_code VARCHAR2(30);
47578 l_line_definition_owner_code VARCHAR2(1);
47579 --
47580 -- adr variables
47581 l_segment VARCHAR2(30);
47582 l_ccid NUMBER;
47583 l_adr_transaction_coa_id NUMBER;
47584 l_adr_accounting_coa_id NUMBER;
47585 l_adr_flexfield_segment_code VARCHAR2(30);
47586 l_adr_flex_value_set_id NUMBER;
47587 l_adr_value_type_code VARCHAR2(30);
47588 l_adr_value_combination_id NUMBER;
47589 l_adr_value_segment_code VARCHAR2(30);
47590
47591 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
47592 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
47593 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
47594 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
47595
47596 -- 4262811 Variables ------------------------------------------------------------------------------------------
47597 l_entered_amt_idx NUMBER;
47598 l_accted_amt_idx NUMBER;
47599 l_acc_rev_flag VARCHAR2(1);
47600 l_accrual_line_num NUMBER;
47601 l_tmp_amt NUMBER;
47602 l_acc_rev_natural_side_code VARCHAR2(1);
47603
47604 l_num_entries NUMBER;
47605 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
47606 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
47607 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
47608 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
47609 l_recog_line_1 NUMBER;
47610 l_recog_line_2 NUMBER;
47611
47612 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
47613 l_bflow_applied_to_amt NUMBER; -- 5132302
47614 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
47615
47616 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
47617
47618 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
47619 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
47620
47621 ---------------------------------------------------------------------------------------------------------------
47622
47623
47624 --
47625 -- bulk performance
47626 --
47627 l_balance_type_code VARCHAR2(1);
47628 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
47629 l_log_module VARCHAR2(240);
47630
47631 --
47632 -- Upgrade strategy
47633 --
47634 l_actual_upg_option VARCHAR2(1);
47635 l_enc_upg_option VARCHAR2(1);
47636
47637 --
47638 BEGIN
47639 --
47640 IF g_log_enabled THEN
47641 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_105';
47642 END IF;
47643 --
47644 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
47645
47646 trace
47647 (p_msg => 'BEGIN of AcctLineType_105'
47648 ,p_level => C_LEVEL_PROCEDURE
47649 ,p_module => l_log_module);
47650
47651 END IF;
47652 --
47653 l_component_type := 'AMB_JLT';
47654 l_component_code := 'MISC_RCT_FACTOR';
47655 l_component_type_code := 'S';
47656 l_component_appl_id := 222;
47657 l_amb_context_code := 'DEFAULT';
47658 l_entity_code := 'RECEIPTS';
47659 l_event_class_code := 'MISC_RECEIPT';
47660 l_event_type_code := 'MISC_RECEIPT_ALL';
47661 l_line_definition_owner_code := 'S';
47662 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
47663 --
47664 l_balance_type_code := 'A';
47665 l_segment := NULL;
47666 l_ccid := NULL;
47667 l_adr_transaction_coa_id := NULL;
47668 l_adr_accounting_coa_id := NULL;
47669 l_adr_flexfield_segment_code := NULL;
47670 l_adr_flex_value_set_id := NULL;
47671 l_adr_value_type_code := NULL;
47672 l_adr_value_combination_id := NULL;
47673 l_adr_value_segment_code := NULL;
47674
47675 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
47676 l_bflow_class_code := ''; -- 4219869 Business Flow
47677 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
47678 l_budgetary_control_flag := 'N';
47679
47680 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47681 l_bflow_applied_to_amt := NULL; -- 5132302
47682 l_entered_amt_idx := NULL; -- 4262811
47683 l_accted_amt_idx := NULL; -- 4262811
47684 l_acc_rev_flag := NULL; -- 4262811
47685 l_accrual_line_num := NULL; -- 4262811
47686 l_tmp_amt := NULL; -- 4262811
47687 --
47688
47689 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
47690 l_balance_type_code <> 'B' THEN
47694 ') = 'N'
47691 IF NVL(p_source_22,'
47692 ') = 'FACTOR' AND
47693 NVL(p_source_71,'
47695 THEN
47696
47697 --
47698 XLA_AE_LINES_PKG.SetNewLine;
47699
47700 p_balance_type_code := l_balance_type_code;
47701 -- set the flag so later we will know whether the gain loss line needs to be created
47702
47703 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
47704 p_actual_flag :='A';
47705 END IF;
47706
47707 --
47708 -- bulk performance
47709 --
47710 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
47711 p_header_num => 0); -- 4262811
47712 --
47713 -- set accounting line options
47714 --
47715 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
47716 p_natural_side_code => 'C'
47717 , p_gain_or_loss_flag => 'N'
47718 , p_gl_transfer_mode_code => 'S'
47719 , p_acct_entry_type_code => 'A'
47720 , p_switch_side_flag => 'Y'
47721 , p_merge_duplicate_code => 'A'
47722 );
47723 --
47724 l_acc_rev_natural_side_code := 'D'; -- 4262811
47725 --
47726 --
47727 -- set accounting line type info
47728 --
47729 xla_ae_lines_pkg.SetAcctLineType
47730 (p_component_type => l_component_type
47731 ,p_event_type_code => l_event_type_code
47732 ,p_line_definition_owner_code => l_line_definition_owner_code
47733 ,p_line_definition_code => l_line_definition_code
47734 ,p_accounting_line_code => l_component_code
47735 ,p_accounting_line_type_code => l_component_type_code
47736 ,p_accounting_line_appl_id => l_component_appl_id
47737 ,p_amb_context_code => l_amb_context_code
47738 ,p_entity_code => l_entity_code
47739 ,p_event_class_code => l_event_class_code);
47740 --
47741 -- set accounting class
47742 --
47743 xla_ae_lines_pkg.SetAcctClass(
47744 p_accounting_class_code => 'FACTOR'
47745 , p_ae_header_id => l_ae_header_id
47746 );
47747
47748 --
47749 -- set rounding class
47750 --
47751 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
47752 'RECEIVABLE';
47753
47754 --
47755 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
47756 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
47757 --
47758 -- bulk performance
47759 --
47760 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
47761
47762 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
47763 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
47764
47765 -- 4955764
47766 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
47767 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
47768
47769 -- 4458381 Public Sector Enh
47770
47771 --
47772 -- set accounting attributes for the line type
47773 --
47774 l_entered_amt_idx := 3;
47775 l_accted_amt_idx := 8;
47776 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47777 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
47778 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
47779 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
47780 l_rec_acct_attrs.array_char_value(2) := p_source_25;
47781 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
47782 l_rec_acct_attrs.array_num_value(3) := p_source_26;
47783 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
47784 l_rec_acct_attrs.array_char_value(4) := p_source_27;
47785 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
47786 l_rec_acct_attrs.array_date_value(5) := p_source_59;
47787 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
47788 l_rec_acct_attrs.array_num_value(6) := p_source_29;
47789 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
47790 l_rec_acct_attrs.array_char_value(7) := p_source_30;
47791 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
47792 l_rec_acct_attrs.array_num_value(8) := p_source_31;
47793
47794 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
47795 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
47796
47797 ---------------------------------------------------------------------------------------------------------------
47798 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
47799 ---------------------------------------------------------------------------------------------------------------
47800 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
47801
47802 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47803 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47804
47805 IF xla_accounting_cache_pkg.GetValueChar
47809 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
47806 (p_source_code => 'LEDGER_CATEGORY_CODE'
47807 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
47808 AND l_bflow_method_code = 'PRIOR_ENTRY'
47810 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
47811 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
47812 )
47813 THEN
47814 xla_ae_lines_pkg.BflowUpgEntry
47815 (p_business_method_code => l_bflow_method_code
47816 ,p_business_class_code => l_bflow_class_code
47817 ,p_balance_type => l_balance_type_code);
47818 ELSE
47819 NULL;
47820 -- No business flow processing for business flow method of NONE.
47821 END IF;
47822
47823 --
47824 -- call analytical criteria
47825 --
47826
47827 --
47828 -- call description
47829 --
47830 -- No description or it is inherited.
47831 --
47832 -- call ADRs
47833 -- Bug 4922099
47834 --
47835 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47836 (NVL(l_actual_upg_option, 'N') = 'O') OR
47837 (NVL(l_enc_upg_option, 'N') = 'O')
47838 )
47839 THEN
47840 NULL;
47841 --
47842 --
47843
47844 l_ccid := AcctDerRule_11(
47845 p_application_id => p_application_id
47846 , p_ae_header_id => l_ae_header_id
47847 , p_source_10 => p_source_10
47848 , x_transaction_coa_id => l_adr_transaction_coa_id
47849 , x_accounting_coa_id => l_adr_accounting_coa_id
47850 , x_value_type_code => l_adr_value_type_code
47851 , p_side => 'NA'
47852 );
47853
47854 xla_ae_lines_pkg.set_ccid(
47855 p_code_combination_id => l_ccid
47856 , p_value_type_code => l_adr_value_type_code
47857 , p_transaction_coa_id => l_adr_transaction_coa_id
47858 , p_accounting_coa_id => l_adr_accounting_coa_id
47859 , p_adr_code => 'DIST_CCID'
47860 , p_adr_type_code => 'S'
47861 , p_component_type => l_component_type
47862 , p_component_code => l_component_code
47863 , p_component_type_code => l_component_type_code
47864 , p_component_appl_id => l_component_appl_id
47865 , p_amb_context_code => l_amb_context_code
47866 , p_side => 'NA'
47867 );
47868
47869
47870 --
47871 --
47872 END IF;
47873 --
47874 -- Bug 4922099
47875 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
47876 (NVL(l_enc_upg_option, 'N') = 'O')
47877 ) AND
47878 (l_bflow_method_code = 'PRIOR_ENTRY')
47879 )
47880 THEN
47881 IF
47882 --
47883 1 = 2
47884 --
47885 THEN
47886 xla_accounting_err_pkg.build_message
47887 (p_appli_s_name => 'XLA'
47888 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47889 ,p_token_1 => 'LINE_NUMBER'
47890 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
47891 ,p_token_2 => 'LINE_TYPE_NAME'
47892 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
47893 l_component_type
47894 ,l_component_code
47895 ,l_component_type_code
47896 ,l_component_appl_id
47897 ,l_amb_context_code
47898 ,l_entity_code
47899 ,l_event_class_code
47900 )
47901 ,p_token_3 => 'OWNER'
47902 ,p_value_3 => xla_lookups_pkg.get_meaning(
47903 p_lookup_type => 'XLA_OWNER_TYPE'
47904 ,p_lookup_code => l_component_type_code
47905 )
47906 ,p_token_4 => 'PRODUCT_NAME'
47907 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
47908 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
47909 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
47910 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
47911 ,p_ae_header_id => NULL
47912 );
47913
47914 IF (C_LEVEL_ERROR>= g_log_level) THEN
47915 trace
47919 END IF;
47916 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47917 ,p_level => C_LEVEL_ERROR
47918 ,p_module => l_log_module);
47920 END IF;
47921 END IF;
47922 --
47923 --
47924 ------------------------------------------------------------------------------------------------
47925 -- 4219869 Business Flow
47926 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
47927 -- Prior Entry. Currently, the following code is always generated.
47928 ------------------------------------------------------------------------------------------------
47929 XLA_AE_LINES_PKG.ValidateCurrentLine;
47930
47931 ------------------------------------------------------------------------------------
47932 -- 4219869 Business Flow
47933 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
47934 ------------------------------------------------------------------------------------
47935 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
47936
47937 ----------------------------------------------------------------------------------
47938 -- 4219869 Business Flow
47939 -- Update journal entry status -- Need to generate this within IF <condition>
47940 ----------------------------------------------------------------------------------
47941 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
47942 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
47943 ,p_balance_type_code => l_balance_type_code
47944 );
47945
47946 -------------------------------------------------------------------------------------------
47947 -- 4262811 - Generate the Accrual Reversal lines
47948 -------------------------------------------------------------------------------------------
47949 BEGIN
47950 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
47951 (g_array_event(p_event_id).array_value_num('header_index'));
47952 IF l_acc_rev_flag IS NULL THEN
47953 l_acc_rev_flag := 'N';
47954 END IF;
47955 EXCEPTION
47956 WHEN OTHERS THEN
47957 l_acc_rev_flag := 'N';
47958 END;
47959 --
47960 IF (l_acc_rev_flag = 'Y') THEN
47961
47962 -- 4645092 ------------------------------------------------------------------------------
47963 -- To allow MPA report to determine if it should generate report process
47964 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
47965 ------------------------------------------------------------------------------------------
47966
47967 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
47968 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
47969 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
47970 -- call ADRs
47971 -- Bug 4922099
47972 --
47973 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47974 (NVL(l_actual_upg_option, 'N') = 'O') OR
47975 (NVL(l_enc_upg_option, 'N') = 'O')
47976 )
47977 THEN
47978 NULL;
47979 --
47980 --
47981
47982 l_ccid := AcctDerRule_11(
47983 p_application_id => p_application_id
47984 , p_ae_header_id => l_ae_header_id
47985 , p_source_10 => p_source_10
47986 , x_transaction_coa_id => l_adr_transaction_coa_id
47987 , x_accounting_coa_id => l_adr_accounting_coa_id
47988 , x_value_type_code => l_adr_value_type_code
47989 , p_side => 'NA'
47990 );
47991
47992 xla_ae_lines_pkg.set_ccid(
47993 p_code_combination_id => l_ccid
47994 , p_value_type_code => l_adr_value_type_code
47995 , p_transaction_coa_id => l_adr_transaction_coa_id
47996 , p_accounting_coa_id => l_adr_accounting_coa_id
47997 , p_adr_code => 'DIST_CCID'
47998 , p_adr_type_code => 'S'
47999 , p_component_type => l_component_type
48000 , p_component_code => l_component_code
48001 , p_component_type_code => l_component_type_code
48002 , p_component_appl_id => l_component_appl_id
48003 , p_amb_context_code => l_amb_context_code
48004 , p_side => 'NA'
48005 );
48006
48007
48008 --
48009 --
48010 END IF;
48011
48012 --
48013 -- Update the line information that should be overwritten
48014 --
48015 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
48016 p_header_num => 1);
48017 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
48018
48019 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
48020
48021 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
48022 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
48023 END IF;
48024
48025 --
48026 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
48027 --
48028 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
48029 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
48030 ELSE
48034 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
48031 ---------------------------------------------------------------------------------------------------
48032 -- 4262811a Switch Sign
48033 ---------------------------------------------------------------------------------------------------
48035 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48036 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48037 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48038 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48039 -- 5132302
48040 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
48041 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48042
48043 END IF;
48044
48045 -- 4955764
48046 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48047 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
48048
48049
48050 XLA_AE_LINES_PKG.ValidateCurrentLine;
48051 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
48052
48053 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
48054 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
48055 ,p_balance_type_code => l_balance_type_code);
48056
48057 END IF;
48058
48059 -----------------------------------------------------------------------------------------
48060 -- 4262811 Multiperiod Accounting
48061 -----------------------------------------------------------------------------------------
48062 -- No MPA option is assigned.
48063
48064
48065 END IF;
48066 END IF;
48067 --
48068
48069 --
48070 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48071 trace
48072 (p_msg => 'END of AcctLineType_105'
48073 ,p_level => C_LEVEL_PROCEDURE
48074 ,p_module => l_log_module);
48075 END IF;
48076 --
48077 EXCEPTION
48078 WHEN xla_exceptions_pkg.application_exception THEN
48079 RAISE;
48080 WHEN OTHERS THEN
48081 xla_exceptions_pkg.raise_message
48082 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_105');
48083 END AcctLineType_105;
48084 --
48085
48086 ---------------------------------------
48087 --
48088 -- PRIVATE FUNCTION
48089 -- AcctLineType_106
48090 --
48091 ---------------------------------------
48092 PROCEDURE AcctLineType_106 (
48093 p_application_id IN NUMBER
48094 ,p_event_id IN NUMBER
48095 ,p_calculate_acctd_flag IN VARCHAR2
48096 ,p_calculate_g_l_flag IN VARCHAR2
48097 ,p_actual_flag IN OUT VARCHAR2
48098 ,p_balance_type_code OUT VARCHAR2
48099 ,p_gain_or_loss_ref OUT VARCHAR2
48100
48101 --Distribution GL Account
48102 , p_source_10 IN NUMBER
48103 --Distribution Source Type
48104 , p_source_22 IN VARCHAR2
48105 --Distribution Line Identifier
48106 , p_source_24 IN NUMBER
48107 --Distribution Type
48108 , p_source_25 IN VARCHAR2
48109 --Entered Amount
48110 , p_source_26 IN NUMBER
48111 --Currency Code
48112 , p_source_27 IN VARCHAR2
48113 --Exchange Rate
48114 , p_source_29 IN NUMBER
48115 --Exchange Rate Type
48116 , p_source_30 IN VARCHAR2
48117 --Applied To Document Accounting Amount
48118 , p_source_31 IN NUMBER
48119 --Applied To Document Exchange Date
48120 , p_source_59 IN DATE
48121 --Distribution Multi Fund Additional Entry
48122 , p_source_71 IN VARCHAR2
48123 )
48124 IS
48125
48126 l_component_type VARCHAR2(80);
48127 l_component_code VARCHAR2(30);
48128 l_component_type_code VARCHAR2(1);
48129 l_component_appl_id INTEGER;
48130 l_amb_context_code VARCHAR2(30);
48131 l_entity_code VARCHAR2(30);
48132 l_event_class_code VARCHAR2(30);
48133 l_ae_header_id NUMBER;
48134 l_event_type_code VARCHAR2(30);
48135 l_line_definition_code VARCHAR2(30);
48136 l_line_definition_owner_code VARCHAR2(1);
48137 --
48138 -- adr variables
48139 l_segment VARCHAR2(30);
48140 l_ccid NUMBER;
48141 l_adr_transaction_coa_id NUMBER;
48142 l_adr_accounting_coa_id NUMBER;
48143 l_adr_flexfield_segment_code VARCHAR2(30);
48144 l_adr_flex_value_set_id NUMBER;
48145 l_adr_value_type_code VARCHAR2(30);
48146 l_adr_value_combination_id NUMBER;
48147 l_adr_value_segment_code VARCHAR2(30);
48148
48149 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
48150 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
48151 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
48152 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
48153
48154 -- 4262811 Variables ------------------------------------------------------------------------------------------
48155 l_entered_amt_idx NUMBER;
48156 l_accted_amt_idx NUMBER;
48160 l_acc_rev_natural_side_code VARCHAR2(1);
48157 l_acc_rev_flag VARCHAR2(1);
48158 l_accrual_line_num NUMBER;
48159 l_tmp_amt NUMBER;
48161
48162 l_num_entries NUMBER;
48163 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
48164 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
48165 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
48166 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
48167 l_recog_line_1 NUMBER;
48168 l_recog_line_2 NUMBER;
48169
48170 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
48171 l_bflow_applied_to_amt NUMBER; -- 5132302
48172 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
48173
48174 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
48175
48176 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
48177 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
48178
48179 ---------------------------------------------------------------------------------------------------------------
48180
48181
48182 --
48183 -- bulk performance
48184 --
48185 l_balance_type_code VARCHAR2(1);
48186 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
48187 l_log_module VARCHAR2(240);
48188
48189 --
48190 -- Upgrade strategy
48191 --
48192 l_actual_upg_option VARCHAR2(1);
48193 l_enc_upg_option VARCHAR2(1);
48194
48195 --
48196 BEGIN
48197 --
48198 IF g_log_enabled THEN
48199 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_106';
48200 END IF;
48201 --
48202 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48203
48204 trace
48205 (p_msg => 'BEGIN of AcctLineType_106'
48206 ,p_level => C_LEVEL_PROCEDURE
48207 ,p_module => l_log_module);
48208
48209 END IF;
48210 --
48211 l_component_type := 'AMB_JLT';
48212 l_component_code := 'MISC_RCT_MISCCASH';
48213 l_component_type_code := 'S';
48214 l_component_appl_id := 222;
48215 l_amb_context_code := 'DEFAULT';
48216 l_entity_code := 'RECEIPTS';
48217 l_event_class_code := 'MISC_RECEIPT';
48218 l_event_type_code := 'MISC_RECEIPT_ALL';
48219 l_line_definition_owner_code := 'S';
48220 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
48221 --
48222 l_balance_type_code := 'A';
48223 l_segment := NULL;
48224 l_ccid := NULL;
48225 l_adr_transaction_coa_id := NULL;
48226 l_adr_accounting_coa_id := NULL;
48227 l_adr_flexfield_segment_code := NULL;
48228 l_adr_flex_value_set_id := NULL;
48229 l_adr_value_type_code := NULL;
48230 l_adr_value_combination_id := NULL;
48231 l_adr_value_segment_code := NULL;
48232
48233 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
48234 l_bflow_class_code := ''; -- 4219869 Business Flow
48235 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
48236 l_budgetary_control_flag := 'N';
48237
48238 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48239 l_bflow_applied_to_amt := NULL; -- 5132302
48240 l_entered_amt_idx := NULL; -- 4262811
48241 l_accted_amt_idx := NULL; -- 4262811
48242 l_acc_rev_flag := NULL; -- 4262811
48243 l_accrual_line_num := NULL; -- 4262811
48244 l_tmp_amt := NULL; -- 4262811
48245 --
48246
48247 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
48248 l_balance_type_code <> 'B' THEN
48249 IF NVL(p_source_22,'
48250 ') = 'MISCCASH' AND
48251 NVL(p_source_71,'
48252 ') = 'N'
48253 THEN
48254
48255 --
48256 XLA_AE_LINES_PKG.SetNewLine;
48257
48258 p_balance_type_code := l_balance_type_code;
48259 -- set the flag so later we will know whether the gain loss line needs to be created
48260
48261 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
48262 p_actual_flag :='A';
48263 END IF;
48264
48265 --
48266 -- bulk performance
48267 --
48268 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
48269 p_header_num => 0); -- 4262811
48270 --
48271 -- set accounting line options
48272 --
48273 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
48274 p_natural_side_code => 'C'
48275 , p_gain_or_loss_flag => 'N'
48276 , p_gl_transfer_mode_code => 'S'
48277 , p_acct_entry_type_code => 'A'
48278 , p_switch_side_flag => 'Y'
48279 , p_merge_duplicate_code => 'A'
48280 );
48281 --
48282 l_acc_rev_natural_side_code := 'D'; -- 4262811
48283 --
48284 --
48285 -- set accounting line type info
48286 --
48287 xla_ae_lines_pkg.SetAcctLineType
48288 (p_component_type => l_component_type
48289 ,p_event_type_code => l_event_type_code
48290 ,p_line_definition_owner_code => l_line_definition_owner_code
48291 ,p_line_definition_code => l_line_definition_code
48295 ,p_amb_context_code => l_amb_context_code
48292 ,p_accounting_line_code => l_component_code
48293 ,p_accounting_line_type_code => l_component_type_code
48294 ,p_accounting_line_appl_id => l_component_appl_id
48296 ,p_entity_code => l_entity_code
48297 ,p_event_class_code => l_event_class_code);
48298 --
48299 -- set accounting class
48300 --
48301 xla_ae_lines_pkg.SetAcctClass(
48302 p_accounting_class_code => 'MISC_CASH'
48303 , p_ae_header_id => l_ae_header_id
48304 );
48305
48306 --
48307 -- set rounding class
48308 --
48309 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
48310 'RECEIVABLE';
48311
48312 --
48313 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
48314 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
48315 --
48316 -- bulk performance
48317 --
48318 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
48319
48320 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
48321 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
48322
48323 -- 4955764
48324 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48325 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
48326
48327 -- 4458381 Public Sector Enh
48328
48329 --
48330 -- set accounting attributes for the line type
48331 --
48332 l_entered_amt_idx := 3;
48333 l_accted_amt_idx := 8;
48334 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48335 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
48336 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
48337 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
48338 l_rec_acct_attrs.array_char_value(2) := p_source_25;
48339 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
48340 l_rec_acct_attrs.array_num_value(3) := p_source_26;
48341 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
48342 l_rec_acct_attrs.array_char_value(4) := p_source_27;
48343 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
48344 l_rec_acct_attrs.array_date_value(5) := p_source_59;
48345 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
48346 l_rec_acct_attrs.array_num_value(6) := p_source_29;
48347 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
48348 l_rec_acct_attrs.array_char_value(7) := p_source_30;
48349 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
48350 l_rec_acct_attrs.array_num_value(8) := p_source_31;
48351
48352 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
48353 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
48354
48355 ---------------------------------------------------------------------------------------------------------------
48356 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
48357 ---------------------------------------------------------------------------------------------------------------
48358 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
48359
48360 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48361 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48362
48363 IF xla_accounting_cache_pkg.GetValueChar
48364 (p_source_code => 'LEDGER_CATEGORY_CODE'
48365 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
48366 AND l_bflow_method_code = 'PRIOR_ENTRY'
48367 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
48368 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
48369 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
48370 )
48371 THEN
48372 xla_ae_lines_pkg.BflowUpgEntry
48373 (p_business_method_code => l_bflow_method_code
48374 ,p_business_class_code => l_bflow_class_code
48375 ,p_balance_type => l_balance_type_code);
48376 ELSE
48377 NULL;
48378 -- No business flow processing for business flow method of NONE.
48379 END IF;
48380
48381 --
48382 -- call analytical criteria
48383 --
48384
48385 --
48386 -- call description
48387 --
48388 -- No description or it is inherited.
48389 --
48390 -- call ADRs
48391 -- Bug 4922099
48392 --
48393 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
48394 (NVL(l_actual_upg_option, 'N') = 'O') OR
48395 (NVL(l_enc_upg_option, 'N') = 'O')
48396 )
48397 THEN
48398 NULL;
48399 --
48400 --
48401
48402 l_ccid := AcctDerRule_11(
48403 p_application_id => p_application_id
48404 , p_ae_header_id => l_ae_header_id
48405 , p_source_10 => p_source_10
48406 , x_transaction_coa_id => l_adr_transaction_coa_id
48410 );
48407 , x_accounting_coa_id => l_adr_accounting_coa_id
48408 , x_value_type_code => l_adr_value_type_code
48409 , p_side => 'NA'
48411
48412 xla_ae_lines_pkg.set_ccid(
48413 p_code_combination_id => l_ccid
48414 , p_value_type_code => l_adr_value_type_code
48415 , p_transaction_coa_id => l_adr_transaction_coa_id
48416 , p_accounting_coa_id => l_adr_accounting_coa_id
48417 , p_adr_code => 'DIST_CCID'
48418 , p_adr_type_code => 'S'
48419 , p_component_type => l_component_type
48420 , p_component_code => l_component_code
48421 , p_component_type_code => l_component_type_code
48422 , p_component_appl_id => l_component_appl_id
48423 , p_amb_context_code => l_amb_context_code
48424 , p_side => 'NA'
48425 );
48426
48427
48428 --
48429 --
48430 END IF;
48431 --
48432 -- Bug 4922099
48433 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
48434 (NVL(l_enc_upg_option, 'N') = 'O')
48435 ) AND
48436 (l_bflow_method_code = 'PRIOR_ENTRY')
48437 )
48438 THEN
48439 IF
48440 --
48441 1 = 2
48442 --
48443 THEN
48444 xla_accounting_err_pkg.build_message
48445 (p_appli_s_name => 'XLA'
48446 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
48447 ,p_token_1 => 'LINE_NUMBER'
48448 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
48449 ,p_token_2 => 'LINE_TYPE_NAME'
48450 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
48451 l_component_type
48452 ,l_component_code
48453 ,l_component_type_code
48454 ,l_component_appl_id
48455 ,l_amb_context_code
48456 ,l_entity_code
48457 ,l_event_class_code
48458 )
48459 ,p_token_3 => 'OWNER'
48460 ,p_value_3 => xla_lookups_pkg.get_meaning(
48461 p_lookup_type => 'XLA_OWNER_TYPE'
48462 ,p_lookup_code => l_component_type_code
48463 )
48464 ,p_token_4 => 'PRODUCT_NAME'
48465 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
48466 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
48467 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
48468 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
48469 ,p_ae_header_id => NULL
48470 );
48471
48472 IF (C_LEVEL_ERROR>= g_log_level) THEN
48473 trace
48474 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
48475 ,p_level => C_LEVEL_ERROR
48476 ,p_module => l_log_module);
48477 END IF;
48478 END IF;
48479 END IF;
48480 --
48481 --
48482 ------------------------------------------------------------------------------------------------
48483 -- 4219869 Business Flow
48484 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
48485 -- Prior Entry. Currently, the following code is always generated.
48486 ------------------------------------------------------------------------------------------------
48487 XLA_AE_LINES_PKG.ValidateCurrentLine;
48488
48489 ------------------------------------------------------------------------------------
48490 -- 4219869 Business Flow
48491 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
48492 ------------------------------------------------------------------------------------
48493 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
48494
48495 ----------------------------------------------------------------------------------
48496 -- 4219869 Business Flow
48497 -- Update journal entry status -- Need to generate this within IF <condition>
48498 ----------------------------------------------------------------------------------
48499 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
48500 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
48501 ,p_balance_type_code => l_balance_type_code
48502 );
48503
48507 BEGIN
48504 -------------------------------------------------------------------------------------------
48505 -- 4262811 - Generate the Accrual Reversal lines
48506 -------------------------------------------------------------------------------------------
48508 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
48509 (g_array_event(p_event_id).array_value_num('header_index'));
48510 IF l_acc_rev_flag IS NULL THEN
48511 l_acc_rev_flag := 'N';
48512 END IF;
48513 EXCEPTION
48514 WHEN OTHERS THEN
48515 l_acc_rev_flag := 'N';
48516 END;
48517 --
48518 IF (l_acc_rev_flag = 'Y') THEN
48519
48520 -- 4645092 ------------------------------------------------------------------------------
48521 -- To allow MPA report to determine if it should generate report process
48522 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
48523 ------------------------------------------------------------------------------------------
48524
48525 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
48526 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
48527 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
48528 -- call ADRs
48529 -- Bug 4922099
48530 --
48531 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
48532 (NVL(l_actual_upg_option, 'N') = 'O') OR
48533 (NVL(l_enc_upg_option, 'N') = 'O')
48534 )
48535 THEN
48536 NULL;
48537 --
48538 --
48539
48540 l_ccid := AcctDerRule_11(
48541 p_application_id => p_application_id
48542 , p_ae_header_id => l_ae_header_id
48543 , p_source_10 => p_source_10
48544 , x_transaction_coa_id => l_adr_transaction_coa_id
48545 , x_accounting_coa_id => l_adr_accounting_coa_id
48546 , x_value_type_code => l_adr_value_type_code
48547 , p_side => 'NA'
48548 );
48549
48550 xla_ae_lines_pkg.set_ccid(
48551 p_code_combination_id => l_ccid
48552 , p_value_type_code => l_adr_value_type_code
48553 , p_transaction_coa_id => l_adr_transaction_coa_id
48554 , p_accounting_coa_id => l_adr_accounting_coa_id
48555 , p_adr_code => 'DIST_CCID'
48556 , p_adr_type_code => 'S'
48557 , p_component_type => l_component_type
48558 , p_component_code => l_component_code
48559 , p_component_type_code => l_component_type_code
48560 , p_component_appl_id => l_component_appl_id
48561 , p_amb_context_code => l_amb_context_code
48562 , p_side => 'NA'
48563 );
48564
48565
48566 --
48567 --
48568 END IF;
48569
48570 --
48571 -- Update the line information that should be overwritten
48572 --
48573 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
48574 p_header_num => 1);
48575 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
48576
48577 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
48578
48579 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
48580 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
48581 END IF;
48582
48583 --
48584 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
48585 --
48586 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
48587 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
48588 ELSE
48589 ---------------------------------------------------------------------------------------------------
48590 -- 4262811a Switch Sign
48591 ---------------------------------------------------------------------------------------------------
48592 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
48593 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48594 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48595 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48596 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48597 -- 5132302
48598 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
48599 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48600
48601 END IF;
48602
48603 -- 4955764
48604 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48605 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
48606
48607
48608 XLA_AE_LINES_PKG.ValidateCurrentLine;
48609 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
48610
48611 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
48612 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
48613 ,p_balance_type_code => l_balance_type_code);
48614
48618 -- 4262811 Multiperiod Accounting
48615 END IF;
48616
48617 -----------------------------------------------------------------------------------------
48619 -----------------------------------------------------------------------------------------
48620 -- No MPA option is assigned.
48621
48622
48623 END IF;
48624 END IF;
48625 --
48626
48627 --
48628 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48629 trace
48630 (p_msg => 'END of AcctLineType_106'
48631 ,p_level => C_LEVEL_PROCEDURE
48632 ,p_module => l_log_module);
48633 END IF;
48634 --
48635 EXCEPTION
48636 WHEN xla_exceptions_pkg.application_exception THEN
48637 RAISE;
48638 WHEN OTHERS THEN
48639 xla_exceptions_pkg.raise_message
48640 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_106');
48641 END AcctLineType_106;
48642 --
48643
48644 ---------------------------------------
48645 --
48646 -- PRIVATE FUNCTION
48647 -- AcctLineType_107
48648 --
48649 ---------------------------------------
48650 PROCEDURE AcctLineType_107 (
48651 p_application_id IN NUMBER
48652 ,p_event_id IN NUMBER
48653 ,p_calculate_acctd_flag IN VARCHAR2
48654 ,p_calculate_g_l_flag IN VARCHAR2
48655 ,p_actual_flag IN OUT VARCHAR2
48656 ,p_balance_type_code OUT VARCHAR2
48657 ,p_gain_or_loss_ref OUT VARCHAR2
48658
48659 --Distribution GL Account
48660 , p_source_10 IN NUMBER
48661 --Distribution Source Type
48662 , p_source_22 IN VARCHAR2
48663 --Distribution Line Identifier
48664 , p_source_24 IN NUMBER
48665 --Distribution Type
48666 , p_source_25 IN VARCHAR2
48667 --Entered Amount
48668 , p_source_26 IN NUMBER
48669 --Currency Code
48670 , p_source_27 IN VARCHAR2
48671 --Exchange Rate
48672 , p_source_29 IN NUMBER
48673 --Exchange Rate Type
48674 , p_source_30 IN VARCHAR2
48675 --Applied To Document Accounting Amount
48676 , p_source_31 IN NUMBER
48677 --Applied To Document Exchange Date
48678 , p_source_59 IN DATE
48679 --Distribution Multi Fund Additional Entry
48680 , p_source_71 IN VARCHAR2
48681 )
48682 IS
48683
48684 l_component_type VARCHAR2(80);
48685 l_component_code VARCHAR2(30);
48686 l_component_type_code VARCHAR2(1);
48687 l_component_appl_id INTEGER;
48688 l_amb_context_code VARCHAR2(30);
48689 l_entity_code VARCHAR2(30);
48690 l_event_class_code VARCHAR2(30);
48691 l_ae_header_id NUMBER;
48692 l_event_type_code VARCHAR2(30);
48693 l_line_definition_code VARCHAR2(30);
48694 l_line_definition_owner_code VARCHAR2(1);
48695 --
48696 -- adr variables
48697 l_segment VARCHAR2(30);
48698 l_ccid NUMBER;
48699 l_adr_transaction_coa_id NUMBER;
48700 l_adr_accounting_coa_id NUMBER;
48701 l_adr_flexfield_segment_code VARCHAR2(30);
48702 l_adr_flex_value_set_id NUMBER;
48703 l_adr_value_type_code VARCHAR2(30);
48704 l_adr_value_combination_id NUMBER;
48705 l_adr_value_segment_code VARCHAR2(30);
48706
48707 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
48708 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
48709 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
48710 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
48711
48712 -- 4262811 Variables ------------------------------------------------------------------------------------------
48713 l_entered_amt_idx NUMBER;
48714 l_accted_amt_idx NUMBER;
48715 l_acc_rev_flag VARCHAR2(1);
48716 l_accrual_line_num NUMBER;
48717 l_tmp_amt NUMBER;
48718 l_acc_rev_natural_side_code VARCHAR2(1);
48719
48720 l_num_entries NUMBER;
48721 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
48722 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
48723 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
48724 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
48725 l_recog_line_1 NUMBER;
48726 l_recog_line_2 NUMBER;
48727
48728 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
48729 l_bflow_applied_to_amt NUMBER; -- 5132302
48730 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
48731
48732 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
48733
48734 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
48735 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
48736
48737 ---------------------------------------------------------------------------------------------------------------
48738
48739
48740 --
48741 -- bulk performance
48742 --
48743 l_balance_type_code VARCHAR2(1);
48744 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
48745 l_log_module VARCHAR2(240);
48746
48747 --
48748 -- Upgrade strategy
48749 --
48750 l_actual_upg_option VARCHAR2(1);
48751 l_enc_upg_option VARCHAR2(1);
48752
48756 IF g_log_enabled THEN
48753 --
48754 BEGIN
48755 --
48757 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_107';
48758 END IF;
48759 --
48760 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48761
48762 trace
48763 (p_msg => 'BEGIN of AcctLineType_107'
48764 ,p_level => C_LEVEL_PROCEDURE
48765 ,p_module => l_log_module);
48766
48767 END IF;
48768 --
48769 l_component_type := 'AMB_JLT';
48770 l_component_code := 'MISC_RCT_TAX';
48771 l_component_type_code := 'S';
48772 l_component_appl_id := 222;
48773 l_amb_context_code := 'DEFAULT';
48774 l_entity_code := 'RECEIPTS';
48775 l_event_class_code := 'MISC_RECEIPT';
48776 l_event_type_code := 'MISC_RECEIPT_ALL';
48777 l_line_definition_owner_code := 'S';
48778 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
48779 --
48780 l_balance_type_code := 'A';
48781 l_segment := NULL;
48782 l_ccid := NULL;
48783 l_adr_transaction_coa_id := NULL;
48784 l_adr_accounting_coa_id := NULL;
48785 l_adr_flexfield_segment_code := NULL;
48786 l_adr_flex_value_set_id := NULL;
48787 l_adr_value_type_code := NULL;
48788 l_adr_value_combination_id := NULL;
48789 l_adr_value_segment_code := NULL;
48790
48791 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
48792 l_bflow_class_code := ''; -- 4219869 Business Flow
48793 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
48794 l_budgetary_control_flag := 'N';
48795
48796 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48797 l_bflow_applied_to_amt := NULL; -- 5132302
48798 l_entered_amt_idx := NULL; -- 4262811
48799 l_accted_amt_idx := NULL; -- 4262811
48800 l_acc_rev_flag := NULL; -- 4262811
48801 l_accrual_line_num := NULL; -- 4262811
48802 l_tmp_amt := NULL; -- 4262811
48803 --
48804
48805 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
48806 l_balance_type_code <> 'B' THEN
48807 IF NVL(p_source_22,'
48808 ') = 'TAX' AND
48809 NVL(p_source_71,'
48810 ') = 'N'
48811 THEN
48812
48813 --
48814 XLA_AE_LINES_PKG.SetNewLine;
48815
48816 p_balance_type_code := l_balance_type_code;
48817 -- set the flag so later we will know whether the gain loss line needs to be created
48818
48819 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
48820 p_actual_flag :='A';
48821 END IF;
48822
48823 --
48824 -- bulk performance
48825 --
48826 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
48827 p_header_num => 0); -- 4262811
48828 --
48829 -- set accounting line options
48830 --
48831 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
48832 p_natural_side_code => 'C'
48833 , p_gain_or_loss_flag => 'N'
48834 , p_gl_transfer_mode_code => 'S'
48835 , p_acct_entry_type_code => 'A'
48836 , p_switch_side_flag => 'Y'
48837 , p_merge_duplicate_code => 'A'
48838 );
48839 --
48840 l_acc_rev_natural_side_code := 'D'; -- 4262811
48841 --
48842 --
48843 -- set accounting line type info
48844 --
48845 xla_ae_lines_pkg.SetAcctLineType
48846 (p_component_type => l_component_type
48847 ,p_event_type_code => l_event_type_code
48848 ,p_line_definition_owner_code => l_line_definition_owner_code
48849 ,p_line_definition_code => l_line_definition_code
48850 ,p_accounting_line_code => l_component_code
48851 ,p_accounting_line_type_code => l_component_type_code
48852 ,p_accounting_line_appl_id => l_component_appl_id
48853 ,p_amb_context_code => l_amb_context_code
48854 ,p_entity_code => l_entity_code
48855 ,p_event_class_code => l_event_class_code);
48856 --
48857 -- set accounting class
48858 --
48859 xla_ae_lines_pkg.SetAcctClass(
48860 p_accounting_class_code => 'TAX'
48861 , p_ae_header_id => l_ae_header_id
48862 );
48863
48864 --
48865 -- set rounding class
48866 --
48867 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
48868 'RECEIVABLE';
48869
48870 --
48871 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
48872 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
48873 --
48874 -- bulk performance
48875 --
48876 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
48877
48878 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
48879 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
48880
48881 -- 4955764
48882 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48883 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
48884
48885 -- 4458381 Public Sector Enh
48889 --
48886
48887 --
48888 -- set accounting attributes for the line type
48890 l_entered_amt_idx := 3;
48891 l_accted_amt_idx := 8;
48892 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48893 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
48894 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_24);
48895 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
48896 l_rec_acct_attrs.array_char_value(2) := p_source_25;
48897 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
48898 l_rec_acct_attrs.array_num_value(3) := p_source_26;
48899 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
48900 l_rec_acct_attrs.array_char_value(4) := p_source_27;
48901 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
48902 l_rec_acct_attrs.array_date_value(5) := p_source_59;
48903 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
48904 l_rec_acct_attrs.array_num_value(6) := p_source_29;
48905 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
48906 l_rec_acct_attrs.array_char_value(7) := p_source_30;
48907 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
48908 l_rec_acct_attrs.array_num_value(8) := p_source_31;
48909
48910 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
48911 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
48912
48913 ---------------------------------------------------------------------------------------------------------------
48914 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
48915 ---------------------------------------------------------------------------------------------------------------
48916 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
48917
48918 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48919 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48920
48921 IF xla_accounting_cache_pkg.GetValueChar
48922 (p_source_code => 'LEDGER_CATEGORY_CODE'
48923 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
48924 AND l_bflow_method_code = 'PRIOR_ENTRY'
48925 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
48926 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
48927 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
48928 )
48929 THEN
48930 xla_ae_lines_pkg.BflowUpgEntry
48931 (p_business_method_code => l_bflow_method_code
48932 ,p_business_class_code => l_bflow_class_code
48933 ,p_balance_type => l_balance_type_code);
48934 ELSE
48935 NULL;
48936 -- No business flow processing for business flow method of NONE.
48937 END IF;
48938
48939 --
48940 -- call analytical criteria
48941 --
48942
48943 --
48944 -- call description
48945 --
48946 -- No description or it is inherited.
48947 --
48948 -- call ADRs
48949 -- Bug 4922099
48950 --
48951 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
48952 (NVL(l_actual_upg_option, 'N') = 'O') OR
48953 (NVL(l_enc_upg_option, 'N') = 'O')
48954 )
48955 THEN
48956 NULL;
48957 --
48958 --
48959
48960 l_ccid := AcctDerRule_11(
48961 p_application_id => p_application_id
48962 , p_ae_header_id => l_ae_header_id
48963 , p_source_10 => p_source_10
48964 , x_transaction_coa_id => l_adr_transaction_coa_id
48965 , x_accounting_coa_id => l_adr_accounting_coa_id
48966 , x_value_type_code => l_adr_value_type_code
48967 , p_side => 'NA'
48968 );
48969
48970 xla_ae_lines_pkg.set_ccid(
48971 p_code_combination_id => l_ccid
48972 , p_value_type_code => l_adr_value_type_code
48973 , p_transaction_coa_id => l_adr_transaction_coa_id
48974 , p_accounting_coa_id => l_adr_accounting_coa_id
48975 , p_adr_code => 'DIST_CCID'
48976 , p_adr_type_code => 'S'
48977 , p_component_type => l_component_type
48978 , p_component_code => l_component_code
48979 , p_component_type_code => l_component_type_code
48980 , p_component_appl_id => l_component_appl_id
48981 , p_amb_context_code => l_amb_context_code
48982 , p_side => 'NA'
48983 );
48984
48985
48986 --
48987 --
48988 END IF;
48989 --
48990 -- Bug 4922099
48991 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
48992 (NVL(l_enc_upg_option, 'N') = 'O')
48993 ) AND
48994 (l_bflow_method_code = 'PRIOR_ENTRY')
48995 )
48996 THEN
48997 IF
48998 --
48999 1 = 2
49000 --
49001 THEN
49002 xla_accounting_err_pkg.build_message
49003 (p_appli_s_name => 'XLA'
49004 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49008 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
49005 ,p_token_1 => 'LINE_NUMBER'
49006 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
49007 ,p_token_2 => 'LINE_TYPE_NAME'
49009 l_component_type
49010 ,l_component_code
49011 ,l_component_type_code
49012 ,l_component_appl_id
49013 ,l_amb_context_code
49014 ,l_entity_code
49015 ,l_event_class_code
49016 )
49017 ,p_token_3 => 'OWNER'
49018 ,p_value_3 => xla_lookups_pkg.get_meaning(
49019 p_lookup_type => 'XLA_OWNER_TYPE'
49020 ,p_lookup_code => l_component_type_code
49021 )
49022 ,p_token_4 => 'PRODUCT_NAME'
49023 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
49024 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
49025 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
49026 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
49027 ,p_ae_header_id => NULL
49028 );
49029
49030 IF (C_LEVEL_ERROR>= g_log_level) THEN
49031 trace
49032 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49033 ,p_level => C_LEVEL_ERROR
49034 ,p_module => l_log_module);
49035 END IF;
49036 END IF;
49037 END IF;
49038 --
49039 --
49040 ------------------------------------------------------------------------------------------------
49041 -- 4219869 Business Flow
49042 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
49043 -- Prior Entry. Currently, the following code is always generated.
49044 ------------------------------------------------------------------------------------------------
49045 XLA_AE_LINES_PKG.ValidateCurrentLine;
49046
49047 ------------------------------------------------------------------------------------
49048 -- 4219869 Business Flow
49049 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
49050 ------------------------------------------------------------------------------------
49051 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49052
49053 ----------------------------------------------------------------------------------
49054 -- 4219869 Business Flow
49055 -- Update journal entry status -- Need to generate this within IF <condition>
49056 ----------------------------------------------------------------------------------
49057 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49058 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
49059 ,p_balance_type_code => l_balance_type_code
49060 );
49061
49062 -------------------------------------------------------------------------------------------
49063 -- 4262811 - Generate the Accrual Reversal lines
49064 -------------------------------------------------------------------------------------------
49065 BEGIN
49066 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
49067 (g_array_event(p_event_id).array_value_num('header_index'));
49068 IF l_acc_rev_flag IS NULL THEN
49069 l_acc_rev_flag := 'N';
49070 END IF;
49071 EXCEPTION
49072 WHEN OTHERS THEN
49073 l_acc_rev_flag := 'N';
49074 END;
49075 --
49076 IF (l_acc_rev_flag = 'Y') THEN
49077
49078 -- 4645092 ------------------------------------------------------------------------------
49079 -- To allow MPA report to determine if it should generate report process
49080 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
49081 ------------------------------------------------------------------------------------------
49082
49083 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
49084 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
49085 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
49086 -- call ADRs
49087 -- Bug 4922099
49088 --
49089 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
49090 (NVL(l_actual_upg_option, 'N') = 'O') OR
49091 (NVL(l_enc_upg_option, 'N') = 'O')
49092 )
49093 THEN
49094 NULL;
49095 --
49096 --
49097
49101 , p_source_10 => p_source_10
49098 l_ccid := AcctDerRule_11(
49099 p_application_id => p_application_id
49100 , p_ae_header_id => l_ae_header_id
49102 , x_transaction_coa_id => l_adr_transaction_coa_id
49103 , x_accounting_coa_id => l_adr_accounting_coa_id
49104 , x_value_type_code => l_adr_value_type_code
49105 , p_side => 'NA'
49106 );
49107
49108 xla_ae_lines_pkg.set_ccid(
49109 p_code_combination_id => l_ccid
49110 , p_value_type_code => l_adr_value_type_code
49111 , p_transaction_coa_id => l_adr_transaction_coa_id
49112 , p_accounting_coa_id => l_adr_accounting_coa_id
49113 , p_adr_code => 'DIST_CCID'
49114 , p_adr_type_code => 'S'
49115 , p_component_type => l_component_type
49116 , p_component_code => l_component_code
49117 , p_component_type_code => l_component_type_code
49118 , p_component_appl_id => l_component_appl_id
49119 , p_amb_context_code => l_amb_context_code
49120 , p_side => 'NA'
49121 );
49122
49123
49124 --
49125 --
49126 END IF;
49127
49128 --
49129 -- Update the line information that should be overwritten
49130 --
49131 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
49132 p_header_num => 1);
49133 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
49134
49135 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
49136
49137 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
49138 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
49139 END IF;
49140
49141 --
49142 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
49143 --
49144 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
49145 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
49146 ELSE
49147 ---------------------------------------------------------------------------------------------------
49148 -- 4262811a Switch Sign
49149 ---------------------------------------------------------------------------------------------------
49150 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
49151 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49152 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49153 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49154 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49155 -- 5132302
49156 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
49157 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49158
49159 END IF;
49160
49161 -- 4955764
49162 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
49163 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
49164
49165
49166 XLA_AE_LINES_PKG.ValidateCurrentLine;
49167 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49168
49169 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49170 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
49171 ,p_balance_type_code => l_balance_type_code);
49172
49173 END IF;
49174
49175 -----------------------------------------------------------------------------------------
49176 -- 4262811 Multiperiod Accounting
49177 -----------------------------------------------------------------------------------------
49178 -- No MPA option is assigned.
49179
49180
49181 END IF;
49182 END IF;
49183 --
49184
49185 --
49186 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49187 trace
49188 (p_msg => 'END of AcctLineType_107'
49189 ,p_level => C_LEVEL_PROCEDURE
49190 ,p_module => l_log_module);
49191 END IF;
49192 --
49193 EXCEPTION
49194 WHEN xla_exceptions_pkg.application_exception THEN
49195 RAISE;
49196 WHEN OTHERS THEN
49197 xla_exceptions_pkg.raise_message
49198 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_107');
49199 END AcctLineType_107;
49200 --
49201
49202 ---------------------------------------
49203 --
49204 -- PRIVATE FUNCTION
49205 -- AcctLineType_108
49206 --
49207 ---------------------------------------
49208 PROCEDURE AcctLineType_108 (
49209 p_application_id IN NUMBER
49210 ,p_event_id IN NUMBER
49211 ,p_calculate_acctd_flag IN VARCHAR2
49212 ,p_calculate_g_l_flag IN VARCHAR2
49213 ,p_actual_flag IN OUT VARCHAR2
49214 ,p_balance_type_code OUT VARCHAR2
49215 ,p_gain_or_loss_ref OUT VARCHAR2
49216
49217 --Distribution GL Account
49218 , p_source_10 IN NUMBER
49222 , p_source_24 IN NUMBER
49219 --Distribution Source Type
49220 , p_source_22 IN VARCHAR2
49221 --Distribution Line Identifier
49223 --Distribution Type
49224 , p_source_25 IN VARCHAR2
49225 --Exchange Date
49226 , p_source_28 IN DATE
49227 --Exchange Rate
49228 , p_source_29 IN NUMBER
49229 --Exchange Rate Type
49230 , p_source_30 IN VARCHAR2
49231 --Transaction Distribution Identifier
49232 , p_source_36 IN NUMBER
49233 --Transaction Distribution Type
49234 , p_source_37 IN VARCHAR2
49235 --Receipt Applied To Application Identifier
49236 , p_source_60 IN NUMBER
49237 --Transaction Entity Code
49238 , p_source_61 IN VARCHAR2
49239 --Transaction Identifier
49240 , p_source_62 IN NUMBER
49241 --Applying Document Currency Code
49242 , p_source_63 IN VARCHAR2
49243 --Distribution Party Identifier
49244 , p_source_65 IN NUMBER
49245 --Distribution Party Site Id
49246 , p_source_66 IN NUMBER
49247 --Distribution Party Type
49248 , p_source_67 IN VARCHAR2
49249 --Distribution Multi Fund Additional Entry
49250 , p_source_71 IN VARCHAR2
49251 --DIST_ENT_AMT_FROM
49252 , p_source_74 IN NUMBER
49253 --Accounting Amount
49254 , p_source_75 IN NUMBER
49255 )
49256 IS
49257
49258 l_component_type VARCHAR2(80);
49259 l_component_code VARCHAR2(30);
49260 l_component_type_code VARCHAR2(1);
49261 l_component_appl_id INTEGER;
49262 l_amb_context_code VARCHAR2(30);
49263 l_entity_code VARCHAR2(30);
49264 l_event_class_code VARCHAR2(30);
49265 l_ae_header_id NUMBER;
49266 l_event_type_code VARCHAR2(30);
49267 l_line_definition_code VARCHAR2(30);
49268 l_line_definition_owner_code VARCHAR2(1);
49269 --
49270 -- adr variables
49271 l_segment VARCHAR2(30);
49272 l_ccid NUMBER;
49273 l_adr_transaction_coa_id NUMBER;
49274 l_adr_accounting_coa_id NUMBER;
49275 l_adr_flexfield_segment_code VARCHAR2(30);
49276 l_adr_flex_value_set_id NUMBER;
49277 l_adr_value_type_code VARCHAR2(30);
49278 l_adr_value_combination_id NUMBER;
49279 l_adr_value_segment_code VARCHAR2(30);
49280
49281 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
49282 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
49283 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
49284 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
49285
49286 -- 4262811 Variables ------------------------------------------------------------------------------------------
49287 l_entered_amt_idx NUMBER;
49288 l_accted_amt_idx NUMBER;
49289 l_acc_rev_flag VARCHAR2(1);
49290 l_accrual_line_num NUMBER;
49291 l_tmp_amt NUMBER;
49292 l_acc_rev_natural_side_code VARCHAR2(1);
49293
49294 l_num_entries NUMBER;
49295 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
49296 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
49297 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
49298 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
49299 l_recog_line_1 NUMBER;
49300 l_recog_line_2 NUMBER;
49301
49302 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
49303 l_bflow_applied_to_amt NUMBER; -- 5132302
49304 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
49305
49306 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
49307
49308 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
49309 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
49310
49311 ---------------------------------------------------------------------------------------------------------------
49312
49313
49314 --
49315 -- bulk performance
49316 --
49317 l_balance_type_code VARCHAR2(1);
49318 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
49319 l_log_module VARCHAR2(240);
49320
49321 --
49322 -- Upgrade strategy
49323 --
49324 l_actual_upg_option VARCHAR2(1);
49325 l_enc_upg_option VARCHAR2(1);
49326
49327 --
49328 BEGIN
49329 --
49330 IF g_log_enabled THEN
49331 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_108';
49332 END IF;
49333 --
49334 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49335
49336 trace
49337 (p_msg => 'BEGIN of AcctLineType_108'
49338 ,p_level => C_LEVEL_PROCEDURE
49339 ,p_module => l_log_module);
49340
49341 END IF;
49342 --
49343 l_component_type := 'AMB_JLT';
49344 l_component_code := 'RCT_ACC';
49345 l_component_type_code := 'S';
49346 l_component_appl_id := 222;
49347 l_amb_context_code := 'DEFAULT';
49348 l_entity_code := 'RECEIPTS';
49349 l_event_class_code := 'RECEIPT';
49350 l_event_type_code := 'RECEIPT_ALL';
49351 l_line_definition_owner_code := 'S';
49352 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
49353 --
49357 l_adr_transaction_coa_id := NULL;
49354 l_balance_type_code := 'A';
49355 l_segment := NULL;
49356 l_ccid := NULL;
49358 l_adr_accounting_coa_id := NULL;
49359 l_adr_flexfield_segment_code := NULL;
49360 l_adr_flex_value_set_id := NULL;
49361 l_adr_value_type_code := NULL;
49362 l_adr_value_combination_id := NULL;
49363 l_adr_value_segment_code := NULL;
49364
49365 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
49366 l_bflow_class_code := ''; -- 4219869 Business Flow
49367 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
49368 l_budgetary_control_flag := 'N';
49369
49370 l_bflow_applied_to_amt_idx := NULL; -- 5132302
49371 l_bflow_applied_to_amt := NULL; -- 5132302
49372 l_entered_amt_idx := NULL; -- 4262811
49373 l_accted_amt_idx := NULL; -- 4262811
49374 l_acc_rev_flag := NULL; -- 4262811
49375 l_accrual_line_num := NULL; -- 4262811
49376 l_tmp_amt := NULL; -- 4262811
49377 --
49378
49379 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
49380 l_balance_type_code <> 'B' THEN
49381 IF NVL(p_source_22,'
49382 ') = 'ACC' AND
49383 NVL(p_source_71,'
49384 ') = 'N'
49385 THEN
49386
49387 --
49388 XLA_AE_LINES_PKG.SetNewLine;
49389
49390 p_balance_type_code := l_balance_type_code;
49391 -- set the flag so later we will know whether the gain loss line needs to be created
49392
49393 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
49394 p_actual_flag :='A';
49395 END IF;
49396
49397 --
49398 -- bulk performance
49399 --
49400 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
49401 p_header_num => 0); -- 4262811
49402 --
49403 -- set accounting line options
49404 --
49405 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
49406 p_natural_side_code => 'C'
49407 , p_gain_or_loss_flag => 'N'
49408 , p_gl_transfer_mode_code => 'S'
49409 , p_acct_entry_type_code => 'A'
49410 , p_switch_side_flag => 'Y'
49411 , p_merge_duplicate_code => 'A'
49412 );
49413 --
49414 l_acc_rev_natural_side_code := 'D'; -- 4262811
49415 --
49416 --
49417 -- set accounting line type info
49418 --
49419 xla_ae_lines_pkg.SetAcctLineType
49420 (p_component_type => l_component_type
49421 ,p_event_type_code => l_event_type_code
49422 ,p_line_definition_owner_code => l_line_definition_owner_code
49423 ,p_line_definition_code => l_line_definition_code
49424 ,p_accounting_line_code => l_component_code
49425 ,p_accounting_line_type_code => l_component_type_code
49426 ,p_accounting_line_appl_id => l_component_appl_id
49427 ,p_amb_context_code => l_amb_context_code
49428 ,p_entity_code => l_entity_code
49429 ,p_event_class_code => l_event_class_code);
49430 --
49431 -- set accounting class
49432 --
49433 xla_ae_lines_pkg.SetAcctClass(
49434 p_accounting_class_code => 'ACC'
49435 , p_ae_header_id => l_ae_header_id
49436 );
49437
49438 --
49439 -- set rounding class
49440 --
49441 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
49442 'RECEIVABLE';
49443
49444 --
49445 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
49446 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
49447 --
49448 -- bulk performance
49449 --
49450 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
49451
49452 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
49453 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
49454
49455 -- 4955764
49456 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
49457 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
49458
49459 -- 4458381 Public Sector Enh
49460
49461 --
49462 -- set accounting attributes for the line type
49463 --
49464 l_entered_amt_idx := 8;
49465 l_accted_amt_idx := 13;
49466 l_bflow_applied_to_amt_idx := NULL; -- 5132302
49467 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
49468 l_rec_acct_attrs.array_num_value(1) := p_source_60;
49469 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
49470 l_rec_acct_attrs.array_char_value(2) := p_source_37;
49471 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
49472 l_rec_acct_attrs.array_char_value(3) := p_source_61;
49473 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
49474 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
49475 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
49476 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
49480 l_rec_acct_attrs.array_char_value(7) := p_source_25;
49477 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
49478 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
49479 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
49481 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
49482 l_rec_acct_attrs.array_num_value(8) := p_source_74;
49483 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
49484 l_rec_acct_attrs.array_char_value(9) := p_source_63;
49485 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
49486 l_rec_acct_attrs.array_date_value(10) := p_source_28;
49487 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
49488 l_rec_acct_attrs.array_num_value(11) := p_source_29;
49489 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
49490 l_rec_acct_attrs.array_char_value(12) := p_source_30;
49491 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
49492 l_rec_acct_attrs.array_num_value(13) := p_source_75;
49493 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
49494 l_rec_acct_attrs.array_num_value(14) := p_source_65;
49495 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
49496 l_rec_acct_attrs.array_num_value(15) := p_source_66;
49497 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
49498 l_rec_acct_attrs.array_char_value(16) := p_source_67;
49499
49500 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
49501 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
49502
49503 ---------------------------------------------------------------------------------------------------------------
49504 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
49505 ---------------------------------------------------------------------------------------------------------------
49506 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
49507
49508 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
49509 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
49510
49511 IF xla_accounting_cache_pkg.GetValueChar
49512 (p_source_code => 'LEDGER_CATEGORY_CODE'
49513 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
49514 AND l_bflow_method_code = 'PRIOR_ENTRY'
49515 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
49516 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
49517 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
49518 )
49519 THEN
49520 xla_ae_lines_pkg.BflowUpgEntry
49521 (p_business_method_code => l_bflow_method_code
49522 ,p_business_class_code => l_bflow_class_code
49523 ,p_balance_type => l_balance_type_code);
49524 ELSE
49525 NULL;
49526 -- No business flow processing for business flow method of NONE.
49527 END IF;
49528
49529 --
49530 -- call analytical criteria
49531 --
49532
49533 --
49534 -- call description
49535 --
49536 -- No description or it is inherited.
49537 --
49538 -- call ADRs
49539 -- Bug 4922099
49540 --
49541 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
49542 (NVL(l_actual_upg_option, 'N') = 'O') OR
49543 (NVL(l_enc_upg_option, 'N') = 'O')
49544 )
49545 THEN
49546 NULL;
49547 --
49548 --
49549
49550 l_ccid := AcctDerRule_11(
49551 p_application_id => p_application_id
49552 , p_ae_header_id => l_ae_header_id
49553 , p_source_10 => p_source_10
49554 , x_transaction_coa_id => l_adr_transaction_coa_id
49555 , x_accounting_coa_id => l_adr_accounting_coa_id
49556 , x_value_type_code => l_adr_value_type_code
49557 , p_side => 'NA'
49558 );
49559
49560 xla_ae_lines_pkg.set_ccid(
49561 p_code_combination_id => l_ccid
49562 , p_value_type_code => l_adr_value_type_code
49563 , p_transaction_coa_id => l_adr_transaction_coa_id
49564 , p_accounting_coa_id => l_adr_accounting_coa_id
49565 , p_adr_code => 'DIST_CCID'
49566 , p_adr_type_code => 'S'
49567 , p_component_type => l_component_type
49568 , p_component_code => l_component_code
49569 , p_component_type_code => l_component_type_code
49570 , p_component_appl_id => l_component_appl_id
49571 , p_amb_context_code => l_amb_context_code
49572 , p_side => 'NA'
49573 );
49574
49575
49576 --
49577 --
49578 END IF;
49579 --
49580 -- Bug 4922099
49581 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
49582 (NVL(l_enc_upg_option, 'N') = 'O')
49583 ) AND
49584 (l_bflow_method_code = 'PRIOR_ENTRY')
49585 )
49586 THEN
49587 IF
49588 --
49589 1 = 2
49590 --
49591 THEN
49592 xla_accounting_err_pkg.build_message
49593 (p_appli_s_name => 'XLA'
49597 ,p_token_2 => 'LINE_TYPE_NAME'
49594 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49595 ,p_token_1 => 'LINE_NUMBER'
49596 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
49598 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
49599 l_component_type
49600 ,l_component_code
49601 ,l_component_type_code
49602 ,l_component_appl_id
49603 ,l_amb_context_code
49604 ,l_entity_code
49605 ,l_event_class_code
49606 )
49607 ,p_token_3 => 'OWNER'
49608 ,p_value_3 => xla_lookups_pkg.get_meaning(
49609 p_lookup_type => 'XLA_OWNER_TYPE'
49610 ,p_lookup_code => l_component_type_code
49611 )
49612 ,p_token_4 => 'PRODUCT_NAME'
49613 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
49614 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
49615 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
49616 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
49617 ,p_ae_header_id => NULL
49618 );
49619
49620 IF (C_LEVEL_ERROR>= g_log_level) THEN
49621 trace
49622 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49623 ,p_level => C_LEVEL_ERROR
49624 ,p_module => l_log_module);
49625 END IF;
49626 END IF;
49627 END IF;
49628 --
49629 --
49630 ------------------------------------------------------------------------------------------------
49631 -- 4219869 Business Flow
49632 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
49633 -- Prior Entry. Currently, the following code is always generated.
49634 ------------------------------------------------------------------------------------------------
49635 XLA_AE_LINES_PKG.ValidateCurrentLine;
49636
49637 ------------------------------------------------------------------------------------
49638 -- 4219869 Business Flow
49639 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
49640 ------------------------------------------------------------------------------------
49641 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49642
49643 ----------------------------------------------------------------------------------
49644 -- 4219869 Business Flow
49645 -- Update journal entry status -- Need to generate this within IF <condition>
49646 ----------------------------------------------------------------------------------
49647 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49648 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
49649 ,p_balance_type_code => l_balance_type_code
49650 );
49651
49652 -------------------------------------------------------------------------------------------
49653 -- 4262811 - Generate the Accrual Reversal lines
49654 -------------------------------------------------------------------------------------------
49655 BEGIN
49656 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
49657 (g_array_event(p_event_id).array_value_num('header_index'));
49658 IF l_acc_rev_flag IS NULL THEN
49659 l_acc_rev_flag := 'N';
49660 END IF;
49661 EXCEPTION
49662 WHEN OTHERS THEN
49663 l_acc_rev_flag := 'N';
49664 END;
49665 --
49666 IF (l_acc_rev_flag = 'Y') THEN
49667
49668 -- 4645092 ------------------------------------------------------------------------------
49669 -- To allow MPA report to determine if it should generate report process
49670 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
49671 ------------------------------------------------------------------------------------------
49672
49673 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
49674 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
49675 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
49676 -- call ADRs
49677 -- Bug 4922099
49678 --
49679 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
49680 (NVL(l_actual_upg_option, 'N') = 'O') OR
49684 NULL;
49681 (NVL(l_enc_upg_option, 'N') = 'O')
49682 )
49683 THEN
49685 --
49686 --
49687
49688 l_ccid := AcctDerRule_11(
49689 p_application_id => p_application_id
49690 , p_ae_header_id => l_ae_header_id
49691 , p_source_10 => p_source_10
49692 , x_transaction_coa_id => l_adr_transaction_coa_id
49693 , x_accounting_coa_id => l_adr_accounting_coa_id
49694 , x_value_type_code => l_adr_value_type_code
49695 , p_side => 'NA'
49696 );
49697
49698 xla_ae_lines_pkg.set_ccid(
49699 p_code_combination_id => l_ccid
49700 , p_value_type_code => l_adr_value_type_code
49701 , p_transaction_coa_id => l_adr_transaction_coa_id
49702 , p_accounting_coa_id => l_adr_accounting_coa_id
49703 , p_adr_code => 'DIST_CCID'
49704 , p_adr_type_code => 'S'
49705 , p_component_type => l_component_type
49706 , p_component_code => l_component_code
49707 , p_component_type_code => l_component_type_code
49708 , p_component_appl_id => l_component_appl_id
49709 , p_amb_context_code => l_amb_context_code
49710 , p_side => 'NA'
49711 );
49712
49713
49714 --
49715 --
49716 END IF;
49717
49718 --
49719 -- Update the line information that should be overwritten
49720 --
49721 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
49722 p_header_num => 1);
49723 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
49724
49725 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
49726
49727 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
49728 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
49729 END IF;
49730
49731 --
49732 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
49733 --
49734 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
49735 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
49736 ELSE
49737 ---------------------------------------------------------------------------------------------------
49738 -- 4262811a Switch Sign
49739 ---------------------------------------------------------------------------------------------------
49740 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
49741 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49742 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49743 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49744 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49745 -- 5132302
49746 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
49747 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49748
49749 END IF;
49750
49751 -- 4955764
49752 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
49753 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
49754
49755
49756 XLA_AE_LINES_PKG.ValidateCurrentLine;
49757 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49758
49759 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49760 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
49761 ,p_balance_type_code => l_balance_type_code);
49762
49763 END IF;
49764
49765 -----------------------------------------------------------------------------------------
49766 -- 4262811 Multiperiod Accounting
49767 -----------------------------------------------------------------------------------------
49768 -- No MPA option is assigned.
49769
49770
49771 END IF;
49772 END IF;
49773 --
49774
49775 --
49776 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49777 trace
49778 (p_msg => 'END of AcctLineType_108'
49779 ,p_level => C_LEVEL_PROCEDURE
49780 ,p_module => l_log_module);
49781 END IF;
49782 --
49783 EXCEPTION
49784 WHEN xla_exceptions_pkg.application_exception THEN
49785 RAISE;
49786 WHEN OTHERS THEN
49787 xla_exceptions_pkg.raise_message
49788 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_108');
49789 END AcctLineType_108;
49790 --
49791
49792 ---------------------------------------
49793 --
49794 -- PRIVATE FUNCTION
49795 -- AcctLineType_109
49796 --
49797 ---------------------------------------
49798 PROCEDURE AcctLineType_109 (
49799 p_application_id IN NUMBER
49800 ,p_event_id IN NUMBER
49801 ,p_calculate_acctd_flag IN VARCHAR2
49802 ,p_calculate_g_l_flag IN VARCHAR2
49806
49803 ,p_actual_flag IN OUT VARCHAR2
49804 ,p_balance_type_code OUT VARCHAR2
49805 ,p_gain_or_loss_ref OUT VARCHAR2
49807 --Remittance Bank Account Cash Account
49808 , p_source_5 IN NUMBER
49809 --Transaction Distribution GL Account
49810 , p_source_21 IN NUMBER
49811 --Distribution Source Type
49812 , p_source_22 IN VARCHAR2
49813 --Distribution Line Identifier
49814 , p_source_24 IN NUMBER
49815 --Distribution Type
49816 , p_source_25 IN VARCHAR2
49817 --Exchange Date
49818 , p_source_28 IN DATE
49819 --Exchange Rate
49820 , p_source_29 IN NUMBER
49821 --Exchange Rate Type
49822 , p_source_30 IN VARCHAR2
49823 --Transaction Distribution Account Class
49824 , p_source_35 IN VARCHAR2
49825 --Transaction Distribution Identifier
49826 , p_source_36 IN NUMBER
49827 --Transaction Distribution Type
49828 , p_source_37 IN VARCHAR2
49829 --Receipt Applied To Application Identifier
49830 , p_source_60 IN NUMBER
49831 --Transaction Entity Code
49832 , p_source_61 IN VARCHAR2
49833 --Transaction Identifier
49834 , p_source_62 IN NUMBER
49835 --Applying Document Currency Code
49836 , p_source_63 IN VARCHAR2
49837 --Distribution Party Identifier
49838 , p_source_65 IN NUMBER
49839 --Distribution Party Site Id
49840 , p_source_66 IN NUMBER
49841 --Distribution Party Type
49842 , p_source_67 IN VARCHAR2
49843 --Distribution Multi Fund Additional Entry
49844 , p_source_71 IN VARCHAR2
49845 --Receipt Class Require Remittance Flag
49846 , p_source_72 IN VARCHAR2
49847 --Receipt Class Confirm Flag
49848 , p_source_73 IN VARCHAR2
49849 --DIST_ENT_AMT_FROM
49850 , p_source_74 IN NUMBER
49851 --Accounting Amount
49852 , p_source_75 IN NUMBER
49853 )
49854 IS
49855
49856 l_component_type VARCHAR2(80);
49857 l_component_code VARCHAR2(30);
49858 l_component_type_code VARCHAR2(1);
49859 l_component_appl_id INTEGER;
49860 l_amb_context_code VARCHAR2(30);
49861 l_entity_code VARCHAR2(30);
49862 l_event_class_code VARCHAR2(30);
49863 l_ae_header_id NUMBER;
49864 l_event_type_code VARCHAR2(30);
49865 l_line_definition_code VARCHAR2(30);
49866 l_line_definition_owner_code VARCHAR2(1);
49867 --
49868 -- adr variables
49869 l_segment VARCHAR2(30);
49870 l_ccid NUMBER;
49871 l_adr_transaction_coa_id NUMBER;
49872 l_adr_accounting_coa_id NUMBER;
49873 l_adr_flexfield_segment_code VARCHAR2(30);
49874 l_adr_flex_value_set_id NUMBER;
49875 l_adr_value_type_code VARCHAR2(30);
49876 l_adr_value_combination_id NUMBER;
49877 l_adr_value_segment_code VARCHAR2(30);
49878
49879 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
49880 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
49881 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
49882 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
49883
49884 -- 4262811 Variables ------------------------------------------------------------------------------------------
49885 l_entered_amt_idx NUMBER;
49886 l_accted_amt_idx NUMBER;
49887 l_acc_rev_flag VARCHAR2(1);
49888 l_accrual_line_num NUMBER;
49889 l_tmp_amt NUMBER;
49890 l_acc_rev_natural_side_code VARCHAR2(1);
49891
49892 l_num_entries NUMBER;
49893 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
49894 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
49895 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
49896 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
49897 l_recog_line_1 NUMBER;
49898 l_recog_line_2 NUMBER;
49899
49900 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
49901 l_bflow_applied_to_amt NUMBER; -- 5132302
49902 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
49903
49904 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
49905
49906 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
49907 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
49908
49909 ---------------------------------------------------------------------------------------------------------------
49910
49911
49912 --
49913 -- bulk performance
49914 --
49915 l_balance_type_code VARCHAR2(1);
49916 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
49917 l_log_module VARCHAR2(240);
49918
49919 --
49920 -- Upgrade strategy
49921 --
49922 l_actual_upg_option VARCHAR2(1);
49923 l_enc_upg_option VARCHAR2(1);
49924
49925 --
49926 BEGIN
49927 --
49928 IF g_log_enabled THEN
49929 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_109';
49930 END IF;
49931 --
49932 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49933
49934 trace
49935 (p_msg => 'BEGIN of AcctLineType_109'
49936 ,p_level => C_LEVEL_PROCEDURE
49940 --
49937 ,p_module => l_log_module);
49938
49939 END IF;
49941 l_component_type := 'AMB_JLT';
49942 l_component_code := 'RCT_APP_MFAR_TRX_CASH';
49943 l_component_type_code := 'S';
49944 l_component_appl_id := 222;
49945 l_amb_context_code := 'DEFAULT';
49946 l_entity_code := 'RECEIPTS';
49947 l_event_class_code := 'RECEIPT';
49948 l_event_type_code := 'RECEIPT_ALL';
49949 l_line_definition_owner_code := 'S';
49950 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
49951 --
49952 l_balance_type_code := 'A';
49953 l_segment := NULL;
49954 l_ccid := NULL;
49955 l_adr_transaction_coa_id := NULL;
49956 l_adr_accounting_coa_id := NULL;
49957 l_adr_flexfield_segment_code := NULL;
49958 l_adr_flex_value_set_id := NULL;
49959 l_adr_value_type_code := NULL;
49960 l_adr_value_combination_id := NULL;
49961 l_adr_value_segment_code := NULL;
49962
49963 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
49964 l_bflow_class_code := ''; -- 4219869 Business Flow
49965 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
49966 l_budgetary_control_flag := 'N';
49967
49968 l_bflow_applied_to_amt_idx := NULL; -- 5132302
49969 l_bflow_applied_to_amt := NULL; -- 5132302
49970 l_entered_amt_idx := NULL; -- 4262811
49971 l_accted_amt_idx := NULL; -- 4262811
49972 l_acc_rev_flag := NULL; -- 4262811
49973 l_accrual_line_num := NULL; -- 4262811
49974 l_tmp_amt := NULL; -- 4262811
49975 --
49976
49977 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
49978 l_balance_type_code <> 'B' THEN
49979 IF (NVL(p_source_35,'
49980 ') = 'REV' OR
49981 NVL(p_source_35,'
49982 ') = 'TAX' OR
49983 NVL(p_source_35,'
49984 ') = 'FREIGHT' OR
49985 NVL(p_source_35,'
49986 ') = 'CHARGES' OR
49987 NVL(p_source_35,'
49988 ') = 'ROUND') AND
49989 NVL(p_source_22,'
49990 ') = 'REC' AND
49991 NVL(p_source_71,'
49992 ') = 'N' AND
49993 NVL(p_source_72,'
49994 ') = 'N' AND
49995 NVL(p_source_73,'
49996 ') = 'N'
49997 THEN
49998
49999 --
50000 XLA_AE_LINES_PKG.SetNewLine;
50001
50002 p_balance_type_code := l_balance_type_code;
50003 -- set the flag so later we will know whether the gain loss line needs to be created
50004
50005 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
50006 p_actual_flag :='A';
50007 END IF;
50008
50009 --
50010 -- bulk performance
50011 --
50012 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
50013 p_header_num => 0); -- 4262811
50014 --
50015 -- set accounting line options
50016 --
50017 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
50018 p_natural_side_code => 'D'
50019 , p_gain_or_loss_flag => 'N'
50020 , p_gl_transfer_mode_code => 'S'
50021 , p_acct_entry_type_code => 'A'
50022 , p_switch_side_flag => 'Y'
50023 , p_merge_duplicate_code => 'A'
50024 );
50025 --
50026 l_acc_rev_natural_side_code := 'C'; -- 4262811
50027 --
50028 --
50029 -- set accounting line type info
50030 --
50031 xla_ae_lines_pkg.SetAcctLineType
50032 (p_component_type => l_component_type
50033 ,p_event_type_code => l_event_type_code
50034 ,p_line_definition_owner_code => l_line_definition_owner_code
50035 ,p_line_definition_code => l_line_definition_code
50036 ,p_accounting_line_code => l_component_code
50037 ,p_accounting_line_type_code => l_component_type_code
50038 ,p_accounting_line_appl_id => l_component_appl_id
50039 ,p_amb_context_code => l_amb_context_code
50040 ,p_entity_code => l_entity_code
50041 ,p_event_class_code => l_event_class_code);
50042 --
50043 -- set accounting class
50044 --
50045 xla_ae_lines_pkg.SetAcctClass(
50046 p_accounting_class_code => 'CASH'
50047 , p_ae_header_id => l_ae_header_id
50048 );
50049
50050 --
50051 -- set rounding class
50052 --
50053 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
50054 'RECEIVABLE';
50055
50056 --
50057 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
50058 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
50059 --
50060 -- bulk performance
50061 --
50062 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
50063
50064 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
50065 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
50066
50067 -- 4955764
50068 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50069 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
50070
50074 -- set accounting attributes for the line type
50071 -- 4458381 Public Sector Enh
50072
50073 --
50075 --
50076 l_entered_amt_idx := 8;
50077 l_accted_amt_idx := 13;
50078 l_bflow_applied_to_amt_idx := NULL; -- 5132302
50079 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
50080 l_rec_acct_attrs.array_num_value(1) := p_source_60;
50081 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
50082 l_rec_acct_attrs.array_char_value(2) := p_source_37;
50083 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
50084 l_rec_acct_attrs.array_char_value(3) := p_source_61;
50085 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
50086 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
50087 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
50088 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
50089 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
50090 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
50091 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
50092 l_rec_acct_attrs.array_char_value(7) := p_source_25;
50093 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
50094 l_rec_acct_attrs.array_num_value(8) := p_source_74;
50095 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
50096 l_rec_acct_attrs.array_char_value(9) := p_source_63;
50097 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
50098 l_rec_acct_attrs.array_date_value(10) := p_source_28;
50099 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
50100 l_rec_acct_attrs.array_num_value(11) := p_source_29;
50101 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
50102 l_rec_acct_attrs.array_char_value(12) := p_source_30;
50103 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
50104 l_rec_acct_attrs.array_num_value(13) := p_source_75;
50105 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
50106 l_rec_acct_attrs.array_num_value(14) := p_source_65;
50107 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
50108 l_rec_acct_attrs.array_num_value(15) := p_source_66;
50109 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
50110 l_rec_acct_attrs.array_char_value(16) := p_source_67;
50111
50112 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
50113 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
50114
50115 ---------------------------------------------------------------------------------------------------------------
50116 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
50117 ---------------------------------------------------------------------------------------------------------------
50118 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
50119
50120 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50121 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50122
50123 IF xla_accounting_cache_pkg.GetValueChar
50124 (p_source_code => 'LEDGER_CATEGORY_CODE'
50125 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
50126 AND l_bflow_method_code = 'PRIOR_ENTRY'
50127 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
50128 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
50129 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
50130 )
50131 THEN
50132 xla_ae_lines_pkg.BflowUpgEntry
50133 (p_business_method_code => l_bflow_method_code
50134 ,p_business_class_code => l_bflow_class_code
50135 ,p_balance_type => l_balance_type_code);
50136 ELSE
50137 NULL;
50138 -- No business flow processing for business flow method of NONE.
50139 END IF;
50140
50141 --
50142 -- call analytical criteria
50143 --
50144
50145 --
50146 -- call description
50147 --
50148
50149 xla_ae_lines_pkg.SetLineDescription(
50150 p_ae_header_id => l_ae_header_id
50151 ,p_description => Description_1 (
50152 p_application_id => p_application_id
50153 , p_ae_header_id => l_ae_header_id
50154 )
50155 );
50156
50157
50158 --
50159 -- call ADRs
50160 -- Bug 4922099
50161 --
50162 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50163 (NVL(l_actual_upg_option, 'N') = 'O') OR
50164 (NVL(l_enc_upg_option, 'N') = 'O')
50165 )
50166 THEN
50167 NULL;
50168 --
50169 --
50170
50171 l_ccid := AcctDerRule_34(
50172 p_application_id => p_application_id
50173 , p_ae_header_id => l_ae_header_id
50174 , p_source_21 => p_source_21
50175 , x_transaction_coa_id => l_adr_transaction_coa_id
50176 , x_accounting_coa_id => l_adr_accounting_coa_id
50177 , x_value_type_code => l_adr_value_type_code
50178 , p_side => 'NA'
50179 );
50180
50181 xla_ae_lines_pkg.set_ccid(
50182 p_code_combination_id => l_ccid
50183 , p_value_type_code => l_adr_value_type_code
50187 , p_adr_type_code => 'S'
50184 , p_transaction_coa_id => l_adr_transaction_coa_id
50185 , p_accounting_coa_id => l_adr_accounting_coa_id
50186 , p_adr_code => 'TRX_DIST_CCID'
50188 , p_component_type => l_component_type
50189 , p_component_code => l_component_code
50190 , p_component_type_code => l_component_type_code
50191 , p_component_appl_id => l_component_appl_id
50192 , p_amb_context_code => l_amb_context_code
50193 , p_side => 'NA'
50194 );
50195
50196
50197 l_segment := AcctDerRule_6(
50198 p_application_id => p_application_id
50199 , p_ae_header_id => l_ae_header_id
50200 , p_source_5 => p_source_5
50201 , x_transaction_coa_id => l_adr_transaction_coa_id
50202 , x_accounting_coa_id => l_adr_accounting_coa_id
50203 , x_flexfield_segment_code => l_adr_flexfield_segment_code
50204 , x_flex_value_set_id => l_adr_flex_value_set_id
50205 , x_value_type_code => l_adr_value_type_code
50206 , x_value_combination_id => l_adr_value_combination_id
50207 , x_value_segment_code => l_adr_value_segment_code
50208 , p_side => 'NA'
50209 , p_override_seg_flag => 'Y'
50210 );
50211
50212 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
50213
50214 xla_ae_lines_pkg.set_segment(
50215 p_to_segment_code => 'GL_ACCOUNT'
50216 , p_segment_value => l_segment
50217 , p_from_segment_code => l_adr_value_segment_code
50218 , p_from_combination_id => l_adr_value_combination_id
50219 , p_value_type_code => l_adr_value_type_code
50220 , p_transaction_coa_id => l_adr_transaction_coa_id
50221 , p_accounting_coa_id => l_adr_accounting_coa_id
50222 , p_flexfield_segment_code => l_adr_flexfield_segment_code
50223 , p_flex_value_set_id => l_adr_flex_value_set_id
50224 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
50225 , p_adr_type_code => 'S'
50226 , p_component_type => l_component_type
50227 , p_component_code => l_component_code
50228 , p_component_type_code => l_component_type_code
50229 , p_component_appl_id => l_component_appl_id
50230 , p_amb_context_code => l_amb_context_code
50231 , p_entity_code => 'RECEIPTS'
50232 , p_event_class_code => 'RECEIPT'
50233 , p_side => 'NA'
50234 );
50235
50236 END IF;
50237
50238 --
50239 --
50240 END IF;
50241 --
50242 -- Bug 4922099
50243 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
50244 (NVL(l_enc_upg_option, 'N') = 'O')
50245 ) AND
50246 (l_bflow_method_code = 'PRIOR_ENTRY')
50247 )
50248 THEN
50249 IF
50250 --
50251 1 = 2
50252 --
50253 THEN
50254 xla_accounting_err_pkg.build_message
50255 (p_appli_s_name => 'XLA'
50256 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50257 ,p_token_1 => 'LINE_NUMBER'
50258 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
50259 ,p_token_2 => 'LINE_TYPE_NAME'
50260 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
50261 l_component_type
50262 ,l_component_code
50263 ,l_component_type_code
50264 ,l_component_appl_id
50265 ,l_amb_context_code
50266 ,l_entity_code
50267 ,l_event_class_code
50268 )
50269 ,p_token_3 => 'OWNER'
50270 ,p_value_3 => xla_lookups_pkg.get_meaning(
50271 p_lookup_type => 'XLA_OWNER_TYPE'
50272 ,p_lookup_code => l_component_type_code
50273 )
50274 ,p_token_4 => 'PRODUCT_NAME'
50275 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
50276 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
50277 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
50278 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
50282 IF (C_LEVEL_ERROR>= g_log_level) THEN
50279 ,p_ae_header_id => NULL
50280 );
50281
50283 trace
50284 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50285 ,p_level => C_LEVEL_ERROR
50286 ,p_module => l_log_module);
50287 END IF;
50288 END IF;
50289 END IF;
50290 --
50291 --
50292 ------------------------------------------------------------------------------------------------
50293 -- 4219869 Business Flow
50294 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
50295 -- Prior Entry. Currently, the following code is always generated.
50296 ------------------------------------------------------------------------------------------------
50297 XLA_AE_LINES_PKG.ValidateCurrentLine;
50298
50299 ------------------------------------------------------------------------------------
50300 -- 4219869 Business Flow
50301 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
50302 ------------------------------------------------------------------------------------
50303 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50304
50305 ----------------------------------------------------------------------------------
50306 -- 4219869 Business Flow
50307 -- Update journal entry status -- Need to generate this within IF <condition>
50308 ----------------------------------------------------------------------------------
50309 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50310 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
50311 ,p_balance_type_code => l_balance_type_code
50312 );
50313
50314 -------------------------------------------------------------------------------------------
50315 -- 4262811 - Generate the Accrual Reversal lines
50316 -------------------------------------------------------------------------------------------
50317 BEGIN
50318 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
50319 (g_array_event(p_event_id).array_value_num('header_index'));
50320 IF l_acc_rev_flag IS NULL THEN
50321 l_acc_rev_flag := 'N';
50322 END IF;
50323 EXCEPTION
50324 WHEN OTHERS THEN
50325 l_acc_rev_flag := 'N';
50326 END;
50327 --
50328 IF (l_acc_rev_flag = 'Y') THEN
50329
50330 -- 4645092 ------------------------------------------------------------------------------
50331 -- To allow MPA report to determine if it should generate report process
50332 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
50333 ------------------------------------------------------------------------------------------
50334
50335 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
50336 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
50337 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
50338 -- call ADRs
50339 -- Bug 4922099
50340 --
50341 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50342 (NVL(l_actual_upg_option, 'N') = 'O') OR
50343 (NVL(l_enc_upg_option, 'N') = 'O')
50344 )
50345 THEN
50346 NULL;
50347 --
50348 --
50349
50350 l_ccid := AcctDerRule_34(
50351 p_application_id => p_application_id
50352 , p_ae_header_id => l_ae_header_id
50353 , p_source_21 => p_source_21
50354 , x_transaction_coa_id => l_adr_transaction_coa_id
50355 , x_accounting_coa_id => l_adr_accounting_coa_id
50356 , x_value_type_code => l_adr_value_type_code
50357 , p_side => 'NA'
50358 );
50359
50360 xla_ae_lines_pkg.set_ccid(
50361 p_code_combination_id => l_ccid
50362 , p_value_type_code => l_adr_value_type_code
50363 , p_transaction_coa_id => l_adr_transaction_coa_id
50364 , p_accounting_coa_id => l_adr_accounting_coa_id
50365 , p_adr_code => 'TRX_DIST_CCID'
50366 , p_adr_type_code => 'S'
50367 , p_component_type => l_component_type
50368 , p_component_code => l_component_code
50369 , p_component_type_code => l_component_type_code
50370 , p_component_appl_id => l_component_appl_id
50371 , p_amb_context_code => l_amb_context_code
50372 , p_side => 'NA'
50373 );
50374
50375
50376 l_segment := AcctDerRule_6(
50377 p_application_id => p_application_id
50378 , p_ae_header_id => l_ae_header_id
50379 , p_source_5 => p_source_5
50380 , x_transaction_coa_id => l_adr_transaction_coa_id
50381 , x_accounting_coa_id => l_adr_accounting_coa_id
50382 , x_flexfield_segment_code => l_adr_flexfield_segment_code
50383 , x_flex_value_set_id => l_adr_flex_value_set_id
50384 , x_value_type_code => l_adr_value_type_code
50385 , x_value_combination_id => l_adr_value_combination_id
50386 , x_value_segment_code => l_adr_value_segment_code
50387 , p_side => 'NA'
50388 , p_override_seg_flag => 'Y'
50389 );
50390
50394 p_to_segment_code => 'GL_ACCOUNT'
50391 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
50392
50393 xla_ae_lines_pkg.set_segment(
50395 , p_segment_value => l_segment
50396 , p_from_segment_code => l_adr_value_segment_code
50397 , p_from_combination_id => l_adr_value_combination_id
50398 , p_value_type_code => l_adr_value_type_code
50399 , p_transaction_coa_id => l_adr_transaction_coa_id
50400 , p_accounting_coa_id => l_adr_accounting_coa_id
50401 , p_flexfield_segment_code => l_adr_flexfield_segment_code
50402 , p_flex_value_set_id => l_adr_flex_value_set_id
50403 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
50404 , p_adr_type_code => 'S'
50405 , p_component_type => l_component_type
50406 , p_component_code => l_component_code
50407 , p_component_type_code => l_component_type_code
50408 , p_component_appl_id => l_component_appl_id
50409 , p_amb_context_code => l_amb_context_code
50410 , p_entity_code => 'RECEIPTS'
50411 , p_event_class_code => 'RECEIPT'
50412 , p_side => 'NA'
50413 );
50414
50415 END IF;
50416
50417 --
50418 --
50419 END IF;
50420
50421 --
50422 -- Update the line information that should be overwritten
50423 --
50424 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
50425 p_header_num => 1);
50426 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
50427
50428 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
50429
50430 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
50431 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
50432 END IF;
50433
50434 --
50435 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
50436 --
50437 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
50438 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
50439 ELSE
50440 ---------------------------------------------------------------------------------------------------
50441 -- 4262811a Switch Sign
50442 ---------------------------------------------------------------------------------------------------
50443 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
50444 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
50445 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50446 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
50447 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50448 -- 5132302
50449 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
50450 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50451
50452 END IF;
50453
50454 -- 4955764
50455 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50456 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
50457
50458
50459 XLA_AE_LINES_PKG.ValidateCurrentLine;
50460 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50461
50462 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50463 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
50464 ,p_balance_type_code => l_balance_type_code);
50465
50466 END IF;
50467
50468 -----------------------------------------------------------------------------------------
50469 -- 4262811 Multiperiod Accounting
50470 -----------------------------------------------------------------------------------------
50471 -- No MPA option is assigned.
50472
50473
50474 END IF;
50475 END IF;
50476 --
50477
50478 --
50479 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
50480 trace
50481 (p_msg => 'END of AcctLineType_109'
50482 ,p_level => C_LEVEL_PROCEDURE
50483 ,p_module => l_log_module);
50484 END IF;
50485 --
50486 EXCEPTION
50487 WHEN xla_exceptions_pkg.application_exception THEN
50488 RAISE;
50489 WHEN OTHERS THEN
50490 xla_exceptions_pkg.raise_message
50491 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_109');
50492 END AcctLineType_109;
50493 --
50494
50495 ---------------------------------------
50496 --
50497 -- PRIVATE FUNCTION
50498 -- AcctLineType_110
50499 --
50500 ---------------------------------------
50501 PROCEDURE AcctLineType_110 (
50502 p_application_id IN NUMBER
50503 ,p_event_id IN NUMBER
50504 ,p_calculate_acctd_flag IN VARCHAR2
50505 ,p_calculate_g_l_flag IN VARCHAR2
50506 ,p_actual_flag IN OUT VARCHAR2
50507 ,p_balance_type_code OUT VARCHAR2
50508 ,p_gain_or_loss_ref OUT VARCHAR2
50509
50510 --Remittance Bank Account Cash Account
50514 --Distribution Source Type
50511 , p_source_5 IN NUMBER
50512 --Transaction Distribution GL Account
50513 , p_source_21 IN NUMBER
50515 , p_source_22 IN VARCHAR2
50516 --Distribution Line Identifier
50517 , p_source_24 IN NUMBER
50518 --Distribution Type
50519 , p_source_25 IN VARCHAR2
50520 --Exchange Date
50521 , p_source_28 IN DATE
50522 --Exchange Rate
50523 , p_source_29 IN NUMBER
50524 --Exchange Rate Type
50525 , p_source_30 IN VARCHAR2
50526 --Transaction Distribution Identifier
50527 , p_source_36 IN NUMBER
50528 --Transaction Distribution Type
50529 , p_source_37 IN VARCHAR2
50530 --Receipt Applied To Application Identifier
50531 , p_source_60 IN NUMBER
50532 --Transaction Entity Code
50533 , p_source_61 IN VARCHAR2
50534 --Transaction Identifier
50535 , p_source_62 IN NUMBER
50536 --Applying Document Currency Code
50537 , p_source_63 IN VARCHAR2
50538 --Distribution Party Identifier
50539 , p_source_65 IN NUMBER
50540 --Distribution Party Site Id
50541 , p_source_66 IN NUMBER
50542 --Distribution Party Type
50543 , p_source_67 IN VARCHAR2
50544 --Distribution Multi Fund Additional Entry
50545 , p_source_71 IN VARCHAR2
50546 --Receipt Class Require Remittance Flag
50547 , p_source_72 IN VARCHAR2
50548 --DIST_ENT_AMT_FROM
50549 , p_source_74 IN NUMBER
50550 --Accounting Amount
50551 , p_source_75 IN NUMBER
50552 )
50553 IS
50554
50555 l_component_type VARCHAR2(80);
50556 l_component_code VARCHAR2(30);
50557 l_component_type_code VARCHAR2(1);
50558 l_component_appl_id INTEGER;
50559 l_amb_context_code VARCHAR2(30);
50560 l_entity_code VARCHAR2(30);
50561 l_event_class_code VARCHAR2(30);
50562 l_ae_header_id NUMBER;
50563 l_event_type_code VARCHAR2(30);
50564 l_line_definition_code VARCHAR2(30);
50565 l_line_definition_owner_code VARCHAR2(1);
50566 --
50567 -- adr variables
50568 l_segment VARCHAR2(30);
50569 l_ccid NUMBER;
50570 l_adr_transaction_coa_id NUMBER;
50571 l_adr_accounting_coa_id NUMBER;
50572 l_adr_flexfield_segment_code VARCHAR2(30);
50573 l_adr_flex_value_set_id NUMBER;
50574 l_adr_value_type_code VARCHAR2(30);
50575 l_adr_value_combination_id NUMBER;
50576 l_adr_value_segment_code VARCHAR2(30);
50577
50578 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
50579 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
50580 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
50581 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
50582
50583 -- 4262811 Variables ------------------------------------------------------------------------------------------
50584 l_entered_amt_idx NUMBER;
50585 l_accted_amt_idx NUMBER;
50586 l_acc_rev_flag VARCHAR2(1);
50587 l_accrual_line_num NUMBER;
50588 l_tmp_amt NUMBER;
50589 l_acc_rev_natural_side_code VARCHAR2(1);
50590
50591 l_num_entries NUMBER;
50592 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
50593 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
50594 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
50595 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
50596 l_recog_line_1 NUMBER;
50597 l_recog_line_2 NUMBER;
50598
50599 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
50600 l_bflow_applied_to_amt NUMBER; -- 5132302
50601 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
50602
50603 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
50604
50605 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
50606 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
50607
50608 ---------------------------------------------------------------------------------------------------------------
50609
50610
50611 --
50612 -- bulk performance
50613 --
50614 l_balance_type_code VARCHAR2(1);
50615 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
50616 l_log_module VARCHAR2(240);
50617
50618 --
50619 -- Upgrade strategy
50620 --
50621 l_actual_upg_option VARCHAR2(1);
50622 l_enc_upg_option VARCHAR2(1);
50623
50624 --
50625 BEGIN
50626 --
50627 IF g_log_enabled THEN
50628 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_110';
50629 END IF;
50630 --
50631 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
50632
50633 trace
50634 (p_msg => 'BEGIN of AcctLineType_110'
50635 ,p_level => C_LEVEL_PROCEDURE
50636 ,p_module => l_log_module);
50637
50638 END IF;
50639 --
50640 l_component_type := 'AMB_JLT';
50641 l_component_code := 'RCT_APP_MFAR_TRX_CM_CASH';
50642 l_component_type_code := 'S';
50643 l_component_appl_id := 222;
50647 l_event_type_code := 'RECEIPT_ALL';
50644 l_amb_context_code := 'DEFAULT';
50645 l_entity_code := 'RECEIPTS';
50646 l_event_class_code := 'RECEIPT';
50648 l_line_definition_owner_code := 'S';
50649 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
50650 --
50651 l_balance_type_code := 'A';
50652 l_segment := NULL;
50653 l_ccid := NULL;
50654 l_adr_transaction_coa_id := NULL;
50655 l_adr_accounting_coa_id := NULL;
50656 l_adr_flexfield_segment_code := NULL;
50657 l_adr_flex_value_set_id := NULL;
50658 l_adr_value_type_code := NULL;
50659 l_adr_value_combination_id := NULL;
50660 l_adr_value_segment_code := NULL;
50661
50662 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
50663 l_bflow_class_code := ''; -- 4219869 Business Flow
50664 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
50665 l_budgetary_control_flag := 'N';
50666
50667 l_bflow_applied_to_amt_idx := NULL; -- 5132302
50668 l_bflow_applied_to_amt := NULL; -- 5132302
50669 l_entered_amt_idx := NULL; -- 4262811
50670 l_accted_amt_idx := NULL; -- 4262811
50671 l_acc_rev_flag := NULL; -- 4262811
50672 l_accrual_line_num := NULL; -- 4262811
50673 l_tmp_amt := NULL; -- 4262811
50674 --
50675
50676 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
50677 l_balance_type_code <> 'B' THEN
50678 IF NVL(p_source_22,'
50679 ') = 'CASH' AND
50680 NVL(p_source_71,'
50681 ') = 'Y' AND
50682 NVL(p_source_72,'
50683 ') = 'Y'
50684 THEN
50685
50686 --
50687 XLA_AE_LINES_PKG.SetNewLine;
50688
50689 p_balance_type_code := l_balance_type_code;
50690 -- set the flag so later we will know whether the gain loss line needs to be created
50691
50692 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
50693 p_actual_flag :='A';
50694 END IF;
50695
50696 --
50697 -- bulk performance
50698 --
50699 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
50700 p_header_num => 0); -- 4262811
50701 --
50702 -- set accounting line options
50703 --
50704 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
50705 p_natural_side_code => 'C'
50706 , p_gain_or_loss_flag => 'N'
50707 , p_gl_transfer_mode_code => 'S'
50708 , p_acct_entry_type_code => 'A'
50709 , p_switch_side_flag => 'Y'
50710 , p_merge_duplicate_code => 'A'
50711 );
50712 --
50713 l_acc_rev_natural_side_code := 'D'; -- 4262811
50714 --
50715 --
50716 -- set accounting line type info
50717 --
50718 xla_ae_lines_pkg.SetAcctLineType
50719 (p_component_type => l_component_type
50720 ,p_event_type_code => l_event_type_code
50721 ,p_line_definition_owner_code => l_line_definition_owner_code
50722 ,p_line_definition_code => l_line_definition_code
50723 ,p_accounting_line_code => l_component_code
50724 ,p_accounting_line_type_code => l_component_type_code
50725 ,p_accounting_line_appl_id => l_component_appl_id
50726 ,p_amb_context_code => l_amb_context_code
50727 ,p_entity_code => l_entity_code
50728 ,p_event_class_code => l_event_class_code);
50729 --
50730 -- set accounting class
50731 --
50732 xla_ae_lines_pkg.SetAcctClass(
50733 p_accounting_class_code => 'CASH'
50734 , p_ae_header_id => l_ae_header_id
50735 );
50736
50737 --
50738 -- set rounding class
50739 --
50740 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
50741 'RECEIVABLE';
50742
50743 --
50744 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
50745 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
50746 --
50747 -- bulk performance
50748 --
50749 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
50750
50751 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
50752 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
50753
50754 -- 4955764
50755 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50756 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
50757
50758 -- 4458381 Public Sector Enh
50759
50760 --
50761 -- set accounting attributes for the line type
50762 --
50763 l_entered_amt_idx := 8;
50764 l_accted_amt_idx := 13;
50765 l_bflow_applied_to_amt_idx := NULL; -- 5132302
50766 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
50767 l_rec_acct_attrs.array_num_value(1) := p_source_60;
50768 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
50769 l_rec_acct_attrs.array_char_value(2) := p_source_37;
50770 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
50774 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
50771 l_rec_acct_attrs.array_char_value(3) := p_source_61;
50772 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
50773 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
50775 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
50776 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
50777 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
50778 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
50779 l_rec_acct_attrs.array_char_value(7) := p_source_25;
50780 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
50781 l_rec_acct_attrs.array_num_value(8) := p_source_74;
50782 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
50783 l_rec_acct_attrs.array_char_value(9) := p_source_63;
50784 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
50785 l_rec_acct_attrs.array_date_value(10) := p_source_28;
50786 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
50787 l_rec_acct_attrs.array_num_value(11) := p_source_29;
50788 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
50789 l_rec_acct_attrs.array_char_value(12) := p_source_30;
50790 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
50791 l_rec_acct_attrs.array_num_value(13) := p_source_75;
50792 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
50793 l_rec_acct_attrs.array_num_value(14) := p_source_65;
50794 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
50795 l_rec_acct_attrs.array_num_value(15) := p_source_66;
50796 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
50797 l_rec_acct_attrs.array_char_value(16) := p_source_67;
50798
50799 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
50800 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
50801
50802 ---------------------------------------------------------------------------------------------------------------
50803 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
50804 ---------------------------------------------------------------------------------------------------------------
50805 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
50806
50807 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50808 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50809
50810 IF xla_accounting_cache_pkg.GetValueChar
50811 (p_source_code => 'LEDGER_CATEGORY_CODE'
50812 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
50813 AND l_bflow_method_code = 'PRIOR_ENTRY'
50814 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
50815 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
50816 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
50817 )
50818 THEN
50819 xla_ae_lines_pkg.BflowUpgEntry
50820 (p_business_method_code => l_bflow_method_code
50821 ,p_business_class_code => l_bflow_class_code
50822 ,p_balance_type => l_balance_type_code);
50823 ELSE
50824 NULL;
50825 -- No business flow processing for business flow method of NONE.
50826 END IF;
50827
50828 --
50829 -- call analytical criteria
50830 --
50831
50832 --
50833 -- call description
50834 --
50835
50836 xla_ae_lines_pkg.SetLineDescription(
50837 p_ae_header_id => l_ae_header_id
50838 ,p_description => Description_1 (
50839 p_application_id => p_application_id
50840 , p_ae_header_id => l_ae_header_id
50841 )
50842 );
50843
50844
50845 --
50846 -- call ADRs
50847 -- Bug 4922099
50848 --
50849 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50850 (NVL(l_actual_upg_option, 'N') = 'O') OR
50851 (NVL(l_enc_upg_option, 'N') = 'O')
50852 )
50853 THEN
50854 NULL;
50855 --
50856 --
50857
50858 l_ccid := AcctDerRule_34(
50859 p_application_id => p_application_id
50860 , p_ae_header_id => l_ae_header_id
50861 , p_source_21 => p_source_21
50862 , x_transaction_coa_id => l_adr_transaction_coa_id
50863 , x_accounting_coa_id => l_adr_accounting_coa_id
50864 , x_value_type_code => l_adr_value_type_code
50865 , p_side => 'NA'
50866 );
50867
50868 xla_ae_lines_pkg.set_ccid(
50869 p_code_combination_id => l_ccid
50870 , p_value_type_code => l_adr_value_type_code
50871 , p_transaction_coa_id => l_adr_transaction_coa_id
50872 , p_accounting_coa_id => l_adr_accounting_coa_id
50873 , p_adr_code => 'TRX_DIST_CCID'
50874 , p_adr_type_code => 'S'
50875 , p_component_type => l_component_type
50876 , p_component_code => l_component_code
50877 , p_component_type_code => l_component_type_code
50878 , p_component_appl_id => l_component_appl_id
50882
50879 , p_amb_context_code => l_amb_context_code
50880 , p_side => 'NA'
50881 );
50883
50884 l_segment := AcctDerRule_6(
50885 p_application_id => p_application_id
50886 , p_ae_header_id => l_ae_header_id
50887 , p_source_5 => p_source_5
50888 , x_transaction_coa_id => l_adr_transaction_coa_id
50889 , x_accounting_coa_id => l_adr_accounting_coa_id
50890 , x_flexfield_segment_code => l_adr_flexfield_segment_code
50891 , x_flex_value_set_id => l_adr_flex_value_set_id
50892 , x_value_type_code => l_adr_value_type_code
50893 , x_value_combination_id => l_adr_value_combination_id
50894 , x_value_segment_code => l_adr_value_segment_code
50895 , p_side => 'NA'
50896 , p_override_seg_flag => 'Y'
50897 );
50898
50899 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
50900
50901 xla_ae_lines_pkg.set_segment(
50902 p_to_segment_code => 'GL_ACCOUNT'
50903 , p_segment_value => l_segment
50904 , p_from_segment_code => l_adr_value_segment_code
50905 , p_from_combination_id => l_adr_value_combination_id
50906 , p_value_type_code => l_adr_value_type_code
50907 , p_transaction_coa_id => l_adr_transaction_coa_id
50908 , p_accounting_coa_id => l_adr_accounting_coa_id
50909 , p_flexfield_segment_code => l_adr_flexfield_segment_code
50910 , p_flex_value_set_id => l_adr_flex_value_set_id
50911 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
50912 , p_adr_type_code => 'S'
50913 , p_component_type => l_component_type
50914 , p_component_code => l_component_code
50915 , p_component_type_code => l_component_type_code
50916 , p_component_appl_id => l_component_appl_id
50917 , p_amb_context_code => l_amb_context_code
50918 , p_entity_code => 'RECEIPTS'
50919 , p_event_class_code => 'RECEIPT'
50920 , p_side => 'NA'
50921 );
50922
50923 END IF;
50924
50925 --
50926 --
50927 END IF;
50928 --
50929 -- Bug 4922099
50930 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
50931 (NVL(l_enc_upg_option, 'N') = 'O')
50932 ) AND
50933 (l_bflow_method_code = 'PRIOR_ENTRY')
50934 )
50935 THEN
50936 IF
50937 --
50938 1 = 2
50939 --
50940 THEN
50941 xla_accounting_err_pkg.build_message
50942 (p_appli_s_name => 'XLA'
50943 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50944 ,p_token_1 => 'LINE_NUMBER'
50945 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
50946 ,p_token_2 => 'LINE_TYPE_NAME'
50947 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
50948 l_component_type
50949 ,l_component_code
50950 ,l_component_type_code
50951 ,l_component_appl_id
50952 ,l_amb_context_code
50953 ,l_entity_code
50954 ,l_event_class_code
50955 )
50956 ,p_token_3 => 'OWNER'
50957 ,p_value_3 => xla_lookups_pkg.get_meaning(
50958 p_lookup_type => 'XLA_OWNER_TYPE'
50959 ,p_lookup_code => l_component_type_code
50960 )
50961 ,p_token_4 => 'PRODUCT_NAME'
50962 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
50963 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
50964 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
50965 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
50966 ,p_ae_header_id => NULL
50967 );
50968
50969 IF (C_LEVEL_ERROR>= g_log_level) THEN
50970 trace
50971 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50972 ,p_level => C_LEVEL_ERROR
50973 ,p_module => l_log_module);
50974 END IF;
50975 END IF;
50976 END IF;
50977 --
50978 --
50982 -- Prior Entry. Currently, the following code is always generated.
50979 ------------------------------------------------------------------------------------------------
50980 -- 4219869 Business Flow
50981 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
50983 ------------------------------------------------------------------------------------------------
50984 XLA_AE_LINES_PKG.ValidateCurrentLine;
50985
50986 ------------------------------------------------------------------------------------
50987 -- 4219869 Business Flow
50988 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
50989 ------------------------------------------------------------------------------------
50990 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50991
50992 ----------------------------------------------------------------------------------
50993 -- 4219869 Business Flow
50994 -- Update journal entry status -- Need to generate this within IF <condition>
50995 ----------------------------------------------------------------------------------
50996 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50997 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
50998 ,p_balance_type_code => l_balance_type_code
50999 );
51000
51001 -------------------------------------------------------------------------------------------
51002 -- 4262811 - Generate the Accrual Reversal lines
51003 -------------------------------------------------------------------------------------------
51004 BEGIN
51005 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
51006 (g_array_event(p_event_id).array_value_num('header_index'));
51007 IF l_acc_rev_flag IS NULL THEN
51008 l_acc_rev_flag := 'N';
51009 END IF;
51010 EXCEPTION
51011 WHEN OTHERS THEN
51012 l_acc_rev_flag := 'N';
51013 END;
51014 --
51015 IF (l_acc_rev_flag = 'Y') THEN
51016
51017 -- 4645092 ------------------------------------------------------------------------------
51018 -- To allow MPA report to determine if it should generate report process
51019 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
51020 ------------------------------------------------------------------------------------------
51021
51022 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
51023 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
51024 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
51025 -- call ADRs
51026 -- Bug 4922099
51027 --
51028 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
51029 (NVL(l_actual_upg_option, 'N') = 'O') OR
51030 (NVL(l_enc_upg_option, 'N') = 'O')
51031 )
51032 THEN
51033 NULL;
51034 --
51035 --
51036
51037 l_ccid := AcctDerRule_34(
51038 p_application_id => p_application_id
51039 , p_ae_header_id => l_ae_header_id
51040 , p_source_21 => p_source_21
51041 , x_transaction_coa_id => l_adr_transaction_coa_id
51042 , x_accounting_coa_id => l_adr_accounting_coa_id
51043 , x_value_type_code => l_adr_value_type_code
51044 , p_side => 'NA'
51045 );
51046
51047 xla_ae_lines_pkg.set_ccid(
51048 p_code_combination_id => l_ccid
51049 , p_value_type_code => l_adr_value_type_code
51050 , p_transaction_coa_id => l_adr_transaction_coa_id
51051 , p_accounting_coa_id => l_adr_accounting_coa_id
51052 , p_adr_code => 'TRX_DIST_CCID'
51053 , p_adr_type_code => 'S'
51054 , p_component_type => l_component_type
51055 , p_component_code => l_component_code
51056 , p_component_type_code => l_component_type_code
51057 , p_component_appl_id => l_component_appl_id
51058 , p_amb_context_code => l_amb_context_code
51059 , p_side => 'NA'
51060 );
51061
51062
51063 l_segment := AcctDerRule_6(
51064 p_application_id => p_application_id
51065 , p_ae_header_id => l_ae_header_id
51066 , p_source_5 => p_source_5
51067 , x_transaction_coa_id => l_adr_transaction_coa_id
51068 , x_accounting_coa_id => l_adr_accounting_coa_id
51069 , x_flexfield_segment_code => l_adr_flexfield_segment_code
51070 , x_flex_value_set_id => l_adr_flex_value_set_id
51071 , x_value_type_code => l_adr_value_type_code
51072 , x_value_combination_id => l_adr_value_combination_id
51073 , x_value_segment_code => l_adr_value_segment_code
51074 , p_side => 'NA'
51075 , p_override_seg_flag => 'Y'
51076 );
51077
51078 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
51079
51080 xla_ae_lines_pkg.set_segment(
51081 p_to_segment_code => 'GL_ACCOUNT'
51082 , p_segment_value => l_segment
51083 , p_from_segment_code => l_adr_value_segment_code
51084 , p_from_combination_id => l_adr_value_combination_id
51085 , p_value_type_code => l_adr_value_type_code
51086 , p_transaction_coa_id => l_adr_transaction_coa_id
51087 , p_accounting_coa_id => l_adr_accounting_coa_id
51088 , p_flexfield_segment_code => l_adr_flexfield_segment_code
51092 , p_component_type => l_component_type
51089 , p_flex_value_set_id => l_adr_flex_value_set_id
51090 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
51091 , p_adr_type_code => 'S'
51093 , p_component_code => l_component_code
51094 , p_component_type_code => l_component_type_code
51095 , p_component_appl_id => l_component_appl_id
51096 , p_amb_context_code => l_amb_context_code
51097 , p_entity_code => 'RECEIPTS'
51098 , p_event_class_code => 'RECEIPT'
51099 , p_side => 'NA'
51100 );
51101
51102 END IF;
51103
51104 --
51105 --
51106 END IF;
51107
51108 --
51109 -- Update the line information that should be overwritten
51110 --
51111 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
51112 p_header_num => 1);
51113 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
51114
51115 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
51116
51117 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
51118 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
51119 END IF;
51120
51121 --
51122 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
51123 --
51124 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
51125 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
51126 ELSE
51127 ---------------------------------------------------------------------------------------------------
51128 -- 4262811a Switch Sign
51129 ---------------------------------------------------------------------------------------------------
51130 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
51131 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
51132 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51133 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
51134 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51135 -- 5132302
51136 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
51137 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51138
51139 END IF;
51140
51141 -- 4955764
51142 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
51143 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
51144
51145
51146 XLA_AE_LINES_PKG.ValidateCurrentLine;
51147 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
51148
51149 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
51150 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
51151 ,p_balance_type_code => l_balance_type_code);
51152
51153 END IF;
51154
51155 -----------------------------------------------------------------------------------------
51156 -- 4262811 Multiperiod Accounting
51157 -----------------------------------------------------------------------------------------
51158 -- No MPA option is assigned.
51159
51160
51161 END IF;
51162 END IF;
51163 --
51164
51165 --
51166 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51167 trace
51168 (p_msg => 'END of AcctLineType_110'
51169 ,p_level => C_LEVEL_PROCEDURE
51170 ,p_module => l_log_module);
51171 END IF;
51172 --
51173 EXCEPTION
51174 WHEN xla_exceptions_pkg.application_exception THEN
51175 RAISE;
51176 WHEN OTHERS THEN
51177 xla_exceptions_pkg.raise_message
51178 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_110');
51179 END AcctLineType_110;
51180 --
51181
51182 ---------------------------------------
51183 --
51184 -- PRIVATE FUNCTION
51185 -- AcctLineType_111
51186 --
51187 ---------------------------------------
51188 PROCEDURE AcctLineType_111 (
51189 p_application_id IN NUMBER
51190 ,p_event_id IN NUMBER
51191 ,p_calculate_acctd_flag IN VARCHAR2
51192 ,p_calculate_g_l_flag IN VARCHAR2
51193 ,p_actual_flag IN OUT VARCHAR2
51194 ,p_balance_type_code OUT VARCHAR2
51195 ,p_gain_or_loss_ref OUT VARCHAR2
51196
51197 --Remittance Bank Account Confirmation Account
51198 , p_source_3 IN NUMBER
51199 --Transaction Distribution GL Account
51200 , p_source_21 IN NUMBER
51201 --Distribution Source Type
51202 , p_source_22 IN VARCHAR2
51203 --Distribution Line Identifier
51204 , p_source_24 IN NUMBER
51205 --Distribution Type
51206 , p_source_25 IN VARCHAR2
51207 --Exchange Date
51208 , p_source_28 IN DATE
51209 --Exchange Rate
51210 , p_source_29 IN NUMBER
51211 --Exchange Rate Type
51212 , p_source_30 IN VARCHAR2
51216 , p_source_37 IN VARCHAR2
51213 --Transaction Distribution Identifier
51214 , p_source_36 IN NUMBER
51215 --Transaction Distribution Type
51217 --Receipt Applied To Application Identifier
51218 , p_source_60 IN NUMBER
51219 --Transaction Entity Code
51220 , p_source_61 IN VARCHAR2
51221 --Transaction Identifier
51222 , p_source_62 IN NUMBER
51223 --Applying Document Currency Code
51224 , p_source_63 IN VARCHAR2
51225 --Distribution Party Identifier
51226 , p_source_65 IN NUMBER
51227 --Distribution Party Site Id
51228 , p_source_66 IN NUMBER
51229 --Distribution Party Type
51230 , p_source_67 IN VARCHAR2
51231 --Distribution Multi Fund Additional Entry
51232 , p_source_71 IN VARCHAR2
51233 --DIST_ENT_AMT_FROM
51234 , p_source_74 IN NUMBER
51235 --Accounting Amount
51236 , p_source_75 IN NUMBER
51237 )
51238 IS
51239
51240 l_component_type VARCHAR2(80);
51241 l_component_code VARCHAR2(30);
51242 l_component_type_code VARCHAR2(1);
51243 l_component_appl_id INTEGER;
51244 l_amb_context_code VARCHAR2(30);
51245 l_entity_code VARCHAR2(30);
51246 l_event_class_code VARCHAR2(30);
51247 l_ae_header_id NUMBER;
51248 l_event_type_code VARCHAR2(30);
51249 l_line_definition_code VARCHAR2(30);
51250 l_line_definition_owner_code VARCHAR2(1);
51251 --
51252 -- adr variables
51253 l_segment VARCHAR2(30);
51254 l_ccid NUMBER;
51255 l_adr_transaction_coa_id NUMBER;
51256 l_adr_accounting_coa_id NUMBER;
51257 l_adr_flexfield_segment_code VARCHAR2(30);
51258 l_adr_flex_value_set_id NUMBER;
51259 l_adr_value_type_code VARCHAR2(30);
51260 l_adr_value_combination_id NUMBER;
51261 l_adr_value_segment_code VARCHAR2(30);
51262
51263 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
51264 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
51265 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
51266 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
51267
51268 -- 4262811 Variables ------------------------------------------------------------------------------------------
51269 l_entered_amt_idx NUMBER;
51270 l_accted_amt_idx NUMBER;
51271 l_acc_rev_flag VARCHAR2(1);
51272 l_accrual_line_num NUMBER;
51273 l_tmp_amt NUMBER;
51274 l_acc_rev_natural_side_code VARCHAR2(1);
51275
51276 l_num_entries NUMBER;
51277 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
51278 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
51279 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
51280 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
51281 l_recog_line_1 NUMBER;
51282 l_recog_line_2 NUMBER;
51283
51284 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
51285 l_bflow_applied_to_amt NUMBER; -- 5132302
51286 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
51287
51288 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
51289
51290 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
51291 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
51292
51293 ---------------------------------------------------------------------------------------------------------------
51294
51295
51296 --
51297 -- bulk performance
51298 --
51299 l_balance_type_code VARCHAR2(1);
51300 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
51301 l_log_module VARCHAR2(240);
51302
51303 --
51304 -- Upgrade strategy
51305 --
51306 l_actual_upg_option VARCHAR2(1);
51307 l_enc_upg_option VARCHAR2(1);
51308
51309 --
51310 BEGIN
51311 --
51312 IF g_log_enabled THEN
51313 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_111';
51314 END IF;
51315 --
51316 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51317
51318 trace
51319 (p_msg => 'BEGIN of AcctLineType_111'
51320 ,p_level => C_LEVEL_PROCEDURE
51321 ,p_module => l_log_module);
51322
51323 END IF;
51324 --
51325 l_component_type := 'AMB_JLT';
51326 l_component_code := 'RCT_APP_MFAR_TRX_CONFIRMATION';
51327 l_component_type_code := 'S';
51328 l_component_appl_id := 222;
51329 l_amb_context_code := 'DEFAULT';
51330 l_entity_code := 'RECEIPTS';
51331 l_event_class_code := 'RECEIPT';
51332 l_event_type_code := 'RECEIPT_ALL';
51333 l_line_definition_owner_code := 'S';
51334 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
51335 --
51336 l_balance_type_code := 'A';
51337 l_segment := NULL;
51338 l_ccid := NULL;
51339 l_adr_transaction_coa_id := NULL;
51340 l_adr_accounting_coa_id := NULL;
51341 l_adr_flexfield_segment_code := NULL;
51342 l_adr_flex_value_set_id := NULL;
51343 l_adr_value_type_code := NULL;
51347 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
51344 l_adr_value_combination_id := NULL;
51345 l_adr_value_segment_code := NULL;
51346
51348 l_bflow_class_code := ''; -- 4219869 Business Flow
51349 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
51350 l_budgetary_control_flag := 'N';
51351
51352 l_bflow_applied_to_amt_idx := NULL; -- 5132302
51353 l_bflow_applied_to_amt := NULL; -- 5132302
51354 l_entered_amt_idx := NULL; -- 4262811
51355 l_accted_amt_idx := NULL; -- 4262811
51356 l_acc_rev_flag := NULL; -- 4262811
51357 l_accrual_line_num := NULL; -- 4262811
51358 l_tmp_amt := NULL; -- 4262811
51359 --
51360
51361 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
51362 l_balance_type_code <> 'B' THEN
51363 IF NVL(p_source_22,'
51364 ') = 'CONFIRMATION' AND
51365 NVL(p_source_71,'
51366 ') = 'Y'
51367 THEN
51368
51369 --
51370 XLA_AE_LINES_PKG.SetNewLine;
51371
51372 p_balance_type_code := l_balance_type_code;
51373 -- set the flag so later we will know whether the gain loss line needs to be created
51374
51375 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
51376 p_actual_flag :='A';
51377 END IF;
51378
51379 --
51380 -- bulk performance
51381 --
51382 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
51383 p_header_num => 0); -- 4262811
51384 --
51385 -- set accounting line options
51386 --
51387 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
51388 p_natural_side_code => 'C'
51389 , p_gain_or_loss_flag => 'N'
51390 , p_gl_transfer_mode_code => 'S'
51391 , p_acct_entry_type_code => 'A'
51392 , p_switch_side_flag => 'Y'
51393 , p_merge_duplicate_code => 'A'
51394 );
51395 --
51396 l_acc_rev_natural_side_code := 'D'; -- 4262811
51397 --
51398 --
51399 -- set accounting line type info
51400 --
51401 xla_ae_lines_pkg.SetAcctLineType
51402 (p_component_type => l_component_type
51403 ,p_event_type_code => l_event_type_code
51404 ,p_line_definition_owner_code => l_line_definition_owner_code
51405 ,p_line_definition_code => l_line_definition_code
51406 ,p_accounting_line_code => l_component_code
51407 ,p_accounting_line_type_code => l_component_type_code
51408 ,p_accounting_line_appl_id => l_component_appl_id
51409 ,p_amb_context_code => l_amb_context_code
51410 ,p_entity_code => l_entity_code
51411 ,p_event_class_code => l_event_class_code);
51412 --
51413 -- set accounting class
51414 --
51415 xla_ae_lines_pkg.SetAcctClass(
51416 p_accounting_class_code => 'CONFIRMATION'
51417 , p_ae_header_id => l_ae_header_id
51418 );
51419
51420 --
51421 -- set rounding class
51422 --
51423 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
51424 'RECEIVABLE';
51425
51426 --
51427 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
51428 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
51429 --
51430 -- bulk performance
51431 --
51432 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
51433
51434 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
51435 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
51436
51437 -- 4955764
51438 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
51439 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
51440
51441 -- 4458381 Public Sector Enh
51442
51443 --
51444 -- set accounting attributes for the line type
51445 --
51446 l_entered_amt_idx := 8;
51447 l_accted_amt_idx := 13;
51448 l_bflow_applied_to_amt_idx := NULL; -- 5132302
51449 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
51450 l_rec_acct_attrs.array_num_value(1) := p_source_60;
51451 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
51452 l_rec_acct_attrs.array_char_value(2) := p_source_37;
51453 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
51454 l_rec_acct_attrs.array_char_value(3) := p_source_61;
51455 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
51456 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
51457 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
51458 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
51459 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
51460 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
51461 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
51462 l_rec_acct_attrs.array_char_value(7) := p_source_25;
51466 l_rec_acct_attrs.array_char_value(9) := p_source_63;
51463 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
51464 l_rec_acct_attrs.array_num_value(8) := p_source_74;
51465 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
51467 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
51468 l_rec_acct_attrs.array_date_value(10) := p_source_28;
51469 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
51470 l_rec_acct_attrs.array_num_value(11) := p_source_29;
51471 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
51472 l_rec_acct_attrs.array_char_value(12) := p_source_30;
51473 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
51474 l_rec_acct_attrs.array_num_value(13) := p_source_75;
51475 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
51476 l_rec_acct_attrs.array_num_value(14) := p_source_65;
51477 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
51478 l_rec_acct_attrs.array_num_value(15) := p_source_66;
51479 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
51480 l_rec_acct_attrs.array_char_value(16) := p_source_67;
51481
51482 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
51483 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
51484
51485 ---------------------------------------------------------------------------------------------------------------
51486 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
51487 ---------------------------------------------------------------------------------------------------------------
51488 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
51489
51490 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
51491 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
51492
51493 IF xla_accounting_cache_pkg.GetValueChar
51494 (p_source_code => 'LEDGER_CATEGORY_CODE'
51495 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
51496 AND l_bflow_method_code = 'PRIOR_ENTRY'
51497 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
51498 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
51499 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
51500 )
51501 THEN
51502 xla_ae_lines_pkg.BflowUpgEntry
51503 (p_business_method_code => l_bflow_method_code
51504 ,p_business_class_code => l_bflow_class_code
51505 ,p_balance_type => l_balance_type_code);
51506 ELSE
51507 NULL;
51508 -- No business flow processing for business flow method of NONE.
51509 END IF;
51510
51511 --
51512 -- call analytical criteria
51513 --
51514
51515 --
51516 -- call description
51517 --
51518
51519 xla_ae_lines_pkg.SetLineDescription(
51520 p_ae_header_id => l_ae_header_id
51521 ,p_description => Description_1 (
51522 p_application_id => p_application_id
51523 , p_ae_header_id => l_ae_header_id
51524 )
51525 );
51526
51527
51528 --
51529 -- call ADRs
51530 -- Bug 4922099
51531 --
51532 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
51533 (NVL(l_actual_upg_option, 'N') = 'O') OR
51534 (NVL(l_enc_upg_option, 'N') = 'O')
51535 )
51536 THEN
51537 NULL;
51538 --
51539 --
51540
51541 l_ccid := AcctDerRule_34(
51542 p_application_id => p_application_id
51543 , p_ae_header_id => l_ae_header_id
51544 , p_source_21 => p_source_21
51545 , x_transaction_coa_id => l_adr_transaction_coa_id
51546 , x_accounting_coa_id => l_adr_accounting_coa_id
51547 , x_value_type_code => l_adr_value_type_code
51548 , p_side => 'NA'
51549 );
51550
51551 xla_ae_lines_pkg.set_ccid(
51552 p_code_combination_id => l_ccid
51553 , p_value_type_code => l_adr_value_type_code
51554 , p_transaction_coa_id => l_adr_transaction_coa_id
51555 , p_accounting_coa_id => l_adr_accounting_coa_id
51556 , p_adr_code => 'TRX_DIST_CCID'
51557 , p_adr_type_code => 'S'
51558 , p_component_type => l_component_type
51559 , p_component_code => l_component_code
51560 , p_component_type_code => l_component_type_code
51561 , p_component_appl_id => l_component_appl_id
51562 , p_amb_context_code => l_amb_context_code
51563 , p_side => 'NA'
51564 );
51565
51566
51567 l_segment := AcctDerRule_4(
51568 p_application_id => p_application_id
51569 , p_ae_header_id => l_ae_header_id
51570 , p_source_3 => p_source_3
51571 , x_transaction_coa_id => l_adr_transaction_coa_id
51572 , x_accounting_coa_id => l_adr_accounting_coa_id
51573 , x_flexfield_segment_code => l_adr_flexfield_segment_code
51574 , x_flex_value_set_id => l_adr_flex_value_set_id
51575 , x_value_type_code => l_adr_value_type_code
51579 , p_override_seg_flag => 'Y'
51576 , x_value_combination_id => l_adr_value_combination_id
51577 , x_value_segment_code => l_adr_value_segment_code
51578 , p_side => 'NA'
51580 );
51581
51582 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
51583
51584 xla_ae_lines_pkg.set_segment(
51585 p_to_segment_code => 'GL_ACCOUNT'
51586 , p_segment_value => l_segment
51587 , p_from_segment_code => l_adr_value_segment_code
51588 , p_from_combination_id => l_adr_value_combination_id
51589 , p_value_type_code => l_adr_value_type_code
51590 , p_transaction_coa_id => l_adr_transaction_coa_id
51591 , p_accounting_coa_id => l_adr_accounting_coa_id
51592 , p_flexfield_segment_code => l_adr_flexfield_segment_code
51593 , p_flex_value_set_id => l_adr_flex_value_set_id
51594 , p_adr_code => 'MFAR_RCT_CONFIRMATION_NATSEG'
51595 , p_adr_type_code => 'S'
51596 , p_component_type => l_component_type
51597 , p_component_code => l_component_code
51598 , p_component_type_code => l_component_type_code
51599 , p_component_appl_id => l_component_appl_id
51600 , p_amb_context_code => l_amb_context_code
51601 , p_entity_code => 'RECEIPTS'
51602 , p_event_class_code => 'RECEIPT'
51603 , p_side => 'NA'
51604 );
51605
51606 END IF;
51607
51608 --
51609 --
51610 END IF;
51611 --
51612 -- Bug 4922099
51613 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
51614 (NVL(l_enc_upg_option, 'N') = 'O')
51615 ) AND
51616 (l_bflow_method_code = 'PRIOR_ENTRY')
51617 )
51618 THEN
51619 IF
51620 --
51621 1 = 2
51622 --
51623 THEN
51624 xla_accounting_err_pkg.build_message
51625 (p_appli_s_name => 'XLA'
51626 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
51627 ,p_token_1 => 'LINE_NUMBER'
51628 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
51629 ,p_token_2 => 'LINE_TYPE_NAME'
51630 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
51631 l_component_type
51632 ,l_component_code
51633 ,l_component_type_code
51634 ,l_component_appl_id
51635 ,l_amb_context_code
51636 ,l_entity_code
51637 ,l_event_class_code
51638 )
51639 ,p_token_3 => 'OWNER'
51640 ,p_value_3 => xla_lookups_pkg.get_meaning(
51641 p_lookup_type => 'XLA_OWNER_TYPE'
51642 ,p_lookup_code => l_component_type_code
51643 )
51644 ,p_token_4 => 'PRODUCT_NAME'
51645 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
51646 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
51647 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
51648 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
51649 ,p_ae_header_id => NULL
51650 );
51651
51652 IF (C_LEVEL_ERROR>= g_log_level) THEN
51653 trace
51654 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
51655 ,p_level => C_LEVEL_ERROR
51656 ,p_module => l_log_module);
51657 END IF;
51658 END IF;
51659 END IF;
51660 --
51661 --
51662 ------------------------------------------------------------------------------------------------
51663 -- 4219869 Business Flow
51664 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
51665 -- Prior Entry. Currently, the following code is always generated.
51666 ------------------------------------------------------------------------------------------------
51667 XLA_AE_LINES_PKG.ValidateCurrentLine;
51668
51669 ------------------------------------------------------------------------------------
51670 -- 4219869 Business Flow
51671 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
51675 ----------------------------------------------------------------------------------
51672 ------------------------------------------------------------------------------------
51673 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
51674
51676 -- 4219869 Business Flow
51677 -- Update journal entry status -- Need to generate this within IF <condition>
51678 ----------------------------------------------------------------------------------
51679 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
51680 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
51681 ,p_balance_type_code => l_balance_type_code
51682 );
51683
51684 -------------------------------------------------------------------------------------------
51685 -- 4262811 - Generate the Accrual Reversal lines
51686 -------------------------------------------------------------------------------------------
51687 BEGIN
51688 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
51689 (g_array_event(p_event_id).array_value_num('header_index'));
51690 IF l_acc_rev_flag IS NULL THEN
51691 l_acc_rev_flag := 'N';
51692 END IF;
51693 EXCEPTION
51694 WHEN OTHERS THEN
51695 l_acc_rev_flag := 'N';
51696 END;
51697 --
51698 IF (l_acc_rev_flag = 'Y') THEN
51699
51700 -- 4645092 ------------------------------------------------------------------------------
51701 -- To allow MPA report to determine if it should generate report process
51702 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
51703 ------------------------------------------------------------------------------------------
51704
51705 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
51706 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
51707 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
51708 -- call ADRs
51709 -- Bug 4922099
51710 --
51711 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
51712 (NVL(l_actual_upg_option, 'N') = 'O') OR
51713 (NVL(l_enc_upg_option, 'N') = 'O')
51714 )
51715 THEN
51716 NULL;
51717 --
51718 --
51719
51720 l_ccid := AcctDerRule_34(
51721 p_application_id => p_application_id
51722 , p_ae_header_id => l_ae_header_id
51723 , p_source_21 => p_source_21
51724 , x_transaction_coa_id => l_adr_transaction_coa_id
51725 , x_accounting_coa_id => l_adr_accounting_coa_id
51726 , x_value_type_code => l_adr_value_type_code
51727 , p_side => 'NA'
51728 );
51729
51730 xla_ae_lines_pkg.set_ccid(
51731 p_code_combination_id => l_ccid
51732 , p_value_type_code => l_adr_value_type_code
51733 , p_transaction_coa_id => l_adr_transaction_coa_id
51734 , p_accounting_coa_id => l_adr_accounting_coa_id
51735 , p_adr_code => 'TRX_DIST_CCID'
51736 , p_adr_type_code => 'S'
51737 , p_component_type => l_component_type
51738 , p_component_code => l_component_code
51739 , p_component_type_code => l_component_type_code
51740 , p_component_appl_id => l_component_appl_id
51741 , p_amb_context_code => l_amb_context_code
51742 , p_side => 'NA'
51743 );
51744
51745
51746 l_segment := AcctDerRule_4(
51747 p_application_id => p_application_id
51748 , p_ae_header_id => l_ae_header_id
51749 , p_source_3 => p_source_3
51750 , x_transaction_coa_id => l_adr_transaction_coa_id
51751 , x_accounting_coa_id => l_adr_accounting_coa_id
51752 , x_flexfield_segment_code => l_adr_flexfield_segment_code
51753 , x_flex_value_set_id => l_adr_flex_value_set_id
51754 , x_value_type_code => l_adr_value_type_code
51755 , x_value_combination_id => l_adr_value_combination_id
51756 , x_value_segment_code => l_adr_value_segment_code
51757 , p_side => 'NA'
51758 , p_override_seg_flag => 'Y'
51759 );
51760
51761 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
51762
51763 xla_ae_lines_pkg.set_segment(
51764 p_to_segment_code => 'GL_ACCOUNT'
51765 , p_segment_value => l_segment
51766 , p_from_segment_code => l_adr_value_segment_code
51767 , p_from_combination_id => l_adr_value_combination_id
51768 , p_value_type_code => l_adr_value_type_code
51769 , p_transaction_coa_id => l_adr_transaction_coa_id
51770 , p_accounting_coa_id => l_adr_accounting_coa_id
51771 , p_flexfield_segment_code => l_adr_flexfield_segment_code
51772 , p_flex_value_set_id => l_adr_flex_value_set_id
51773 , p_adr_code => 'MFAR_RCT_CONFIRMATION_NATSEG'
51774 , p_adr_type_code => 'S'
51775 , p_component_type => l_component_type
51776 , p_component_code => l_component_code
51777 , p_component_type_code => l_component_type_code
51778 , p_component_appl_id => l_component_appl_id
51779 , p_amb_context_code => l_amb_context_code
51780 , p_entity_code => 'RECEIPTS'
51781 , p_event_class_code => 'RECEIPT'
51782 , p_side => 'NA'
51786
51783 );
51784
51785 END IF;
51787 --
51788 --
51789 END IF;
51790
51791 --
51792 -- Update the line information that should be overwritten
51793 --
51794 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
51795 p_header_num => 1);
51796 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
51797
51798 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
51799
51800 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
51801 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
51802 END IF;
51803
51804 --
51805 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
51806 --
51807 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
51808 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
51809 ELSE
51810 ---------------------------------------------------------------------------------------------------
51811 -- 4262811a Switch Sign
51812 ---------------------------------------------------------------------------------------------------
51813 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
51814 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
51815 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51816 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
51817 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51818 -- 5132302
51819 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
51820 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51821
51822 END IF;
51823
51824 -- 4955764
51825 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
51826 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
51827
51828
51829 XLA_AE_LINES_PKG.ValidateCurrentLine;
51830 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
51831
51832 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
51833 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
51834 ,p_balance_type_code => l_balance_type_code);
51835
51836 END IF;
51837
51838 -----------------------------------------------------------------------------------------
51839 -- 4262811 Multiperiod Accounting
51840 -----------------------------------------------------------------------------------------
51841 -- No MPA option is assigned.
51842
51843
51844 END IF;
51845 END IF;
51846 --
51847
51848 --
51849 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51850 trace
51851 (p_msg => 'END of AcctLineType_111'
51852 ,p_level => C_LEVEL_PROCEDURE
51853 ,p_module => l_log_module);
51854 END IF;
51855 --
51856 EXCEPTION
51857 WHEN xla_exceptions_pkg.application_exception THEN
51858 RAISE;
51859 WHEN OTHERS THEN
51860 xla_exceptions_pkg.raise_message
51861 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_111');
51862 END AcctLineType_111;
51863 --
51864
51865 ---------------------------------------
51866 --
51867 -- PRIVATE FUNCTION
51868 -- AcctLineType_112
51869 --
51870 ---------------------------------------
51871 PROCEDURE AcctLineType_112 (
51872 p_application_id IN NUMBER
51873 ,p_event_id IN NUMBER
51874 ,p_calculate_acctd_flag IN VARCHAR2
51875 ,p_calculate_g_l_flag IN VARCHAR2
51876 ,p_actual_flag IN OUT VARCHAR2
51877 ,p_balance_type_code OUT VARCHAR2
51878 ,p_gain_or_loss_ref OUT VARCHAR2
51879
51880 --Distribution Source Type
51881 , p_source_22 IN VARCHAR2
51882 --Distribution Line Identifier
51883 , p_source_24 IN NUMBER
51884 --Distribution Type
51885 , p_source_25 IN VARCHAR2
51886 --Entered Amount
51887 , p_source_26 IN NUMBER
51888 --Currency Code
51889 , p_source_27 IN VARCHAR2
51890 --Applied To Document Accounting Amount
51891 , p_source_31 IN NUMBER
51892 --Transaction Distribution Account Class
51893 , p_source_35 IN VARCHAR2
51894 --Transaction Distribution Identifier
51895 , p_source_36 IN NUMBER
51896 --Transaction Distribution Type
51897 , p_source_37 IN VARCHAR2
51898 --Receipt Applied To Application Identifier
51899 , p_source_60 IN NUMBER
51900 --Transaction Entity Code
51901 , p_source_61 IN VARCHAR2
51902 --Transaction Identifier
51903 , p_source_62 IN NUMBER
51904 --Distribution Party Type
51905 , p_source_67 IN VARCHAR2
51906 --Distribution Multi Fund Additional Entry
51907 , p_source_71 IN VARCHAR2
51908 )
51909 IS
51910
51911 l_component_type VARCHAR2(80);
51915 l_amb_context_code VARCHAR2(30);
51912 l_component_code VARCHAR2(30);
51913 l_component_type_code VARCHAR2(1);
51914 l_component_appl_id INTEGER;
51916 l_entity_code VARCHAR2(30);
51917 l_event_class_code VARCHAR2(30);
51918 l_ae_header_id NUMBER;
51919 l_event_type_code VARCHAR2(30);
51920 l_line_definition_code VARCHAR2(30);
51921 l_line_definition_owner_code VARCHAR2(1);
51922 --
51923 -- adr variables
51924 l_segment VARCHAR2(30);
51925 l_ccid NUMBER;
51926 l_adr_transaction_coa_id NUMBER;
51927 l_adr_accounting_coa_id NUMBER;
51928 l_adr_flexfield_segment_code VARCHAR2(30);
51929 l_adr_flex_value_set_id NUMBER;
51930 l_adr_value_type_code VARCHAR2(30);
51931 l_adr_value_combination_id NUMBER;
51932 l_adr_value_segment_code VARCHAR2(30);
51933
51934 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
51935 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
51936 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
51937 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
51938
51939 -- 4262811 Variables ------------------------------------------------------------------------------------------
51940 l_entered_amt_idx NUMBER;
51941 l_accted_amt_idx NUMBER;
51942 l_acc_rev_flag VARCHAR2(1);
51943 l_accrual_line_num NUMBER;
51944 l_tmp_amt NUMBER;
51945 l_acc_rev_natural_side_code VARCHAR2(1);
51946
51947 l_num_entries NUMBER;
51948 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
51949 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
51950 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
51951 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
51952 l_recog_line_1 NUMBER;
51953 l_recog_line_2 NUMBER;
51954
51955 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
51956 l_bflow_applied_to_amt NUMBER; -- 5132302
51957 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
51958
51959 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
51960
51961 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
51962 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
51963
51964 ---------------------------------------------------------------------------------------------------------------
51965
51966
51967 --
51968 -- bulk performance
51969 --
51970 l_balance_type_code VARCHAR2(1);
51971 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
51972 l_log_module VARCHAR2(240);
51973
51974 --
51975 -- Upgrade strategy
51976 --
51977 l_actual_upg_option VARCHAR2(1);
51978 l_enc_upg_option VARCHAR2(1);
51979
51980 --
51981 BEGIN
51982 --
51983 IF g_log_enabled THEN
51984 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_112';
51985 END IF;
51986 --
51987 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51988
51989 trace
51990 (p_msg => 'BEGIN of AcctLineType_112'
51991 ,p_level => C_LEVEL_PROCEDURE
51992 ,p_module => l_log_module);
51993
51994 END IF;
51995 --
51996 l_component_type := 'AMB_JLT';
51997 l_component_code := 'RCT_APP_MFAR_TRX_REC';
51998 l_component_type_code := 'S';
51999 l_component_appl_id := 222;
52000 l_amb_context_code := 'DEFAULT';
52001 l_entity_code := 'RECEIPTS';
52002 l_event_class_code := 'RECEIPT';
52003 l_event_type_code := 'RECEIPT_ALL';
52004 l_line_definition_owner_code := 'S';
52005 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
52006 --
52007 l_balance_type_code := 'A';
52008 l_segment := NULL;
52009 l_ccid := NULL;
52010 l_adr_transaction_coa_id := NULL;
52011 l_adr_accounting_coa_id := NULL;
52012 l_adr_flexfield_segment_code := NULL;
52013 l_adr_flex_value_set_id := NULL;
52014 l_adr_value_type_code := NULL;
52015 l_adr_value_combination_id := NULL;
52016 l_adr_value_segment_code := NULL;
52017
52018 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
52019 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
52020 l_inherit_desc_flag := 'Y'; -- 4219869 Business Flow
52021 l_budgetary_control_flag := 'N';
52022
52023 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52024 l_bflow_applied_to_amt := NULL; -- 5132302
52025 l_entered_amt_idx := NULL; -- 4262811
52026 l_accted_amt_idx := NULL; -- 4262811
52027 l_acc_rev_flag := NULL; -- 4262811
52028 l_accrual_line_num := NULL; -- 4262811
52029 l_tmp_amt := NULL; -- 4262811
52030 --
52031
52032 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
52033 l_balance_type_code <> 'B' THEN
52034 IF (NVL(p_source_35,'
52035 ') = 'REV' OR
52036 NVL(p_source_35,'
52037 ') = 'TAX' OR
52041 ') = 'ROUND' OR
52038 NVL(p_source_35,'
52039 ') = 'FREIGHT' OR
52040 NVL(p_source_35,'
52042 NVL(p_source_35,'
52043 ') = 'CHARGES') AND
52044 NVL(p_source_22,'
52045 ') = 'REC' AND
52046 NVL(p_source_71,'
52047 ') = 'N'
52048 THEN
52049
52050 --
52051 XLA_AE_LINES_PKG.SetNewLine;
52052
52053 p_balance_type_code := l_balance_type_code;
52054 -- set the flag so later we will know whether the gain loss line needs to be created
52055
52056 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
52057 p_actual_flag :='A';
52058 END IF;
52059
52060 --
52061 -- bulk performance
52062 --
52063 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
52064 p_header_num => 0); -- 4262811
52065 --
52066 -- set accounting line options
52067 --
52068 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
52069 p_natural_side_code => 'C'
52070 , p_gain_or_loss_flag => 'N'
52071 , p_gl_transfer_mode_code => 'S'
52072 , p_acct_entry_type_code => 'A'
52073 , p_switch_side_flag => 'Y'
52074 , p_merge_duplicate_code => 'A'
52075 );
52076 --
52077 l_acc_rev_natural_side_code := 'D'; -- 4262811
52078 --
52079 --
52080 -- set accounting line type info
52081 --
52082 xla_ae_lines_pkg.SetAcctLineType
52083 (p_component_type => l_component_type
52084 ,p_event_type_code => l_event_type_code
52085 ,p_line_definition_owner_code => l_line_definition_owner_code
52086 ,p_line_definition_code => l_line_definition_code
52087 ,p_accounting_line_code => l_component_code
52088 ,p_accounting_line_type_code => l_component_type_code
52089 ,p_accounting_line_appl_id => l_component_appl_id
52090 ,p_amb_context_code => l_amb_context_code
52091 ,p_entity_code => l_entity_code
52092 ,p_event_class_code => l_event_class_code);
52093 --
52094 -- set accounting class
52095 --
52096 xla_ae_lines_pkg.SetAcctClass(
52097 p_accounting_class_code => 'RECEIVABLE'
52098 , p_ae_header_id => l_ae_header_id
52099 );
52100
52101 --
52102 -- set rounding class
52103 --
52104 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
52105 'RECEIVABLE';
52106
52107 --
52108 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
52109 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
52110 --
52111 -- bulk performance
52112 --
52113 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
52114
52115 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
52116 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
52117
52118 -- 4955764
52119 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52120 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
52121
52122 -- 4458381 Public Sector Enh
52123
52124 --
52125 -- set accounting attributes for the line type
52126 --
52127 l_entered_amt_idx := 8;
52128 l_accted_amt_idx := 10;
52129 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52130 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
52131 l_rec_acct_attrs.array_num_value(1) := p_source_60;
52132 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
52133 l_rec_acct_attrs.array_char_value(2) := p_source_37;
52134 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
52135 l_rec_acct_attrs.array_char_value(3) := p_source_61;
52136 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
52137 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
52138 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
52139 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
52140 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
52141 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
52142 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
52143 l_rec_acct_attrs.array_char_value(7) := p_source_25;
52144 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
52145 l_rec_acct_attrs.array_num_value(8) := p_source_26;
52146 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
52147 l_rec_acct_attrs.array_char_value(9) := p_source_27;
52148 l_rec_acct_attrs.array_acct_attr_code(10) := 'LEDGER_AMOUNT';
52149 l_rec_acct_attrs.array_num_value(10) := p_source_31;
52150 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
52151 l_rec_acct_attrs.array_char_value(11) := p_source_67;
52152
52153 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
52154 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
52155
52156 ---------------------------------------------------------------------------------------------------------------
52160
52157 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
52158 ---------------------------------------------------------------------------------------------------------------
52159 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
52161 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52162 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52163
52164 IF xla_accounting_cache_pkg.GetValueChar
52165 (p_source_code => 'LEDGER_CATEGORY_CODE'
52166 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
52167 AND l_bflow_method_code = 'PRIOR_ENTRY'
52168 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
52169 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
52170 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
52171 )
52172 THEN
52173 xla_ae_lines_pkg.BflowUpgEntry
52174 (p_business_method_code => l_bflow_method_code
52175 ,p_business_class_code => l_bflow_class_code
52176 ,p_balance_type => l_balance_type_code);
52177 ELSE
52178 NULL;
52179 XLA_AE_LINES_PKG.business_flow_validation(
52180 p_business_method_code => l_bflow_method_code
52181 ,p_business_class_code => l_bflow_class_code
52182 ,p_inherit_description_flag => l_inherit_desc_flag);
52183 END IF;
52184
52185 --
52186 -- call analytical criteria
52187 --
52188 -- Inherited Analytical Criteria for business flow method of Prior Entry.
52189 --
52190 -- call description
52191 --
52192 -- No description or it is inherited.
52193 --
52194 -- call ADRs
52195 -- Bug 4922099
52196 --
52197 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52198 (NVL(l_actual_upg_option, 'N') = 'O') OR
52199 (NVL(l_enc_upg_option, 'N') = 'O')
52200 )
52201 THEN
52202 NULL;
52203 --
52204 --
52205
52206 --
52207 --
52208 END IF;
52209 --
52210 -- Bug 4922099
52211 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
52212 (NVL(l_enc_upg_option, 'N') = 'O')
52213 ) AND
52214 (l_bflow_method_code = 'PRIOR_ENTRY')
52215 )
52216 THEN
52217 IF
52218 --
52219 1 = 1
52220 --
52221 THEN
52222 xla_accounting_err_pkg.build_message
52223 (p_appli_s_name => 'XLA'
52224 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52225 ,p_token_1 => 'LINE_NUMBER'
52226 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
52227 ,p_token_2 => 'LINE_TYPE_NAME'
52228 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
52229 l_component_type
52230 ,l_component_code
52231 ,l_component_type_code
52232 ,l_component_appl_id
52233 ,l_amb_context_code
52234 ,l_entity_code
52235 ,l_event_class_code
52236 )
52237 ,p_token_3 => 'OWNER'
52238 ,p_value_3 => xla_lookups_pkg.get_meaning(
52239 p_lookup_type => 'XLA_OWNER_TYPE'
52240 ,p_lookup_code => l_component_type_code
52241 )
52242 ,p_token_4 => 'PRODUCT_NAME'
52243 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
52244 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
52245 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
52246 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
52247 ,p_ae_header_id => NULL
52248 );
52249
52250 IF (C_LEVEL_ERROR>= g_log_level) THEN
52251 trace
52252 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52253 ,p_level => C_LEVEL_ERROR
52254 ,p_module => l_log_module);
52255 END IF;
52256 END IF;
52257 END IF;
52258 --
52259 --
52263 -- Prior Entry. Currently, the following code is always generated.
52260 ------------------------------------------------------------------------------------------------
52261 -- 4219869 Business Flow
52262 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
52264 ------------------------------------------------------------------------------------------------
52265 -- No ValidateCurrentLine for business flow method of Prior Entry
52266
52267 ------------------------------------------------------------------------------------
52268 -- 4219869 Business Flow
52269 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
52270 ------------------------------------------------------------------------------------
52271 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52272
52273 ----------------------------------------------------------------------------------
52274 -- 4219869 Business Flow
52275 -- Update journal entry status -- Need to generate this within IF <condition>
52276 ----------------------------------------------------------------------------------
52277 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52278 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
52279 ,p_balance_type_code => l_balance_type_code
52280 );
52281
52282 -------------------------------------------------------------------------------------------
52283 -- 4262811 - Generate the Accrual Reversal lines
52284 -------------------------------------------------------------------------------------------
52285 BEGIN
52286 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
52287 (g_array_event(p_event_id).array_value_num('header_index'));
52288 IF l_acc_rev_flag IS NULL THEN
52289 l_acc_rev_flag := 'N';
52290 END IF;
52291 EXCEPTION
52292 WHEN OTHERS THEN
52293 l_acc_rev_flag := 'N';
52294 END;
52295 --
52296 IF (l_acc_rev_flag = 'Y') THEN
52297
52298 -- 4645092 ------------------------------------------------------------------------------
52299 -- To allow MPA report to determine if it should generate report process
52300 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
52301 ------------------------------------------------------------------------------------------
52302
52303 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
52304 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
52305 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
52306 -- call ADRs
52307 -- Bug 4922099
52308 --
52309 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52310 (NVL(l_actual_upg_option, 'N') = 'O') OR
52311 (NVL(l_enc_upg_option, 'N') = 'O')
52312 )
52313 THEN
52314 NULL;
52315 --
52316 --
52317
52318 --
52319 --
52320 END IF;
52321
52322 --
52323 -- Update the line information that should be overwritten
52324 --
52325 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
52326 p_header_num => 1);
52327 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
52328
52329 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
52330
52331 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
52332 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
52333 END IF;
52334
52335 --
52336 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
52337 --
52338 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
52339 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
52340 ELSE
52341 ---------------------------------------------------------------------------------------------------
52342 -- 4262811a Switch Sign
52343 ---------------------------------------------------------------------------------------------------
52344 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
52345 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52346 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52347 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52348 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52349 -- 5132302
52350 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
52351 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52352
52353 END IF;
52354
52355 -- 4955764
52356 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52357 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
52358
52359
52360 XLA_AE_LINES_PKG.ValidateCurrentLine;
52361 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52362
52363 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52367 END IF;
52364 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
52365 ,p_balance_type_code => l_balance_type_code);
52366
52368
52369 -----------------------------------------------------------------------------------------
52370 -- 4262811 Multiperiod Accounting
52371 -----------------------------------------------------------------------------------------
52372 -- No MPA option is assigned.
52373
52374
52375 END IF;
52376 END IF;
52377 --
52378
52379 --
52380 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
52381 trace
52382 (p_msg => 'END of AcctLineType_112'
52383 ,p_level => C_LEVEL_PROCEDURE
52384 ,p_module => l_log_module);
52385 END IF;
52386 --
52387 EXCEPTION
52388 WHEN xla_exceptions_pkg.application_exception THEN
52389 RAISE;
52390 WHEN OTHERS THEN
52391 xla_exceptions_pkg.raise_message
52392 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_112');
52393 END AcctLineType_112;
52394 --
52395
52396 ---------------------------------------
52397 --
52398 -- PRIVATE FUNCTION
52399 -- AcctLineType_113
52400 --
52401 ---------------------------------------
52402 PROCEDURE AcctLineType_113 (
52403 p_application_id IN NUMBER
52404 ,p_event_id IN NUMBER
52405 ,p_calculate_acctd_flag IN VARCHAR2
52406 ,p_calculate_g_l_flag IN VARCHAR2
52407 ,p_actual_flag IN OUT VARCHAR2
52408 ,p_balance_type_code OUT VARCHAR2
52409 ,p_gain_or_loss_ref OUT VARCHAR2
52410
52411 --Remittance Bank Account Remittance Account
52412 , p_source_6 IN NUMBER
52413 --Transaction Distribution GL Account
52414 , p_source_21 IN NUMBER
52415 --Distribution Source Type
52416 , p_source_22 IN VARCHAR2
52417 --Distribution Line Identifier
52418 , p_source_24 IN NUMBER
52419 --Distribution Type
52420 , p_source_25 IN VARCHAR2
52421 --Exchange Date
52422 , p_source_28 IN DATE
52423 --Exchange Rate
52424 , p_source_29 IN NUMBER
52425 --Exchange Rate Type
52426 , p_source_30 IN VARCHAR2
52427 --Transaction Distribution Identifier
52428 , p_source_36 IN NUMBER
52429 --Transaction Distribution Type
52430 , p_source_37 IN VARCHAR2
52431 --Receipt Applied To Application Identifier
52432 , p_source_60 IN NUMBER
52433 --Transaction Entity Code
52434 , p_source_61 IN VARCHAR2
52435 --Transaction Identifier
52436 , p_source_62 IN NUMBER
52437 --Applying Document Currency Code
52438 , p_source_63 IN VARCHAR2
52439 --Distribution Party Identifier
52440 , p_source_65 IN NUMBER
52441 --Distribution Party Site Id
52442 , p_source_66 IN NUMBER
52443 --Distribution Party Type
52444 , p_source_67 IN VARCHAR2
52445 --Distribution Multi Fund Additional Entry
52446 , p_source_71 IN VARCHAR2
52447 --DIST_ENT_AMT_FROM
52448 , p_source_74 IN NUMBER
52449 --Accounting Amount
52450 , p_source_75 IN NUMBER
52451 )
52452 IS
52453
52454 l_component_type VARCHAR2(80);
52455 l_component_code VARCHAR2(30);
52456 l_component_type_code VARCHAR2(1);
52457 l_component_appl_id INTEGER;
52458 l_amb_context_code VARCHAR2(30);
52459 l_entity_code VARCHAR2(30);
52460 l_event_class_code VARCHAR2(30);
52461 l_ae_header_id NUMBER;
52462 l_event_type_code VARCHAR2(30);
52463 l_line_definition_code VARCHAR2(30);
52464 l_line_definition_owner_code VARCHAR2(1);
52465 --
52466 -- adr variables
52467 l_segment VARCHAR2(30);
52468 l_ccid NUMBER;
52469 l_adr_transaction_coa_id NUMBER;
52470 l_adr_accounting_coa_id NUMBER;
52471 l_adr_flexfield_segment_code VARCHAR2(30);
52472 l_adr_flex_value_set_id NUMBER;
52473 l_adr_value_type_code VARCHAR2(30);
52474 l_adr_value_combination_id NUMBER;
52475 l_adr_value_segment_code VARCHAR2(30);
52476
52477 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
52478 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
52479 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
52480 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
52481
52482 -- 4262811 Variables ------------------------------------------------------------------------------------------
52483 l_entered_amt_idx NUMBER;
52484 l_accted_amt_idx NUMBER;
52485 l_acc_rev_flag VARCHAR2(1);
52486 l_accrual_line_num NUMBER;
52487 l_tmp_amt NUMBER;
52488 l_acc_rev_natural_side_code VARCHAR2(1);
52489
52490 l_num_entries NUMBER;
52491 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
52492 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
52493 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
52494 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
52495 l_recog_line_1 NUMBER;
52496 l_recog_line_2 NUMBER;
52497
52498 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
52502 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
52499 l_bflow_applied_to_amt NUMBER; -- 5132302
52500 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
52501
52503
52504 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
52505 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
52506
52507 ---------------------------------------------------------------------------------------------------------------
52508
52509
52510 --
52511 -- bulk performance
52512 --
52513 l_balance_type_code VARCHAR2(1);
52514 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
52515 l_log_module VARCHAR2(240);
52516
52517 --
52518 -- Upgrade strategy
52519 --
52520 l_actual_upg_option VARCHAR2(1);
52521 l_enc_upg_option VARCHAR2(1);
52522
52523 --
52524 BEGIN
52525 --
52526 IF g_log_enabled THEN
52527 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_113';
52528 END IF;
52529 --
52530 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
52531
52532 trace
52533 (p_msg => 'BEGIN of AcctLineType_113'
52534 ,p_level => C_LEVEL_PROCEDURE
52535 ,p_module => l_log_module);
52536
52537 END IF;
52538 --
52539 l_component_type := 'AMB_JLT';
52540 l_component_code := 'RCT_APP_MFAR_TRX_REMITTANCE';
52541 l_component_type_code := 'S';
52542 l_component_appl_id := 222;
52543 l_amb_context_code := 'DEFAULT';
52544 l_entity_code := 'RECEIPTS';
52545 l_event_class_code := 'RECEIPT';
52546 l_event_type_code := 'RECEIPT_ALL';
52547 l_line_definition_owner_code := 'S';
52548 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
52549 --
52550 l_balance_type_code := 'A';
52551 l_segment := NULL;
52552 l_ccid := NULL;
52553 l_adr_transaction_coa_id := NULL;
52554 l_adr_accounting_coa_id := NULL;
52555 l_adr_flexfield_segment_code := NULL;
52556 l_adr_flex_value_set_id := NULL;
52557 l_adr_value_type_code := NULL;
52558 l_adr_value_combination_id := NULL;
52559 l_adr_value_segment_code := NULL;
52560
52561 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
52562 l_bflow_class_code := ''; -- 4219869 Business Flow
52563 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
52564 l_budgetary_control_flag := 'N';
52565
52566 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52567 l_bflow_applied_to_amt := NULL; -- 5132302
52568 l_entered_amt_idx := NULL; -- 4262811
52569 l_accted_amt_idx := NULL; -- 4262811
52570 l_acc_rev_flag := NULL; -- 4262811
52571 l_accrual_line_num := NULL; -- 4262811
52572 l_tmp_amt := NULL; -- 4262811
52573 --
52574
52575 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
52576 l_balance_type_code <> 'B' THEN
52577 IF NVL(p_source_22,'
52578 ') = 'REMITTANCE' AND
52579 NVL(p_source_71,'
52580 ') = 'Y'
52581 THEN
52582
52583 --
52584 XLA_AE_LINES_PKG.SetNewLine;
52585
52586 p_balance_type_code := l_balance_type_code;
52587 -- set the flag so later we will know whether the gain loss line needs to be created
52588
52589 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
52590 p_actual_flag :='A';
52591 END IF;
52592
52593 --
52594 -- bulk performance
52595 --
52596 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
52597 p_header_num => 0); -- 4262811
52598 --
52599 -- set accounting line options
52600 --
52601 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
52602 p_natural_side_code => 'C'
52603 , p_gain_or_loss_flag => 'N'
52604 , p_gl_transfer_mode_code => 'S'
52605 , p_acct_entry_type_code => 'A'
52606 , p_switch_side_flag => 'Y'
52607 , p_merge_duplicate_code => 'A'
52608 );
52609 --
52610 l_acc_rev_natural_side_code := 'D'; -- 4262811
52611 --
52612 --
52613 -- set accounting line type info
52614 --
52615 xla_ae_lines_pkg.SetAcctLineType
52616 (p_component_type => l_component_type
52617 ,p_event_type_code => l_event_type_code
52618 ,p_line_definition_owner_code => l_line_definition_owner_code
52619 ,p_line_definition_code => l_line_definition_code
52620 ,p_accounting_line_code => l_component_code
52621 ,p_accounting_line_type_code => l_component_type_code
52622 ,p_accounting_line_appl_id => l_component_appl_id
52623 ,p_amb_context_code => l_amb_context_code
52624 ,p_entity_code => l_entity_code
52625 ,p_event_class_code => l_event_class_code);
52626 --
52627 -- set accounting class
52628 --
52629 xla_ae_lines_pkg.SetAcctClass(
52630 p_accounting_class_code => 'REMITTANCE'
52631 , p_ae_header_id => l_ae_header_id
52632 );
52633
52634 --
52638 'RECEIVABLE';
52635 -- set rounding class
52636 --
52637 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
52639
52640 --
52641 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
52642 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
52643 --
52644 -- bulk performance
52645 --
52646 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
52647
52648 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
52649 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
52650
52651 -- 4955764
52652 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52653 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
52654
52655 -- 4458381 Public Sector Enh
52656
52657 --
52658 -- set accounting attributes for the line type
52659 --
52660 l_entered_amt_idx := 8;
52661 l_accted_amt_idx := 13;
52662 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52663 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
52664 l_rec_acct_attrs.array_num_value(1) := p_source_60;
52665 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
52666 l_rec_acct_attrs.array_char_value(2) := p_source_37;
52667 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
52668 l_rec_acct_attrs.array_char_value(3) := p_source_61;
52669 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
52670 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
52671 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
52672 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
52673 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
52674 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
52675 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
52676 l_rec_acct_attrs.array_char_value(7) := p_source_25;
52677 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
52678 l_rec_acct_attrs.array_num_value(8) := p_source_74;
52679 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
52680 l_rec_acct_attrs.array_char_value(9) := p_source_63;
52681 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
52682 l_rec_acct_attrs.array_date_value(10) := p_source_28;
52683 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
52684 l_rec_acct_attrs.array_num_value(11) := p_source_29;
52685 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
52686 l_rec_acct_attrs.array_char_value(12) := p_source_30;
52687 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
52688 l_rec_acct_attrs.array_num_value(13) := p_source_75;
52689 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
52690 l_rec_acct_attrs.array_num_value(14) := p_source_65;
52691 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
52692 l_rec_acct_attrs.array_num_value(15) := p_source_66;
52693 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
52694 l_rec_acct_attrs.array_char_value(16) := p_source_67;
52695
52696 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
52697 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
52698
52699 ---------------------------------------------------------------------------------------------------------------
52700 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
52701 ---------------------------------------------------------------------------------------------------------------
52702 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
52703
52704 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52705 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52706
52707 IF xla_accounting_cache_pkg.GetValueChar
52708 (p_source_code => 'LEDGER_CATEGORY_CODE'
52709 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
52710 AND l_bflow_method_code = 'PRIOR_ENTRY'
52711 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
52712 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
52713 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
52714 )
52715 THEN
52716 xla_ae_lines_pkg.BflowUpgEntry
52717 (p_business_method_code => l_bflow_method_code
52718 ,p_business_class_code => l_bflow_class_code
52719 ,p_balance_type => l_balance_type_code);
52720 ELSE
52721 NULL;
52722 -- No business flow processing for business flow method of NONE.
52723 END IF;
52724
52725 --
52726 -- call analytical criteria
52727 --
52728
52729 --
52730 -- call description
52731 --
52732
52733 xla_ae_lines_pkg.SetLineDescription(
52734 p_ae_header_id => l_ae_header_id
52735 ,p_description => Description_1 (
52736 p_application_id => p_application_id
52737 , p_ae_header_id => l_ae_header_id
52738 )
52742 --
52739 );
52740
52741
52743 -- call ADRs
52744 -- Bug 4922099
52745 --
52746 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52747 (NVL(l_actual_upg_option, 'N') = 'O') OR
52748 (NVL(l_enc_upg_option, 'N') = 'O')
52749 )
52750 THEN
52751 NULL;
52752 --
52753 --
52754
52755 l_ccid := AcctDerRule_34(
52756 p_application_id => p_application_id
52757 , p_ae_header_id => l_ae_header_id
52758 , p_source_21 => p_source_21
52759 , x_transaction_coa_id => l_adr_transaction_coa_id
52760 , x_accounting_coa_id => l_adr_accounting_coa_id
52761 , x_value_type_code => l_adr_value_type_code
52762 , p_side => 'NA'
52763 );
52764
52765 xla_ae_lines_pkg.set_ccid(
52766 p_code_combination_id => l_ccid
52767 , p_value_type_code => l_adr_value_type_code
52768 , p_transaction_coa_id => l_adr_transaction_coa_id
52769 , p_accounting_coa_id => l_adr_accounting_coa_id
52770 , p_adr_code => 'TRX_DIST_CCID'
52771 , p_adr_type_code => 'S'
52772 , p_component_type => l_component_type
52773 , p_component_code => l_component_code
52774 , p_component_type_code => l_component_type_code
52775 , p_component_appl_id => l_component_appl_id
52776 , p_amb_context_code => l_amb_context_code
52777 , p_side => 'NA'
52778 );
52779
52780
52781 l_segment := AcctDerRule_7(
52782 p_application_id => p_application_id
52783 , p_ae_header_id => l_ae_header_id
52784 , p_source_6 => p_source_6
52785 , x_transaction_coa_id => l_adr_transaction_coa_id
52786 , x_accounting_coa_id => l_adr_accounting_coa_id
52787 , x_flexfield_segment_code => l_adr_flexfield_segment_code
52788 , x_flex_value_set_id => l_adr_flex_value_set_id
52789 , x_value_type_code => l_adr_value_type_code
52790 , x_value_combination_id => l_adr_value_combination_id
52791 , x_value_segment_code => l_adr_value_segment_code
52792 , p_side => 'NA'
52793 , p_override_seg_flag => 'Y'
52794 );
52795
52796 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
52797
52798 xla_ae_lines_pkg.set_segment(
52799 p_to_segment_code => 'GL_ACCOUNT'
52800 , p_segment_value => l_segment
52801 , p_from_segment_code => l_adr_value_segment_code
52802 , p_from_combination_id => l_adr_value_combination_id
52803 , p_value_type_code => l_adr_value_type_code
52804 , p_transaction_coa_id => l_adr_transaction_coa_id
52805 , p_accounting_coa_id => l_adr_accounting_coa_id
52806 , p_flexfield_segment_code => l_adr_flexfield_segment_code
52807 , p_flex_value_set_id => l_adr_flex_value_set_id
52808 , p_adr_code => 'MFAR_RCT_REMITTANCE_NATSEG'
52809 , p_adr_type_code => 'S'
52810 , p_component_type => l_component_type
52811 , p_component_code => l_component_code
52812 , p_component_type_code => l_component_type_code
52813 , p_component_appl_id => l_component_appl_id
52814 , p_amb_context_code => l_amb_context_code
52815 , p_entity_code => 'RECEIPTS'
52816 , p_event_class_code => 'RECEIPT'
52817 , p_side => 'NA'
52818 );
52819
52820 END IF;
52821
52822 --
52823 --
52824 END IF;
52825 --
52826 -- Bug 4922099
52827 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
52828 (NVL(l_enc_upg_option, 'N') = 'O')
52829 ) AND
52830 (l_bflow_method_code = 'PRIOR_ENTRY')
52831 )
52832 THEN
52833 IF
52834 --
52835 1 = 2
52836 --
52837 THEN
52838 xla_accounting_err_pkg.build_message
52839 (p_appli_s_name => 'XLA'
52840 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52841 ,p_token_1 => 'LINE_NUMBER'
52842 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
52843 ,p_token_2 => 'LINE_TYPE_NAME'
52844 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
52845 l_component_type
52846 ,l_component_code
52847 ,l_component_type_code
52848 ,l_component_appl_id
52849 ,l_amb_context_code
52850 ,l_entity_code
52851 ,l_event_class_code
52852 )
52856 ,p_lookup_code => l_component_type_code
52853 ,p_token_3 => 'OWNER'
52854 ,p_value_3 => xla_lookups_pkg.get_meaning(
52855 p_lookup_type => 'XLA_OWNER_TYPE'
52857 )
52858 ,p_token_4 => 'PRODUCT_NAME'
52859 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
52860 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
52861 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
52862 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
52863 ,p_ae_header_id => NULL
52864 );
52865
52866 IF (C_LEVEL_ERROR>= g_log_level) THEN
52867 trace
52868 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52869 ,p_level => C_LEVEL_ERROR
52870 ,p_module => l_log_module);
52871 END IF;
52872 END IF;
52873 END IF;
52874 --
52875 --
52876 ------------------------------------------------------------------------------------------------
52877 -- 4219869 Business Flow
52878 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
52879 -- Prior Entry. Currently, the following code is always generated.
52880 ------------------------------------------------------------------------------------------------
52881 XLA_AE_LINES_PKG.ValidateCurrentLine;
52882
52883 ------------------------------------------------------------------------------------
52884 -- 4219869 Business Flow
52885 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
52886 ------------------------------------------------------------------------------------
52887 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52888
52889 ----------------------------------------------------------------------------------
52890 -- 4219869 Business Flow
52891 -- Update journal entry status -- Need to generate this within IF <condition>
52892 ----------------------------------------------------------------------------------
52893 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52894 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
52895 ,p_balance_type_code => l_balance_type_code
52896 );
52897
52898 -------------------------------------------------------------------------------------------
52899 -- 4262811 - Generate the Accrual Reversal lines
52900 -------------------------------------------------------------------------------------------
52901 BEGIN
52902 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
52903 (g_array_event(p_event_id).array_value_num('header_index'));
52904 IF l_acc_rev_flag IS NULL THEN
52905 l_acc_rev_flag := 'N';
52906 END IF;
52907 EXCEPTION
52908 WHEN OTHERS THEN
52909 l_acc_rev_flag := 'N';
52910 END;
52911 --
52912 IF (l_acc_rev_flag = 'Y') THEN
52913
52914 -- 4645092 ------------------------------------------------------------------------------
52915 -- To allow MPA report to determine if it should generate report process
52916 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
52917 ------------------------------------------------------------------------------------------
52918
52919 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
52920 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
52921 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
52922 -- call ADRs
52923 -- Bug 4922099
52924 --
52925 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52926 (NVL(l_actual_upg_option, 'N') = 'O') OR
52927 (NVL(l_enc_upg_option, 'N') = 'O')
52928 )
52929 THEN
52930 NULL;
52931 --
52932 --
52933
52934 l_ccid := AcctDerRule_34(
52935 p_application_id => p_application_id
52936 , p_ae_header_id => l_ae_header_id
52937 , p_source_21 => p_source_21
52938 , x_transaction_coa_id => l_adr_transaction_coa_id
52939 , x_accounting_coa_id => l_adr_accounting_coa_id
52940 , x_value_type_code => l_adr_value_type_code
52941 , p_side => 'NA'
52942 );
52943
52944 xla_ae_lines_pkg.set_ccid(
52945 p_code_combination_id => l_ccid
52946 , p_value_type_code => l_adr_value_type_code
52947 , p_transaction_coa_id => l_adr_transaction_coa_id
52948 , p_accounting_coa_id => l_adr_accounting_coa_id
52949 , p_adr_code => 'TRX_DIST_CCID'
52950 , p_adr_type_code => 'S'
52951 , p_component_type => l_component_type
52952 , p_component_code => l_component_code
52953 , p_component_type_code => l_component_type_code
52954 , p_component_appl_id => l_component_appl_id
52955 , p_amb_context_code => l_amb_context_code
52956 , p_side => 'NA'
52960 l_segment := AcctDerRule_7(
52957 );
52958
52959
52961 p_application_id => p_application_id
52962 , p_ae_header_id => l_ae_header_id
52963 , p_source_6 => p_source_6
52964 , x_transaction_coa_id => l_adr_transaction_coa_id
52965 , x_accounting_coa_id => l_adr_accounting_coa_id
52966 , x_flexfield_segment_code => l_adr_flexfield_segment_code
52967 , x_flex_value_set_id => l_adr_flex_value_set_id
52968 , x_value_type_code => l_adr_value_type_code
52969 , x_value_combination_id => l_adr_value_combination_id
52970 , x_value_segment_code => l_adr_value_segment_code
52971 , p_side => 'NA'
52972 , p_override_seg_flag => 'Y'
52973 );
52974
52975 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
52976
52977 xla_ae_lines_pkg.set_segment(
52978 p_to_segment_code => 'GL_ACCOUNT'
52979 , p_segment_value => l_segment
52980 , p_from_segment_code => l_adr_value_segment_code
52981 , p_from_combination_id => l_adr_value_combination_id
52982 , p_value_type_code => l_adr_value_type_code
52983 , p_transaction_coa_id => l_adr_transaction_coa_id
52984 , p_accounting_coa_id => l_adr_accounting_coa_id
52985 , p_flexfield_segment_code => l_adr_flexfield_segment_code
52986 , p_flex_value_set_id => l_adr_flex_value_set_id
52987 , p_adr_code => 'MFAR_RCT_REMITTANCE_NATSEG'
52988 , p_adr_type_code => 'S'
52989 , p_component_type => l_component_type
52990 , p_component_code => l_component_code
52991 , p_component_type_code => l_component_type_code
52992 , p_component_appl_id => l_component_appl_id
52993 , p_amb_context_code => l_amb_context_code
52994 , p_entity_code => 'RECEIPTS'
52995 , p_event_class_code => 'RECEIPT'
52996 , p_side => 'NA'
52997 );
52998
52999 END IF;
53000
53001 --
53002 --
53003 END IF;
53004
53005 --
53006 -- Update the line information that should be overwritten
53007 --
53008 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
53009 p_header_num => 1);
53010 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
53011
53012 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
53013
53014 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
53015 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
53016 END IF;
53017
53018 --
53019 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
53020 --
53021 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
53022 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
53023 ELSE
53024 ---------------------------------------------------------------------------------------------------
53025 -- 4262811a Switch Sign
53026 ---------------------------------------------------------------------------------------------------
53027 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
53028 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
53029 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53030 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
53031 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53032 -- 5132302
53033 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
53034 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53035
53036 END IF;
53037
53038 -- 4955764
53039 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
53040 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
53041
53042
53043 XLA_AE_LINES_PKG.ValidateCurrentLine;
53044 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
53045
53046 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
53047 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
53048 ,p_balance_type_code => l_balance_type_code);
53049
53050 END IF;
53051
53052 -----------------------------------------------------------------------------------------
53053 -- 4262811 Multiperiod Accounting
53054 -----------------------------------------------------------------------------------------
53055 -- No MPA option is assigned.
53056
53057
53058 END IF;
53059 END IF;
53060 --
53061
53062 --
53063 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53064 trace
53065 (p_msg => 'END of AcctLineType_113'
53066 ,p_level => C_LEVEL_PROCEDURE
53067 ,p_module => l_log_module);
53068 END IF;
53072 RAISE;
53069 --
53070 EXCEPTION
53071 WHEN xla_exceptions_pkg.application_exception THEN
53073 WHEN OTHERS THEN
53074 xla_exceptions_pkg.raise_message
53075 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_113');
53076 END AcctLineType_113;
53077 --
53078
53079 ---------------------------------------
53080 --
53081 -- PRIVATE FUNCTION
53082 -- AcctLineType_114
53083 --
53084 ---------------------------------------
53085 PROCEDURE AcctLineType_114 (
53086 p_application_id IN NUMBER
53087 ,p_event_id IN NUMBER
53088 ,p_calculate_acctd_flag IN VARCHAR2
53089 ,p_calculate_g_l_flag IN VARCHAR2
53090 ,p_actual_flag IN OUT VARCHAR2
53091 ,p_balance_type_code OUT VARCHAR2
53092 ,p_gain_or_loss_ref OUT VARCHAR2
53093
53094 --Distribution GL Account
53095 , p_source_10 IN NUMBER
53096 --Distribution Source Type
53097 , p_source_22 IN VARCHAR2
53098 --Distribution Line Identifier
53099 , p_source_24 IN NUMBER
53100 --Distribution Type
53101 , p_source_25 IN VARCHAR2
53102 --Exchange Date
53103 , p_source_28 IN DATE
53104 --Exchange Rate
53105 , p_source_29 IN NUMBER
53106 --Exchange Rate Type
53107 , p_source_30 IN VARCHAR2
53108 --Transaction Distribution Identifier
53109 , p_source_36 IN NUMBER
53110 --Transaction Distribution Type
53111 , p_source_37 IN VARCHAR2
53112 --Receipt Applied To Application Identifier
53113 , p_source_60 IN NUMBER
53114 --Transaction Entity Code
53115 , p_source_61 IN VARCHAR2
53116 --Transaction Identifier
53117 , p_source_62 IN NUMBER
53118 --Applying Document Currency Code
53119 , p_source_63 IN VARCHAR2
53120 --Distribution Party Identifier
53121 , p_source_65 IN NUMBER
53122 --Distribution Party Site Id
53123 , p_source_66 IN NUMBER
53124 --Distribution Party Type
53125 , p_source_67 IN VARCHAR2
53126 --Distribution Multi Fund Additional Entry
53127 , p_source_71 IN VARCHAR2
53128 --DIST_ENT_AMT_FROM
53129 , p_source_74 IN NUMBER
53130 --Accounting Amount
53131 , p_source_75 IN NUMBER
53132 )
53133 IS
53134
53135 l_component_type VARCHAR2(80);
53136 l_component_code VARCHAR2(30);
53137 l_component_type_code VARCHAR2(1);
53138 l_component_appl_id INTEGER;
53139 l_amb_context_code VARCHAR2(30);
53140 l_entity_code VARCHAR2(30);
53141 l_event_class_code VARCHAR2(30);
53142 l_ae_header_id NUMBER;
53143 l_event_type_code VARCHAR2(30);
53144 l_line_definition_code VARCHAR2(30);
53145 l_line_definition_owner_code VARCHAR2(1);
53146 --
53147 -- adr variables
53148 l_segment VARCHAR2(30);
53149 l_ccid NUMBER;
53150 l_adr_transaction_coa_id NUMBER;
53151 l_adr_accounting_coa_id NUMBER;
53152 l_adr_flexfield_segment_code VARCHAR2(30);
53153 l_adr_flex_value_set_id NUMBER;
53154 l_adr_value_type_code VARCHAR2(30);
53155 l_adr_value_combination_id NUMBER;
53156 l_adr_value_segment_code VARCHAR2(30);
53157
53158 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
53159 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
53160 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
53161 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
53162
53163 -- 4262811 Variables ------------------------------------------------------------------------------------------
53164 l_entered_amt_idx NUMBER;
53165 l_accted_amt_idx NUMBER;
53166 l_acc_rev_flag VARCHAR2(1);
53167 l_accrual_line_num NUMBER;
53168 l_tmp_amt NUMBER;
53169 l_acc_rev_natural_side_code VARCHAR2(1);
53170
53171 l_num_entries NUMBER;
53172 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
53173 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
53174 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
53175 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
53176 l_recog_line_1 NUMBER;
53177 l_recog_line_2 NUMBER;
53178
53179 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
53180 l_bflow_applied_to_amt NUMBER; -- 5132302
53181 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
53182
53183 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
53184
53185 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
53186 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
53187
53188 ---------------------------------------------------------------------------------------------------------------
53189
53190
53191 --
53192 -- bulk performance
53193 --
53194 l_balance_type_code VARCHAR2(1);
53195 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
53196 l_log_module VARCHAR2(240);
53197
53198 --
53199 -- Upgrade strategy
53200 --
53201 l_actual_upg_option VARCHAR2(1);
53205 BEGIN
53202 l_enc_upg_option VARCHAR2(1);
53203
53204 --
53206 --
53207 IF g_log_enabled THEN
53208 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_114';
53209 END IF;
53210 --
53211 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53212
53213 trace
53214 (p_msg => 'BEGIN of AcctLineType_114'
53215 ,p_level => C_LEVEL_PROCEDURE
53216 ,p_module => l_log_module);
53217
53218 END IF;
53219 --
53220 l_component_type := 'AMB_JLT';
53221 l_component_code := 'RCT_BNK_CHG';
53222 l_component_type_code := 'S';
53223 l_component_appl_id := 222;
53224 l_amb_context_code := 'DEFAULT';
53225 l_entity_code := 'RECEIPTS';
53226 l_event_class_code := 'RECEIPT';
53227 l_event_type_code := 'RECEIPT_ALL';
53228 l_line_definition_owner_code := 'S';
53229 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
53230 --
53231 l_balance_type_code := 'A';
53232 l_segment := NULL;
53233 l_ccid := NULL;
53234 l_adr_transaction_coa_id := NULL;
53235 l_adr_accounting_coa_id := NULL;
53236 l_adr_flexfield_segment_code := NULL;
53237 l_adr_flex_value_set_id := NULL;
53238 l_adr_value_type_code := NULL;
53239 l_adr_value_combination_id := NULL;
53240 l_adr_value_segment_code := NULL;
53241
53242 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
53243 l_bflow_class_code := ''; -- 4219869 Business Flow
53244 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
53245 l_budgetary_control_flag := 'N';
53246
53247 l_bflow_applied_to_amt_idx := NULL; -- 5132302
53248 l_bflow_applied_to_amt := NULL; -- 5132302
53249 l_entered_amt_idx := NULL; -- 4262811
53250 l_accted_amt_idx := NULL; -- 4262811
53251 l_acc_rev_flag := NULL; -- 4262811
53252 l_accrual_line_num := NULL; -- 4262811
53253 l_tmp_amt := NULL; -- 4262811
53254 --
53255
53256 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
53257 l_balance_type_code <> 'B' THEN
53258 IF NVL(p_source_22,'
53259 ') = 'BANK_CHARGES' AND
53260 NVL(p_source_71,'
53261 ') = 'N'
53262 THEN
53263
53264 --
53265 XLA_AE_LINES_PKG.SetNewLine;
53266
53267 p_balance_type_code := l_balance_type_code;
53268 -- set the flag so later we will know whether the gain loss line needs to be created
53269
53270 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
53271 p_actual_flag :='A';
53272 END IF;
53273
53274 --
53275 -- bulk performance
53276 --
53277 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
53278 p_header_num => 0); -- 4262811
53279 --
53280 -- set accounting line options
53281 --
53282 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
53283 p_natural_side_code => 'C'
53284 , p_gain_or_loss_flag => 'N'
53285 , p_gl_transfer_mode_code => 'S'
53286 , p_acct_entry_type_code => 'A'
53287 , p_switch_side_flag => 'Y'
53288 , p_merge_duplicate_code => 'A'
53289 );
53290 --
53291 l_acc_rev_natural_side_code := 'D'; -- 4262811
53292 --
53293 --
53294 -- set accounting line type info
53295 --
53296 xla_ae_lines_pkg.SetAcctLineType
53297 (p_component_type => l_component_type
53298 ,p_event_type_code => l_event_type_code
53299 ,p_line_definition_owner_code => l_line_definition_owner_code
53300 ,p_line_definition_code => l_line_definition_code
53301 ,p_accounting_line_code => l_component_code
53302 ,p_accounting_line_type_code => l_component_type_code
53303 ,p_accounting_line_appl_id => l_component_appl_id
53304 ,p_amb_context_code => l_amb_context_code
53305 ,p_entity_code => l_entity_code
53306 ,p_event_class_code => l_event_class_code);
53307 --
53308 -- set accounting class
53309 --
53310 xla_ae_lines_pkg.SetAcctClass(
53311 p_accounting_class_code => 'BANK_CHG'
53312 , p_ae_header_id => l_ae_header_id
53313 );
53314
53315 --
53316 -- set rounding class
53317 --
53318 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
53319 'RECEIVABLE';
53320
53321 --
53322 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
53323 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
53324 --
53325 -- bulk performance
53326 --
53327 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
53328
53329 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
53330 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
53331
53332 -- 4955764
53333 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
53337
53334 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
53335
53336 -- 4458381 Public Sector Enh
53338 --
53339 -- set accounting attributes for the line type
53340 --
53341 l_entered_amt_idx := 8;
53342 l_accted_amt_idx := 13;
53343 l_bflow_applied_to_amt_idx := NULL; -- 5132302
53344 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
53345 l_rec_acct_attrs.array_num_value(1) := p_source_60;
53346 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
53347 l_rec_acct_attrs.array_char_value(2) := p_source_37;
53348 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
53349 l_rec_acct_attrs.array_char_value(3) := p_source_61;
53350 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
53351 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
53352 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
53353 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
53354 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
53355 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
53356 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
53357 l_rec_acct_attrs.array_char_value(7) := p_source_25;
53358 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
53359 l_rec_acct_attrs.array_num_value(8) := p_source_74;
53360 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
53361 l_rec_acct_attrs.array_char_value(9) := p_source_63;
53362 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
53363 l_rec_acct_attrs.array_date_value(10) := p_source_28;
53364 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
53365 l_rec_acct_attrs.array_num_value(11) := p_source_29;
53366 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
53367 l_rec_acct_attrs.array_char_value(12) := p_source_30;
53368 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
53369 l_rec_acct_attrs.array_num_value(13) := p_source_75;
53370 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
53371 l_rec_acct_attrs.array_num_value(14) := p_source_65;
53372 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
53373 l_rec_acct_attrs.array_num_value(15) := p_source_66;
53374 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
53375 l_rec_acct_attrs.array_char_value(16) := p_source_67;
53376
53377 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
53378 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
53379
53380 ---------------------------------------------------------------------------------------------------------------
53381 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
53382 ---------------------------------------------------------------------------------------------------------------
53383 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
53384
53385 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
53386 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
53387
53388 IF xla_accounting_cache_pkg.GetValueChar
53389 (p_source_code => 'LEDGER_CATEGORY_CODE'
53390 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
53391 AND l_bflow_method_code = 'PRIOR_ENTRY'
53392 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
53393 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
53394 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
53395 )
53396 THEN
53397 xla_ae_lines_pkg.BflowUpgEntry
53398 (p_business_method_code => l_bflow_method_code
53399 ,p_business_class_code => l_bflow_class_code
53400 ,p_balance_type => l_balance_type_code);
53401 ELSE
53402 NULL;
53403 -- No business flow processing for business flow method of NONE.
53404 END IF;
53405
53406 --
53407 -- call analytical criteria
53408 --
53409
53410 --
53411 -- call description
53412 --
53413 -- No description or it is inherited.
53414 --
53415 -- call ADRs
53416 -- Bug 4922099
53417 --
53418 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
53419 (NVL(l_actual_upg_option, 'N') = 'O') OR
53420 (NVL(l_enc_upg_option, 'N') = 'O')
53421 )
53422 THEN
53423 NULL;
53424 --
53425 --
53426
53427 l_ccid := AcctDerRule_11(
53428 p_application_id => p_application_id
53429 , p_ae_header_id => l_ae_header_id
53430 , p_source_10 => p_source_10
53431 , x_transaction_coa_id => l_adr_transaction_coa_id
53432 , x_accounting_coa_id => l_adr_accounting_coa_id
53433 , x_value_type_code => l_adr_value_type_code
53434 , p_side => 'NA'
53435 );
53436
53437 xla_ae_lines_pkg.set_ccid(
53438 p_code_combination_id => l_ccid
53439 , p_value_type_code => l_adr_value_type_code
53440 , p_transaction_coa_id => l_adr_transaction_coa_id
53441 , p_accounting_coa_id => l_adr_accounting_coa_id
53445 , p_component_code => l_component_code
53442 , p_adr_code => 'DIST_CCID'
53443 , p_adr_type_code => 'S'
53444 , p_component_type => l_component_type
53446 , p_component_type_code => l_component_type_code
53447 , p_component_appl_id => l_component_appl_id
53448 , p_amb_context_code => l_amb_context_code
53449 , p_side => 'NA'
53450 );
53451
53452
53453 --
53454 --
53455 END IF;
53456 --
53457 -- Bug 4922099
53458 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
53459 (NVL(l_enc_upg_option, 'N') = 'O')
53460 ) AND
53461 (l_bflow_method_code = 'PRIOR_ENTRY')
53462 )
53463 THEN
53464 IF
53465 --
53466 1 = 2
53467 --
53468 THEN
53469 xla_accounting_err_pkg.build_message
53470 (p_appli_s_name => 'XLA'
53471 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
53472 ,p_token_1 => 'LINE_NUMBER'
53473 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
53474 ,p_token_2 => 'LINE_TYPE_NAME'
53475 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
53476 l_component_type
53477 ,l_component_code
53478 ,l_component_type_code
53479 ,l_component_appl_id
53480 ,l_amb_context_code
53481 ,l_entity_code
53482 ,l_event_class_code
53483 )
53484 ,p_token_3 => 'OWNER'
53485 ,p_value_3 => xla_lookups_pkg.get_meaning(
53486 p_lookup_type => 'XLA_OWNER_TYPE'
53487 ,p_lookup_code => l_component_type_code
53488 )
53489 ,p_token_4 => 'PRODUCT_NAME'
53490 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
53491 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
53492 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
53493 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
53494 ,p_ae_header_id => NULL
53495 );
53496
53497 IF (C_LEVEL_ERROR>= g_log_level) THEN
53498 trace
53499 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
53500 ,p_level => C_LEVEL_ERROR
53501 ,p_module => l_log_module);
53502 END IF;
53503 END IF;
53504 END IF;
53505 --
53506 --
53507 ------------------------------------------------------------------------------------------------
53508 -- 4219869 Business Flow
53509 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
53510 -- Prior Entry. Currently, the following code is always generated.
53511 ------------------------------------------------------------------------------------------------
53512 XLA_AE_LINES_PKG.ValidateCurrentLine;
53513
53514 ------------------------------------------------------------------------------------
53515 -- 4219869 Business Flow
53516 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
53517 ------------------------------------------------------------------------------------
53518 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
53519
53520 ----------------------------------------------------------------------------------
53521 -- 4219869 Business Flow
53522 -- Update journal entry status -- Need to generate this within IF <condition>
53523 ----------------------------------------------------------------------------------
53524 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
53525 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
53526 ,p_balance_type_code => l_balance_type_code
53527 );
53528
53529 -------------------------------------------------------------------------------------------
53530 -- 4262811 - Generate the Accrual Reversal lines
53531 -------------------------------------------------------------------------------------------
53532 BEGIN
53533 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
53534 (g_array_event(p_event_id).array_value_num('header_index'));
53535 IF l_acc_rev_flag IS NULL THEN
53536 l_acc_rev_flag := 'N';
53537 END IF;
53538 EXCEPTION
53539 WHEN OTHERS THEN
53543 IF (l_acc_rev_flag = 'Y') THEN
53540 l_acc_rev_flag := 'N';
53541 END;
53542 --
53544
53545 -- 4645092 ------------------------------------------------------------------------------
53546 -- To allow MPA report to determine if it should generate report process
53547 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
53548 ------------------------------------------------------------------------------------------
53549
53550 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
53551 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
53552 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
53553 -- call ADRs
53554 -- Bug 4922099
53555 --
53556 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
53557 (NVL(l_actual_upg_option, 'N') = 'O') OR
53558 (NVL(l_enc_upg_option, 'N') = 'O')
53559 )
53560 THEN
53561 NULL;
53562 --
53563 --
53564
53565 l_ccid := AcctDerRule_11(
53566 p_application_id => p_application_id
53567 , p_ae_header_id => l_ae_header_id
53568 , p_source_10 => p_source_10
53569 , x_transaction_coa_id => l_adr_transaction_coa_id
53570 , x_accounting_coa_id => l_adr_accounting_coa_id
53571 , x_value_type_code => l_adr_value_type_code
53572 , p_side => 'NA'
53573 );
53574
53575 xla_ae_lines_pkg.set_ccid(
53576 p_code_combination_id => l_ccid
53577 , p_value_type_code => l_adr_value_type_code
53578 , p_transaction_coa_id => l_adr_transaction_coa_id
53579 , p_accounting_coa_id => l_adr_accounting_coa_id
53580 , p_adr_code => 'DIST_CCID'
53581 , p_adr_type_code => 'S'
53582 , p_component_type => l_component_type
53583 , p_component_code => l_component_code
53584 , p_component_type_code => l_component_type_code
53585 , p_component_appl_id => l_component_appl_id
53586 , p_amb_context_code => l_amb_context_code
53587 , p_side => 'NA'
53588 );
53589
53590
53591 --
53592 --
53593 END IF;
53594
53595 --
53596 -- Update the line information that should be overwritten
53597 --
53598 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
53599 p_header_num => 1);
53600 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
53601
53602 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
53603
53604 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
53605 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
53606 END IF;
53607
53608 --
53609 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
53610 --
53611 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
53612 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
53613 ELSE
53614 ---------------------------------------------------------------------------------------------------
53615 -- 4262811a Switch Sign
53616 ---------------------------------------------------------------------------------------------------
53617 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
53618 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
53619 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53620 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
53621 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53622 -- 5132302
53623 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
53624 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53625
53626 END IF;
53627
53628 -- 4955764
53629 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
53630 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
53631
53632
53633 XLA_AE_LINES_PKG.ValidateCurrentLine;
53634 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
53635
53636 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
53637 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
53638 ,p_balance_type_code => l_balance_type_code);
53639
53640 END IF;
53641
53642 -----------------------------------------------------------------------------------------
53643 -- 4262811 Multiperiod Accounting
53644 -----------------------------------------------------------------------------------------
53645 -- No MPA option is assigned.
53646
53647
53648 END IF;
53649 END IF;
53650 --
53651
53652 --
53653 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53654 trace
53655 (p_msg => 'END of AcctLineType_114'
53656 ,p_level => C_LEVEL_PROCEDURE
53660 EXCEPTION
53657 ,p_module => l_log_module);
53658 END IF;
53659 --
53661 WHEN xla_exceptions_pkg.application_exception THEN
53662 RAISE;
53663 WHEN OTHERS THEN
53664 xla_exceptions_pkg.raise_message
53665 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_114');
53666 END AcctLineType_114;
53667 --
53668
53669 ---------------------------------------
53670 --
53671 -- PRIVATE FUNCTION
53672 -- AcctLineType_115
53673 --
53674 ---------------------------------------
53675 PROCEDURE AcctLineType_115 (
53676 p_application_id IN NUMBER
53677 ,p_event_id IN NUMBER
53678 ,p_calculate_acctd_flag IN VARCHAR2
53679 ,p_calculate_g_l_flag IN VARCHAR2
53680 ,p_actual_flag IN OUT VARCHAR2
53681 ,p_balance_type_code OUT VARCHAR2
53682 ,p_gain_or_loss_ref OUT VARCHAR2
53683
53684 --Distribution GL Account
53685 , p_source_10 IN NUMBER
53686 --Distribution Source Type
53687 , p_source_22 IN VARCHAR2
53688 --Distribution Line Identifier
53689 , p_source_24 IN NUMBER
53690 --Distribution Type
53691 , p_source_25 IN VARCHAR2
53692 --Exchange Date
53693 , p_source_28 IN DATE
53694 --Exchange Rate
53695 , p_source_29 IN NUMBER
53696 --Exchange Rate Type
53697 , p_source_30 IN VARCHAR2
53698 --Transaction Distribution Identifier
53699 , p_source_36 IN NUMBER
53700 --Transaction Distribution Type
53701 , p_source_37 IN VARCHAR2
53702 --Receipt Applied To Application Identifier
53703 , p_source_60 IN NUMBER
53704 --Transaction Entity Code
53705 , p_source_61 IN VARCHAR2
53706 --Transaction Identifier
53707 , p_source_62 IN NUMBER
53708 --Applying Document Currency Code
53709 , p_source_63 IN VARCHAR2
53710 --Distribution Party Identifier
53711 , p_source_65 IN NUMBER
53712 --Distribution Party Site Id
53713 , p_source_66 IN NUMBER
53714 --Distribution Party Type
53715 , p_source_67 IN VARCHAR2
53716 --Distribution Multi Fund Additional Entry
53717 , p_source_71 IN VARCHAR2
53718 --DIST_ENT_AMT_FROM
53719 , p_source_74 IN NUMBER
53720 --Accounting Amount
53721 , p_source_75 IN NUMBER
53722 )
53723 IS
53724
53725 l_component_type VARCHAR2(80);
53726 l_component_code VARCHAR2(30);
53727 l_component_type_code VARCHAR2(1);
53728 l_component_appl_id INTEGER;
53729 l_amb_context_code VARCHAR2(30);
53730 l_entity_code VARCHAR2(30);
53731 l_event_class_code VARCHAR2(30);
53732 l_ae_header_id NUMBER;
53733 l_event_type_code VARCHAR2(30);
53734 l_line_definition_code VARCHAR2(30);
53735 l_line_definition_owner_code VARCHAR2(1);
53736 --
53737 -- adr variables
53738 l_segment VARCHAR2(30);
53739 l_ccid NUMBER;
53740 l_adr_transaction_coa_id NUMBER;
53741 l_adr_accounting_coa_id NUMBER;
53742 l_adr_flexfield_segment_code VARCHAR2(30);
53743 l_adr_flex_value_set_id NUMBER;
53744 l_adr_value_type_code VARCHAR2(30);
53745 l_adr_value_combination_id NUMBER;
53746 l_adr_value_segment_code VARCHAR2(30);
53747
53748 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
53749 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
53750 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
53751 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
53752
53753 -- 4262811 Variables ------------------------------------------------------------------------------------------
53754 l_entered_amt_idx NUMBER;
53755 l_accted_amt_idx NUMBER;
53756 l_acc_rev_flag VARCHAR2(1);
53757 l_accrual_line_num NUMBER;
53758 l_tmp_amt NUMBER;
53759 l_acc_rev_natural_side_code VARCHAR2(1);
53760
53761 l_num_entries NUMBER;
53762 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
53763 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
53764 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
53765 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
53766 l_recog_line_1 NUMBER;
53767 l_recog_line_2 NUMBER;
53768
53769 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
53770 l_bflow_applied_to_amt NUMBER; -- 5132302
53771 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
53772
53773 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
53774
53775 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
53776 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
53777
53778 ---------------------------------------------------------------------------------------------------------------
53779
53780
53781 --
53782 -- bulk performance
53783 --
53784 l_balance_type_code VARCHAR2(1);
53785 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
53786 l_log_module VARCHAR2(240);
53787
53788 --
53792 l_enc_upg_option VARCHAR2(1);
53789 -- Upgrade strategy
53790 --
53791 l_actual_upg_option VARCHAR2(1);
53793
53794 --
53795 BEGIN
53796 --
53797 IF g_log_enabled THEN
53798 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_115';
53799 END IF;
53800 --
53801 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53802
53803 trace
53804 (p_msg => 'BEGIN of AcctLineType_115'
53805 ,p_level => C_LEVEL_PROCEDURE
53806 ,p_module => l_log_module);
53807
53808 END IF;
53809 --
53810 l_component_type := 'AMB_JLT';
53811 l_component_code := 'RCT_CASH';
53812 l_component_type_code := 'S';
53813 l_component_appl_id := 222;
53814 l_amb_context_code := 'DEFAULT';
53815 l_entity_code := 'RECEIPTS';
53816 l_event_class_code := 'RECEIPT';
53817 l_event_type_code := 'RECEIPT_ALL';
53818 l_line_definition_owner_code := 'S';
53819 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
53820 --
53821 l_balance_type_code := 'A';
53822 l_segment := NULL;
53823 l_ccid := NULL;
53824 l_adr_transaction_coa_id := NULL;
53825 l_adr_accounting_coa_id := NULL;
53826 l_adr_flexfield_segment_code := NULL;
53827 l_adr_flex_value_set_id := NULL;
53828 l_adr_value_type_code := NULL;
53829 l_adr_value_combination_id := NULL;
53830 l_adr_value_segment_code := NULL;
53831
53832 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
53833 l_bflow_class_code := ''; -- 4219869 Business Flow
53834 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
53835 l_budgetary_control_flag := 'N';
53836
53837 l_bflow_applied_to_amt_idx := NULL; -- 5132302
53838 l_bflow_applied_to_amt := NULL; -- 5132302
53839 l_entered_amt_idx := NULL; -- 4262811
53840 l_accted_amt_idx := NULL; -- 4262811
53841 l_acc_rev_flag := NULL; -- 4262811
53842 l_accrual_line_num := NULL; -- 4262811
53843 l_tmp_amt := NULL; -- 4262811
53844 --
53845
53846 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
53847 l_balance_type_code <> 'B' THEN
53848 IF NVL(p_source_22,'
53849 ') = 'CASH' AND
53850 NVL(p_source_71,'
53851 ') = 'N'
53852 THEN
53853
53854 --
53855 XLA_AE_LINES_PKG.SetNewLine;
53856
53857 p_balance_type_code := l_balance_type_code;
53858 -- set the flag so later we will know whether the gain loss line needs to be created
53859
53860 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
53861 p_actual_flag :='A';
53862 END IF;
53863
53864 --
53865 -- bulk performance
53866 --
53867 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
53868 p_header_num => 0); -- 4262811
53869 --
53870 -- set accounting line options
53871 --
53872 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
53873 p_natural_side_code => 'C'
53874 , p_gain_or_loss_flag => 'N'
53875 , p_gl_transfer_mode_code => 'S'
53876 , p_acct_entry_type_code => 'A'
53877 , p_switch_side_flag => 'Y'
53878 , p_merge_duplicate_code => 'A'
53879 );
53880 --
53881 l_acc_rev_natural_side_code := 'D'; -- 4262811
53882 --
53883 --
53884 -- set accounting line type info
53885 --
53886 xla_ae_lines_pkg.SetAcctLineType
53887 (p_component_type => l_component_type
53888 ,p_event_type_code => l_event_type_code
53889 ,p_line_definition_owner_code => l_line_definition_owner_code
53890 ,p_line_definition_code => l_line_definition_code
53891 ,p_accounting_line_code => l_component_code
53892 ,p_accounting_line_type_code => l_component_type_code
53893 ,p_accounting_line_appl_id => l_component_appl_id
53894 ,p_amb_context_code => l_amb_context_code
53895 ,p_entity_code => l_entity_code
53896 ,p_event_class_code => l_event_class_code);
53897 --
53898 -- set accounting class
53899 --
53900 xla_ae_lines_pkg.SetAcctClass(
53901 p_accounting_class_code => 'CASH'
53902 , p_ae_header_id => l_ae_header_id
53903 );
53904
53905 --
53906 -- set rounding class
53907 --
53908 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
53909 'RECEIVABLE';
53910
53911 --
53912 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
53913 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
53914 --
53915 -- bulk performance
53916 --
53917 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
53918
53919 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
53920 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
53921
53922 -- 4955764
53926 -- 4458381 Public Sector Enh
53923 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
53924 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
53925
53927
53928 --
53929 -- set accounting attributes for the line type
53930 --
53931 l_entered_amt_idx := 8;
53932 l_accted_amt_idx := 13;
53933 l_bflow_applied_to_amt_idx := NULL; -- 5132302
53934 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
53935 l_rec_acct_attrs.array_num_value(1) := p_source_60;
53936 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
53937 l_rec_acct_attrs.array_char_value(2) := p_source_37;
53938 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
53939 l_rec_acct_attrs.array_char_value(3) := p_source_61;
53940 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
53941 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
53942 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
53943 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
53944 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
53945 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
53946 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
53947 l_rec_acct_attrs.array_char_value(7) := p_source_25;
53948 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
53949 l_rec_acct_attrs.array_num_value(8) := p_source_74;
53950 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
53951 l_rec_acct_attrs.array_char_value(9) := p_source_63;
53952 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
53953 l_rec_acct_attrs.array_date_value(10) := p_source_28;
53954 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
53955 l_rec_acct_attrs.array_num_value(11) := p_source_29;
53956 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
53957 l_rec_acct_attrs.array_char_value(12) := p_source_30;
53958 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
53959 l_rec_acct_attrs.array_num_value(13) := p_source_75;
53960 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
53961 l_rec_acct_attrs.array_num_value(14) := p_source_65;
53962 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
53963 l_rec_acct_attrs.array_num_value(15) := p_source_66;
53964 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
53965 l_rec_acct_attrs.array_char_value(16) := p_source_67;
53966
53967 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
53968 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
53969
53970 ---------------------------------------------------------------------------------------------------------------
53971 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
53972 ---------------------------------------------------------------------------------------------------------------
53973 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
53974
53975 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
53976 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
53977
53978 IF xla_accounting_cache_pkg.GetValueChar
53979 (p_source_code => 'LEDGER_CATEGORY_CODE'
53980 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
53981 AND l_bflow_method_code = 'PRIOR_ENTRY'
53982 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
53983 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
53984 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
53985 )
53986 THEN
53987 xla_ae_lines_pkg.BflowUpgEntry
53988 (p_business_method_code => l_bflow_method_code
53989 ,p_business_class_code => l_bflow_class_code
53990 ,p_balance_type => l_balance_type_code);
53991 ELSE
53992 NULL;
53993 -- No business flow processing for business flow method of NONE.
53994 END IF;
53995
53996 --
53997 -- call analytical criteria
53998 --
53999
54000 --
54001 -- call description
54002 --
54003 -- No description or it is inherited.
54004 --
54005 -- call ADRs
54006 -- Bug 4922099
54007 --
54008 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
54009 (NVL(l_actual_upg_option, 'N') = 'O') OR
54010 (NVL(l_enc_upg_option, 'N') = 'O')
54011 )
54012 THEN
54013 NULL;
54014 --
54015 --
54016
54017 l_ccid := AcctDerRule_11(
54018 p_application_id => p_application_id
54019 , p_ae_header_id => l_ae_header_id
54020 , p_source_10 => p_source_10
54021 , x_transaction_coa_id => l_adr_transaction_coa_id
54022 , x_accounting_coa_id => l_adr_accounting_coa_id
54023 , x_value_type_code => l_adr_value_type_code
54024 , p_side => 'NA'
54025 );
54026
54027 xla_ae_lines_pkg.set_ccid(
54028 p_code_combination_id => l_ccid
54029 , p_value_type_code => l_adr_value_type_code
54030 , p_transaction_coa_id => l_adr_transaction_coa_id
54034 , p_component_type => l_component_type
54031 , p_accounting_coa_id => l_adr_accounting_coa_id
54032 , p_adr_code => 'DIST_CCID'
54033 , p_adr_type_code => 'S'
54035 , p_component_code => l_component_code
54036 , p_component_type_code => l_component_type_code
54037 , p_component_appl_id => l_component_appl_id
54038 , p_amb_context_code => l_amb_context_code
54039 , p_side => 'NA'
54040 );
54041
54042
54043 --
54044 --
54045 END IF;
54046 --
54047 -- Bug 4922099
54048 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
54049 (NVL(l_enc_upg_option, 'N') = 'O')
54050 ) AND
54051 (l_bflow_method_code = 'PRIOR_ENTRY')
54052 )
54053 THEN
54054 IF
54055 --
54056 1 = 2
54057 --
54058 THEN
54059 xla_accounting_err_pkg.build_message
54060 (p_appli_s_name => 'XLA'
54061 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
54062 ,p_token_1 => 'LINE_NUMBER'
54063 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
54064 ,p_token_2 => 'LINE_TYPE_NAME'
54065 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
54066 l_component_type
54067 ,l_component_code
54068 ,l_component_type_code
54069 ,l_component_appl_id
54070 ,l_amb_context_code
54071 ,l_entity_code
54072 ,l_event_class_code
54073 )
54074 ,p_token_3 => 'OWNER'
54075 ,p_value_3 => xla_lookups_pkg.get_meaning(
54076 p_lookup_type => 'XLA_OWNER_TYPE'
54077 ,p_lookup_code => l_component_type_code
54078 )
54079 ,p_token_4 => 'PRODUCT_NAME'
54080 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
54081 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
54082 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
54083 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
54084 ,p_ae_header_id => NULL
54085 );
54086
54087 IF (C_LEVEL_ERROR>= g_log_level) THEN
54088 trace
54089 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
54090 ,p_level => C_LEVEL_ERROR
54091 ,p_module => l_log_module);
54092 END IF;
54093 END IF;
54094 END IF;
54095 --
54096 --
54097 ------------------------------------------------------------------------------------------------
54098 -- 4219869 Business Flow
54099 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
54100 -- Prior Entry. Currently, the following code is always generated.
54101 ------------------------------------------------------------------------------------------------
54102 XLA_AE_LINES_PKG.ValidateCurrentLine;
54103
54104 ------------------------------------------------------------------------------------
54105 -- 4219869 Business Flow
54106 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
54107 ------------------------------------------------------------------------------------
54108 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
54109
54110 ----------------------------------------------------------------------------------
54111 -- 4219869 Business Flow
54112 -- Update journal entry status -- Need to generate this within IF <condition>
54113 ----------------------------------------------------------------------------------
54114 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
54115 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
54116 ,p_balance_type_code => l_balance_type_code
54117 );
54118
54119 -------------------------------------------------------------------------------------------
54120 -- 4262811 - Generate the Accrual Reversal lines
54121 -------------------------------------------------------------------------------------------
54122 BEGIN
54123 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
54124 (g_array_event(p_event_id).array_value_num('header_index'));
54125 IF l_acc_rev_flag IS NULL THEN
54126 l_acc_rev_flag := 'N';
54127 END IF;
54131 END;
54128 EXCEPTION
54129 WHEN OTHERS THEN
54130 l_acc_rev_flag := 'N';
54132 --
54133 IF (l_acc_rev_flag = 'Y') THEN
54134
54135 -- 4645092 ------------------------------------------------------------------------------
54136 -- To allow MPA report to determine if it should generate report process
54137 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
54138 ------------------------------------------------------------------------------------------
54139
54140 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
54141 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
54142 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
54143 -- call ADRs
54144 -- Bug 4922099
54145 --
54146 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
54147 (NVL(l_actual_upg_option, 'N') = 'O') OR
54148 (NVL(l_enc_upg_option, 'N') = 'O')
54149 )
54150 THEN
54151 NULL;
54152 --
54153 --
54154
54155 l_ccid := AcctDerRule_11(
54156 p_application_id => p_application_id
54157 , p_ae_header_id => l_ae_header_id
54158 , p_source_10 => p_source_10
54159 , x_transaction_coa_id => l_adr_transaction_coa_id
54160 , x_accounting_coa_id => l_adr_accounting_coa_id
54161 , x_value_type_code => l_adr_value_type_code
54162 , p_side => 'NA'
54163 );
54164
54165 xla_ae_lines_pkg.set_ccid(
54166 p_code_combination_id => l_ccid
54167 , p_value_type_code => l_adr_value_type_code
54168 , p_transaction_coa_id => l_adr_transaction_coa_id
54169 , p_accounting_coa_id => l_adr_accounting_coa_id
54170 , p_adr_code => 'DIST_CCID'
54171 , p_adr_type_code => 'S'
54172 , p_component_type => l_component_type
54173 , p_component_code => l_component_code
54174 , p_component_type_code => l_component_type_code
54175 , p_component_appl_id => l_component_appl_id
54176 , p_amb_context_code => l_amb_context_code
54177 , p_side => 'NA'
54178 );
54179
54180
54181 --
54182 --
54183 END IF;
54184
54185 --
54186 -- Update the line information that should be overwritten
54187 --
54188 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
54189 p_header_num => 1);
54190 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
54191
54192 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
54193
54194 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
54195 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
54196 END IF;
54197
54198 --
54199 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
54200 --
54201 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
54202 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
54203 ELSE
54204 ---------------------------------------------------------------------------------------------------
54205 -- 4262811a Switch Sign
54206 ---------------------------------------------------------------------------------------------------
54207 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
54208 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
54209 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54210 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
54211 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54212 -- 5132302
54213 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
54214 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54215
54216 END IF;
54217
54218 -- 4955764
54219 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
54220 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
54221
54222
54223 XLA_AE_LINES_PKG.ValidateCurrentLine;
54224 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
54225
54226 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
54227 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
54228 ,p_balance_type_code => l_balance_type_code);
54229
54230 END IF;
54231
54232 -----------------------------------------------------------------------------------------
54233 -- 4262811 Multiperiod Accounting
54234 -----------------------------------------------------------------------------------------
54235 -- No MPA option is assigned.
54236
54237
54238 END IF;
54239 END IF;
54240 --
54241
54242 --
54243 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54244 trace
54248 END IF;
54245 (p_msg => 'END of AcctLineType_115'
54246 ,p_level => C_LEVEL_PROCEDURE
54247 ,p_module => l_log_module);
54249 --
54250 EXCEPTION
54251 WHEN xla_exceptions_pkg.application_exception THEN
54252 RAISE;
54253 WHEN OTHERS THEN
54254 xla_exceptions_pkg.raise_message
54255 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_115');
54256 END AcctLineType_115;
54257 --
54258
54259 ---------------------------------------
54260 --
54261 -- PRIVATE FUNCTION
54262 -- AcctLineType_116
54263 --
54264 ---------------------------------------
54265 PROCEDURE AcctLineType_116 (
54266 p_application_id IN NUMBER
54267 ,p_event_id IN NUMBER
54268 ,p_calculate_acctd_flag IN VARCHAR2
54269 ,p_calculate_g_l_flag IN VARCHAR2
54270 ,p_actual_flag IN OUT VARCHAR2
54271 ,p_balance_type_code OUT VARCHAR2
54272 ,p_gain_or_loss_ref OUT VARCHAR2
54273
54274 --Distribution GL Account
54275 , p_source_10 IN NUMBER
54276 --Distribution Source Type
54277 , p_source_22 IN VARCHAR2
54278 --Receivable Activity Type
54279 , p_source_23 IN VARCHAR2
54280 --Distribution Line Identifier
54281 , p_source_24 IN NUMBER
54282 --Distribution Type
54283 , p_source_25 IN VARCHAR2
54284 --Exchange Date
54285 , p_source_28 IN DATE
54286 --Exchange Rate
54287 , p_source_29 IN NUMBER
54288 --Transaction Distribution Identifier
54289 , p_source_36 IN NUMBER
54290 --Transaction Distribution Type
54291 , p_source_37 IN VARCHAR2
54292 --Receipt Applied To Application Identifier
54293 , p_source_60 IN NUMBER
54294 --Transaction Entity Code
54295 , p_source_61 IN VARCHAR2
54296 --Transaction Identifier
54297 , p_source_62 IN NUMBER
54298 --Applying Document Currency Code
54299 , p_source_63 IN VARCHAR2
54300 --Distribution Party Identifier
54301 , p_source_65 IN NUMBER
54302 --Distribution Party Site Id
54303 , p_source_66 IN NUMBER
54304 --Distribution Party Type
54305 , p_source_67 IN VARCHAR2
54306 --Distribution Multi Fund Additional Entry
54307 , p_source_71 IN VARCHAR2
54308 --DIST_ENT_AMT_FROM
54309 , p_source_74 IN NUMBER
54310 --Accounting Amount
54311 , p_source_75 IN NUMBER
54312 --Applied To Document Exchange Rate Type
54313 , p_source_76 IN VARCHAR2
54314 )
54315 IS
54316
54317 l_component_type VARCHAR2(80);
54318 l_component_code VARCHAR2(30);
54319 l_component_type_code VARCHAR2(1);
54320 l_component_appl_id INTEGER;
54321 l_amb_context_code VARCHAR2(30);
54322 l_entity_code VARCHAR2(30);
54323 l_event_class_code VARCHAR2(30);
54324 l_ae_header_id NUMBER;
54325 l_event_type_code VARCHAR2(30);
54326 l_line_definition_code VARCHAR2(30);
54327 l_line_definition_owner_code VARCHAR2(1);
54328 --
54329 -- adr variables
54330 l_segment VARCHAR2(30);
54331 l_ccid NUMBER;
54332 l_adr_transaction_coa_id NUMBER;
54333 l_adr_accounting_coa_id NUMBER;
54334 l_adr_flexfield_segment_code VARCHAR2(30);
54335 l_adr_flex_value_set_id NUMBER;
54336 l_adr_value_type_code VARCHAR2(30);
54337 l_adr_value_combination_id NUMBER;
54338 l_adr_value_segment_code VARCHAR2(30);
54339
54340 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
54341 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
54342 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
54343 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
54344
54345 -- 4262811 Variables ------------------------------------------------------------------------------------------
54346 l_entered_amt_idx NUMBER;
54347 l_accted_amt_idx NUMBER;
54348 l_acc_rev_flag VARCHAR2(1);
54349 l_accrual_line_num NUMBER;
54350 l_tmp_amt NUMBER;
54351 l_acc_rev_natural_side_code VARCHAR2(1);
54352
54353 l_num_entries NUMBER;
54354 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
54355 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
54356 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
54357 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
54358 l_recog_line_1 NUMBER;
54359 l_recog_line_2 NUMBER;
54360
54361 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
54362 l_bflow_applied_to_amt NUMBER; -- 5132302
54363 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
54364
54365 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
54366
54367 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
54368 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
54369
54370 ---------------------------------------------------------------------------------------------------------------
54371
54372
54373 --
54374 -- bulk performance
54375 --
54379
54376 l_balance_type_code VARCHAR2(1);
54377 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
54378 l_log_module VARCHAR2(240);
54380 --
54381 -- Upgrade strategy
54382 --
54383 l_actual_upg_option VARCHAR2(1);
54384 l_enc_upg_option VARCHAR2(1);
54385
54386 --
54387 BEGIN
54388 --
54389 IF g_log_enabled THEN
54390 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_116';
54391 END IF;
54392 --
54393 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54394
54395 trace
54396 (p_msg => 'BEGIN of AcctLineType_116'
54397 ,p_level => C_LEVEL_PROCEDURE
54398 ,p_module => l_log_module);
54399
54400 END IF;
54401 --
54402 l_component_type := 'AMB_JLT';
54403 l_component_code := 'RCT_CLAIM';
54404 l_component_type_code := 'S';
54405 l_component_appl_id := 222;
54406 l_amb_context_code := 'DEFAULT';
54407 l_entity_code := 'RECEIPTS';
54408 l_event_class_code := 'RECEIPT';
54409 l_event_type_code := 'RECEIPT_ALL';
54410 l_line_definition_owner_code := 'S';
54411 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
54412 --
54413 l_balance_type_code := 'A';
54414 l_segment := NULL;
54415 l_ccid := NULL;
54416 l_adr_transaction_coa_id := NULL;
54417 l_adr_accounting_coa_id := NULL;
54418 l_adr_flexfield_segment_code := NULL;
54419 l_adr_flex_value_set_id := NULL;
54420 l_adr_value_type_code := NULL;
54421 l_adr_value_combination_id := NULL;
54422 l_adr_value_segment_code := NULL;
54423
54424 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
54425 l_bflow_class_code := ''; -- 4219869 Business Flow
54426 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
54427 l_budgetary_control_flag := 'N';
54428
54429 l_bflow_applied_to_amt_idx := NULL; -- 5132302
54430 l_bflow_applied_to_amt := NULL; -- 5132302
54431 l_entered_amt_idx := NULL; -- 4262811
54432 l_accted_amt_idx := NULL; -- 4262811
54433 l_acc_rev_flag := NULL; -- 4262811
54434 l_accrual_line_num := NULL; -- 4262811
54435 l_tmp_amt := NULL; -- 4262811
54436 --
54437
54438 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
54439 l_balance_type_code <> 'B' THEN
54440 IF NVL(p_source_22,'
54441 ') = 'OTHER ACC' AND
54442 NVL(p_source_23,'
54443 ') = 'CLAIM_INVESTIGATION' AND
54444 NVL(p_source_71,'
54445 ') = 'N'
54446 THEN
54447
54448 --
54449 XLA_AE_LINES_PKG.SetNewLine;
54450
54451 p_balance_type_code := l_balance_type_code;
54452 -- set the flag so later we will know whether the gain loss line needs to be created
54453
54454 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
54455 p_actual_flag :='A';
54456 END IF;
54457
54458 --
54459 -- bulk performance
54460 --
54461 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
54462 p_header_num => 0); -- 4262811
54463 --
54464 -- set accounting line options
54465 --
54466 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
54467 p_natural_side_code => 'C'
54468 , p_gain_or_loss_flag => 'N'
54469 , p_gl_transfer_mode_code => 'S'
54470 , p_acct_entry_type_code => 'A'
54471 , p_switch_side_flag => 'Y'
54472 , p_merge_duplicate_code => 'A'
54473 );
54474 --
54475 l_acc_rev_natural_side_code := 'D'; -- 4262811
54476 --
54477 --
54478 -- set accounting line type info
54479 --
54480 xla_ae_lines_pkg.SetAcctLineType
54481 (p_component_type => l_component_type
54482 ,p_event_type_code => l_event_type_code
54483 ,p_line_definition_owner_code => l_line_definition_owner_code
54484 ,p_line_definition_code => l_line_definition_code
54485 ,p_accounting_line_code => l_component_code
54486 ,p_accounting_line_type_code => l_component_type_code
54487 ,p_accounting_line_appl_id => l_component_appl_id
54488 ,p_amb_context_code => l_amb_context_code
54489 ,p_entity_code => l_entity_code
54490 ,p_event_class_code => l_event_class_code);
54491 --
54492 -- set accounting class
54493 --
54494 xla_ae_lines_pkg.SetAcctClass(
54495 p_accounting_class_code => 'CLAIM'
54496 , p_ae_header_id => l_ae_header_id
54497 );
54498
54499 --
54500 -- set rounding class
54501 --
54502 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
54503 'RECEIVABLE';
54504
54505 --
54506 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
54507 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
54508 --
54509 -- bulk performance
54510 --
54514 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
54511 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
54512
54513 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
54515
54516 -- 4955764
54517 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
54518 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
54519
54520 -- 4458381 Public Sector Enh
54521
54522 --
54523 -- set accounting attributes for the line type
54524 --
54525 l_entered_amt_idx := 8;
54526 l_accted_amt_idx := 13;
54527 l_bflow_applied_to_amt_idx := NULL; -- 5132302
54528 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
54529 l_rec_acct_attrs.array_num_value(1) := p_source_60;
54530 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
54531 l_rec_acct_attrs.array_char_value(2) := p_source_37;
54532 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
54533 l_rec_acct_attrs.array_char_value(3) := p_source_61;
54534 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
54535 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
54536 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
54537 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
54538 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
54539 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
54540 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
54541 l_rec_acct_attrs.array_char_value(7) := p_source_25;
54542 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
54543 l_rec_acct_attrs.array_num_value(8) := p_source_74;
54544 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
54545 l_rec_acct_attrs.array_char_value(9) := p_source_63;
54546 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
54547 l_rec_acct_attrs.array_date_value(10) := p_source_28;
54548 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
54549 l_rec_acct_attrs.array_num_value(11) := p_source_29;
54550 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
54551 l_rec_acct_attrs.array_char_value(12) := p_source_76;
54552 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
54553 l_rec_acct_attrs.array_num_value(13) := p_source_75;
54554 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
54555 l_rec_acct_attrs.array_num_value(14) := p_source_65;
54556 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
54557 l_rec_acct_attrs.array_num_value(15) := p_source_66;
54558 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
54559 l_rec_acct_attrs.array_char_value(16) := p_source_67;
54560
54561 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
54562 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
54563
54564 ---------------------------------------------------------------------------------------------------------------
54565 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
54566 ---------------------------------------------------------------------------------------------------------------
54567 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
54568
54569 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
54570 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
54571
54572 IF xla_accounting_cache_pkg.GetValueChar
54573 (p_source_code => 'LEDGER_CATEGORY_CODE'
54574 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
54575 AND l_bflow_method_code = 'PRIOR_ENTRY'
54576 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
54577 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
54578 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
54579 )
54580 THEN
54581 xla_ae_lines_pkg.BflowUpgEntry
54582 (p_business_method_code => l_bflow_method_code
54583 ,p_business_class_code => l_bflow_class_code
54584 ,p_balance_type => l_balance_type_code);
54585 ELSE
54586 NULL;
54587 -- No business flow processing for business flow method of NONE.
54588 END IF;
54589
54590 --
54591 -- call analytical criteria
54592 --
54593
54594 --
54595 -- call description
54596 --
54597 -- No description or it is inherited.
54598 --
54599 -- call ADRs
54600 -- Bug 4922099
54601 --
54602 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
54603 (NVL(l_actual_upg_option, 'N') = 'O') OR
54604 (NVL(l_enc_upg_option, 'N') = 'O')
54605 )
54606 THEN
54607 NULL;
54608 --
54609 --
54610
54611 l_ccid := AcctDerRule_11(
54612 p_application_id => p_application_id
54613 , p_ae_header_id => l_ae_header_id
54614 , p_source_10 => p_source_10
54615 , x_transaction_coa_id => l_adr_transaction_coa_id
54616 , x_accounting_coa_id => l_adr_accounting_coa_id
54617 , x_value_type_code => l_adr_value_type_code
54618 , p_side => 'NA'
54622 p_code_combination_id => l_ccid
54619 );
54620
54621 xla_ae_lines_pkg.set_ccid(
54623 , p_value_type_code => l_adr_value_type_code
54624 , p_transaction_coa_id => l_adr_transaction_coa_id
54625 , p_accounting_coa_id => l_adr_accounting_coa_id
54626 , p_adr_code => 'DIST_CCID'
54627 , p_adr_type_code => 'S'
54628 , p_component_type => l_component_type
54629 , p_component_code => l_component_code
54630 , p_component_type_code => l_component_type_code
54631 , p_component_appl_id => l_component_appl_id
54632 , p_amb_context_code => l_amb_context_code
54633 , p_side => 'NA'
54634 );
54635
54636
54637 --
54638 --
54639 END IF;
54640 --
54641 -- Bug 4922099
54642 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
54643 (NVL(l_enc_upg_option, 'N') = 'O')
54644 ) AND
54645 (l_bflow_method_code = 'PRIOR_ENTRY')
54646 )
54647 THEN
54648 IF
54649 --
54650 1 = 2
54651 --
54652 THEN
54653 xla_accounting_err_pkg.build_message
54654 (p_appli_s_name => 'XLA'
54655 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
54656 ,p_token_1 => 'LINE_NUMBER'
54657 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
54658 ,p_token_2 => 'LINE_TYPE_NAME'
54659 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
54660 l_component_type
54661 ,l_component_code
54662 ,l_component_type_code
54663 ,l_component_appl_id
54664 ,l_amb_context_code
54665 ,l_entity_code
54666 ,l_event_class_code
54667 )
54668 ,p_token_3 => 'OWNER'
54669 ,p_value_3 => xla_lookups_pkg.get_meaning(
54670 p_lookup_type => 'XLA_OWNER_TYPE'
54671 ,p_lookup_code => l_component_type_code
54672 )
54673 ,p_token_4 => 'PRODUCT_NAME'
54674 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
54675 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
54676 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
54677 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
54678 ,p_ae_header_id => NULL
54679 );
54680
54681 IF (C_LEVEL_ERROR>= g_log_level) THEN
54682 trace
54683 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
54684 ,p_level => C_LEVEL_ERROR
54685 ,p_module => l_log_module);
54686 END IF;
54687 END IF;
54688 END IF;
54689 --
54690 --
54691 ------------------------------------------------------------------------------------------------
54692 -- 4219869 Business Flow
54693 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
54694 -- Prior Entry. Currently, the following code is always generated.
54695 ------------------------------------------------------------------------------------------------
54696 XLA_AE_LINES_PKG.ValidateCurrentLine;
54697
54698 ------------------------------------------------------------------------------------
54699 -- 4219869 Business Flow
54700 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
54701 ------------------------------------------------------------------------------------
54702 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
54703
54704 ----------------------------------------------------------------------------------
54705 -- 4219869 Business Flow
54706 -- Update journal entry status -- Need to generate this within IF <condition>
54707 ----------------------------------------------------------------------------------
54708 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
54709 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
54710 ,p_balance_type_code => l_balance_type_code
54711 );
54712
54713 -------------------------------------------------------------------------------------------
54714 -- 4262811 - Generate the Accrual Reversal lines
54715 -------------------------------------------------------------------------------------------
54716 BEGIN
54720 l_acc_rev_flag := 'N';
54717 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
54718 (g_array_event(p_event_id).array_value_num('header_index'));
54719 IF l_acc_rev_flag IS NULL THEN
54721 END IF;
54722 EXCEPTION
54723 WHEN OTHERS THEN
54724 l_acc_rev_flag := 'N';
54725 END;
54726 --
54727 IF (l_acc_rev_flag = 'Y') THEN
54728
54729 -- 4645092 ------------------------------------------------------------------------------
54730 -- To allow MPA report to determine if it should generate report process
54731 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
54732 ------------------------------------------------------------------------------------------
54733
54734 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
54735 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
54736 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
54737 -- call ADRs
54738 -- Bug 4922099
54739 --
54740 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
54741 (NVL(l_actual_upg_option, 'N') = 'O') OR
54742 (NVL(l_enc_upg_option, 'N') = 'O')
54743 )
54744 THEN
54745 NULL;
54746 --
54747 --
54748
54749 l_ccid := AcctDerRule_11(
54750 p_application_id => p_application_id
54751 , p_ae_header_id => l_ae_header_id
54752 , p_source_10 => p_source_10
54753 , x_transaction_coa_id => l_adr_transaction_coa_id
54754 , x_accounting_coa_id => l_adr_accounting_coa_id
54755 , x_value_type_code => l_adr_value_type_code
54756 , p_side => 'NA'
54757 );
54758
54759 xla_ae_lines_pkg.set_ccid(
54760 p_code_combination_id => l_ccid
54761 , p_value_type_code => l_adr_value_type_code
54762 , p_transaction_coa_id => l_adr_transaction_coa_id
54763 , p_accounting_coa_id => l_adr_accounting_coa_id
54764 , p_adr_code => 'DIST_CCID'
54765 , p_adr_type_code => 'S'
54766 , p_component_type => l_component_type
54767 , p_component_code => l_component_code
54768 , p_component_type_code => l_component_type_code
54769 , p_component_appl_id => l_component_appl_id
54770 , p_amb_context_code => l_amb_context_code
54771 , p_side => 'NA'
54772 );
54773
54774
54775 --
54776 --
54777 END IF;
54778
54779 --
54780 -- Update the line information that should be overwritten
54781 --
54782 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
54783 p_header_num => 1);
54784 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
54785
54786 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
54787
54788 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
54789 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
54790 END IF;
54791
54792 --
54793 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
54794 --
54795 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
54796 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
54797 ELSE
54798 ---------------------------------------------------------------------------------------------------
54799 -- 4262811a Switch Sign
54800 ---------------------------------------------------------------------------------------------------
54801 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
54802 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
54803 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54804 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
54805 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54806 -- 5132302
54807 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
54808 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54809
54810 END IF;
54811
54812 -- 4955764
54813 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
54814 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
54815
54816
54817 XLA_AE_LINES_PKG.ValidateCurrentLine;
54818 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
54819
54820 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
54821 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
54822 ,p_balance_type_code => l_balance_type_code);
54823
54824 END IF;
54825
54826 -----------------------------------------------------------------------------------------
54827 -- 4262811 Multiperiod Accounting
54831
54828 -----------------------------------------------------------------------------------------
54829 -- No MPA option is assigned.
54830
54832 END IF;
54833 END IF;
54834 --
54835
54836 --
54837 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54838 trace
54839 (p_msg => 'END of AcctLineType_116'
54840 ,p_level => C_LEVEL_PROCEDURE
54841 ,p_module => l_log_module);
54842 END IF;
54843 --
54844 EXCEPTION
54845 WHEN xla_exceptions_pkg.application_exception THEN
54846 RAISE;
54847 WHEN OTHERS THEN
54848 xla_exceptions_pkg.raise_message
54849 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_116');
54850 END AcctLineType_116;
54851 --
54852
54853 ---------------------------------------
54854 --
54855 -- PRIVATE FUNCTION
54856 -- AcctLineType_117
54857 --
54858 ---------------------------------------
54859 PROCEDURE AcctLineType_117 (
54860 p_application_id IN NUMBER
54861 ,p_event_id IN NUMBER
54862 ,p_calculate_acctd_flag IN VARCHAR2
54863 ,p_calculate_g_l_flag IN VARCHAR2
54864 ,p_actual_flag IN OUT VARCHAR2
54865 ,p_balance_type_code OUT VARCHAR2
54866 ,p_gain_or_loss_ref OUT VARCHAR2
54867
54868 --Distribution GL Account
54869 , p_source_10 IN NUMBER
54870 --Distribution Source Type
54871 , p_source_22 IN VARCHAR2
54872 --Distribution Line Identifier
54873 , p_source_24 IN NUMBER
54874 --Distribution Type
54875 , p_source_25 IN VARCHAR2
54876 --Exchange Date
54877 , p_source_28 IN DATE
54878 --Exchange Rate
54879 , p_source_29 IN NUMBER
54880 --Exchange Rate Type
54881 , p_source_30 IN VARCHAR2
54882 --Transaction Distribution Identifier
54883 , p_source_36 IN NUMBER
54884 --Transaction Distribution Type
54885 , p_source_37 IN VARCHAR2
54886 --Receipt Applied To Application Identifier
54887 , p_source_60 IN NUMBER
54888 --Transaction Entity Code
54889 , p_source_61 IN VARCHAR2
54890 --Transaction Identifier
54891 , p_source_62 IN NUMBER
54892 --Applying Document Currency Code
54893 , p_source_63 IN VARCHAR2
54894 --Distribution Party Identifier
54895 , p_source_65 IN NUMBER
54896 --Distribution Party Site Id
54897 , p_source_66 IN NUMBER
54898 --Distribution Party Type
54899 , p_source_67 IN VARCHAR2
54900 --Distribution Multi Fund Additional Entry
54901 , p_source_71 IN VARCHAR2
54902 --DIST_ENT_AMT_FROM
54903 , p_source_74 IN NUMBER
54904 --Accounting Amount
54905 , p_source_75 IN NUMBER
54906 )
54907 IS
54908
54909 l_component_type VARCHAR2(80);
54910 l_component_code VARCHAR2(30);
54911 l_component_type_code VARCHAR2(1);
54912 l_component_appl_id INTEGER;
54913 l_amb_context_code VARCHAR2(30);
54914 l_entity_code VARCHAR2(30);
54915 l_event_class_code VARCHAR2(30);
54916 l_ae_header_id NUMBER;
54917 l_event_type_code VARCHAR2(30);
54918 l_line_definition_code VARCHAR2(30);
54919 l_line_definition_owner_code VARCHAR2(1);
54920 --
54921 -- adr variables
54922 l_segment VARCHAR2(30);
54923 l_ccid NUMBER;
54924 l_adr_transaction_coa_id NUMBER;
54925 l_adr_accounting_coa_id NUMBER;
54926 l_adr_flexfield_segment_code VARCHAR2(30);
54927 l_adr_flex_value_set_id NUMBER;
54928 l_adr_value_type_code VARCHAR2(30);
54929 l_adr_value_combination_id NUMBER;
54930 l_adr_value_segment_code VARCHAR2(30);
54931
54932 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
54933 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
54934 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
54935 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
54936
54937 -- 4262811 Variables ------------------------------------------------------------------------------------------
54938 l_entered_amt_idx NUMBER;
54939 l_accted_amt_idx NUMBER;
54940 l_acc_rev_flag VARCHAR2(1);
54941 l_accrual_line_num NUMBER;
54942 l_tmp_amt NUMBER;
54943 l_acc_rev_natural_side_code VARCHAR2(1);
54944
54945 l_num_entries NUMBER;
54946 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
54947 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
54948 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
54949 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
54950 l_recog_line_1 NUMBER;
54951 l_recog_line_2 NUMBER;
54952
54953 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
54954 l_bflow_applied_to_amt NUMBER; -- 5132302
54955 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
54956
54957 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
54958
54959 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
54963
54960 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
54961
54962 ---------------------------------------------------------------------------------------------------------------
54964
54965 --
54966 -- bulk performance
54967 --
54968 l_balance_type_code VARCHAR2(1);
54969 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
54970 l_log_module VARCHAR2(240);
54971
54972 --
54973 -- Upgrade strategy
54974 --
54975 l_actual_upg_option VARCHAR2(1);
54976 l_enc_upg_option VARCHAR2(1);
54977
54978 --
54979 BEGIN
54980 --
54981 IF g_log_enabled THEN
54982 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_117';
54983 END IF;
54984 --
54985 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54986
54987 trace
54988 (p_msg => 'BEGIN of AcctLineType_117'
54989 ,p_level => C_LEVEL_PROCEDURE
54990 ,p_module => l_log_module);
54991
54992 END IF;
54993 --
54994 l_component_type := 'AMB_JLT';
54995 l_component_code := 'RCT_CONFIRM';
54996 l_component_type_code := 'S';
54997 l_component_appl_id := 222;
54998 l_amb_context_code := 'DEFAULT';
54999 l_entity_code := 'RECEIPTS';
55000 l_event_class_code := 'RECEIPT';
55001 l_event_type_code := 'RECEIPT_ALL';
55002 l_line_definition_owner_code := 'S';
55003 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
55004 --
55005 l_balance_type_code := 'A';
55006 l_segment := NULL;
55007 l_ccid := NULL;
55008 l_adr_transaction_coa_id := NULL;
55009 l_adr_accounting_coa_id := NULL;
55010 l_adr_flexfield_segment_code := NULL;
55011 l_adr_flex_value_set_id := NULL;
55012 l_adr_value_type_code := NULL;
55013 l_adr_value_combination_id := NULL;
55014 l_adr_value_segment_code := NULL;
55015
55016 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
55017 l_bflow_class_code := ''; -- 4219869 Business Flow
55018 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
55019 l_budgetary_control_flag := 'N';
55020
55021 l_bflow_applied_to_amt_idx := NULL; -- 5132302
55022 l_bflow_applied_to_amt := NULL; -- 5132302
55023 l_entered_amt_idx := NULL; -- 4262811
55024 l_accted_amt_idx := NULL; -- 4262811
55025 l_acc_rev_flag := NULL; -- 4262811
55026 l_accrual_line_num := NULL; -- 4262811
55027 l_tmp_amt := NULL; -- 4262811
55028 --
55029
55030 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
55031 l_balance_type_code <> 'B' THEN
55032 IF NVL(p_source_22,'
55033 ') = 'CONFIRMATION' AND
55034 NVL(p_source_71,'
55035 ') = 'N'
55036 THEN
55037
55038 --
55039 XLA_AE_LINES_PKG.SetNewLine;
55040
55041 p_balance_type_code := l_balance_type_code;
55042 -- set the flag so later we will know whether the gain loss line needs to be created
55043
55044 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
55045 p_actual_flag :='A';
55046 END IF;
55047
55048 --
55049 -- bulk performance
55050 --
55051 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
55052 p_header_num => 0); -- 4262811
55053 --
55054 -- set accounting line options
55055 --
55056 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
55057 p_natural_side_code => 'C'
55058 , p_gain_or_loss_flag => 'N'
55059 , p_gl_transfer_mode_code => 'S'
55060 , p_acct_entry_type_code => 'A'
55061 , p_switch_side_flag => 'Y'
55062 , p_merge_duplicate_code => 'A'
55063 );
55064 --
55065 l_acc_rev_natural_side_code := 'D'; -- 4262811
55066 --
55067 --
55068 -- set accounting line type info
55069 --
55070 xla_ae_lines_pkg.SetAcctLineType
55071 (p_component_type => l_component_type
55072 ,p_event_type_code => l_event_type_code
55073 ,p_line_definition_owner_code => l_line_definition_owner_code
55074 ,p_line_definition_code => l_line_definition_code
55075 ,p_accounting_line_code => l_component_code
55076 ,p_accounting_line_type_code => l_component_type_code
55077 ,p_accounting_line_appl_id => l_component_appl_id
55078 ,p_amb_context_code => l_amb_context_code
55079 ,p_entity_code => l_entity_code
55080 ,p_event_class_code => l_event_class_code);
55081 --
55082 -- set accounting class
55083 --
55084 xla_ae_lines_pkg.SetAcctClass(
55085 p_accounting_class_code => 'CONFIRMATION'
55086 , p_ae_header_id => l_ae_header_id
55087 );
55088
55089 --
55090 -- set rounding class
55091 --
55092 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
55093 'RECEIVABLE';
55094
55095 --
55099 -- bulk performance
55096 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
55097 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
55098 --
55100 --
55101 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
55102
55103 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
55104 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
55105
55106 -- 4955764
55107 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
55108 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
55109
55110 -- 4458381 Public Sector Enh
55111
55112 --
55113 -- set accounting attributes for the line type
55114 --
55115 l_entered_amt_idx := 8;
55116 l_accted_amt_idx := 13;
55117 l_bflow_applied_to_amt_idx := NULL; -- 5132302
55118 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
55119 l_rec_acct_attrs.array_num_value(1) := p_source_60;
55120 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
55121 l_rec_acct_attrs.array_char_value(2) := p_source_37;
55122 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
55123 l_rec_acct_attrs.array_char_value(3) := p_source_61;
55124 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
55125 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
55126 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
55127 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
55128 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
55129 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
55130 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
55131 l_rec_acct_attrs.array_char_value(7) := p_source_25;
55132 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
55133 l_rec_acct_attrs.array_num_value(8) := p_source_74;
55134 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
55135 l_rec_acct_attrs.array_char_value(9) := p_source_63;
55136 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
55137 l_rec_acct_attrs.array_date_value(10) := p_source_28;
55138 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
55139 l_rec_acct_attrs.array_num_value(11) := p_source_29;
55140 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
55141 l_rec_acct_attrs.array_char_value(12) := p_source_30;
55142 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
55143 l_rec_acct_attrs.array_num_value(13) := p_source_75;
55144 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
55145 l_rec_acct_attrs.array_num_value(14) := p_source_65;
55146 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
55147 l_rec_acct_attrs.array_num_value(15) := p_source_66;
55148 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
55149 l_rec_acct_attrs.array_char_value(16) := p_source_67;
55150
55151 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
55152 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
55153
55154 ---------------------------------------------------------------------------------------------------------------
55155 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
55156 ---------------------------------------------------------------------------------------------------------------
55157 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
55158
55159 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
55160 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
55161
55162 IF xla_accounting_cache_pkg.GetValueChar
55163 (p_source_code => 'LEDGER_CATEGORY_CODE'
55164 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
55165 AND l_bflow_method_code = 'PRIOR_ENTRY'
55166 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
55167 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
55168 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
55169 )
55170 THEN
55171 xla_ae_lines_pkg.BflowUpgEntry
55172 (p_business_method_code => l_bflow_method_code
55173 ,p_business_class_code => l_bflow_class_code
55174 ,p_balance_type => l_balance_type_code);
55175 ELSE
55176 NULL;
55177 -- No business flow processing for business flow method of NONE.
55178 END IF;
55179
55180 --
55181 -- call analytical criteria
55182 --
55183
55184 --
55185 -- call description
55186 --
55187 -- No description or it is inherited.
55188 --
55189 -- call ADRs
55190 -- Bug 4922099
55191 --
55192 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
55193 (NVL(l_actual_upg_option, 'N') = 'O') OR
55194 (NVL(l_enc_upg_option, 'N') = 'O')
55195 )
55196 THEN
55197 NULL;
55198 --
55199 --
55200
55201 l_ccid := AcctDerRule_11(
55202 p_application_id => p_application_id
55203 , p_ae_header_id => l_ae_header_id
55207 , x_value_type_code => l_adr_value_type_code
55204 , p_source_10 => p_source_10
55205 , x_transaction_coa_id => l_adr_transaction_coa_id
55206 , x_accounting_coa_id => l_adr_accounting_coa_id
55208 , p_side => 'NA'
55209 );
55210
55211 xla_ae_lines_pkg.set_ccid(
55212 p_code_combination_id => l_ccid
55213 , p_value_type_code => l_adr_value_type_code
55214 , p_transaction_coa_id => l_adr_transaction_coa_id
55215 , p_accounting_coa_id => l_adr_accounting_coa_id
55216 , p_adr_code => 'DIST_CCID'
55217 , p_adr_type_code => 'S'
55218 , p_component_type => l_component_type
55219 , p_component_code => l_component_code
55220 , p_component_type_code => l_component_type_code
55221 , p_component_appl_id => l_component_appl_id
55222 , p_amb_context_code => l_amb_context_code
55223 , p_side => 'NA'
55224 );
55225
55226
55227 --
55228 --
55229 END IF;
55230 --
55231 -- Bug 4922099
55232 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
55233 (NVL(l_enc_upg_option, 'N') = 'O')
55234 ) AND
55235 (l_bflow_method_code = 'PRIOR_ENTRY')
55236 )
55237 THEN
55238 IF
55239 --
55240 1 = 2
55241 --
55242 THEN
55243 xla_accounting_err_pkg.build_message
55244 (p_appli_s_name => 'XLA'
55245 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
55246 ,p_token_1 => 'LINE_NUMBER'
55247 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
55248 ,p_token_2 => 'LINE_TYPE_NAME'
55249 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
55250 l_component_type
55251 ,l_component_code
55252 ,l_component_type_code
55253 ,l_component_appl_id
55254 ,l_amb_context_code
55255 ,l_entity_code
55256 ,l_event_class_code
55257 )
55258 ,p_token_3 => 'OWNER'
55259 ,p_value_3 => xla_lookups_pkg.get_meaning(
55260 p_lookup_type => 'XLA_OWNER_TYPE'
55261 ,p_lookup_code => l_component_type_code
55262 )
55263 ,p_token_4 => 'PRODUCT_NAME'
55264 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
55265 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
55266 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
55267 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
55268 ,p_ae_header_id => NULL
55269 );
55270
55271 IF (C_LEVEL_ERROR>= g_log_level) THEN
55272 trace
55273 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
55274 ,p_level => C_LEVEL_ERROR
55275 ,p_module => l_log_module);
55276 END IF;
55277 END IF;
55278 END IF;
55279 --
55280 --
55281 ------------------------------------------------------------------------------------------------
55282 -- 4219869 Business Flow
55283 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
55284 -- Prior Entry. Currently, the following code is always generated.
55285 ------------------------------------------------------------------------------------------------
55286 XLA_AE_LINES_PKG.ValidateCurrentLine;
55287
55288 ------------------------------------------------------------------------------------
55289 -- 4219869 Business Flow
55290 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
55291 ------------------------------------------------------------------------------------
55292 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
55293
55294 ----------------------------------------------------------------------------------
55295 -- 4219869 Business Flow
55296 -- Update journal entry status -- Need to generate this within IF <condition>
55297 ----------------------------------------------------------------------------------
55298 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
55299 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
55300 ,p_balance_type_code => l_balance_type_code
55301 );
55302
55306 BEGIN
55303 -------------------------------------------------------------------------------------------
55304 -- 4262811 - Generate the Accrual Reversal lines
55305 -------------------------------------------------------------------------------------------
55307 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
55308 (g_array_event(p_event_id).array_value_num('header_index'));
55309 IF l_acc_rev_flag IS NULL THEN
55310 l_acc_rev_flag := 'N';
55311 END IF;
55312 EXCEPTION
55313 WHEN OTHERS THEN
55314 l_acc_rev_flag := 'N';
55315 END;
55316 --
55317 IF (l_acc_rev_flag = 'Y') THEN
55318
55319 -- 4645092 ------------------------------------------------------------------------------
55320 -- To allow MPA report to determine if it should generate report process
55321 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
55322 ------------------------------------------------------------------------------------------
55323
55324 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
55325 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
55326 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
55327 -- call ADRs
55328 -- Bug 4922099
55329 --
55330 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
55331 (NVL(l_actual_upg_option, 'N') = 'O') OR
55332 (NVL(l_enc_upg_option, 'N') = 'O')
55333 )
55334 THEN
55335 NULL;
55336 --
55337 --
55338
55339 l_ccid := AcctDerRule_11(
55340 p_application_id => p_application_id
55341 , p_ae_header_id => l_ae_header_id
55342 , p_source_10 => p_source_10
55343 , x_transaction_coa_id => l_adr_transaction_coa_id
55344 , x_accounting_coa_id => l_adr_accounting_coa_id
55345 , x_value_type_code => l_adr_value_type_code
55346 , p_side => 'NA'
55347 );
55348
55349 xla_ae_lines_pkg.set_ccid(
55350 p_code_combination_id => l_ccid
55351 , p_value_type_code => l_adr_value_type_code
55352 , p_transaction_coa_id => l_adr_transaction_coa_id
55353 , p_accounting_coa_id => l_adr_accounting_coa_id
55354 , p_adr_code => 'DIST_CCID'
55355 , p_adr_type_code => 'S'
55356 , p_component_type => l_component_type
55357 , p_component_code => l_component_code
55358 , p_component_type_code => l_component_type_code
55359 , p_component_appl_id => l_component_appl_id
55360 , p_amb_context_code => l_amb_context_code
55361 , p_side => 'NA'
55362 );
55363
55364
55365 --
55366 --
55367 END IF;
55368
55369 --
55370 -- Update the line information that should be overwritten
55371 --
55372 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
55373 p_header_num => 1);
55374 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
55375
55376 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
55377
55378 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
55379 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
55380 END IF;
55381
55382 --
55383 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
55384 --
55385 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
55386 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
55387 ELSE
55388 ---------------------------------------------------------------------------------------------------
55389 -- 4262811a Switch Sign
55390 ---------------------------------------------------------------------------------------------------
55391 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
55392 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
55393 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55394 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
55395 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55396 -- 5132302
55397 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
55398 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55399
55400 END IF;
55401
55402 -- 4955764
55403 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
55404 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
55405
55406
55407 XLA_AE_LINES_PKG.ValidateCurrentLine;
55408 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
55409
55410 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
55411 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
55415
55412 ,p_balance_type_code => l_balance_type_code);
55413
55414 END IF;
55416 -----------------------------------------------------------------------------------------
55417 -- 4262811 Multiperiod Accounting
55418 -----------------------------------------------------------------------------------------
55419 -- No MPA option is assigned.
55420
55421
55422 END IF;
55423 END IF;
55424 --
55425
55426 --
55427 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
55428 trace
55429 (p_msg => 'END of AcctLineType_117'
55430 ,p_level => C_LEVEL_PROCEDURE
55431 ,p_module => l_log_module);
55432 END IF;
55433 --
55434 EXCEPTION
55435 WHEN xla_exceptions_pkg.application_exception THEN
55436 RAISE;
55437 WHEN OTHERS THEN
55438 xla_exceptions_pkg.raise_message
55439 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_117');
55440 END AcctLineType_117;
55441 --
55442
55443 ---------------------------------------
55444 --
55445 -- PRIVATE FUNCTION
55446 -- AcctLineType_118
55447 --
55448 ---------------------------------------
55449 PROCEDURE AcctLineType_118 (
55450 p_application_id IN NUMBER
55451 ,p_event_id IN NUMBER
55452 ,p_calculate_acctd_flag IN VARCHAR2
55453 ,p_calculate_g_l_flag IN VARCHAR2
55454 ,p_actual_flag IN OUT VARCHAR2
55455 ,p_balance_type_code OUT VARCHAR2
55456 ,p_gain_or_loss_ref OUT VARCHAR2
55457
55458 --Distribution GL Account
55459 , p_source_10 IN NUMBER
55460 --Distribution Source Type
55461 , p_source_22 IN VARCHAR2
55462 --Distribution Line Identifier
55463 , p_source_24 IN NUMBER
55464 --Distribution Type
55465 , p_source_25 IN VARCHAR2
55466 --Exchange Date
55467 , p_source_28 IN DATE
55468 --Exchange Rate
55469 , p_source_29 IN NUMBER
55470 --Exchange Rate Type
55471 , p_source_30 IN VARCHAR2
55472 --Transaction Distribution Identifier
55473 , p_source_36 IN NUMBER
55474 --Transaction Distribution Type
55475 , p_source_37 IN VARCHAR2
55476 --Receipt Applied To Application Identifier
55477 , p_source_60 IN NUMBER
55478 --Transaction Entity Code
55479 , p_source_61 IN VARCHAR2
55480 --Transaction Identifier
55481 , p_source_62 IN NUMBER
55482 --Applying Document Currency Code
55483 , p_source_63 IN VARCHAR2
55484 --Distribution Party Identifier
55485 , p_source_65 IN NUMBER
55486 --Distribution Party Site Id
55487 , p_source_66 IN NUMBER
55488 --Distribution Party Type
55489 , p_source_67 IN VARCHAR2
55490 --Distribution Multi Fund Additional Entry
55491 , p_source_71 IN VARCHAR2
55492 --DIST_ENT_AMT_FROM
55493 , p_source_74 IN NUMBER
55494 --Accounting Amount
55495 , p_source_75 IN NUMBER
55496 )
55497 IS
55498
55499 l_component_type VARCHAR2(80);
55500 l_component_code VARCHAR2(30);
55501 l_component_type_code VARCHAR2(1);
55502 l_component_appl_id INTEGER;
55503 l_amb_context_code VARCHAR2(30);
55504 l_entity_code VARCHAR2(30);
55505 l_event_class_code VARCHAR2(30);
55506 l_ae_header_id NUMBER;
55507 l_event_type_code VARCHAR2(30);
55508 l_line_definition_code VARCHAR2(30);
55509 l_line_definition_owner_code VARCHAR2(1);
55510 --
55511 -- adr variables
55512 l_segment VARCHAR2(30);
55513 l_ccid NUMBER;
55514 l_adr_transaction_coa_id NUMBER;
55515 l_adr_accounting_coa_id NUMBER;
55516 l_adr_flexfield_segment_code VARCHAR2(30);
55517 l_adr_flex_value_set_id NUMBER;
55518 l_adr_value_type_code VARCHAR2(30);
55519 l_adr_value_combination_id NUMBER;
55520 l_adr_value_segment_code VARCHAR2(30);
55521
55522 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
55523 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
55524 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
55525 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
55526
55527 -- 4262811 Variables ------------------------------------------------------------------------------------------
55528 l_entered_amt_idx NUMBER;
55529 l_accted_amt_idx NUMBER;
55530 l_acc_rev_flag VARCHAR2(1);
55531 l_accrual_line_num NUMBER;
55532 l_tmp_amt NUMBER;
55533 l_acc_rev_natural_side_code VARCHAR2(1);
55534
55535 l_num_entries NUMBER;
55536 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
55537 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
55538 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
55539 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
55540 l_recog_line_1 NUMBER;
55541 l_recog_line_2 NUMBER;
55542
55543 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
55544 l_bflow_applied_to_amt NUMBER; -- 5132302
55545 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
55546
55550 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
55547 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
55548
55549 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
55551
55552 ---------------------------------------------------------------------------------------------------------------
55553
55554
55555 --
55556 -- bulk performance
55557 --
55558 l_balance_type_code VARCHAR2(1);
55559 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
55560 l_log_module VARCHAR2(240);
55561
55562 --
55563 -- Upgrade strategy
55564 --
55565 l_actual_upg_option VARCHAR2(1);
55566 l_enc_upg_option VARCHAR2(1);
55567
55568 --
55569 BEGIN
55570 --
55571 IF g_log_enabled THEN
55572 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_118';
55573 END IF;
55574 --
55575 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
55576
55577 trace
55578 (p_msg => 'BEGIN of AcctLineType_118'
55579 ,p_level => C_LEVEL_PROCEDURE
55580 ,p_module => l_log_module);
55581
55582 END IF;
55583 --
55584 l_component_type := 'AMB_JLT';
55585 l_component_code := 'RCT_CURR_ROUND';
55586 l_component_type_code := 'S';
55587 l_component_appl_id := 222;
55588 l_amb_context_code := 'DEFAULT';
55589 l_entity_code := 'RECEIPTS';
55590 l_event_class_code := 'RECEIPT';
55591 l_event_type_code := 'RECEIPT_ALL';
55592 l_line_definition_owner_code := 'S';
55593 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
55594 --
55595 l_balance_type_code := 'A';
55596 l_segment := NULL;
55597 l_ccid := NULL;
55598 l_adr_transaction_coa_id := NULL;
55599 l_adr_accounting_coa_id := NULL;
55600 l_adr_flexfield_segment_code := NULL;
55601 l_adr_flex_value_set_id := NULL;
55602 l_adr_value_type_code := NULL;
55603 l_adr_value_combination_id := NULL;
55604 l_adr_value_segment_code := NULL;
55605
55606 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
55607 l_bflow_class_code := ''; -- 4219869 Business Flow
55608 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
55609 l_budgetary_control_flag := 'N';
55610
55611 l_bflow_applied_to_amt_idx := NULL; -- 5132302
55612 l_bflow_applied_to_amt := NULL; -- 5132302
55613 l_entered_amt_idx := NULL; -- 4262811
55614 l_accted_amt_idx := NULL; -- 4262811
55615 l_acc_rev_flag := NULL; -- 4262811
55616 l_accrual_line_num := NULL; -- 4262811
55617 l_tmp_amt := NULL; -- 4262811
55618 --
55619
55620 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
55621 l_balance_type_code <> 'B' THEN
55622 IF NVL(p_source_22,'
55623 ') = 'CURR_ROUND' AND
55624 NVL(p_source_71,'
55625 ') = 'N'
55626 THEN
55627
55628 --
55629 XLA_AE_LINES_PKG.SetNewLine;
55630
55631 p_balance_type_code := l_balance_type_code;
55632 -- set the flag so later we will know whether the gain loss line needs to be created
55633
55634 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
55635 p_actual_flag :='A';
55636 END IF;
55637
55638 --
55639 -- bulk performance
55640 --
55641 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
55642 p_header_num => 0); -- 4262811
55643 --
55644 -- set accounting line options
55645 --
55646 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
55647 p_natural_side_code => 'C'
55648 , p_gain_or_loss_flag => 'N'
55649 , p_gl_transfer_mode_code => 'S'
55650 , p_acct_entry_type_code => 'A'
55651 , p_switch_side_flag => 'Y'
55652 , p_merge_duplicate_code => 'A'
55653 );
55654 --
55655 l_acc_rev_natural_side_code := 'D'; -- 4262811
55656 --
55657 --
55658 -- set accounting line type info
55659 --
55660 xla_ae_lines_pkg.SetAcctLineType
55661 (p_component_type => l_component_type
55662 ,p_event_type_code => l_event_type_code
55663 ,p_line_definition_owner_code => l_line_definition_owner_code
55664 ,p_line_definition_code => l_line_definition_code
55665 ,p_accounting_line_code => l_component_code
55666 ,p_accounting_line_type_code => l_component_type_code
55667 ,p_accounting_line_appl_id => l_component_appl_id
55668 ,p_amb_context_code => l_amb_context_code
55669 ,p_entity_code => l_entity_code
55670 ,p_event_class_code => l_event_class_code);
55671 --
55672 -- set accounting class
55673 --
55674 xla_ae_lines_pkg.SetAcctClass(
55675 p_accounting_class_code => 'ROUNDING'
55676 , p_ae_header_id => l_ae_header_id
55677 );
55678
55679 --
55680 -- set rounding class
55681 --
55685 --
55682 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
55683 'RECEIVABLE';
55684
55686 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
55687 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
55688 --
55689 -- bulk performance
55690 --
55691 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
55692
55693 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
55694 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
55695
55696 -- 4955764
55697 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
55698 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
55699
55700 -- 4458381 Public Sector Enh
55701
55702 --
55703 -- set accounting attributes for the line type
55704 --
55705 l_entered_amt_idx := 8;
55706 l_accted_amt_idx := 13;
55707 l_bflow_applied_to_amt_idx := NULL; -- 5132302
55708 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
55709 l_rec_acct_attrs.array_num_value(1) := p_source_60;
55710 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
55711 l_rec_acct_attrs.array_char_value(2) := p_source_37;
55712 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
55713 l_rec_acct_attrs.array_char_value(3) := p_source_61;
55714 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
55715 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
55716 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
55717 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
55718 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
55719 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
55720 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
55721 l_rec_acct_attrs.array_char_value(7) := p_source_25;
55722 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
55723 l_rec_acct_attrs.array_num_value(8) := p_source_74;
55724 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
55725 l_rec_acct_attrs.array_char_value(9) := p_source_63;
55726 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
55727 l_rec_acct_attrs.array_date_value(10) := p_source_28;
55728 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
55729 l_rec_acct_attrs.array_num_value(11) := p_source_29;
55730 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
55731 l_rec_acct_attrs.array_char_value(12) := p_source_30;
55732 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
55733 l_rec_acct_attrs.array_num_value(13) := p_source_75;
55734 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
55735 l_rec_acct_attrs.array_num_value(14) := p_source_65;
55736 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
55737 l_rec_acct_attrs.array_num_value(15) := p_source_66;
55738 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
55739 l_rec_acct_attrs.array_char_value(16) := p_source_67;
55740
55741 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
55742 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
55743
55744 ---------------------------------------------------------------------------------------------------------------
55745 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
55746 ---------------------------------------------------------------------------------------------------------------
55747 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
55748
55749 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
55750 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
55751
55752 IF xla_accounting_cache_pkg.GetValueChar
55753 (p_source_code => 'LEDGER_CATEGORY_CODE'
55754 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
55755 AND l_bflow_method_code = 'PRIOR_ENTRY'
55756 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
55757 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
55758 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
55759 )
55760 THEN
55761 xla_ae_lines_pkg.BflowUpgEntry
55762 (p_business_method_code => l_bflow_method_code
55763 ,p_business_class_code => l_bflow_class_code
55764 ,p_balance_type => l_balance_type_code);
55765 ELSE
55766 NULL;
55767 -- No business flow processing for business flow method of NONE.
55768 END IF;
55769
55770 --
55771 -- call analytical criteria
55772 --
55773
55774 --
55775 -- call description
55776 --
55777 -- No description or it is inherited.
55778 --
55779 -- call ADRs
55780 -- Bug 4922099
55781 --
55782 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
55783 (NVL(l_actual_upg_option, 'N') = 'O') OR
55784 (NVL(l_enc_upg_option, 'N') = 'O')
55785 )
55786 THEN
55787 NULL;
55788 --
55789 --
55790
55794 , p_source_10 => p_source_10
55791 l_ccid := AcctDerRule_11(
55792 p_application_id => p_application_id
55793 , p_ae_header_id => l_ae_header_id
55795 , x_transaction_coa_id => l_adr_transaction_coa_id
55796 , x_accounting_coa_id => l_adr_accounting_coa_id
55797 , x_value_type_code => l_adr_value_type_code
55798 , p_side => 'NA'
55799 );
55800
55801 xla_ae_lines_pkg.set_ccid(
55802 p_code_combination_id => l_ccid
55803 , p_value_type_code => l_adr_value_type_code
55804 , p_transaction_coa_id => l_adr_transaction_coa_id
55805 , p_accounting_coa_id => l_adr_accounting_coa_id
55806 , p_adr_code => 'DIST_CCID'
55807 , p_adr_type_code => 'S'
55808 , p_component_type => l_component_type
55809 , p_component_code => l_component_code
55810 , p_component_type_code => l_component_type_code
55811 , p_component_appl_id => l_component_appl_id
55812 , p_amb_context_code => l_amb_context_code
55813 , p_side => 'NA'
55814 );
55815
55816
55817 --
55818 --
55819 END IF;
55820 --
55821 -- Bug 4922099
55822 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
55823 (NVL(l_enc_upg_option, 'N') = 'O')
55824 ) AND
55825 (l_bflow_method_code = 'PRIOR_ENTRY')
55826 )
55827 THEN
55828 IF
55829 --
55830 1 = 2
55831 --
55832 THEN
55833 xla_accounting_err_pkg.build_message
55834 (p_appli_s_name => 'XLA'
55835 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
55836 ,p_token_1 => 'LINE_NUMBER'
55837 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
55838 ,p_token_2 => 'LINE_TYPE_NAME'
55839 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
55840 l_component_type
55841 ,l_component_code
55842 ,l_component_type_code
55843 ,l_component_appl_id
55844 ,l_amb_context_code
55845 ,l_entity_code
55846 ,l_event_class_code
55847 )
55848 ,p_token_3 => 'OWNER'
55849 ,p_value_3 => xla_lookups_pkg.get_meaning(
55850 p_lookup_type => 'XLA_OWNER_TYPE'
55851 ,p_lookup_code => l_component_type_code
55852 )
55853 ,p_token_4 => 'PRODUCT_NAME'
55854 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
55855 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
55856 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
55857 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
55858 ,p_ae_header_id => NULL
55859 );
55860
55861 IF (C_LEVEL_ERROR>= g_log_level) THEN
55862 trace
55863 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
55864 ,p_level => C_LEVEL_ERROR
55865 ,p_module => l_log_module);
55866 END IF;
55867 END IF;
55868 END IF;
55869 --
55870 --
55871 ------------------------------------------------------------------------------------------------
55872 -- 4219869 Business Flow
55873 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
55874 -- Prior Entry. Currently, the following code is always generated.
55875 ------------------------------------------------------------------------------------------------
55876 XLA_AE_LINES_PKG.ValidateCurrentLine;
55877
55878 ------------------------------------------------------------------------------------
55879 -- 4219869 Business Flow
55880 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
55881 ------------------------------------------------------------------------------------
55882 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
55883
55884 ----------------------------------------------------------------------------------
55885 -- 4219869 Business Flow
55886 -- Update journal entry status -- Need to generate this within IF <condition>
55887 ----------------------------------------------------------------------------------
55888 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
55892
55889 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
55890 ,p_balance_type_code => l_balance_type_code
55891 );
55893 -------------------------------------------------------------------------------------------
55894 -- 4262811 - Generate the Accrual Reversal lines
55895 -------------------------------------------------------------------------------------------
55896 BEGIN
55897 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
55898 (g_array_event(p_event_id).array_value_num('header_index'));
55899 IF l_acc_rev_flag IS NULL THEN
55900 l_acc_rev_flag := 'N';
55901 END IF;
55902 EXCEPTION
55903 WHEN OTHERS THEN
55904 l_acc_rev_flag := 'N';
55905 END;
55906 --
55907 IF (l_acc_rev_flag = 'Y') THEN
55908
55909 -- 4645092 ------------------------------------------------------------------------------
55910 -- To allow MPA report to determine if it should generate report process
55911 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
55912 ------------------------------------------------------------------------------------------
55913
55914 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
55915 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
55916 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
55917 -- call ADRs
55918 -- Bug 4922099
55919 --
55920 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
55921 (NVL(l_actual_upg_option, 'N') = 'O') OR
55922 (NVL(l_enc_upg_option, 'N') = 'O')
55923 )
55924 THEN
55925 NULL;
55926 --
55927 --
55928
55929 l_ccid := AcctDerRule_11(
55930 p_application_id => p_application_id
55931 , p_ae_header_id => l_ae_header_id
55932 , p_source_10 => p_source_10
55933 , x_transaction_coa_id => l_adr_transaction_coa_id
55934 , x_accounting_coa_id => l_adr_accounting_coa_id
55935 , x_value_type_code => l_adr_value_type_code
55936 , p_side => 'NA'
55937 );
55938
55939 xla_ae_lines_pkg.set_ccid(
55940 p_code_combination_id => l_ccid
55941 , p_value_type_code => l_adr_value_type_code
55942 , p_transaction_coa_id => l_adr_transaction_coa_id
55943 , p_accounting_coa_id => l_adr_accounting_coa_id
55944 , p_adr_code => 'DIST_CCID'
55945 , p_adr_type_code => 'S'
55946 , p_component_type => l_component_type
55947 , p_component_code => l_component_code
55948 , p_component_type_code => l_component_type_code
55949 , p_component_appl_id => l_component_appl_id
55950 , p_amb_context_code => l_amb_context_code
55951 , p_side => 'NA'
55952 );
55953
55954
55955 --
55956 --
55957 END IF;
55958
55959 --
55960 -- Update the line information that should be overwritten
55961 --
55962 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
55963 p_header_num => 1);
55964 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
55965
55966 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
55967
55968 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
55969 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
55970 END IF;
55971
55972 --
55973 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
55974 --
55975 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
55976 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
55977 ELSE
55978 ---------------------------------------------------------------------------------------------------
55979 -- 4262811a Switch Sign
55980 ---------------------------------------------------------------------------------------------------
55981 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
55982 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
55983 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55984 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
55985 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55986 -- 5132302
55987 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
55988 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55989
55990 END IF;
55991
55992 -- 4955764
55993 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
55994 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
55995
55996
55997 XLA_AE_LINES_PKG.ValidateCurrentLine;
55998 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
55999
56003
56000 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
56001 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
56002 ,p_balance_type_code => l_balance_type_code);
56004 END IF;
56005
56006 -----------------------------------------------------------------------------------------
56007 -- 4262811 Multiperiod Accounting
56008 -----------------------------------------------------------------------------------------
56009 -- No MPA option is assigned.
56010
56011
56012 END IF;
56013 END IF;
56014 --
56015
56016 --
56017 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
56018 trace
56019 (p_msg => 'END of AcctLineType_118'
56020 ,p_level => C_LEVEL_PROCEDURE
56021 ,p_module => l_log_module);
56022 END IF;
56023 --
56024 EXCEPTION
56025 WHEN xla_exceptions_pkg.application_exception THEN
56026 RAISE;
56027 WHEN OTHERS THEN
56028 xla_exceptions_pkg.raise_message
56029 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_118');
56030 END AcctLineType_118;
56031 --
56032
56033 ---------------------------------------
56034 --
56035 -- PRIVATE FUNCTION
56036 -- AcctLineType_119
56037 --
56038 ---------------------------------------
56039 PROCEDURE AcctLineType_119 (
56040 p_application_id IN NUMBER
56041 ,p_event_id IN NUMBER
56042 ,p_calculate_acctd_flag IN VARCHAR2
56043 ,p_calculate_g_l_flag IN VARCHAR2
56044 ,p_actual_flag IN OUT VARCHAR2
56045 ,p_balance_type_code OUT VARCHAR2
56046 ,p_gain_or_loss_ref OUT VARCHAR2
56047
56048 --Distribution GL Account
56049 , p_source_10 IN NUMBER
56050 --Distribution Source Type
56051 , p_source_22 IN VARCHAR2
56052 --Distribution Line Identifier
56053 , p_source_24 IN NUMBER
56054 --Distribution Type
56055 , p_source_25 IN VARCHAR2
56056 --Exchange Date
56057 , p_source_28 IN DATE
56058 --Exchange Rate
56059 , p_source_29 IN NUMBER
56060 --Exchange Rate Type
56061 , p_source_30 IN VARCHAR2
56062 --Transaction Distribution Identifier
56063 , p_source_36 IN NUMBER
56064 --Transaction Distribution Type
56065 , p_source_37 IN VARCHAR2
56066 --Receipt Applied To Application Identifier
56067 , p_source_60 IN NUMBER
56068 --Transaction Entity Code
56069 , p_source_61 IN VARCHAR2
56070 --Transaction Identifier
56071 , p_source_62 IN NUMBER
56072 --Applying Document Currency Code
56073 , p_source_63 IN VARCHAR2
56074 --Distribution Party Identifier
56075 , p_source_65 IN NUMBER
56076 --Distribution Party Site Id
56077 , p_source_66 IN NUMBER
56078 --Distribution Party Type
56079 , p_source_67 IN VARCHAR2
56080 --Distribution Multi Fund Additional Entry
56081 , p_source_71 IN VARCHAR2
56082 --DIST_ENT_AMT_FROM
56083 , p_source_74 IN NUMBER
56084 --Accounting Amount
56085 , p_source_75 IN NUMBER
56086 )
56087 IS
56088
56089 l_component_type VARCHAR2(80);
56090 l_component_code VARCHAR2(30);
56091 l_component_type_code VARCHAR2(1);
56092 l_component_appl_id INTEGER;
56093 l_amb_context_code VARCHAR2(30);
56094 l_entity_code VARCHAR2(30);
56095 l_event_class_code VARCHAR2(30);
56096 l_ae_header_id NUMBER;
56097 l_event_type_code VARCHAR2(30);
56098 l_line_definition_code VARCHAR2(30);
56099 l_line_definition_owner_code VARCHAR2(1);
56100 --
56101 -- adr variables
56102 l_segment VARCHAR2(30);
56103 l_ccid NUMBER;
56104 l_adr_transaction_coa_id NUMBER;
56105 l_adr_accounting_coa_id NUMBER;
56106 l_adr_flexfield_segment_code VARCHAR2(30);
56107 l_adr_flex_value_set_id NUMBER;
56108 l_adr_value_type_code VARCHAR2(30);
56109 l_adr_value_combination_id NUMBER;
56110 l_adr_value_segment_code VARCHAR2(30);
56111
56112 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
56113 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
56114 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
56115 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
56116
56117 -- 4262811 Variables ------------------------------------------------------------------------------------------
56118 l_entered_amt_idx NUMBER;
56119 l_accted_amt_idx NUMBER;
56120 l_acc_rev_flag VARCHAR2(1);
56121 l_accrual_line_num NUMBER;
56122 l_tmp_amt NUMBER;
56123 l_acc_rev_natural_side_code VARCHAR2(1);
56124
56125 l_num_entries NUMBER;
56126 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
56127 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
56128 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
56129 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
56130 l_recog_line_1 NUMBER;
56131 l_recog_line_2 NUMBER;
56132
56133 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
56137 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
56134 l_bflow_applied_to_amt NUMBER; -- 5132302
56135 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
56136
56138
56139 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
56140 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
56141
56142 ---------------------------------------------------------------------------------------------------------------
56143
56144
56145 --
56146 -- bulk performance
56147 --
56148 l_balance_type_code VARCHAR2(1);
56149 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
56150 l_log_module VARCHAR2(240);
56151
56152 --
56153 -- Upgrade strategy
56154 --
56155 l_actual_upg_option VARCHAR2(1);
56156 l_enc_upg_option VARCHAR2(1);
56157
56158 --
56159 BEGIN
56160 --
56161 IF g_log_enabled THEN
56162 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_119';
56163 END IF;
56164 --
56165 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
56166
56167 trace
56168 (p_msg => 'BEGIN of AcctLineType_119'
56169 ,p_level => C_LEVEL_PROCEDURE
56170 ,p_module => l_log_module);
56171
56172 END IF;
56173 --
56174 l_component_type := 'AMB_JLT';
56175 l_component_code := 'RCT_DEBT';
56176 l_component_type_code := 'S';
56177 l_component_appl_id := 222;
56178 l_amb_context_code := 'DEFAULT';
56179 l_entity_code := 'RECEIPTS';
56180 l_event_class_code := 'RECEIPT';
56181 l_event_type_code := 'RECEIPT_ALL';
56182 l_line_definition_owner_code := 'S';
56183 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
56184 --
56185 l_balance_type_code := 'A';
56186 l_segment := NULL;
56187 l_ccid := NULL;
56188 l_adr_transaction_coa_id := NULL;
56189 l_adr_accounting_coa_id := NULL;
56190 l_adr_flexfield_segment_code := NULL;
56191 l_adr_flex_value_set_id := NULL;
56192 l_adr_value_type_code := NULL;
56193 l_adr_value_combination_id := NULL;
56194 l_adr_value_segment_code := NULL;
56195
56196 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
56197 l_bflow_class_code := ''; -- 4219869 Business Flow
56198 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
56199 l_budgetary_control_flag := 'N';
56200
56201 l_bflow_applied_to_amt_idx := NULL; -- 5132302
56202 l_bflow_applied_to_amt := NULL; -- 5132302
56203 l_entered_amt_idx := NULL; -- 4262811
56204 l_accted_amt_idx := NULL; -- 4262811
56205 l_acc_rev_flag := NULL; -- 4262811
56206 l_accrual_line_num := NULL; -- 4262811
56207 l_tmp_amt := NULL; -- 4262811
56208 --
56209
56210 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
56211 l_balance_type_code <> 'B' THEN
56212 IF NVL(p_source_22,'
56213 ') = 'SHORT_TERM_DEBT' AND
56214 NVL(p_source_71,'
56215 ') = 'N'
56216 THEN
56217
56218 --
56219 XLA_AE_LINES_PKG.SetNewLine;
56220
56221 p_balance_type_code := l_balance_type_code;
56222 -- set the flag so later we will know whether the gain loss line needs to be created
56223
56224 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
56225 p_actual_flag :='A';
56226 END IF;
56227
56228 --
56229 -- bulk performance
56230 --
56231 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
56232 p_header_num => 0); -- 4262811
56233 --
56234 -- set accounting line options
56235 --
56236 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
56237 p_natural_side_code => 'C'
56238 , p_gain_or_loss_flag => 'N'
56239 , p_gl_transfer_mode_code => 'S'
56240 , p_acct_entry_type_code => 'A'
56241 , p_switch_side_flag => 'Y'
56242 , p_merge_duplicate_code => 'A'
56243 );
56244 --
56245 l_acc_rev_natural_side_code := 'D'; -- 4262811
56246 --
56247 --
56248 -- set accounting line type info
56249 --
56250 xla_ae_lines_pkg.SetAcctLineType
56251 (p_component_type => l_component_type
56252 ,p_event_type_code => l_event_type_code
56253 ,p_line_definition_owner_code => l_line_definition_owner_code
56254 ,p_line_definition_code => l_line_definition_code
56255 ,p_accounting_line_code => l_component_code
56256 ,p_accounting_line_type_code => l_component_type_code
56257 ,p_accounting_line_appl_id => l_component_appl_id
56258 ,p_amb_context_code => l_amb_context_code
56259 ,p_entity_code => l_entity_code
56260 ,p_event_class_code => l_event_class_code);
56261 --
56262 -- set accounting class
56263 --
56264 xla_ae_lines_pkg.SetAcctClass(
56265 p_accounting_class_code => 'SHORT_TERM_DEBT'
56266 , p_ae_header_id => l_ae_header_id
56270 -- set rounding class
56267 );
56268
56269 --
56271 --
56272 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
56273 'RECEIVABLE';
56274
56275 --
56276 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
56277 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
56278 --
56279 -- bulk performance
56280 --
56281 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
56282
56283 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
56284 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
56285
56286 -- 4955764
56287 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
56288 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
56289
56290 -- 4458381 Public Sector Enh
56291
56292 --
56293 -- set accounting attributes for the line type
56294 --
56295 l_entered_amt_idx := 8;
56296 l_accted_amt_idx := 13;
56297 l_bflow_applied_to_amt_idx := NULL; -- 5132302
56298 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
56299 l_rec_acct_attrs.array_num_value(1) := p_source_60;
56300 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
56301 l_rec_acct_attrs.array_char_value(2) := p_source_37;
56302 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
56303 l_rec_acct_attrs.array_char_value(3) := p_source_61;
56304 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
56305 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
56306 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
56307 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
56308 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
56309 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
56310 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
56311 l_rec_acct_attrs.array_char_value(7) := p_source_25;
56312 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
56313 l_rec_acct_attrs.array_num_value(8) := p_source_74;
56314 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
56315 l_rec_acct_attrs.array_char_value(9) := p_source_63;
56316 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
56317 l_rec_acct_attrs.array_date_value(10) := p_source_28;
56318 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
56319 l_rec_acct_attrs.array_num_value(11) := p_source_29;
56320 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
56321 l_rec_acct_attrs.array_char_value(12) := p_source_30;
56322 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
56323 l_rec_acct_attrs.array_num_value(13) := p_source_75;
56324 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
56325 l_rec_acct_attrs.array_num_value(14) := p_source_65;
56326 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
56327 l_rec_acct_attrs.array_num_value(15) := p_source_66;
56328 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
56329 l_rec_acct_attrs.array_char_value(16) := p_source_67;
56330
56331 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
56332 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
56333
56334 ---------------------------------------------------------------------------------------------------------------
56335 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
56336 ---------------------------------------------------------------------------------------------------------------
56337 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
56338
56339 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
56340 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
56341
56342 IF xla_accounting_cache_pkg.GetValueChar
56343 (p_source_code => 'LEDGER_CATEGORY_CODE'
56344 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
56345 AND l_bflow_method_code = 'PRIOR_ENTRY'
56346 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
56347 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
56348 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
56349 )
56350 THEN
56351 xla_ae_lines_pkg.BflowUpgEntry
56352 (p_business_method_code => l_bflow_method_code
56353 ,p_business_class_code => l_bflow_class_code
56354 ,p_balance_type => l_balance_type_code);
56355 ELSE
56356 NULL;
56357 -- No business flow processing for business flow method of NONE.
56358 END IF;
56359
56360 --
56361 -- call analytical criteria
56362 --
56363
56364 --
56365 -- call description
56366 --
56367 -- No description or it is inherited.
56368 --
56369 -- call ADRs
56370 -- Bug 4922099
56371 --
56372 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
56373 (NVL(l_actual_upg_option, 'N') = 'O') OR
56374 (NVL(l_enc_upg_option, 'N') = 'O')
56375 )
56379 --
56376 THEN
56377 NULL;
56378 --
56380
56381 l_ccid := AcctDerRule_11(
56382 p_application_id => p_application_id
56383 , p_ae_header_id => l_ae_header_id
56384 , p_source_10 => p_source_10
56385 , x_transaction_coa_id => l_adr_transaction_coa_id
56386 , x_accounting_coa_id => l_adr_accounting_coa_id
56387 , x_value_type_code => l_adr_value_type_code
56388 , p_side => 'NA'
56389 );
56390
56391 xla_ae_lines_pkg.set_ccid(
56392 p_code_combination_id => l_ccid
56393 , p_value_type_code => l_adr_value_type_code
56394 , p_transaction_coa_id => l_adr_transaction_coa_id
56395 , p_accounting_coa_id => l_adr_accounting_coa_id
56396 , p_adr_code => 'DIST_CCID'
56397 , p_adr_type_code => 'S'
56398 , p_component_type => l_component_type
56399 , p_component_code => l_component_code
56400 , p_component_type_code => l_component_type_code
56401 , p_component_appl_id => l_component_appl_id
56402 , p_amb_context_code => l_amb_context_code
56403 , p_side => 'NA'
56404 );
56405
56406
56407 --
56408 --
56409 END IF;
56410 --
56411 -- Bug 4922099
56412 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
56413 (NVL(l_enc_upg_option, 'N') = 'O')
56414 ) AND
56415 (l_bflow_method_code = 'PRIOR_ENTRY')
56416 )
56417 THEN
56418 IF
56419 --
56420 1 = 2
56421 --
56422 THEN
56423 xla_accounting_err_pkg.build_message
56424 (p_appli_s_name => 'XLA'
56425 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
56426 ,p_token_1 => 'LINE_NUMBER'
56427 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
56428 ,p_token_2 => 'LINE_TYPE_NAME'
56429 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
56430 l_component_type
56431 ,l_component_code
56432 ,l_component_type_code
56433 ,l_component_appl_id
56434 ,l_amb_context_code
56435 ,l_entity_code
56436 ,l_event_class_code
56437 )
56438 ,p_token_3 => 'OWNER'
56439 ,p_value_3 => xla_lookups_pkg.get_meaning(
56440 p_lookup_type => 'XLA_OWNER_TYPE'
56441 ,p_lookup_code => l_component_type_code
56442 )
56443 ,p_token_4 => 'PRODUCT_NAME'
56444 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
56445 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
56446 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
56447 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
56448 ,p_ae_header_id => NULL
56449 );
56450
56451 IF (C_LEVEL_ERROR>= g_log_level) THEN
56452 trace
56453 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
56454 ,p_level => C_LEVEL_ERROR
56455 ,p_module => l_log_module);
56456 END IF;
56457 END IF;
56458 END IF;
56459 --
56460 --
56461 ------------------------------------------------------------------------------------------------
56462 -- 4219869 Business Flow
56463 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
56464 -- Prior Entry. Currently, the following code is always generated.
56465 ------------------------------------------------------------------------------------------------
56466 XLA_AE_LINES_PKG.ValidateCurrentLine;
56467
56468 ------------------------------------------------------------------------------------
56469 -- 4219869 Business Flow
56470 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
56471 ------------------------------------------------------------------------------------
56472 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
56473
56474 ----------------------------------------------------------------------------------
56475 -- 4219869 Business Flow
56476 -- Update journal entry status -- Need to generate this within IF <condition>
56480 ,p_balance_type_code => l_balance_type_code
56477 ----------------------------------------------------------------------------------
56478 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
56479 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
56481 );
56482
56483 -------------------------------------------------------------------------------------------
56484 -- 4262811 - Generate the Accrual Reversal lines
56485 -------------------------------------------------------------------------------------------
56486 BEGIN
56487 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
56488 (g_array_event(p_event_id).array_value_num('header_index'));
56489 IF l_acc_rev_flag IS NULL THEN
56490 l_acc_rev_flag := 'N';
56491 END IF;
56492 EXCEPTION
56493 WHEN OTHERS THEN
56494 l_acc_rev_flag := 'N';
56495 END;
56496 --
56497 IF (l_acc_rev_flag = 'Y') THEN
56498
56499 -- 4645092 ------------------------------------------------------------------------------
56500 -- To allow MPA report to determine if it should generate report process
56501 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
56502 ------------------------------------------------------------------------------------------
56503
56504 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
56505 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
56506 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
56507 -- call ADRs
56508 -- Bug 4922099
56509 --
56510 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
56511 (NVL(l_actual_upg_option, 'N') = 'O') OR
56512 (NVL(l_enc_upg_option, 'N') = 'O')
56513 )
56514 THEN
56515 NULL;
56516 --
56517 --
56518
56519 l_ccid := AcctDerRule_11(
56520 p_application_id => p_application_id
56521 , p_ae_header_id => l_ae_header_id
56522 , p_source_10 => p_source_10
56523 , x_transaction_coa_id => l_adr_transaction_coa_id
56524 , x_accounting_coa_id => l_adr_accounting_coa_id
56525 , x_value_type_code => l_adr_value_type_code
56526 , p_side => 'NA'
56527 );
56528
56529 xla_ae_lines_pkg.set_ccid(
56530 p_code_combination_id => l_ccid
56531 , p_value_type_code => l_adr_value_type_code
56532 , p_transaction_coa_id => l_adr_transaction_coa_id
56533 , p_accounting_coa_id => l_adr_accounting_coa_id
56534 , p_adr_code => 'DIST_CCID'
56535 , p_adr_type_code => 'S'
56536 , p_component_type => l_component_type
56537 , p_component_code => l_component_code
56538 , p_component_type_code => l_component_type_code
56539 , p_component_appl_id => l_component_appl_id
56540 , p_amb_context_code => l_amb_context_code
56541 , p_side => 'NA'
56542 );
56543
56544
56545 --
56546 --
56547 END IF;
56548
56549 --
56550 -- Update the line information that should be overwritten
56551 --
56552 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
56553 p_header_num => 1);
56554 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
56555
56556 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
56557
56558 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
56559 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
56560 END IF;
56561
56562 --
56563 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
56564 --
56565 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
56566 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
56567 ELSE
56568 ---------------------------------------------------------------------------------------------------
56569 -- 4262811a Switch Sign
56570 ---------------------------------------------------------------------------------------------------
56571 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
56572 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
56573 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56574 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
56575 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56576 -- 5132302
56577 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
56578 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56579
56580 END IF;
56581
56582 -- 4955764
56583 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
56584 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
56585
56589
56586
56587 XLA_AE_LINES_PKG.ValidateCurrentLine;
56588 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
56590 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
56591 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
56592 ,p_balance_type_code => l_balance_type_code);
56593
56594 END IF;
56595
56596 -----------------------------------------------------------------------------------------
56597 -- 4262811 Multiperiod Accounting
56598 -----------------------------------------------------------------------------------------
56599 -- No MPA option is assigned.
56600
56601
56602 END IF;
56603 END IF;
56604 --
56605
56606 --
56607 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
56608 trace
56609 (p_msg => 'END of AcctLineType_119'
56610 ,p_level => C_LEVEL_PROCEDURE
56611 ,p_module => l_log_module);
56612 END IF;
56613 --
56614 EXCEPTION
56615 WHEN xla_exceptions_pkg.application_exception THEN
56616 RAISE;
56617 WHEN OTHERS THEN
56618 xla_exceptions_pkg.raise_message
56619 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_119');
56620 END AcctLineType_119;
56621 --
56622
56623 ---------------------------------------
56624 --
56625 -- PRIVATE FUNCTION
56626 -- AcctLineType_120
56627 --
56628 ---------------------------------------
56629 PROCEDURE AcctLineType_120 (
56630 p_application_id IN NUMBER
56631 ,p_event_id IN NUMBER
56632 ,p_calculate_acctd_flag IN VARCHAR2
56633 ,p_calculate_g_l_flag IN VARCHAR2
56634 ,p_actual_flag IN OUT VARCHAR2
56635 ,p_balance_type_code OUT VARCHAR2
56636 ,p_gain_or_loss_ref OUT VARCHAR2
56637
56638 --Distribution GL Account
56639 , p_source_10 IN NUMBER
56640 --Distribution Source Type
56641 , p_source_22 IN VARCHAR2
56642 --Distribution Line Identifier
56643 , p_source_24 IN NUMBER
56644 --Distribution Type
56645 , p_source_25 IN VARCHAR2
56646 --Entered Amount
56647 , p_source_26 IN NUMBER
56648 --Currency Code
56649 , p_source_27 IN VARCHAR2
56650 --Applied To Document Accounting Amount
56651 , p_source_31 IN NUMBER
56652 --Transaction Distribution Identifier
56653 , p_source_36 IN NUMBER
56654 --Transaction Distribution Type
56655 , p_source_37 IN VARCHAR2
56656 --Applied To Document Exchange Date
56657 , p_source_59 IN DATE
56658 --Receipt Applied To Application Identifier
56659 , p_source_60 IN NUMBER
56660 --Transaction Entity Code
56661 , p_source_61 IN VARCHAR2
56662 --Transaction Identifier
56663 , p_source_62 IN NUMBER
56664 --Applied To Document Exchange Rate
56665 , p_source_64 IN NUMBER
56666 --Distribution Party Identifier
56667 , p_source_65 IN NUMBER
56668 --Distribution Party Site Id
56669 , p_source_66 IN NUMBER
56670 --Distribution Party Type
56671 , p_source_67 IN VARCHAR2
56672 --Distribution Multi Fund Additional Entry
56673 , p_source_71 IN VARCHAR2
56674 --Applied To Document Exchange Rate Type
56675 , p_source_76 IN VARCHAR2
56676 )
56677 IS
56678
56679 l_component_type VARCHAR2(80);
56680 l_component_code VARCHAR2(30);
56681 l_component_type_code VARCHAR2(1);
56682 l_component_appl_id INTEGER;
56683 l_amb_context_code VARCHAR2(30);
56684 l_entity_code VARCHAR2(30);
56685 l_event_class_code VARCHAR2(30);
56686 l_ae_header_id NUMBER;
56687 l_event_type_code VARCHAR2(30);
56688 l_line_definition_code VARCHAR2(30);
56689 l_line_definition_owner_code VARCHAR2(1);
56690 --
56691 -- adr variables
56692 l_segment VARCHAR2(30);
56693 l_ccid NUMBER;
56694 l_adr_transaction_coa_id NUMBER;
56695 l_adr_accounting_coa_id NUMBER;
56696 l_adr_flexfield_segment_code VARCHAR2(30);
56697 l_adr_flex_value_set_id NUMBER;
56698 l_adr_value_type_code VARCHAR2(30);
56699 l_adr_value_combination_id NUMBER;
56700 l_adr_value_segment_code VARCHAR2(30);
56701
56702 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
56703 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
56704 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
56705 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
56706
56707 -- 4262811 Variables ------------------------------------------------------------------------------------------
56708 l_entered_amt_idx NUMBER;
56709 l_accted_amt_idx NUMBER;
56710 l_acc_rev_flag VARCHAR2(1);
56711 l_accrual_line_num NUMBER;
56712 l_tmp_amt NUMBER;
56713 l_acc_rev_natural_side_code VARCHAR2(1);
56714
56715 l_num_entries NUMBER;
56716 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
56717 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
56718 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
56719 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
56723 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
56720 l_recog_line_1 NUMBER;
56721 l_recog_line_2 NUMBER;
56722
56724 l_bflow_applied_to_amt NUMBER; -- 5132302
56725 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
56726
56727 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
56728
56729 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
56730 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
56731
56732 ---------------------------------------------------------------------------------------------------------------
56733
56734
56735 --
56736 -- bulk performance
56737 --
56738 l_balance_type_code VARCHAR2(1);
56739 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
56740 l_log_module VARCHAR2(240);
56741
56742 --
56743 -- Upgrade strategy
56744 --
56745 l_actual_upg_option VARCHAR2(1);
56746 l_enc_upg_option VARCHAR2(1);
56747
56748 --
56749 BEGIN
56750 --
56751 IF g_log_enabled THEN
56752 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_120';
56753 END IF;
56754 --
56755 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
56756
56757 trace
56758 (p_msg => 'BEGIN of AcctLineType_120'
56759 ,p_level => C_LEVEL_PROCEDURE
56760 ,p_module => l_log_module);
56761
56762 END IF;
56763 --
56764 l_component_type := 'AMB_JLT';
56765 l_component_code := 'RCT_DEFERRED_TAX';
56766 l_component_type_code := 'S';
56767 l_component_appl_id := 222;
56768 l_amb_context_code := 'DEFAULT';
56769 l_entity_code := 'RECEIPTS';
56770 l_event_class_code := 'RECEIPT';
56771 l_event_type_code := 'RECEIPT_ALL';
56772 l_line_definition_owner_code := 'S';
56773 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
56774 --
56775 l_balance_type_code := 'A';
56776 l_segment := NULL;
56777 l_ccid := NULL;
56778 l_adr_transaction_coa_id := NULL;
56779 l_adr_accounting_coa_id := NULL;
56780 l_adr_flexfield_segment_code := NULL;
56781 l_adr_flex_value_set_id := NULL;
56782 l_adr_value_type_code := NULL;
56783 l_adr_value_combination_id := NULL;
56784 l_adr_value_segment_code := NULL;
56785
56786 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
56787 l_bflow_class_code := ''; -- 4219869 Business Flow
56788 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
56789 l_budgetary_control_flag := 'N';
56790
56791 l_bflow_applied_to_amt_idx := NULL; -- 5132302
56792 l_bflow_applied_to_amt := NULL; -- 5132302
56793 l_entered_amt_idx := NULL; -- 4262811
56794 l_accted_amt_idx := NULL; -- 4262811
56795 l_acc_rev_flag := NULL; -- 4262811
56796 l_accrual_line_num := NULL; -- 4262811
56797 l_tmp_amt := NULL; -- 4262811
56798 --
56799
56800 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
56801 l_balance_type_code <> 'B' THEN
56802 IF NVL(p_source_22,'
56803 ') = 'DEFERRED_TAX' AND
56804 NVL(p_source_71,'
56805 ') = 'N'
56806 THEN
56807
56808 --
56809 XLA_AE_LINES_PKG.SetNewLine;
56810
56811 p_balance_type_code := l_balance_type_code;
56812 -- set the flag so later we will know whether the gain loss line needs to be created
56813
56814 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
56815 p_actual_flag :='A';
56816 END IF;
56817
56818 --
56819 -- bulk performance
56820 --
56821 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
56822 p_header_num => 0); -- 4262811
56823 --
56824 -- set accounting line options
56825 --
56826 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
56827 p_natural_side_code => 'C'
56828 , p_gain_or_loss_flag => 'N'
56829 , p_gl_transfer_mode_code => 'S'
56830 , p_acct_entry_type_code => 'A'
56831 , p_switch_side_flag => 'Y'
56832 , p_merge_duplicate_code => 'A'
56833 );
56834 --
56835 l_acc_rev_natural_side_code := 'D'; -- 4262811
56836 --
56837 --
56838 -- set accounting line type info
56839 --
56840 xla_ae_lines_pkg.SetAcctLineType
56841 (p_component_type => l_component_type
56842 ,p_event_type_code => l_event_type_code
56843 ,p_line_definition_owner_code => l_line_definition_owner_code
56844 ,p_line_definition_code => l_line_definition_code
56845 ,p_accounting_line_code => l_component_code
56846 ,p_accounting_line_type_code => l_component_type_code
56847 ,p_accounting_line_appl_id => l_component_appl_id
56848 ,p_amb_context_code => l_amb_context_code
56849 ,p_entity_code => l_entity_code
56850 ,p_event_class_code => l_event_class_code);
56851 --
56855 p_accounting_class_code => 'DEFERRED_TAX'
56852 -- set accounting class
56853 --
56854 xla_ae_lines_pkg.SetAcctClass(
56856 , p_ae_header_id => l_ae_header_id
56857 );
56858
56859 --
56860 -- set rounding class
56861 --
56862 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
56863 'RECEIVABLE';
56864
56865 --
56866 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
56867 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
56868 --
56869 -- bulk performance
56870 --
56871 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
56872
56873 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
56874 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
56875
56876 -- 4955764
56877 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
56878 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
56879
56880 -- 4458381 Public Sector Enh
56881
56882 --
56883 -- set accounting attributes for the line type
56884 --
56885 l_entered_amt_idx := 8;
56886 l_accted_amt_idx := 13;
56887 l_bflow_applied_to_amt_idx := NULL; -- 5132302
56888 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
56889 l_rec_acct_attrs.array_num_value(1) := p_source_60;
56890 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
56891 l_rec_acct_attrs.array_char_value(2) := p_source_37;
56892 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
56893 l_rec_acct_attrs.array_char_value(3) := p_source_61;
56894 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
56895 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
56896 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
56897 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
56898 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
56899 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
56900 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
56901 l_rec_acct_attrs.array_char_value(7) := p_source_25;
56902 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
56903 l_rec_acct_attrs.array_num_value(8) := p_source_26;
56904 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
56905 l_rec_acct_attrs.array_char_value(9) := p_source_27;
56906 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
56907 l_rec_acct_attrs.array_date_value(10) := p_source_59;
56908 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
56909 l_rec_acct_attrs.array_num_value(11) := p_source_64;
56910 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
56911 l_rec_acct_attrs.array_char_value(12) := p_source_76;
56912 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
56913 l_rec_acct_attrs.array_num_value(13) := p_source_31;
56914 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
56915 l_rec_acct_attrs.array_num_value(14) := p_source_65;
56916 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
56917 l_rec_acct_attrs.array_num_value(15) := p_source_66;
56918 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
56919 l_rec_acct_attrs.array_char_value(16) := p_source_67;
56920
56921 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
56922 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
56923
56924 ---------------------------------------------------------------------------------------------------------------
56925 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
56926 ---------------------------------------------------------------------------------------------------------------
56927 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
56928
56929 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
56930 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
56931
56932 IF xla_accounting_cache_pkg.GetValueChar
56933 (p_source_code => 'LEDGER_CATEGORY_CODE'
56934 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
56935 AND l_bflow_method_code = 'PRIOR_ENTRY'
56936 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
56937 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
56938 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
56939 )
56940 THEN
56941 xla_ae_lines_pkg.BflowUpgEntry
56942 (p_business_method_code => l_bflow_method_code
56943 ,p_business_class_code => l_bflow_class_code
56944 ,p_balance_type => l_balance_type_code);
56945 ELSE
56946 NULL;
56947 -- No business flow processing for business flow method of NONE.
56948 END IF;
56949
56950 --
56951 -- call analytical criteria
56952 --
56953
56954 --
56955 -- call description
56956 --
56957 -- No description or it is inherited.
56958 --
56959 -- call ADRs
56963 (NVL(l_actual_upg_option, 'N') = 'O') OR
56960 -- Bug 4922099
56961 --
56962 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
56964 (NVL(l_enc_upg_option, 'N') = 'O')
56965 )
56966 THEN
56967 NULL;
56968 --
56969 --
56970
56971 l_ccid := AcctDerRule_11(
56972 p_application_id => p_application_id
56973 , p_ae_header_id => l_ae_header_id
56974 , p_source_10 => p_source_10
56975 , x_transaction_coa_id => l_adr_transaction_coa_id
56976 , x_accounting_coa_id => l_adr_accounting_coa_id
56977 , x_value_type_code => l_adr_value_type_code
56978 , p_side => 'NA'
56979 );
56980
56981 xla_ae_lines_pkg.set_ccid(
56982 p_code_combination_id => l_ccid
56983 , p_value_type_code => l_adr_value_type_code
56984 , p_transaction_coa_id => l_adr_transaction_coa_id
56985 , p_accounting_coa_id => l_adr_accounting_coa_id
56986 , p_adr_code => 'DIST_CCID'
56987 , p_adr_type_code => 'S'
56988 , p_component_type => l_component_type
56989 , p_component_code => l_component_code
56990 , p_component_type_code => l_component_type_code
56991 , p_component_appl_id => l_component_appl_id
56992 , p_amb_context_code => l_amb_context_code
56993 , p_side => 'NA'
56994 );
56995
56996
56997 --
56998 --
56999 END IF;
57000 --
57001 -- Bug 4922099
57002 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
57003 (NVL(l_enc_upg_option, 'N') = 'O')
57004 ) AND
57005 (l_bflow_method_code = 'PRIOR_ENTRY')
57006 )
57007 THEN
57008 IF
57009 --
57010 1 = 2
57011 --
57012 THEN
57013 xla_accounting_err_pkg.build_message
57014 (p_appli_s_name => 'XLA'
57015 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
57016 ,p_token_1 => 'LINE_NUMBER'
57017 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
57018 ,p_token_2 => 'LINE_TYPE_NAME'
57019 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
57020 l_component_type
57021 ,l_component_code
57022 ,l_component_type_code
57023 ,l_component_appl_id
57024 ,l_amb_context_code
57025 ,l_entity_code
57026 ,l_event_class_code
57027 )
57028 ,p_token_3 => 'OWNER'
57029 ,p_value_3 => xla_lookups_pkg.get_meaning(
57030 p_lookup_type => 'XLA_OWNER_TYPE'
57031 ,p_lookup_code => l_component_type_code
57032 )
57033 ,p_token_4 => 'PRODUCT_NAME'
57034 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
57035 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
57036 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
57037 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
57038 ,p_ae_header_id => NULL
57039 );
57040
57041 IF (C_LEVEL_ERROR>= g_log_level) THEN
57042 trace
57043 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
57044 ,p_level => C_LEVEL_ERROR
57045 ,p_module => l_log_module);
57046 END IF;
57047 END IF;
57048 END IF;
57049 --
57050 --
57051 ------------------------------------------------------------------------------------------------
57052 -- 4219869 Business Flow
57053 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
57054 -- Prior Entry. Currently, the following code is always generated.
57055 ------------------------------------------------------------------------------------------------
57056 XLA_AE_LINES_PKG.ValidateCurrentLine;
57057
57058 ------------------------------------------------------------------------------------
57059 -- 4219869 Business Flow
57060 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
57061 ------------------------------------------------------------------------------------
57062 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
57066 -- Update journal entry status -- Need to generate this within IF <condition>
57063
57064 ----------------------------------------------------------------------------------
57065 -- 4219869 Business Flow
57067 ----------------------------------------------------------------------------------
57068 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
57069 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
57070 ,p_balance_type_code => l_balance_type_code
57071 );
57072
57073 -------------------------------------------------------------------------------------------
57074 -- 4262811 - Generate the Accrual Reversal lines
57075 -------------------------------------------------------------------------------------------
57076 BEGIN
57077 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
57078 (g_array_event(p_event_id).array_value_num('header_index'));
57079 IF l_acc_rev_flag IS NULL THEN
57080 l_acc_rev_flag := 'N';
57081 END IF;
57082 EXCEPTION
57083 WHEN OTHERS THEN
57084 l_acc_rev_flag := 'N';
57085 END;
57086 --
57087 IF (l_acc_rev_flag = 'Y') THEN
57088
57089 -- 4645092 ------------------------------------------------------------------------------
57090 -- To allow MPA report to determine if it should generate report process
57091 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
57092 ------------------------------------------------------------------------------------------
57093
57094 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
57095 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
57096 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
57097 -- call ADRs
57098 -- Bug 4922099
57099 --
57100 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
57101 (NVL(l_actual_upg_option, 'N') = 'O') OR
57102 (NVL(l_enc_upg_option, 'N') = 'O')
57103 )
57104 THEN
57105 NULL;
57106 --
57107 --
57108
57109 l_ccid := AcctDerRule_11(
57110 p_application_id => p_application_id
57111 , p_ae_header_id => l_ae_header_id
57112 , p_source_10 => p_source_10
57113 , x_transaction_coa_id => l_adr_transaction_coa_id
57114 , x_accounting_coa_id => l_adr_accounting_coa_id
57115 , x_value_type_code => l_adr_value_type_code
57116 , p_side => 'NA'
57117 );
57118
57119 xla_ae_lines_pkg.set_ccid(
57120 p_code_combination_id => l_ccid
57121 , p_value_type_code => l_adr_value_type_code
57122 , p_transaction_coa_id => l_adr_transaction_coa_id
57123 , p_accounting_coa_id => l_adr_accounting_coa_id
57124 , p_adr_code => 'DIST_CCID'
57125 , p_adr_type_code => 'S'
57126 , p_component_type => l_component_type
57127 , p_component_code => l_component_code
57128 , p_component_type_code => l_component_type_code
57129 , p_component_appl_id => l_component_appl_id
57130 , p_amb_context_code => l_amb_context_code
57131 , p_side => 'NA'
57132 );
57133
57134
57135 --
57136 --
57137 END IF;
57138
57139 --
57140 -- Update the line information that should be overwritten
57141 --
57142 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
57143 p_header_num => 1);
57144 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
57145
57146 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
57147
57148 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
57149 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
57150 END IF;
57151
57152 --
57153 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
57154 --
57155 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
57156 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
57157 ELSE
57158 ---------------------------------------------------------------------------------------------------
57159 -- 4262811a Switch Sign
57160 ---------------------------------------------------------------------------------------------------
57161 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
57162 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
57163 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57164 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
57165 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57166 -- 5132302
57167 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
57168 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57169
57170 END IF;
57171
57172 -- 4955764
57176
57173 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
57174 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
57175
57177 XLA_AE_LINES_PKG.ValidateCurrentLine;
57178 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
57179
57180 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
57181 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
57182 ,p_balance_type_code => l_balance_type_code);
57183
57184 END IF;
57185
57186 -----------------------------------------------------------------------------------------
57187 -- 4262811 Multiperiod Accounting
57188 -----------------------------------------------------------------------------------------
57189 -- No MPA option is assigned.
57190
57191
57192 END IF;
57193 END IF;
57194 --
57195
57196 --
57197 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57198 trace
57199 (p_msg => 'END of AcctLineType_120'
57200 ,p_level => C_LEVEL_PROCEDURE
57201 ,p_module => l_log_module);
57202 END IF;
57203 --
57204 EXCEPTION
57205 WHEN xla_exceptions_pkg.application_exception THEN
57206 RAISE;
57207 WHEN OTHERS THEN
57208 xla_exceptions_pkg.raise_message
57209 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_120');
57210 END AcctLineType_120;
57211 --
57212
57213 ---------------------------------------
57214 --
57215 -- PRIVATE FUNCTION
57216 -- AcctLineType_121
57217 --
57218 ---------------------------------------
57219 PROCEDURE AcctLineType_121 (
57220 p_application_id IN NUMBER
57221 ,p_event_id IN NUMBER
57222 ,p_calculate_acctd_flag IN VARCHAR2
57223 ,p_calculate_g_l_flag IN VARCHAR2
57224 ,p_actual_flag IN OUT VARCHAR2
57225 ,p_balance_type_code OUT VARCHAR2
57226 ,p_gain_or_loss_ref OUT VARCHAR2
57227
57228 --Remittance Bank Account Earned Account
57229 , p_source_4 IN NUMBER
57230 --Transaction Distribution GL Account
57231 , p_source_21 IN NUMBER
57232 --Distribution Source Type
57233 , p_source_22 IN VARCHAR2
57234 --Distribution Line Identifier
57235 , p_source_24 IN NUMBER
57236 --Distribution Type
57237 , p_source_25 IN VARCHAR2
57238 --Entered Amount
57239 , p_source_26 IN NUMBER
57240 --Currency Code
57241 , p_source_27 IN VARCHAR2
57242 --Applied To Document Accounting Amount
57243 , p_source_31 IN NUMBER
57244 --Transaction Distribution Identifier
57245 , p_source_36 IN NUMBER
57246 --Transaction Distribution Type
57247 , p_source_37 IN VARCHAR2
57248 --Applied To Document Exchange Date
57249 , p_source_59 IN DATE
57250 --Receipt Applied To Application Identifier
57251 , p_source_60 IN NUMBER
57252 --Transaction Entity Code
57253 , p_source_61 IN VARCHAR2
57254 --Transaction Identifier
57255 , p_source_62 IN NUMBER
57256 --Applied To Document Exchange Rate
57257 , p_source_64 IN NUMBER
57258 --Distribution Party Identifier
57259 , p_source_65 IN NUMBER
57260 --Distribution Party Site Id
57261 , p_source_66 IN NUMBER
57262 --Distribution Party Type
57263 , p_source_67 IN VARCHAR2
57264 --Distribution Multi Fund Additional Entry
57265 , p_source_71 IN VARCHAR2
57266 --Applied To Document Exchange Rate Type
57267 , p_source_76 IN VARCHAR2
57268 )
57269 IS
57270
57271 l_component_type VARCHAR2(80);
57272 l_component_code VARCHAR2(30);
57273 l_component_type_code VARCHAR2(1);
57274 l_component_appl_id INTEGER;
57275 l_amb_context_code VARCHAR2(30);
57276 l_entity_code VARCHAR2(30);
57277 l_event_class_code VARCHAR2(30);
57278 l_ae_header_id NUMBER;
57279 l_event_type_code VARCHAR2(30);
57280 l_line_definition_code VARCHAR2(30);
57281 l_line_definition_owner_code VARCHAR2(1);
57282 --
57283 -- adr variables
57284 l_segment VARCHAR2(30);
57285 l_ccid NUMBER;
57286 l_adr_transaction_coa_id NUMBER;
57287 l_adr_accounting_coa_id NUMBER;
57288 l_adr_flexfield_segment_code VARCHAR2(30);
57289 l_adr_flex_value_set_id NUMBER;
57290 l_adr_value_type_code VARCHAR2(30);
57291 l_adr_value_combination_id NUMBER;
57292 l_adr_value_segment_code VARCHAR2(30);
57293
57294 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
57295 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
57296 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
57297 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
57298
57299 -- 4262811 Variables ------------------------------------------------------------------------------------------
57300 l_entered_amt_idx NUMBER;
57301 l_accted_amt_idx NUMBER;
57302 l_acc_rev_flag VARCHAR2(1);
57303 l_accrual_line_num NUMBER;
57304 l_tmp_amt NUMBER;
57305 l_acc_rev_natural_side_code VARCHAR2(1);
57306
57307 l_num_entries NUMBER;
57311 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
57308 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
57309 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
57310 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
57312 l_recog_line_1 NUMBER;
57313 l_recog_line_2 NUMBER;
57314
57315 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
57316 l_bflow_applied_to_amt NUMBER; -- 5132302
57317 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
57318
57319 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
57320
57321 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
57322 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
57323
57324 ---------------------------------------------------------------------------------------------------------------
57325
57326
57327 --
57328 -- bulk performance
57329 --
57330 l_balance_type_code VARCHAR2(1);
57331 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
57332 l_log_module VARCHAR2(240);
57333
57334 --
57335 -- Upgrade strategy
57336 --
57337 l_actual_upg_option VARCHAR2(1);
57338 l_enc_upg_option VARCHAR2(1);
57339
57340 --
57341 BEGIN
57342 --
57343 IF g_log_enabled THEN
57344 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_121';
57345 END IF;
57346 --
57347 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57348
57349 trace
57350 (p_msg => 'BEGIN of AcctLineType_121'
57351 ,p_level => C_LEVEL_PROCEDURE
57352 ,p_module => l_log_module);
57353
57354 END IF;
57355 --
57356 l_component_type := 'AMB_JLT';
57357 l_component_code := 'RCT_EDISC';
57358 l_component_type_code := 'S';
57359 l_component_appl_id := 222;
57360 l_amb_context_code := 'DEFAULT';
57361 l_entity_code := 'RECEIPTS';
57362 l_event_class_code := 'RECEIPT';
57363 l_event_type_code := 'RECEIPT_ALL';
57364 l_line_definition_owner_code := 'S';
57365 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
57366 --
57367 l_balance_type_code := 'A';
57368 l_segment := NULL;
57369 l_ccid := NULL;
57370 l_adr_transaction_coa_id := NULL;
57371 l_adr_accounting_coa_id := NULL;
57372 l_adr_flexfield_segment_code := NULL;
57373 l_adr_flex_value_set_id := NULL;
57374 l_adr_value_type_code := NULL;
57375 l_adr_value_combination_id := NULL;
57376 l_adr_value_segment_code := NULL;
57377
57378 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
57379 l_bflow_class_code := ''; -- 4219869 Business Flow
57380 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
57381 l_budgetary_control_flag := 'N';
57382
57383 l_bflow_applied_to_amt_idx := NULL; -- 5132302
57384 l_bflow_applied_to_amt := NULL; -- 5132302
57385 l_entered_amt_idx := NULL; -- 4262811
57386 l_accted_amt_idx := NULL; -- 4262811
57387 l_acc_rev_flag := NULL; -- 4262811
57388 l_accrual_line_num := NULL; -- 4262811
57389 l_tmp_amt := NULL; -- 4262811
57390 --
57391
57392 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
57393 l_balance_type_code <> 'B' THEN
57394 IF NVL(p_source_22,'
57395 ') = 'EDISC' AND
57396 NVL(p_source_71,'
57397 ') = 'N'
57398 THEN
57399
57400 --
57401 XLA_AE_LINES_PKG.SetNewLine;
57402
57403 p_balance_type_code := l_balance_type_code;
57404 -- set the flag so later we will know whether the gain loss line needs to be created
57405
57406 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
57407 p_actual_flag :='A';
57408 END IF;
57409
57410 --
57411 -- bulk performance
57412 --
57413 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
57414 p_header_num => 0); -- 4262811
57415 --
57416 -- set accounting line options
57417 --
57418 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
57419 p_natural_side_code => 'C'
57420 , p_gain_or_loss_flag => 'N'
57421 , p_gl_transfer_mode_code => 'S'
57422 , p_acct_entry_type_code => 'A'
57423 , p_switch_side_flag => 'Y'
57424 , p_merge_duplicate_code => 'A'
57425 );
57426 --
57427 l_acc_rev_natural_side_code := 'D'; -- 4262811
57428 --
57429 --
57430 -- set accounting line type info
57431 --
57432 xla_ae_lines_pkg.SetAcctLineType
57433 (p_component_type => l_component_type
57434 ,p_event_type_code => l_event_type_code
57435 ,p_line_definition_owner_code => l_line_definition_owner_code
57436 ,p_line_definition_code => l_line_definition_code
57437 ,p_accounting_line_code => l_component_code
57438 ,p_accounting_line_type_code => l_component_type_code
57442 ,p_event_class_code => l_event_class_code);
57439 ,p_accounting_line_appl_id => l_component_appl_id
57440 ,p_amb_context_code => l_amb_context_code
57441 ,p_entity_code => l_entity_code
57443 --
57444 -- set accounting class
57445 --
57446 xla_ae_lines_pkg.SetAcctClass(
57447 p_accounting_class_code => 'EDISC'
57448 , p_ae_header_id => l_ae_header_id
57449 );
57450
57451 --
57452 -- set rounding class
57453 --
57454 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
57455 'RECEIVABLE';
57456
57457 --
57458 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
57459 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
57460 --
57461 -- bulk performance
57462 --
57463 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
57464
57465 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
57466 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
57467
57468 -- 4955764
57469 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
57470 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
57471
57472 -- 4458381 Public Sector Enh
57473
57474 --
57475 -- set accounting attributes for the line type
57476 --
57477 l_entered_amt_idx := 8;
57478 l_accted_amt_idx := 13;
57479 l_bflow_applied_to_amt_idx := NULL; -- 5132302
57480 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
57481 l_rec_acct_attrs.array_num_value(1) := p_source_60;
57482 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
57483 l_rec_acct_attrs.array_char_value(2) := p_source_37;
57484 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
57485 l_rec_acct_attrs.array_char_value(3) := p_source_61;
57486 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
57487 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
57488 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
57489 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
57490 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
57491 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
57492 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
57493 l_rec_acct_attrs.array_char_value(7) := p_source_25;
57494 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
57495 l_rec_acct_attrs.array_num_value(8) := p_source_26;
57496 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
57497 l_rec_acct_attrs.array_char_value(9) := p_source_27;
57498 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
57499 l_rec_acct_attrs.array_date_value(10) := p_source_59;
57500 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
57501 l_rec_acct_attrs.array_num_value(11) := p_source_64;
57502 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
57503 l_rec_acct_attrs.array_char_value(12) := p_source_76;
57504 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
57505 l_rec_acct_attrs.array_num_value(13) := p_source_31;
57506 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
57507 l_rec_acct_attrs.array_num_value(14) := p_source_65;
57508 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
57509 l_rec_acct_attrs.array_num_value(15) := p_source_66;
57510 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
57511 l_rec_acct_attrs.array_char_value(16) := p_source_67;
57512
57513 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
57514 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
57515
57516 ---------------------------------------------------------------------------------------------------------------
57517 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
57518 ---------------------------------------------------------------------------------------------------------------
57519 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
57520
57521 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
57522 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
57523
57524 IF xla_accounting_cache_pkg.GetValueChar
57525 (p_source_code => 'LEDGER_CATEGORY_CODE'
57526 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
57527 AND l_bflow_method_code = 'PRIOR_ENTRY'
57528 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
57529 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
57530 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
57531 )
57532 THEN
57533 xla_ae_lines_pkg.BflowUpgEntry
57534 (p_business_method_code => l_bflow_method_code
57535 ,p_business_class_code => l_bflow_class_code
57536 ,p_balance_type => l_balance_type_code);
57537 ELSE
57538 NULL;
57539 -- No business flow processing for business flow method of NONE.
57540 END IF;
57544 --
57541
57542 --
57543 -- call analytical criteria
57545
57546 --
57547 -- call description
57548 --
57549
57550 xla_ae_lines_pkg.SetLineDescription(
57551 p_ae_header_id => l_ae_header_id
57552 ,p_description => Description_1 (
57553 p_application_id => p_application_id
57554 , p_ae_header_id => l_ae_header_id
57555 )
57556 );
57557
57558
57559 --
57560 -- call ADRs
57561 -- Bug 4922099
57562 --
57563 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
57564 (NVL(l_actual_upg_option, 'N') = 'O') OR
57565 (NVL(l_enc_upg_option, 'N') = 'O')
57566 )
57567 THEN
57568 NULL;
57569 --
57570 --
57571
57572 l_ccid := AcctDerRule_34(
57573 p_application_id => p_application_id
57574 , p_ae_header_id => l_ae_header_id
57575 , p_source_21 => p_source_21
57576 , x_transaction_coa_id => l_adr_transaction_coa_id
57577 , x_accounting_coa_id => l_adr_accounting_coa_id
57578 , x_value_type_code => l_adr_value_type_code
57579 , p_side => 'NA'
57580 );
57581
57582 xla_ae_lines_pkg.set_ccid(
57583 p_code_combination_id => l_ccid
57584 , p_value_type_code => l_adr_value_type_code
57585 , p_transaction_coa_id => l_adr_transaction_coa_id
57586 , p_accounting_coa_id => l_adr_accounting_coa_id
57587 , p_adr_code => 'TRX_DIST_CCID'
57588 , p_adr_type_code => 'S'
57589 , p_component_type => l_component_type
57590 , p_component_code => l_component_code
57591 , p_component_type_code => l_component_type_code
57592 , p_component_appl_id => l_component_appl_id
57593 , p_amb_context_code => l_amb_context_code
57594 , p_side => 'NA'
57595 );
57596
57597
57598 l_segment := AcctDerRule_5(
57599 p_application_id => p_application_id
57600 , p_ae_header_id => l_ae_header_id
57601 , p_source_4 => p_source_4
57602 , x_transaction_coa_id => l_adr_transaction_coa_id
57603 , x_accounting_coa_id => l_adr_accounting_coa_id
57604 , x_flexfield_segment_code => l_adr_flexfield_segment_code
57605 , x_flex_value_set_id => l_adr_flex_value_set_id
57606 , x_value_type_code => l_adr_value_type_code
57607 , x_value_combination_id => l_adr_value_combination_id
57608 , x_value_segment_code => l_adr_value_segment_code
57609 , p_side => 'NA'
57610 , p_override_seg_flag => 'Y'
57611 );
57612
57613 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
57614
57615 xla_ae_lines_pkg.set_segment(
57616 p_to_segment_code => 'GL_ACCOUNT'
57617 , p_segment_value => l_segment
57618 , p_from_segment_code => l_adr_value_segment_code
57619 , p_from_combination_id => l_adr_value_combination_id
57620 , p_value_type_code => l_adr_value_type_code
57621 , p_transaction_coa_id => l_adr_transaction_coa_id
57622 , p_accounting_coa_id => l_adr_accounting_coa_id
57623 , p_flexfield_segment_code => l_adr_flexfield_segment_code
57624 , p_flex_value_set_id => l_adr_flex_value_set_id
57625 , p_adr_code => 'MFAR_RCT_EARNED_NATURAL_SEG'
57626 , p_adr_type_code => 'S'
57627 , p_component_type => l_component_type
57628 , p_component_code => l_component_code
57629 , p_component_type_code => l_component_type_code
57630 , p_component_appl_id => l_component_appl_id
57631 , p_amb_context_code => l_amb_context_code
57632 , p_entity_code => 'RECEIPTS'
57633 , p_event_class_code => 'RECEIPT'
57634 , p_side => 'NA'
57635 );
57636
57637 END IF;
57638
57639 --
57640 --
57641 END IF;
57642 --
57643 -- Bug 4922099
57644 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
57645 (NVL(l_enc_upg_option, 'N') = 'O')
57646 ) AND
57647 (l_bflow_method_code = 'PRIOR_ENTRY')
57648 )
57649 THEN
57650 IF
57651 --
57652 1 = 2
57653 --
57654 THEN
57655 xla_accounting_err_pkg.build_message
57656 (p_appli_s_name => 'XLA'
57657 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
57658 ,p_token_1 => 'LINE_NUMBER'
57659 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
57660 ,p_token_2 => 'LINE_TYPE_NAME'
57661 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
57662 l_component_type
57663 ,l_component_code
57664 ,l_component_type_code
57665 ,l_component_appl_id
57669 )
57666 ,l_amb_context_code
57667 ,l_entity_code
57668 ,l_event_class_code
57670 ,p_token_3 => 'OWNER'
57671 ,p_value_3 => xla_lookups_pkg.get_meaning(
57672 p_lookup_type => 'XLA_OWNER_TYPE'
57673 ,p_lookup_code => l_component_type_code
57674 )
57675 ,p_token_4 => 'PRODUCT_NAME'
57676 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
57677 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
57678 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
57679 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
57680 ,p_ae_header_id => NULL
57681 );
57682
57683 IF (C_LEVEL_ERROR>= g_log_level) THEN
57684 trace
57685 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
57686 ,p_level => C_LEVEL_ERROR
57687 ,p_module => l_log_module);
57688 END IF;
57689 END IF;
57690 END IF;
57691 --
57692 --
57693 ------------------------------------------------------------------------------------------------
57694 -- 4219869 Business Flow
57695 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
57696 -- Prior Entry. Currently, the following code is always generated.
57697 ------------------------------------------------------------------------------------------------
57698 XLA_AE_LINES_PKG.ValidateCurrentLine;
57699
57700 ------------------------------------------------------------------------------------
57701 -- 4219869 Business Flow
57702 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
57703 ------------------------------------------------------------------------------------
57704 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
57705
57706 ----------------------------------------------------------------------------------
57707 -- 4219869 Business Flow
57708 -- Update journal entry status -- Need to generate this within IF <condition>
57709 ----------------------------------------------------------------------------------
57710 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
57711 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
57712 ,p_balance_type_code => l_balance_type_code
57713 );
57714
57715 -------------------------------------------------------------------------------------------
57716 -- 4262811 - Generate the Accrual Reversal lines
57717 -------------------------------------------------------------------------------------------
57718 BEGIN
57719 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
57720 (g_array_event(p_event_id).array_value_num('header_index'));
57721 IF l_acc_rev_flag IS NULL THEN
57722 l_acc_rev_flag := 'N';
57723 END IF;
57724 EXCEPTION
57725 WHEN OTHERS THEN
57726 l_acc_rev_flag := 'N';
57727 END;
57728 --
57729 IF (l_acc_rev_flag = 'Y') THEN
57730
57731 -- 4645092 ------------------------------------------------------------------------------
57732 -- To allow MPA report to determine if it should generate report process
57733 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
57734 ------------------------------------------------------------------------------------------
57735
57736 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
57737 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
57738 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
57739 -- call ADRs
57740 -- Bug 4922099
57741 --
57742 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
57743 (NVL(l_actual_upg_option, 'N') = 'O') OR
57744 (NVL(l_enc_upg_option, 'N') = 'O')
57745 )
57746 THEN
57747 NULL;
57748 --
57749 --
57750
57751 l_ccid := AcctDerRule_34(
57752 p_application_id => p_application_id
57753 , p_ae_header_id => l_ae_header_id
57754 , p_source_21 => p_source_21
57755 , x_transaction_coa_id => l_adr_transaction_coa_id
57756 , x_accounting_coa_id => l_adr_accounting_coa_id
57757 , x_value_type_code => l_adr_value_type_code
57758 , p_side => 'NA'
57759 );
57760
57761 xla_ae_lines_pkg.set_ccid(
57762 p_code_combination_id => l_ccid
57763 , p_value_type_code => l_adr_value_type_code
57764 , p_transaction_coa_id => l_adr_transaction_coa_id
57765 , p_accounting_coa_id => l_adr_accounting_coa_id
57766 , p_adr_code => 'TRX_DIST_CCID'
57770 , p_component_type_code => l_component_type_code
57767 , p_adr_type_code => 'S'
57768 , p_component_type => l_component_type
57769 , p_component_code => l_component_code
57771 , p_component_appl_id => l_component_appl_id
57772 , p_amb_context_code => l_amb_context_code
57773 , p_side => 'NA'
57774 );
57775
57776
57777 l_segment := AcctDerRule_5(
57778 p_application_id => p_application_id
57779 , p_ae_header_id => l_ae_header_id
57780 , p_source_4 => p_source_4
57781 , x_transaction_coa_id => l_adr_transaction_coa_id
57782 , x_accounting_coa_id => l_adr_accounting_coa_id
57783 , x_flexfield_segment_code => l_adr_flexfield_segment_code
57784 , x_flex_value_set_id => l_adr_flex_value_set_id
57785 , x_value_type_code => l_adr_value_type_code
57786 , x_value_combination_id => l_adr_value_combination_id
57787 , x_value_segment_code => l_adr_value_segment_code
57788 , p_side => 'NA'
57789 , p_override_seg_flag => 'Y'
57790 );
57791
57792 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
57793
57794 xla_ae_lines_pkg.set_segment(
57795 p_to_segment_code => 'GL_ACCOUNT'
57796 , p_segment_value => l_segment
57797 , p_from_segment_code => l_adr_value_segment_code
57798 , p_from_combination_id => l_adr_value_combination_id
57799 , p_value_type_code => l_adr_value_type_code
57800 , p_transaction_coa_id => l_adr_transaction_coa_id
57801 , p_accounting_coa_id => l_adr_accounting_coa_id
57802 , p_flexfield_segment_code => l_adr_flexfield_segment_code
57803 , p_flex_value_set_id => l_adr_flex_value_set_id
57804 , p_adr_code => 'MFAR_RCT_EARNED_NATURAL_SEG'
57805 , p_adr_type_code => 'S'
57806 , p_component_type => l_component_type
57807 , p_component_code => l_component_code
57808 , p_component_type_code => l_component_type_code
57809 , p_component_appl_id => l_component_appl_id
57810 , p_amb_context_code => l_amb_context_code
57811 , p_entity_code => 'RECEIPTS'
57812 , p_event_class_code => 'RECEIPT'
57813 , p_side => 'NA'
57814 );
57815
57816 END IF;
57817
57818 --
57819 --
57820 END IF;
57821
57822 --
57823 -- Update the line information that should be overwritten
57824 --
57825 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
57826 p_header_num => 1);
57827 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
57828
57829 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
57830
57831 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
57832 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
57833 END IF;
57834
57835 --
57836 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
57837 --
57838 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
57839 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
57840 ELSE
57841 ---------------------------------------------------------------------------------------------------
57842 -- 4262811a Switch Sign
57843 ---------------------------------------------------------------------------------------------------
57844 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
57845 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
57846 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57847 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
57848 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57849 -- 5132302
57850 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
57851 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57852
57853 END IF;
57854
57855 -- 4955764
57856 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
57857 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
57858
57859
57860 XLA_AE_LINES_PKG.ValidateCurrentLine;
57861 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
57862
57863 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
57864 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
57865 ,p_balance_type_code => l_balance_type_code);
57866
57867 END IF;
57868
57869 -----------------------------------------------------------------------------------------
57870 -- 4262811 Multiperiod Accounting
57874
57871 -----------------------------------------------------------------------------------------
57872 -- No MPA option is assigned.
57873
57875 END IF;
57876 END IF;
57877 --
57878
57879 --
57880 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57881 trace
57882 (p_msg => 'END of AcctLineType_121'
57883 ,p_level => C_LEVEL_PROCEDURE
57884 ,p_module => l_log_module);
57885 END IF;
57886 --
57887 EXCEPTION
57888 WHEN xla_exceptions_pkg.application_exception THEN
57889 RAISE;
57890 WHEN OTHERS THEN
57891 xla_exceptions_pkg.raise_message
57892 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_121');
57893 END AcctLineType_121;
57894 --
57895
57896 ---------------------------------------
57897 --
57898 -- PRIVATE FUNCTION
57899 -- AcctLineType_122
57900 --
57901 ---------------------------------------
57902 PROCEDURE AcctLineType_122 (
57903 p_application_id IN NUMBER
57904 ,p_event_id IN NUMBER
57905 ,p_calculate_acctd_flag IN VARCHAR2
57906 ,p_calculate_g_l_flag IN VARCHAR2
57907 ,p_actual_flag IN OUT VARCHAR2
57908 ,p_balance_type_code OUT VARCHAR2
57909 ,p_gain_or_loss_ref OUT VARCHAR2
57910
57911 --Distribution GL Account
57912 , p_source_10 IN NUMBER
57913 --Distribution Source Type
57914 , p_source_22 IN VARCHAR2
57915 --Distribution Line Identifier
57916 , p_source_24 IN NUMBER
57917 --Distribution Type
57918 , p_source_25 IN VARCHAR2
57919 --Entered Amount
57920 , p_source_26 IN NUMBER
57921 --Exchange Date
57922 , p_source_28 IN DATE
57923 --Exchange Rate
57924 , p_source_29 IN NUMBER
57925 --Exchange Rate Type
57926 , p_source_30 IN VARCHAR2
57927 --Applied To Document Accounting Amount
57928 , p_source_31 IN NUMBER
57929 --Transaction Distribution Identifier
57930 , p_source_36 IN NUMBER
57931 --Transaction Distribution Type
57932 , p_source_37 IN VARCHAR2
57933 --Receipt Applied To Application Identifier
57934 , p_source_60 IN NUMBER
57935 --Transaction Entity Code
57936 , p_source_61 IN VARCHAR2
57937 --Transaction Identifier
57938 , p_source_62 IN NUMBER
57939 --Applying Document Currency Code
57940 , p_source_63 IN VARCHAR2
57941 --Distribution Party Identifier
57942 , p_source_65 IN NUMBER
57943 --Distribution Party Site Id
57944 , p_source_66 IN NUMBER
57945 --Distribution Party Type
57946 , p_source_67 IN VARCHAR2
57947 )
57948 IS
57949
57950 l_component_type VARCHAR2(80);
57951 l_component_code VARCHAR2(30);
57952 l_component_type_code VARCHAR2(1);
57953 l_component_appl_id INTEGER;
57954 l_amb_context_code VARCHAR2(30);
57955 l_entity_code VARCHAR2(30);
57956 l_event_class_code VARCHAR2(30);
57957 l_ae_header_id NUMBER;
57958 l_event_type_code VARCHAR2(30);
57959 l_line_definition_code VARCHAR2(30);
57960 l_line_definition_owner_code VARCHAR2(1);
57961 --
57962 -- adr variables
57963 l_segment VARCHAR2(30);
57964 l_ccid NUMBER;
57965 l_adr_transaction_coa_id NUMBER;
57966 l_adr_accounting_coa_id NUMBER;
57967 l_adr_flexfield_segment_code VARCHAR2(30);
57968 l_adr_flex_value_set_id NUMBER;
57969 l_adr_value_type_code VARCHAR2(30);
57970 l_adr_value_combination_id NUMBER;
57971 l_adr_value_segment_code VARCHAR2(30);
57972
57973 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
57974 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
57975 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
57976 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
57977
57978 -- 4262811 Variables ------------------------------------------------------------------------------------------
57979 l_entered_amt_idx NUMBER;
57980 l_accted_amt_idx NUMBER;
57981 l_acc_rev_flag VARCHAR2(1);
57982 l_accrual_line_num NUMBER;
57983 l_tmp_amt NUMBER;
57984 l_acc_rev_natural_side_code VARCHAR2(1);
57985
57986 l_num_entries NUMBER;
57987 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
57988 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
57989 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
57990 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
57991 l_recog_line_1 NUMBER;
57992 l_recog_line_2 NUMBER;
57993
57994 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
57995 l_bflow_applied_to_amt NUMBER; -- 5132302
57996 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
57997
57998 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
57999
58000 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
58001 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
58002
58006 --
58003 ---------------------------------------------------------------------------------------------------------------
58004
58005
58007 -- bulk performance
58008 --
58009 l_balance_type_code VARCHAR2(1);
58010 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
58011 l_log_module VARCHAR2(240);
58012
58013 --
58014 -- Upgrade strategy
58015 --
58016 l_actual_upg_option VARCHAR2(1);
58017 l_enc_upg_option VARCHAR2(1);
58018
58019 --
58020 BEGIN
58021 --
58022 IF g_log_enabled THEN
58023 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_122';
58024 END IF;
58025 --
58026 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
58027
58028 trace
58029 (p_msg => 'BEGIN of AcctLineType_122'
58030 ,p_level => C_LEVEL_PROCEDURE
58031 ,p_module => l_log_module);
58032
58033 END IF;
58034 --
58035 l_component_type := 'AMB_JLT';
58036 l_component_code := 'RCT_EXCH_GAIN';
58037 l_component_type_code := 'S';
58038 l_component_appl_id := 222;
58039 l_amb_context_code := 'DEFAULT';
58040 l_entity_code := 'RECEIPTS';
58041 l_event_class_code := 'RECEIPT';
58042 l_event_type_code := 'RECEIPT_ALL';
58043 l_line_definition_owner_code := 'S';
58044 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
58045 --
58046 l_balance_type_code := 'A';
58047 l_segment := NULL;
58048 l_ccid := NULL;
58049 l_adr_transaction_coa_id := NULL;
58050 l_adr_accounting_coa_id := NULL;
58051 l_adr_flexfield_segment_code := NULL;
58052 l_adr_flex_value_set_id := NULL;
58053 l_adr_value_type_code := NULL;
58054 l_adr_value_combination_id := NULL;
58055 l_adr_value_segment_code := NULL;
58056
58057 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
58058 l_bflow_class_code := ''; -- 4219869 Business Flow
58059 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
58060 l_budgetary_control_flag := 'N';
58061
58062 l_bflow_applied_to_amt_idx := NULL; -- 5132302
58063 l_bflow_applied_to_amt := NULL; -- 5132302
58064 l_entered_amt_idx := NULL; -- 4262811
58065 l_accted_amt_idx := NULL; -- 4262811
58066 l_acc_rev_flag := NULL; -- 4262811
58067 l_accrual_line_num := NULL; -- 4262811
58068 l_tmp_amt := NULL; -- 4262811
58069 --
58070 IF ((p_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
58071 (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')) THEN
58072 return;
58073 END IF;
58074
58075 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
58076 l_balance_type_code <> 'B' THEN
58077 IF NVL(p_source_22,'
58078 ') = 'EXCH_GAIN'
58079 THEN
58080
58081 --
58082 XLA_AE_LINES_PKG.SetNewLine;
58083
58084 p_balance_type_code := l_balance_type_code;
58085 -- set the flag so later we will know whether the gain loss line needs to be created
58086
58087 IF(l_balance_type_code = 'A' ) THEN
58088 p_actual_flag :='G';
58089 END IF;
58090
58091 --
58092 -- bulk performance
58093 --
58094 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
58095 p_header_num => 0); -- 4262811
58096 --
58097 -- set accounting line options
58098 --
58099 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
58100 p_natural_side_code => 'C'
58101 , p_gain_or_loss_flag => 'Y'
58102 , p_gl_transfer_mode_code => 'S'
58103 , p_acct_entry_type_code => 'A'
58104 , p_switch_side_flag => 'Y'
58105 , p_merge_duplicate_code => 'A'
58106 );
58107 --
58108 l_acc_rev_natural_side_code := 'D'; -- 4262811
58109 --
58110 --
58111 -- set accounting line type info
58112 --
58113 xla_ae_lines_pkg.SetAcctLineType
58114 (p_component_type => l_component_type
58115 ,p_event_type_code => l_event_type_code
58116 ,p_line_definition_owner_code => l_line_definition_owner_code
58117 ,p_line_definition_code => l_line_definition_code
58118 ,p_accounting_line_code => l_component_code
58119 ,p_accounting_line_type_code => l_component_type_code
58120 ,p_accounting_line_appl_id => l_component_appl_id
58121 ,p_amb_context_code => l_amb_context_code
58122 ,p_entity_code => l_entity_code
58123 ,p_event_class_code => l_event_class_code);
58124 --
58125 -- set accounting class
58126 --
58127 xla_ae_lines_pkg.SetAcctClass(
58128 p_accounting_class_code => 'GAIN'
58129 , p_ae_header_id => l_ae_header_id
58130 );
58131
58132 --
58133 -- set rounding class
58134 --
58135 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
58136 'RECEIVABLE';
58137
58138 --
58142 -- bulk performance
58139 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
58140 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
58141 --
58143 --
58144 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
58145
58146 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
58147 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
58148
58149 -- 4955764
58150 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
58151 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
58152
58153 -- 4458381 Public Sector Enh
58154
58155 --
58156 -- set accounting attributes for the line type
58157 --
58158 l_entered_amt_idx := 8;
58159 l_accted_amt_idx := 13;
58160 l_bflow_applied_to_amt_idx := NULL; -- 5132302
58161 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
58162 l_rec_acct_attrs.array_num_value(1) := p_source_60;
58163 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
58164 l_rec_acct_attrs.array_char_value(2) := p_source_37;
58165 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
58166 l_rec_acct_attrs.array_char_value(3) := p_source_61;
58167 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
58168 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
58169 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
58170 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
58171 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
58172 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
58173 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
58174 l_rec_acct_attrs.array_char_value(7) := p_source_25;
58175 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
58176 l_rec_acct_attrs.array_num_value(8) := p_source_26;
58177 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
58178 l_rec_acct_attrs.array_char_value(9) := p_source_63;
58179 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
58180 l_rec_acct_attrs.array_date_value(10) := p_source_28;
58181 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
58182 l_rec_acct_attrs.array_num_value(11) := p_source_29;
58183 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
58184 l_rec_acct_attrs.array_char_value(12) := p_source_30;
58185 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
58186 l_rec_acct_attrs.array_num_value(13) := p_source_31;
58187 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
58188 l_rec_acct_attrs.array_num_value(14) := p_source_65;
58189 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
58190 l_rec_acct_attrs.array_num_value(15) := p_source_66;
58191 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
58192 l_rec_acct_attrs.array_char_value(16) := p_source_67;
58193
58194 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
58195 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
58196
58197 ---------------------------------------------------------------------------------------------------------------
58198 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
58199 ---------------------------------------------------------------------------------------------------------------
58200 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
58201
58202 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
58203 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
58204
58205 IF xla_accounting_cache_pkg.GetValueChar
58206 (p_source_code => 'LEDGER_CATEGORY_CODE'
58207 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
58208 AND l_bflow_method_code = 'PRIOR_ENTRY'
58209 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
58210 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
58211 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
58212 )
58213 THEN
58214 xla_ae_lines_pkg.BflowUpgEntry
58215 (p_business_method_code => l_bflow_method_code
58216 ,p_business_class_code => l_bflow_class_code
58217 ,p_balance_type => l_balance_type_code);
58218 ELSE
58219 NULL;
58220 -- No business flow processing for business flow method of NONE.
58221 END IF;
58222
58223 --
58224 -- call analytical criteria
58225 --
58226
58227 --
58228 -- call description
58229 --
58230 -- No description or it is inherited.
58231 --
58232 -- call ADRs
58233 -- Bug 4922099
58234 --
58235 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
58236 (NVL(l_actual_upg_option, 'N') = 'O') OR
58237 (NVL(l_enc_upg_option, 'N') = 'O')
58238 )
58239 THEN
58240 NULL;
58241 --
58242 --
58243
58244 l_ccid := AcctDerRule_11(
58245 p_application_id => p_application_id
58246 , p_ae_header_id => l_ae_header_id
58250 , x_value_type_code => l_adr_value_type_code
58247 , p_source_10 => p_source_10
58248 , x_transaction_coa_id => l_adr_transaction_coa_id
58249 , x_accounting_coa_id => l_adr_accounting_coa_id
58251 , p_side => 'NA'
58252 );
58253
58254 xla_ae_lines_pkg.set_ccid(
58255 p_code_combination_id => l_ccid
58256 , p_value_type_code => l_adr_value_type_code
58257 , p_transaction_coa_id => l_adr_transaction_coa_id
58258 , p_accounting_coa_id => l_adr_accounting_coa_id
58259 , p_adr_code => 'DIST_CCID'
58260 , p_adr_type_code => 'S'
58261 , p_component_type => l_component_type
58262 , p_component_code => l_component_code
58263 , p_component_type_code => l_component_type_code
58264 , p_component_appl_id => l_component_appl_id
58265 , p_amb_context_code => l_amb_context_code
58266 , p_side => 'NA'
58267 );
58268
58269
58270 --
58271 --
58272 END IF;
58273 --
58274 -- Bug 4922099
58275 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
58276 (NVL(l_enc_upg_option, 'N') = 'O')
58277 ) AND
58278 (l_bflow_method_code = 'PRIOR_ENTRY')
58279 )
58280 THEN
58281 IF
58282 --
58283 1 = 2
58284 --
58285 THEN
58286 xla_accounting_err_pkg.build_message
58287 (p_appli_s_name => 'XLA'
58288 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
58289 ,p_token_1 => 'LINE_NUMBER'
58290 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
58291 ,p_token_2 => 'LINE_TYPE_NAME'
58292 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
58293 l_component_type
58294 ,l_component_code
58295 ,l_component_type_code
58296 ,l_component_appl_id
58297 ,l_amb_context_code
58298 ,l_entity_code
58299 ,l_event_class_code
58300 )
58301 ,p_token_3 => 'OWNER'
58302 ,p_value_3 => xla_lookups_pkg.get_meaning(
58303 p_lookup_type => 'XLA_OWNER_TYPE'
58304 ,p_lookup_code => l_component_type_code
58305 )
58306 ,p_token_4 => 'PRODUCT_NAME'
58307 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
58308 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
58309 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
58310 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
58311 ,p_ae_header_id => NULL
58312 );
58313
58314 IF (C_LEVEL_ERROR>= g_log_level) THEN
58315 trace
58316 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
58317 ,p_level => C_LEVEL_ERROR
58318 ,p_module => l_log_module);
58319 END IF;
58320 END IF;
58321 END IF;
58322 --
58323 --
58324 ------------------------------------------------------------------------------------------------
58325 -- 4219869 Business Flow
58326 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
58327 -- Prior Entry. Currently, the following code is always generated.
58328 ------------------------------------------------------------------------------------------------
58329 XLA_AE_LINES_PKG.ValidateCurrentLine;
58330
58331 ------------------------------------------------------------------------------------
58332 -- 4219869 Business Flow
58333 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
58334 ------------------------------------------------------------------------------------
58335 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
58336
58337 ----------------------------------------------------------------------------------
58338 -- 4219869 Business Flow
58339 -- Update journal entry status -- Need to generate this within IF <condition>
58340 ----------------------------------------------------------------------------------
58341 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
58342 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
58343 ,p_balance_type_code => l_balance_type_code
58347 -- 4262811 - Generate the Accrual Reversal lines
58344 );
58345
58346 -------------------------------------------------------------------------------------------
58348 -------------------------------------------------------------------------------------------
58349 BEGIN
58350 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
58351 (g_array_event(p_event_id).array_value_num('header_index'));
58352 IF l_acc_rev_flag IS NULL THEN
58353 l_acc_rev_flag := 'N';
58354 END IF;
58355 EXCEPTION
58356 WHEN OTHERS THEN
58357 l_acc_rev_flag := 'N';
58358 END;
58359 --
58360 IF (l_acc_rev_flag = 'Y') THEN
58361
58362 -- 4645092 ------------------------------------------------------------------------------
58363 -- To allow MPA report to determine if it should generate report process
58364 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
58365 ------------------------------------------------------------------------------------------
58366
58367 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
58368 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
58369 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
58370 -- call ADRs
58371 -- Bug 4922099
58372 --
58373 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
58374 (NVL(l_actual_upg_option, 'N') = 'O') OR
58375 (NVL(l_enc_upg_option, 'N') = 'O')
58376 )
58377 THEN
58378 NULL;
58379 --
58380 --
58381
58382 l_ccid := AcctDerRule_11(
58383 p_application_id => p_application_id
58384 , p_ae_header_id => l_ae_header_id
58385 , p_source_10 => p_source_10
58386 , x_transaction_coa_id => l_adr_transaction_coa_id
58387 , x_accounting_coa_id => l_adr_accounting_coa_id
58388 , x_value_type_code => l_adr_value_type_code
58389 , p_side => 'NA'
58390 );
58391
58392 xla_ae_lines_pkg.set_ccid(
58393 p_code_combination_id => l_ccid
58394 , p_value_type_code => l_adr_value_type_code
58395 , p_transaction_coa_id => l_adr_transaction_coa_id
58396 , p_accounting_coa_id => l_adr_accounting_coa_id
58397 , p_adr_code => 'DIST_CCID'
58398 , p_adr_type_code => 'S'
58399 , p_component_type => l_component_type
58400 , p_component_code => l_component_code
58401 , p_component_type_code => l_component_type_code
58402 , p_component_appl_id => l_component_appl_id
58403 , p_amb_context_code => l_amb_context_code
58404 , p_side => 'NA'
58405 );
58406
58407
58408 --
58409 --
58410 END IF;
58411
58412 --
58413 -- Update the line information that should be overwritten
58414 --
58415 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
58416 p_header_num => 1);
58417 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
58418
58419 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
58420
58421 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
58422 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
58423 END IF;
58424
58425 --
58426 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
58427 --
58428 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
58429 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
58430 ELSE
58431 ---------------------------------------------------------------------------------------------------
58432 -- 4262811a Switch Sign
58433 ---------------------------------------------------------------------------------------------------
58434 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
58435 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
58436 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58437 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
58438 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58439 -- 5132302
58440 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
58441 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58442
58443 END IF;
58444
58445 -- 4955764
58446 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
58447 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
58448
58449
58450 XLA_AE_LINES_PKG.ValidateCurrentLine;
58451 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
58452
58453 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
58457 END IF;
58454 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
58455 ,p_balance_type_code => l_balance_type_code);
58456
58458
58459 -----------------------------------------------------------------------------------------
58460 -- 4262811 Multiperiod Accounting
58461 -----------------------------------------------------------------------------------------
58462 -- No MPA option is assigned.
58463
58464
58465 END IF;
58466 END IF;
58467 --
58468
58469 --
58470 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
58471 trace
58472 (p_msg => 'END of AcctLineType_122'
58473 ,p_level => C_LEVEL_PROCEDURE
58474 ,p_module => l_log_module);
58475 END IF;
58476 --
58477 EXCEPTION
58478 WHEN xla_exceptions_pkg.application_exception THEN
58479 RAISE;
58480 WHEN OTHERS THEN
58481 xla_exceptions_pkg.raise_message
58482 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_122');
58483 END AcctLineType_122;
58484 --
58485
58486 ---------------------------------------
58487 --
58488 -- PRIVATE FUNCTION
58489 -- AcctLineType_123
58490 --
58491 ---------------------------------------
58492 PROCEDURE AcctLineType_123 (
58493 p_application_id IN NUMBER
58494 ,p_event_id IN NUMBER
58495 ,p_calculate_acctd_flag IN VARCHAR2
58496 ,p_calculate_g_l_flag IN VARCHAR2
58497 ,p_actual_flag IN OUT VARCHAR2
58498 ,p_balance_type_code OUT VARCHAR2
58499 ,p_gain_or_loss_ref OUT VARCHAR2
58500
58501 --Distribution GL Account
58502 , p_source_10 IN NUMBER
58503 --Distribution Source Type
58504 , p_source_22 IN VARCHAR2
58505 --Distribution Line Identifier
58506 , p_source_24 IN NUMBER
58507 --Distribution Type
58508 , p_source_25 IN VARCHAR2
58509 --Entered Amount
58510 , p_source_26 IN NUMBER
58511 --Exchange Date
58512 , p_source_28 IN DATE
58513 --Exchange Rate
58514 , p_source_29 IN NUMBER
58515 --Exchange Rate Type
58516 , p_source_30 IN VARCHAR2
58517 --Applied To Document Accounting Amount
58518 , p_source_31 IN NUMBER
58519 --Transaction Distribution Identifier
58520 , p_source_36 IN NUMBER
58521 --Transaction Distribution Type
58522 , p_source_37 IN VARCHAR2
58523 --Receipt Applied To Application Identifier
58524 , p_source_60 IN NUMBER
58525 --Transaction Entity Code
58526 , p_source_61 IN VARCHAR2
58527 --Transaction Identifier
58528 , p_source_62 IN NUMBER
58529 --Applying Document Currency Code
58530 , p_source_63 IN VARCHAR2
58531 --Distribution Party Identifier
58532 , p_source_65 IN NUMBER
58533 --Distribution Party Site Id
58534 , p_source_66 IN NUMBER
58535 --Distribution Party Type
58536 , p_source_67 IN VARCHAR2
58537 )
58538 IS
58539
58540 l_component_type VARCHAR2(80);
58541 l_component_code VARCHAR2(30);
58542 l_component_type_code VARCHAR2(1);
58543 l_component_appl_id INTEGER;
58544 l_amb_context_code VARCHAR2(30);
58545 l_entity_code VARCHAR2(30);
58546 l_event_class_code VARCHAR2(30);
58547 l_ae_header_id NUMBER;
58548 l_event_type_code VARCHAR2(30);
58549 l_line_definition_code VARCHAR2(30);
58550 l_line_definition_owner_code VARCHAR2(1);
58551 --
58552 -- adr variables
58553 l_segment VARCHAR2(30);
58554 l_ccid NUMBER;
58555 l_adr_transaction_coa_id NUMBER;
58556 l_adr_accounting_coa_id NUMBER;
58557 l_adr_flexfield_segment_code VARCHAR2(30);
58558 l_adr_flex_value_set_id NUMBER;
58559 l_adr_value_type_code VARCHAR2(30);
58560 l_adr_value_combination_id NUMBER;
58561 l_adr_value_segment_code VARCHAR2(30);
58562
58563 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
58564 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
58565 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
58566 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
58567
58568 -- 4262811 Variables ------------------------------------------------------------------------------------------
58569 l_entered_amt_idx NUMBER;
58570 l_accted_amt_idx NUMBER;
58571 l_acc_rev_flag VARCHAR2(1);
58572 l_accrual_line_num NUMBER;
58573 l_tmp_amt NUMBER;
58574 l_acc_rev_natural_side_code VARCHAR2(1);
58575
58576 l_num_entries NUMBER;
58577 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
58578 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
58579 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
58580 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
58581 l_recog_line_1 NUMBER;
58582 l_recog_line_2 NUMBER;
58583
58584 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
58585 l_bflow_applied_to_amt NUMBER; -- 5132302
58586 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
58587
58591 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
58588 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
58589
58590 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
58592
58593 ---------------------------------------------------------------------------------------------------------------
58594
58595
58596 --
58597 -- bulk performance
58598 --
58599 l_balance_type_code VARCHAR2(1);
58600 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
58601 l_log_module VARCHAR2(240);
58602
58603 --
58604 -- Upgrade strategy
58605 --
58606 l_actual_upg_option VARCHAR2(1);
58607 l_enc_upg_option VARCHAR2(1);
58608
58609 --
58610 BEGIN
58611 --
58612 IF g_log_enabled THEN
58613 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_123';
58614 END IF;
58615 --
58616 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
58617
58618 trace
58619 (p_msg => 'BEGIN of AcctLineType_123'
58620 ,p_level => C_LEVEL_PROCEDURE
58621 ,p_module => l_log_module);
58622
58623 END IF;
58624 --
58625 l_component_type := 'AMB_JLT';
58626 l_component_code := 'RCT_EXCH_LOSS';
58627 l_component_type_code := 'S';
58628 l_component_appl_id := 222;
58629 l_amb_context_code := 'DEFAULT';
58630 l_entity_code := 'RECEIPTS';
58631 l_event_class_code := 'RECEIPT';
58632 l_event_type_code := 'RECEIPT_ALL';
58633 l_line_definition_owner_code := 'S';
58634 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
58635 --
58636 l_balance_type_code := 'A';
58637 l_segment := NULL;
58638 l_ccid := NULL;
58639 l_adr_transaction_coa_id := NULL;
58640 l_adr_accounting_coa_id := NULL;
58641 l_adr_flexfield_segment_code := NULL;
58642 l_adr_flex_value_set_id := NULL;
58643 l_adr_value_type_code := NULL;
58644 l_adr_value_combination_id := NULL;
58645 l_adr_value_segment_code := NULL;
58646
58647 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
58648 l_bflow_class_code := ''; -- 4219869 Business Flow
58649 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
58650 l_budgetary_control_flag := 'N';
58651
58652 l_bflow_applied_to_amt_idx := NULL; -- 5132302
58653 l_bflow_applied_to_amt := NULL; -- 5132302
58654 l_entered_amt_idx := NULL; -- 4262811
58655 l_accted_amt_idx := NULL; -- 4262811
58656 l_acc_rev_flag := NULL; -- 4262811
58657 l_accrual_line_num := NULL; -- 4262811
58658 l_tmp_amt := NULL; -- 4262811
58659 --
58660 IF ((p_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
58661 (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')) THEN
58662 return;
58663 END IF;
58664
58665 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
58666 l_balance_type_code <> 'B' THEN
58667 IF NVL(p_source_22,'
58668 ') = 'EXCH_LOSS'
58669 THEN
58670
58671 --
58672 XLA_AE_LINES_PKG.SetNewLine;
58673
58674 p_balance_type_code := l_balance_type_code;
58675 -- set the flag so later we will know whether the gain loss line needs to be created
58676
58677 IF(l_balance_type_code = 'A' ) THEN
58678 p_actual_flag :='G';
58679 END IF;
58680
58681 --
58682 -- bulk performance
58683 --
58684 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
58685 p_header_num => 0); -- 4262811
58686 --
58687 -- set accounting line options
58688 --
58689 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
58690 p_natural_side_code => 'C'
58691 , p_gain_or_loss_flag => 'Y'
58692 , p_gl_transfer_mode_code => 'S'
58693 , p_acct_entry_type_code => 'A'
58694 , p_switch_side_flag => 'Y'
58695 , p_merge_duplicate_code => 'A'
58696 );
58697 --
58698 l_acc_rev_natural_side_code := 'D'; -- 4262811
58699 --
58700 --
58701 -- set accounting line type info
58702 --
58703 xla_ae_lines_pkg.SetAcctLineType
58704 (p_component_type => l_component_type
58705 ,p_event_type_code => l_event_type_code
58706 ,p_line_definition_owner_code => l_line_definition_owner_code
58707 ,p_line_definition_code => l_line_definition_code
58708 ,p_accounting_line_code => l_component_code
58709 ,p_accounting_line_type_code => l_component_type_code
58710 ,p_accounting_line_appl_id => l_component_appl_id
58711 ,p_amb_context_code => l_amb_context_code
58712 ,p_entity_code => l_entity_code
58713 ,p_event_class_code => l_event_class_code);
58714 --
58715 -- set accounting class
58716 --
58717 xla_ae_lines_pkg.SetAcctClass(
58718 p_accounting_class_code => 'LOSS'
58719 , p_ae_header_id => l_ae_header_id
58720 );
58724 --
58721
58722 --
58723 -- set rounding class
58725 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
58726 'RECEIVABLE';
58727
58728 --
58729 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
58730 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
58731 --
58732 -- bulk performance
58733 --
58734 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
58735
58736 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
58737 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
58738
58739 -- 4955764
58740 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
58741 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
58742
58743 -- 4458381 Public Sector Enh
58744
58745 --
58746 -- set accounting attributes for the line type
58747 --
58748 l_entered_amt_idx := 8;
58749 l_accted_amt_idx := 13;
58750 l_bflow_applied_to_amt_idx := NULL; -- 5132302
58751 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
58752 l_rec_acct_attrs.array_num_value(1) := p_source_60;
58753 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
58754 l_rec_acct_attrs.array_char_value(2) := p_source_37;
58755 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
58756 l_rec_acct_attrs.array_char_value(3) := p_source_61;
58757 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
58758 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
58759 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
58760 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
58761 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
58762 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
58763 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
58764 l_rec_acct_attrs.array_char_value(7) := p_source_25;
58765 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
58766 l_rec_acct_attrs.array_num_value(8) := p_source_26;
58767 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
58768 l_rec_acct_attrs.array_char_value(9) := p_source_63;
58769 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
58770 l_rec_acct_attrs.array_date_value(10) := p_source_28;
58771 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
58772 l_rec_acct_attrs.array_num_value(11) := p_source_29;
58773 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
58774 l_rec_acct_attrs.array_char_value(12) := p_source_30;
58775 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
58776 l_rec_acct_attrs.array_num_value(13) := p_source_31;
58777 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
58778 l_rec_acct_attrs.array_num_value(14) := p_source_65;
58779 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
58780 l_rec_acct_attrs.array_num_value(15) := p_source_66;
58781 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
58782 l_rec_acct_attrs.array_char_value(16) := p_source_67;
58783
58784 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
58785 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
58786
58787 ---------------------------------------------------------------------------------------------------------------
58788 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
58789 ---------------------------------------------------------------------------------------------------------------
58790 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
58791
58792 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
58793 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
58794
58795 IF xla_accounting_cache_pkg.GetValueChar
58796 (p_source_code => 'LEDGER_CATEGORY_CODE'
58797 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
58798 AND l_bflow_method_code = 'PRIOR_ENTRY'
58799 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
58800 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
58801 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
58802 )
58803 THEN
58804 xla_ae_lines_pkg.BflowUpgEntry
58805 (p_business_method_code => l_bflow_method_code
58806 ,p_business_class_code => l_bflow_class_code
58807 ,p_balance_type => l_balance_type_code);
58808 ELSE
58809 NULL;
58810 -- No business flow processing for business flow method of NONE.
58811 END IF;
58812
58813 --
58814 -- call analytical criteria
58815 --
58816
58817 --
58818 -- call description
58819 --
58820 -- No description or it is inherited.
58821 --
58822 -- call ADRs
58823 -- Bug 4922099
58824 --
58825 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
58826 (NVL(l_actual_upg_option, 'N') = 'O') OR
58827 (NVL(l_enc_upg_option, 'N') = 'O')
58831 --
58828 )
58829 THEN
58830 NULL;
58832 --
58833
58834 l_ccid := AcctDerRule_11(
58835 p_application_id => p_application_id
58836 , p_ae_header_id => l_ae_header_id
58837 , p_source_10 => p_source_10
58838 , x_transaction_coa_id => l_adr_transaction_coa_id
58839 , x_accounting_coa_id => l_adr_accounting_coa_id
58840 , x_value_type_code => l_adr_value_type_code
58841 , p_side => 'NA'
58842 );
58843
58844 xla_ae_lines_pkg.set_ccid(
58845 p_code_combination_id => l_ccid
58846 , p_value_type_code => l_adr_value_type_code
58847 , p_transaction_coa_id => l_adr_transaction_coa_id
58848 , p_accounting_coa_id => l_adr_accounting_coa_id
58849 , p_adr_code => 'DIST_CCID'
58850 , p_adr_type_code => 'S'
58851 , p_component_type => l_component_type
58852 , p_component_code => l_component_code
58853 , p_component_type_code => l_component_type_code
58854 , p_component_appl_id => l_component_appl_id
58855 , p_amb_context_code => l_amb_context_code
58856 , p_side => 'NA'
58857 );
58858
58859
58860 --
58861 --
58862 END IF;
58863 --
58864 -- Bug 4922099
58865 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
58866 (NVL(l_enc_upg_option, 'N') = 'O')
58867 ) AND
58868 (l_bflow_method_code = 'PRIOR_ENTRY')
58869 )
58870 THEN
58871 IF
58872 --
58873 1 = 2
58874 --
58875 THEN
58876 xla_accounting_err_pkg.build_message
58877 (p_appli_s_name => 'XLA'
58878 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
58879 ,p_token_1 => 'LINE_NUMBER'
58880 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
58881 ,p_token_2 => 'LINE_TYPE_NAME'
58882 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
58883 l_component_type
58884 ,l_component_code
58885 ,l_component_type_code
58886 ,l_component_appl_id
58887 ,l_amb_context_code
58888 ,l_entity_code
58889 ,l_event_class_code
58890 )
58891 ,p_token_3 => 'OWNER'
58892 ,p_value_3 => xla_lookups_pkg.get_meaning(
58893 p_lookup_type => 'XLA_OWNER_TYPE'
58894 ,p_lookup_code => l_component_type_code
58895 )
58896 ,p_token_4 => 'PRODUCT_NAME'
58897 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
58898 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
58899 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
58900 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
58901 ,p_ae_header_id => NULL
58902 );
58903
58904 IF (C_LEVEL_ERROR>= g_log_level) THEN
58905 trace
58906 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
58907 ,p_level => C_LEVEL_ERROR
58908 ,p_module => l_log_module);
58909 END IF;
58910 END IF;
58911 END IF;
58912 --
58913 --
58914 ------------------------------------------------------------------------------------------------
58915 -- 4219869 Business Flow
58916 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
58917 -- Prior Entry. Currently, the following code is always generated.
58918 ------------------------------------------------------------------------------------------------
58919 XLA_AE_LINES_PKG.ValidateCurrentLine;
58920
58921 ------------------------------------------------------------------------------------
58922 -- 4219869 Business Flow
58923 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
58924 ------------------------------------------------------------------------------------
58925 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
58926
58927 ----------------------------------------------------------------------------------
58928 -- 4219869 Business Flow
58932 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
58929 -- Update journal entry status -- Need to generate this within IF <condition>
58930 ----------------------------------------------------------------------------------
58931 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
58933 ,p_balance_type_code => l_balance_type_code
58934 );
58935
58936 -------------------------------------------------------------------------------------------
58937 -- 4262811 - Generate the Accrual Reversal lines
58938 -------------------------------------------------------------------------------------------
58939 BEGIN
58940 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
58941 (g_array_event(p_event_id).array_value_num('header_index'));
58942 IF l_acc_rev_flag IS NULL THEN
58943 l_acc_rev_flag := 'N';
58944 END IF;
58945 EXCEPTION
58946 WHEN OTHERS THEN
58947 l_acc_rev_flag := 'N';
58948 END;
58949 --
58950 IF (l_acc_rev_flag = 'Y') THEN
58951
58952 -- 4645092 ------------------------------------------------------------------------------
58953 -- To allow MPA report to determine if it should generate report process
58954 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
58955 ------------------------------------------------------------------------------------------
58956
58957 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
58958 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
58959 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
58960 -- call ADRs
58961 -- Bug 4922099
58962 --
58963 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
58964 (NVL(l_actual_upg_option, 'N') = 'O') OR
58965 (NVL(l_enc_upg_option, 'N') = 'O')
58966 )
58967 THEN
58968 NULL;
58969 --
58970 --
58971
58972 l_ccid := AcctDerRule_11(
58973 p_application_id => p_application_id
58974 , p_ae_header_id => l_ae_header_id
58975 , p_source_10 => p_source_10
58976 , x_transaction_coa_id => l_adr_transaction_coa_id
58977 , x_accounting_coa_id => l_adr_accounting_coa_id
58978 , x_value_type_code => l_adr_value_type_code
58979 , p_side => 'NA'
58980 );
58981
58982 xla_ae_lines_pkg.set_ccid(
58983 p_code_combination_id => l_ccid
58984 , p_value_type_code => l_adr_value_type_code
58985 , p_transaction_coa_id => l_adr_transaction_coa_id
58986 , p_accounting_coa_id => l_adr_accounting_coa_id
58987 , p_adr_code => 'DIST_CCID'
58988 , p_adr_type_code => 'S'
58989 , p_component_type => l_component_type
58990 , p_component_code => l_component_code
58991 , p_component_type_code => l_component_type_code
58992 , p_component_appl_id => l_component_appl_id
58993 , p_amb_context_code => l_amb_context_code
58994 , p_side => 'NA'
58995 );
58996
58997
58998 --
58999 --
59000 END IF;
59001
59002 --
59003 -- Update the line information that should be overwritten
59004 --
59005 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
59006 p_header_num => 1);
59007 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
59008
59009 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
59010
59011 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
59012 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
59013 END IF;
59014
59015 --
59016 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
59017 --
59018 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
59019 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
59020 ELSE
59021 ---------------------------------------------------------------------------------------------------
59022 -- 4262811a Switch Sign
59023 ---------------------------------------------------------------------------------------------------
59024 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
59025 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
59026 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59027 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
59028 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59029 -- 5132302
59030 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
59031 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59032
59033 END IF;
59034
59035 -- 4955764
59039
59036 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
59037 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
59038
59040 XLA_AE_LINES_PKG.ValidateCurrentLine;
59041 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
59042
59043 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
59044 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
59045 ,p_balance_type_code => l_balance_type_code);
59046
59047 END IF;
59048
59049 -----------------------------------------------------------------------------------------
59050 -- 4262811 Multiperiod Accounting
59051 -----------------------------------------------------------------------------------------
59052 -- No MPA option is assigned.
59053
59054
59055 END IF;
59056 END IF;
59057 --
59058
59059 --
59060 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59061 trace
59062 (p_msg => 'END of AcctLineType_123'
59063 ,p_level => C_LEVEL_PROCEDURE
59064 ,p_module => l_log_module);
59065 END IF;
59066 --
59067 EXCEPTION
59068 WHEN xla_exceptions_pkg.application_exception THEN
59069 RAISE;
59070 WHEN OTHERS THEN
59071 xla_exceptions_pkg.raise_message
59072 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_123');
59073 END AcctLineType_123;
59074 --
59075
59076 ---------------------------------------
59077 --
59078 -- PRIVATE FUNCTION
59079 -- AcctLineType_124
59080 --
59081 ---------------------------------------
59082 PROCEDURE AcctLineType_124 (
59083 p_application_id IN NUMBER
59084 ,p_event_id IN NUMBER
59085 ,p_calculate_acctd_flag IN VARCHAR2
59086 ,p_calculate_g_l_flag IN VARCHAR2
59087 ,p_actual_flag IN OUT VARCHAR2
59088 ,p_balance_type_code OUT VARCHAR2
59089 ,p_gain_or_loss_ref OUT VARCHAR2
59090
59091 --Distribution GL Account
59092 , p_source_10 IN NUMBER
59093 --Distribution Source Type
59094 , p_source_22 IN VARCHAR2
59095 --Distribution Line Identifier
59096 , p_source_24 IN NUMBER
59097 --Distribution Type
59098 , p_source_25 IN VARCHAR2
59099 --Exchange Date
59100 , p_source_28 IN DATE
59101 --Exchange Rate
59102 , p_source_29 IN NUMBER
59103 --Exchange Rate Type
59104 , p_source_30 IN VARCHAR2
59105 --Transaction Distribution Identifier
59106 , p_source_36 IN NUMBER
59107 --Transaction Distribution Type
59108 , p_source_37 IN VARCHAR2
59109 --Receipt Applied To Application Identifier
59110 , p_source_60 IN NUMBER
59111 --Transaction Entity Code
59112 , p_source_61 IN VARCHAR2
59113 --Transaction Identifier
59114 , p_source_62 IN NUMBER
59115 --Applying Document Currency Code
59116 , p_source_63 IN VARCHAR2
59117 --Distribution Party Identifier
59118 , p_source_65 IN NUMBER
59119 --Distribution Party Site Id
59120 , p_source_66 IN NUMBER
59121 --Distribution Party Type
59122 , p_source_67 IN VARCHAR2
59123 --Distribution Multi Fund Additional Entry
59124 , p_source_71 IN VARCHAR2
59125 --DIST_ENT_AMT_FROM
59126 , p_source_74 IN NUMBER
59127 --Accounting Amount
59128 , p_source_75 IN NUMBER
59129 --Distribution Source Table
59130 , p_source_77 IN VARCHAR2
59131 )
59132 IS
59133
59134 l_component_type VARCHAR2(80);
59135 l_component_code VARCHAR2(30);
59136 l_component_type_code VARCHAR2(1);
59137 l_component_appl_id INTEGER;
59138 l_amb_context_code VARCHAR2(30);
59139 l_entity_code VARCHAR2(30);
59140 l_event_class_code VARCHAR2(30);
59141 l_ae_header_id NUMBER;
59142 l_event_type_code VARCHAR2(30);
59143 l_line_definition_code VARCHAR2(30);
59144 l_line_definition_owner_code VARCHAR2(1);
59145 --
59146 -- adr variables
59147 l_segment VARCHAR2(30);
59148 l_ccid NUMBER;
59149 l_adr_transaction_coa_id NUMBER;
59150 l_adr_accounting_coa_id NUMBER;
59151 l_adr_flexfield_segment_code VARCHAR2(30);
59152 l_adr_flex_value_set_id NUMBER;
59153 l_adr_value_type_code VARCHAR2(30);
59154 l_adr_value_combination_id NUMBER;
59155 l_adr_value_segment_code VARCHAR2(30);
59156
59157 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
59158 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
59159 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
59160 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
59161
59162 -- 4262811 Variables ------------------------------------------------------------------------------------------
59163 l_entered_amt_idx NUMBER;
59164 l_accted_amt_idx NUMBER;
59165 l_acc_rev_flag VARCHAR2(1);
59166 l_accrual_line_num NUMBER;
59167 l_tmp_amt NUMBER;
59168 l_acc_rev_natural_side_code VARCHAR2(1);
59169
59170 l_num_entries NUMBER;
59171 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
59172 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
59176 l_recog_line_2 NUMBER;
59173 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
59174 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
59175 l_recog_line_1 NUMBER;
59177
59178 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
59179 l_bflow_applied_to_amt NUMBER; -- 5132302
59180 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
59181
59182 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
59183
59184 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
59185 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
59186
59187 ---------------------------------------------------------------------------------------------------------------
59188
59189
59190 --
59191 -- bulk performance
59192 --
59193 l_balance_type_code VARCHAR2(1);
59194 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
59195 l_log_module VARCHAR2(240);
59196
59197 --
59198 -- Upgrade strategy
59199 --
59200 l_actual_upg_option VARCHAR2(1);
59201 l_enc_upg_option VARCHAR2(1);
59202
59203 --
59204 BEGIN
59205 --
59206 IF g_log_enabled THEN
59207 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_124';
59208 END IF;
59209 --
59210 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59211
59212 trace
59213 (p_msg => 'BEGIN of AcctLineType_124'
59214 ,p_level => C_LEVEL_PROCEDURE
59215 ,p_module => l_log_module);
59216
59217 END IF;
59218 --
59219 l_component_type := 'AMB_JLT';
59220 l_component_code := 'RCT_FACTOR';
59221 l_component_type_code := 'S';
59222 l_component_appl_id := 222;
59223 l_amb_context_code := 'DEFAULT';
59224 l_entity_code := 'RECEIPTS';
59225 l_event_class_code := 'RECEIPT';
59226 l_event_type_code := 'RECEIPT_ALL';
59227 l_line_definition_owner_code := 'S';
59228 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
59229 --
59230 l_balance_type_code := 'A';
59231 l_segment := NULL;
59232 l_ccid := NULL;
59233 l_adr_transaction_coa_id := NULL;
59234 l_adr_accounting_coa_id := NULL;
59235 l_adr_flexfield_segment_code := NULL;
59236 l_adr_flex_value_set_id := NULL;
59237 l_adr_value_type_code := NULL;
59238 l_adr_value_combination_id := NULL;
59239 l_adr_value_segment_code := NULL;
59240
59241 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
59242 l_bflow_class_code := ''; -- 4219869 Business Flow
59243 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
59244 l_budgetary_control_flag := 'N';
59245
59246 l_bflow_applied_to_amt_idx := NULL; -- 5132302
59247 l_bflow_applied_to_amt := NULL; -- 5132302
59248 l_entered_amt_idx := NULL; -- 4262811
59249 l_accted_amt_idx := NULL; -- 4262811
59250 l_acc_rev_flag := NULL; -- 4262811
59251 l_accrual_line_num := NULL; -- 4262811
59252 l_tmp_amt := NULL; -- 4262811
59253 --
59254
59255 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
59256 l_balance_type_code <> 'B' THEN
59257 IF NVL(p_source_22,'
59258 ') = 'FACTOR' AND
59259 NVL(p_source_77,'
59260 ') = 'CRH' AND
59261 NVL(p_source_71,'
59262 ') = 'N'
59263 THEN
59264
59265 --
59266 XLA_AE_LINES_PKG.SetNewLine;
59267
59268 p_balance_type_code := l_balance_type_code;
59269 -- set the flag so later we will know whether the gain loss line needs to be created
59270
59271 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
59272 p_actual_flag :='A';
59273 END IF;
59274
59275 --
59276 -- bulk performance
59277 --
59278 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
59279 p_header_num => 0); -- 4262811
59280 --
59281 -- set accounting line options
59282 --
59283 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
59284 p_natural_side_code => 'C'
59285 , p_gain_or_loss_flag => 'N'
59286 , p_gl_transfer_mode_code => 'S'
59287 , p_acct_entry_type_code => 'A'
59288 , p_switch_side_flag => 'Y'
59289 , p_merge_duplicate_code => 'A'
59290 );
59291 --
59292 l_acc_rev_natural_side_code := 'D'; -- 4262811
59293 --
59294 --
59295 -- set accounting line type info
59296 --
59297 xla_ae_lines_pkg.SetAcctLineType
59298 (p_component_type => l_component_type
59299 ,p_event_type_code => l_event_type_code
59300 ,p_line_definition_owner_code => l_line_definition_owner_code
59301 ,p_line_definition_code => l_line_definition_code
59302 ,p_accounting_line_code => l_component_code
59303 ,p_accounting_line_type_code => l_component_type_code
59304 ,p_accounting_line_appl_id => l_component_appl_id
59305 ,p_amb_context_code => l_amb_context_code
59306 ,p_entity_code => l_entity_code
59310 --
59307 ,p_event_class_code => l_event_class_code);
59308 --
59309 -- set accounting class
59311 xla_ae_lines_pkg.SetAcctClass(
59312 p_accounting_class_code => 'FACTOR'
59313 , p_ae_header_id => l_ae_header_id
59314 );
59315
59316 --
59317 -- set rounding class
59318 --
59319 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
59320 'RECEIVABLE';
59321
59322 --
59323 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
59324 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
59325 --
59326 -- bulk performance
59327 --
59328 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
59329
59330 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
59331 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
59332
59333 -- 4955764
59334 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
59335 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
59336
59337 -- 4458381 Public Sector Enh
59338
59339 --
59340 -- set accounting attributes for the line type
59341 --
59342 l_entered_amt_idx := 8;
59343 l_accted_amt_idx := 13;
59344 l_bflow_applied_to_amt_idx := NULL; -- 5132302
59345 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
59346 l_rec_acct_attrs.array_num_value(1) := p_source_60;
59347 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
59348 l_rec_acct_attrs.array_char_value(2) := p_source_37;
59349 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
59350 l_rec_acct_attrs.array_char_value(3) := p_source_61;
59351 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
59352 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
59353 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
59354 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
59355 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
59356 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
59357 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
59358 l_rec_acct_attrs.array_char_value(7) := p_source_25;
59359 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
59360 l_rec_acct_attrs.array_num_value(8) := p_source_74;
59361 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
59362 l_rec_acct_attrs.array_char_value(9) := p_source_63;
59363 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
59364 l_rec_acct_attrs.array_date_value(10) := p_source_28;
59365 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
59366 l_rec_acct_attrs.array_num_value(11) := p_source_29;
59367 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
59368 l_rec_acct_attrs.array_char_value(12) := p_source_30;
59369 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
59370 l_rec_acct_attrs.array_num_value(13) := p_source_75;
59371 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
59372 l_rec_acct_attrs.array_num_value(14) := p_source_65;
59373 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
59374 l_rec_acct_attrs.array_num_value(15) := p_source_66;
59375 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
59376 l_rec_acct_attrs.array_char_value(16) := p_source_67;
59377
59378 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
59379 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
59380
59381 ---------------------------------------------------------------------------------------------------------------
59382 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
59383 ---------------------------------------------------------------------------------------------------------------
59384 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
59385
59386 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
59387 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
59388
59389 IF xla_accounting_cache_pkg.GetValueChar
59390 (p_source_code => 'LEDGER_CATEGORY_CODE'
59391 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
59392 AND l_bflow_method_code = 'PRIOR_ENTRY'
59393 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
59394 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
59395 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
59396 )
59397 THEN
59398 xla_ae_lines_pkg.BflowUpgEntry
59399 (p_business_method_code => l_bflow_method_code
59400 ,p_business_class_code => l_bflow_class_code
59401 ,p_balance_type => l_balance_type_code);
59402 ELSE
59403 NULL;
59404 -- No business flow processing for business flow method of NONE.
59405 END IF;
59406
59407 --
59408 -- call analytical criteria
59409 --
59410
59411 --
59412 -- call description
59413 --
59417 -- Bug 4922099
59414 -- No description or it is inherited.
59415 --
59416 -- call ADRs
59418 --
59419 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
59420 (NVL(l_actual_upg_option, 'N') = 'O') OR
59421 (NVL(l_enc_upg_option, 'N') = 'O')
59422 )
59423 THEN
59424 NULL;
59425 --
59426 --
59427
59428 l_ccid := AcctDerRule_11(
59429 p_application_id => p_application_id
59430 , p_ae_header_id => l_ae_header_id
59431 , p_source_10 => p_source_10
59432 , x_transaction_coa_id => l_adr_transaction_coa_id
59433 , x_accounting_coa_id => l_adr_accounting_coa_id
59434 , x_value_type_code => l_adr_value_type_code
59435 , p_side => 'NA'
59436 );
59437
59438 xla_ae_lines_pkg.set_ccid(
59439 p_code_combination_id => l_ccid
59440 , p_value_type_code => l_adr_value_type_code
59441 , p_transaction_coa_id => l_adr_transaction_coa_id
59442 , p_accounting_coa_id => l_adr_accounting_coa_id
59443 , p_adr_code => 'DIST_CCID'
59444 , p_adr_type_code => 'S'
59445 , p_component_type => l_component_type
59446 , p_component_code => l_component_code
59447 , p_component_type_code => l_component_type_code
59448 , p_component_appl_id => l_component_appl_id
59449 , p_amb_context_code => l_amb_context_code
59450 , p_side => 'NA'
59451 );
59452
59453
59454 --
59455 --
59456 END IF;
59457 --
59458 -- Bug 4922099
59459 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
59460 (NVL(l_enc_upg_option, 'N') = 'O')
59461 ) AND
59462 (l_bflow_method_code = 'PRIOR_ENTRY')
59463 )
59464 THEN
59465 IF
59466 --
59467 1 = 2
59468 --
59469 THEN
59470 xla_accounting_err_pkg.build_message
59471 (p_appli_s_name => 'XLA'
59472 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
59473 ,p_token_1 => 'LINE_NUMBER'
59474 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
59475 ,p_token_2 => 'LINE_TYPE_NAME'
59476 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
59477 l_component_type
59478 ,l_component_code
59479 ,l_component_type_code
59480 ,l_component_appl_id
59481 ,l_amb_context_code
59482 ,l_entity_code
59483 ,l_event_class_code
59484 )
59485 ,p_token_3 => 'OWNER'
59486 ,p_value_3 => xla_lookups_pkg.get_meaning(
59487 p_lookup_type => 'XLA_OWNER_TYPE'
59488 ,p_lookup_code => l_component_type_code
59489 )
59490 ,p_token_4 => 'PRODUCT_NAME'
59491 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
59492 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
59493 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
59494 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
59495 ,p_ae_header_id => NULL
59496 );
59497
59498 IF (C_LEVEL_ERROR>= g_log_level) THEN
59499 trace
59500 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
59501 ,p_level => C_LEVEL_ERROR
59502 ,p_module => l_log_module);
59503 END IF;
59504 END IF;
59505 END IF;
59506 --
59507 --
59508 ------------------------------------------------------------------------------------------------
59509 -- 4219869 Business Flow
59510 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
59511 -- Prior Entry. Currently, the following code is always generated.
59512 ------------------------------------------------------------------------------------------------
59513 XLA_AE_LINES_PKG.ValidateCurrentLine;
59514
59515 ------------------------------------------------------------------------------------
59516 -- 4219869 Business Flow
59517 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
59521 ----------------------------------------------------------------------------------
59518 ------------------------------------------------------------------------------------
59519 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
59520
59522 -- 4219869 Business Flow
59523 -- Update journal entry status -- Need to generate this within IF <condition>
59524 ----------------------------------------------------------------------------------
59525 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
59526 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
59527 ,p_balance_type_code => l_balance_type_code
59528 );
59529
59530 -------------------------------------------------------------------------------------------
59531 -- 4262811 - Generate the Accrual Reversal lines
59532 -------------------------------------------------------------------------------------------
59533 BEGIN
59534 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
59535 (g_array_event(p_event_id).array_value_num('header_index'));
59536 IF l_acc_rev_flag IS NULL THEN
59537 l_acc_rev_flag := 'N';
59538 END IF;
59539 EXCEPTION
59540 WHEN OTHERS THEN
59541 l_acc_rev_flag := 'N';
59542 END;
59543 --
59544 IF (l_acc_rev_flag = 'Y') THEN
59545
59546 -- 4645092 ------------------------------------------------------------------------------
59547 -- To allow MPA report to determine if it should generate report process
59548 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
59549 ------------------------------------------------------------------------------------------
59550
59551 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
59552 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
59553 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
59554 -- call ADRs
59555 -- Bug 4922099
59556 --
59557 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
59558 (NVL(l_actual_upg_option, 'N') = 'O') OR
59559 (NVL(l_enc_upg_option, 'N') = 'O')
59560 )
59561 THEN
59562 NULL;
59563 --
59564 --
59565
59566 l_ccid := AcctDerRule_11(
59567 p_application_id => p_application_id
59568 , p_ae_header_id => l_ae_header_id
59569 , p_source_10 => p_source_10
59570 , x_transaction_coa_id => l_adr_transaction_coa_id
59571 , x_accounting_coa_id => l_adr_accounting_coa_id
59572 , x_value_type_code => l_adr_value_type_code
59573 , p_side => 'NA'
59574 );
59575
59576 xla_ae_lines_pkg.set_ccid(
59577 p_code_combination_id => l_ccid
59578 , p_value_type_code => l_adr_value_type_code
59579 , p_transaction_coa_id => l_adr_transaction_coa_id
59580 , p_accounting_coa_id => l_adr_accounting_coa_id
59581 , p_adr_code => 'DIST_CCID'
59582 , p_adr_type_code => 'S'
59583 , p_component_type => l_component_type
59584 , p_component_code => l_component_code
59585 , p_component_type_code => l_component_type_code
59586 , p_component_appl_id => l_component_appl_id
59587 , p_amb_context_code => l_amb_context_code
59588 , p_side => 'NA'
59589 );
59590
59591
59592 --
59593 --
59594 END IF;
59595
59596 --
59597 -- Update the line information that should be overwritten
59598 --
59599 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
59600 p_header_num => 1);
59601 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
59602
59603 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
59604
59605 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
59606 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
59607 END IF;
59608
59609 --
59610 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
59611 --
59612 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
59613 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
59614 ELSE
59615 ---------------------------------------------------------------------------------------------------
59616 -- 4262811a Switch Sign
59617 ---------------------------------------------------------------------------------------------------
59618 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
59619 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
59620 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59621 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
59622 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59623 -- 5132302
59624 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
59628
59625 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59626
59627 END IF;
59629 -- 4955764
59630 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
59631 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
59632
59633
59634 XLA_AE_LINES_PKG.ValidateCurrentLine;
59635 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
59636
59637 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
59638 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
59639 ,p_balance_type_code => l_balance_type_code);
59640
59641 END IF;
59642
59643 -----------------------------------------------------------------------------------------
59644 -- 4262811 Multiperiod Accounting
59645 -----------------------------------------------------------------------------------------
59646 -- No MPA option is assigned.
59647
59648
59649 END IF;
59650 END IF;
59651 --
59652
59653 --
59654 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59655 trace
59656 (p_msg => 'END of AcctLineType_124'
59657 ,p_level => C_LEVEL_PROCEDURE
59658 ,p_module => l_log_module);
59659 END IF;
59660 --
59661 EXCEPTION
59662 WHEN xla_exceptions_pkg.application_exception THEN
59663 RAISE;
59664 WHEN OTHERS THEN
59665 xla_exceptions_pkg.raise_message
59666 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_124');
59667 END AcctLineType_124;
59668 --
59669
59670 ---------------------------------------
59671 --
59672 -- PRIVATE FUNCTION
59673 -- AcctLineType_125
59674 --
59675 ---------------------------------------
59676 PROCEDURE AcctLineType_125 (
59677 p_application_id IN NUMBER
59678 ,p_event_id IN NUMBER
59679 ,p_calculate_acctd_flag IN VARCHAR2
59680 ,p_calculate_g_l_flag IN VARCHAR2
59681 ,p_actual_flag IN OUT VARCHAR2
59682 ,p_balance_type_code OUT VARCHAR2
59683 ,p_gain_or_loss_ref OUT VARCHAR2
59684
59685 --Distribution GL Account
59686 , p_source_10 IN NUMBER
59687 --Distribution Source Type
59688 , p_source_22 IN VARCHAR2
59689 --Distribution Line Identifier
59690 , p_source_24 IN NUMBER
59691 --Distribution Type
59692 , p_source_25 IN VARCHAR2
59693 --Exchange Date
59694 , p_source_28 IN DATE
59695 --Exchange Rate
59696 , p_source_29 IN NUMBER
59697 --Exchange Rate Type
59698 , p_source_30 IN VARCHAR2
59699 --Transaction Distribution Identifier
59700 , p_source_36 IN NUMBER
59701 --Transaction Distribution Type
59702 , p_source_37 IN VARCHAR2
59703 --Receipt Applied To Application Identifier
59704 , p_source_60 IN NUMBER
59705 --Transaction Entity Code
59706 , p_source_61 IN VARCHAR2
59707 --Transaction Identifier
59708 , p_source_62 IN NUMBER
59709 --Applying Document Currency Code
59710 , p_source_63 IN VARCHAR2
59711 --Distribution Party Identifier
59712 , p_source_65 IN NUMBER
59713 --Distribution Party Site Id
59714 , p_source_66 IN NUMBER
59715 --Distribution Party Type
59716 , p_source_67 IN VARCHAR2
59717 --Distribution Multi Fund Additional Entry
59718 , p_source_71 IN VARCHAR2
59719 --DIST_ENT_AMT_FROM
59720 , p_source_74 IN NUMBER
59721 --Accounting Amount
59722 , p_source_75 IN NUMBER
59723 --Distribution Source Table
59724 , p_source_77 IN VARCHAR2
59725 )
59726 IS
59727
59728 l_component_type VARCHAR2(80);
59729 l_component_code VARCHAR2(30);
59730 l_component_type_code VARCHAR2(1);
59731 l_component_appl_id INTEGER;
59732 l_amb_context_code VARCHAR2(30);
59733 l_entity_code VARCHAR2(30);
59734 l_event_class_code VARCHAR2(30);
59735 l_ae_header_id NUMBER;
59736 l_event_type_code VARCHAR2(30);
59737 l_line_definition_code VARCHAR2(30);
59738 l_line_definition_owner_code VARCHAR2(1);
59739 --
59740 -- adr variables
59741 l_segment VARCHAR2(30);
59742 l_ccid NUMBER;
59743 l_adr_transaction_coa_id NUMBER;
59744 l_adr_accounting_coa_id NUMBER;
59745 l_adr_flexfield_segment_code VARCHAR2(30);
59746 l_adr_flex_value_set_id NUMBER;
59747 l_adr_value_type_code VARCHAR2(30);
59748 l_adr_value_combination_id NUMBER;
59749 l_adr_value_segment_code VARCHAR2(30);
59750
59751 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
59752 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
59753 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
59754 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
59755
59756 -- 4262811 Variables ------------------------------------------------------------------------------------------
59757 l_entered_amt_idx NUMBER;
59758 l_accted_amt_idx NUMBER;
59759 l_acc_rev_flag VARCHAR2(1);
59760 l_accrual_line_num NUMBER;
59761 l_tmp_amt NUMBER;
59762 l_acc_rev_natural_side_code VARCHAR2(1);
59763
59764 l_num_entries NUMBER;
59768 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
59765 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
59766 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
59767 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
59769 l_recog_line_1 NUMBER;
59770 l_recog_line_2 NUMBER;
59771
59772 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
59773 l_bflow_applied_to_amt NUMBER; -- 5132302
59774 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
59775
59776 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
59777
59778 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
59779 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
59780
59781 ---------------------------------------------------------------------------------------------------------------
59782
59783
59784 --
59785 -- bulk performance
59786 --
59787 l_balance_type_code VARCHAR2(1);
59788 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
59789 l_log_module VARCHAR2(240);
59790
59791 --
59792 -- Upgrade strategy
59793 --
59794 l_actual_upg_option VARCHAR2(1);
59795 l_enc_upg_option VARCHAR2(1);
59796
59797 --
59798 BEGIN
59799 --
59800 IF g_log_enabled THEN
59801 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_125';
59802 END IF;
59803 --
59804 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59805
59806 trace
59807 (p_msg => 'BEGIN of AcctLineType_125'
59808 ,p_level => C_LEVEL_PROCEDURE
59809 ,p_module => l_log_module);
59810
59811 END IF;
59812 --
59813 l_component_type := 'AMB_JLT';
59814 l_component_code := 'RCT_FACTOR_BR';
59815 l_component_type_code := 'S';
59816 l_component_appl_id := 222;
59817 l_amb_context_code := 'DEFAULT';
59818 l_entity_code := 'RECEIPTS';
59819 l_event_class_code := 'RECEIPT';
59820 l_event_type_code := 'RECEIPT_ALL';
59821 l_line_definition_owner_code := 'S';
59822 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
59823 --
59824 l_balance_type_code := 'A';
59825 l_segment := NULL;
59826 l_ccid := NULL;
59827 l_adr_transaction_coa_id := NULL;
59828 l_adr_accounting_coa_id := NULL;
59829 l_adr_flexfield_segment_code := NULL;
59830 l_adr_flex_value_set_id := NULL;
59831 l_adr_value_type_code := NULL;
59832 l_adr_value_combination_id := NULL;
59833 l_adr_value_segment_code := NULL;
59834
59835 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
59836 l_bflow_class_code := ''; -- 4219869 Business Flow
59837 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
59838 l_budgetary_control_flag := 'N';
59839
59840 l_bflow_applied_to_amt_idx := NULL; -- 5132302
59841 l_bflow_applied_to_amt := NULL; -- 5132302
59842 l_entered_amt_idx := NULL; -- 4262811
59843 l_accted_amt_idx := NULL; -- 4262811
59844 l_acc_rev_flag := NULL; -- 4262811
59845 l_accrual_line_num := NULL; -- 4262811
59846 l_tmp_amt := NULL; -- 4262811
59847 --
59848
59849 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
59850 l_balance_type_code <> 'B' THEN
59851 IF NVL(p_source_22,'
59852 ') = 'FACTOR' AND
59853 NVL(p_source_77,'
59854 ') = 'RA' AND
59855 NVL(p_source_71,'
59856 ') = 'N'
59857 THEN
59858
59859 --
59860 XLA_AE_LINES_PKG.SetNewLine;
59861
59862 p_balance_type_code := l_balance_type_code;
59863 -- set the flag so later we will know whether the gain loss line needs to be created
59864
59865 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
59866 p_actual_flag :='A';
59867 END IF;
59868
59869 --
59870 -- bulk performance
59871 --
59872 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
59873 p_header_num => 0); -- 4262811
59874 --
59875 -- set accounting line options
59876 --
59877 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
59878 p_natural_side_code => 'C'
59879 , p_gain_or_loss_flag => 'N'
59880 , p_gl_transfer_mode_code => 'S'
59881 , p_acct_entry_type_code => 'A'
59882 , p_switch_side_flag => 'Y'
59883 , p_merge_duplicate_code => 'A'
59884 );
59885 --
59886 l_acc_rev_natural_side_code := 'D'; -- 4262811
59887 --
59888 --
59889 -- set accounting line type info
59890 --
59891 xla_ae_lines_pkg.SetAcctLineType
59892 (p_component_type => l_component_type
59893 ,p_event_type_code => l_event_type_code
59894 ,p_line_definition_owner_code => l_line_definition_owner_code
59895 ,p_line_definition_code => l_line_definition_code
59896 ,p_accounting_line_code => l_component_code
59897 ,p_accounting_line_type_code => l_component_type_code
59901 ,p_event_class_code => l_event_class_code);
59898 ,p_accounting_line_appl_id => l_component_appl_id
59899 ,p_amb_context_code => l_amb_context_code
59900 ,p_entity_code => l_entity_code
59902 --
59903 -- set accounting class
59904 --
59905 xla_ae_lines_pkg.SetAcctClass(
59906 p_accounting_class_code => 'FAC_BR'
59907 , p_ae_header_id => l_ae_header_id
59908 );
59909
59910 --
59911 -- set rounding class
59912 --
59913 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
59914 'RECEIVABLE';
59915
59916 --
59917 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
59918 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
59919 --
59920 -- bulk performance
59921 --
59922 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
59923
59924 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
59925 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
59926
59927 -- 4955764
59928 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
59929 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
59930
59931 -- 4458381 Public Sector Enh
59932
59933 --
59934 -- set accounting attributes for the line type
59935 --
59936 l_entered_amt_idx := 8;
59937 l_accted_amt_idx := 13;
59938 l_bflow_applied_to_amt_idx := NULL; -- 5132302
59939 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
59940 l_rec_acct_attrs.array_num_value(1) := p_source_60;
59941 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
59942 l_rec_acct_attrs.array_char_value(2) := p_source_37;
59943 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
59944 l_rec_acct_attrs.array_char_value(3) := p_source_61;
59945 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
59946 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
59947 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
59948 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
59949 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
59950 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
59951 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
59952 l_rec_acct_attrs.array_char_value(7) := p_source_25;
59953 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
59954 l_rec_acct_attrs.array_num_value(8) := p_source_74;
59955 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
59956 l_rec_acct_attrs.array_char_value(9) := p_source_63;
59957 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
59958 l_rec_acct_attrs.array_date_value(10) := p_source_28;
59959 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
59960 l_rec_acct_attrs.array_num_value(11) := p_source_29;
59961 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
59962 l_rec_acct_attrs.array_char_value(12) := p_source_30;
59963 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
59964 l_rec_acct_attrs.array_num_value(13) := p_source_75;
59965 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
59966 l_rec_acct_attrs.array_num_value(14) := p_source_65;
59967 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
59968 l_rec_acct_attrs.array_num_value(15) := p_source_66;
59969 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
59970 l_rec_acct_attrs.array_char_value(16) := p_source_67;
59971
59972 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
59973 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
59974
59975 ---------------------------------------------------------------------------------------------------------------
59976 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
59977 ---------------------------------------------------------------------------------------------------------------
59978 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
59979
59980 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
59981 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
59982
59983 IF xla_accounting_cache_pkg.GetValueChar
59984 (p_source_code => 'LEDGER_CATEGORY_CODE'
59985 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
59986 AND l_bflow_method_code = 'PRIOR_ENTRY'
59987 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
59988 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
59989 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
59990 )
59991 THEN
59992 xla_ae_lines_pkg.BflowUpgEntry
59993 (p_business_method_code => l_bflow_method_code
59994 ,p_business_class_code => l_bflow_class_code
59995 ,p_balance_type => l_balance_type_code);
59996 ELSE
59997 NULL;
60001 --
59998 -- No business flow processing for business flow method of NONE.
59999 END IF;
60000
60002 -- call analytical criteria
60003 --
60004
60005 --
60006 -- call description
60007 --
60008 -- No description or it is inherited.
60009 --
60010 -- call ADRs
60011 -- Bug 4922099
60012 --
60013 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
60014 (NVL(l_actual_upg_option, 'N') = 'O') OR
60015 (NVL(l_enc_upg_option, 'N') = 'O')
60016 )
60017 THEN
60018 NULL;
60019 --
60020 --
60021
60022 l_ccid := AcctDerRule_11(
60023 p_application_id => p_application_id
60024 , p_ae_header_id => l_ae_header_id
60025 , p_source_10 => p_source_10
60026 , x_transaction_coa_id => l_adr_transaction_coa_id
60027 , x_accounting_coa_id => l_adr_accounting_coa_id
60028 , x_value_type_code => l_adr_value_type_code
60029 , p_side => 'NA'
60030 );
60031
60032 xla_ae_lines_pkg.set_ccid(
60033 p_code_combination_id => l_ccid
60034 , p_value_type_code => l_adr_value_type_code
60035 , p_transaction_coa_id => l_adr_transaction_coa_id
60036 , p_accounting_coa_id => l_adr_accounting_coa_id
60037 , p_adr_code => 'DIST_CCID'
60038 , p_adr_type_code => 'S'
60039 , p_component_type => l_component_type
60040 , p_component_code => l_component_code
60041 , p_component_type_code => l_component_type_code
60042 , p_component_appl_id => l_component_appl_id
60043 , p_amb_context_code => l_amb_context_code
60044 , p_side => 'NA'
60045 );
60046
60047
60048 --
60049 --
60050 END IF;
60051 --
60052 -- Bug 4922099
60053 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
60054 (NVL(l_enc_upg_option, 'N') = 'O')
60055 ) AND
60056 (l_bflow_method_code = 'PRIOR_ENTRY')
60057 )
60058 THEN
60059 IF
60060 --
60061 1 = 2
60062 --
60063 THEN
60064 xla_accounting_err_pkg.build_message
60065 (p_appli_s_name => 'XLA'
60066 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
60067 ,p_token_1 => 'LINE_NUMBER'
60068 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
60069 ,p_token_2 => 'LINE_TYPE_NAME'
60070 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
60071 l_component_type
60072 ,l_component_code
60073 ,l_component_type_code
60074 ,l_component_appl_id
60075 ,l_amb_context_code
60076 ,l_entity_code
60077 ,l_event_class_code
60078 )
60079 ,p_token_3 => 'OWNER'
60080 ,p_value_3 => xla_lookups_pkg.get_meaning(
60081 p_lookup_type => 'XLA_OWNER_TYPE'
60082 ,p_lookup_code => l_component_type_code
60083 )
60084 ,p_token_4 => 'PRODUCT_NAME'
60085 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
60086 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
60087 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
60088 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
60089 ,p_ae_header_id => NULL
60090 );
60091
60092 IF (C_LEVEL_ERROR>= g_log_level) THEN
60093 trace
60094 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
60095 ,p_level => C_LEVEL_ERROR
60096 ,p_module => l_log_module);
60097 END IF;
60098 END IF;
60099 END IF;
60100 --
60101 --
60102 ------------------------------------------------------------------------------------------------
60103 -- 4219869 Business Flow
60104 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
60105 -- Prior Entry. Currently, the following code is always generated.
60109 ------------------------------------------------------------------------------------
60106 ------------------------------------------------------------------------------------------------
60107 XLA_AE_LINES_PKG.ValidateCurrentLine;
60108
60110 -- 4219869 Business Flow
60111 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
60112 ------------------------------------------------------------------------------------
60113 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
60114
60115 ----------------------------------------------------------------------------------
60116 -- 4219869 Business Flow
60117 -- Update journal entry status -- Need to generate this within IF <condition>
60118 ----------------------------------------------------------------------------------
60119 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
60120 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
60121 ,p_balance_type_code => l_balance_type_code
60122 );
60123
60124 -------------------------------------------------------------------------------------------
60125 -- 4262811 - Generate the Accrual Reversal lines
60126 -------------------------------------------------------------------------------------------
60127 BEGIN
60128 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
60129 (g_array_event(p_event_id).array_value_num('header_index'));
60130 IF l_acc_rev_flag IS NULL THEN
60131 l_acc_rev_flag := 'N';
60132 END IF;
60133 EXCEPTION
60134 WHEN OTHERS THEN
60135 l_acc_rev_flag := 'N';
60136 END;
60137 --
60138 IF (l_acc_rev_flag = 'Y') THEN
60139
60140 -- 4645092 ------------------------------------------------------------------------------
60141 -- To allow MPA report to determine if it should generate report process
60142 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
60143 ------------------------------------------------------------------------------------------
60144
60145 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
60146 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
60147 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
60148 -- call ADRs
60149 -- Bug 4922099
60150 --
60151 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
60152 (NVL(l_actual_upg_option, 'N') = 'O') OR
60153 (NVL(l_enc_upg_option, 'N') = 'O')
60154 )
60155 THEN
60156 NULL;
60157 --
60158 --
60159
60160 l_ccid := AcctDerRule_11(
60161 p_application_id => p_application_id
60162 , p_ae_header_id => l_ae_header_id
60163 , p_source_10 => p_source_10
60164 , x_transaction_coa_id => l_adr_transaction_coa_id
60165 , x_accounting_coa_id => l_adr_accounting_coa_id
60166 , x_value_type_code => l_adr_value_type_code
60167 , p_side => 'NA'
60168 );
60169
60170 xla_ae_lines_pkg.set_ccid(
60171 p_code_combination_id => l_ccid
60172 , p_value_type_code => l_adr_value_type_code
60173 , p_transaction_coa_id => l_adr_transaction_coa_id
60174 , p_accounting_coa_id => l_adr_accounting_coa_id
60175 , p_adr_code => 'DIST_CCID'
60176 , p_adr_type_code => 'S'
60177 , p_component_type => l_component_type
60178 , p_component_code => l_component_code
60179 , p_component_type_code => l_component_type_code
60180 , p_component_appl_id => l_component_appl_id
60181 , p_amb_context_code => l_amb_context_code
60182 , p_side => 'NA'
60183 );
60184
60185
60186 --
60187 --
60188 END IF;
60189
60190 --
60191 -- Update the line information that should be overwritten
60192 --
60193 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
60194 p_header_num => 1);
60195 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
60196
60197 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
60198
60199 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
60200 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
60201 END IF;
60202
60203 --
60204 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
60205 --
60206 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
60207 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
60208 ELSE
60209 ---------------------------------------------------------------------------------------------------
60210 -- 4262811a Switch Sign
60211 ---------------------------------------------------------------------------------------------------
60212 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
60213 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
60214 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60218 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
60215 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
60216 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60217 -- 5132302
60219 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60220
60221 END IF;
60222
60223 -- 4955764
60224 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
60225 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
60226
60227
60228 XLA_AE_LINES_PKG.ValidateCurrentLine;
60229 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
60230
60231 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
60232 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
60233 ,p_balance_type_code => l_balance_type_code);
60234
60235 END IF;
60236
60237 -----------------------------------------------------------------------------------------
60238 -- 4262811 Multiperiod Accounting
60239 -----------------------------------------------------------------------------------------
60240 -- No MPA option is assigned.
60241
60242
60243 END IF;
60244 END IF;
60245 --
60246
60247 --
60248 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
60249 trace
60250 (p_msg => 'END of AcctLineType_125'
60251 ,p_level => C_LEVEL_PROCEDURE
60252 ,p_module => l_log_module);
60253 END IF;
60254 --
60255 EXCEPTION
60256 WHEN xla_exceptions_pkg.application_exception THEN
60257 RAISE;
60258 WHEN OTHERS THEN
60259 xla_exceptions_pkg.raise_message
60260 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_125');
60261 END AcctLineType_125;
60262 --
60263
60264 ---------------------------------------
60265 --
60266 -- PRIVATE FUNCTION
60267 -- AcctLineType_126
60268 --
60269 ---------------------------------------
60270 PROCEDURE AcctLineType_126 (
60271 p_application_id IN NUMBER
60272 ,p_event_id IN NUMBER
60273 ,p_calculate_acctd_flag IN VARCHAR2
60274 ,p_calculate_g_l_flag IN VARCHAR2
60275 ,p_actual_flag IN OUT VARCHAR2
60276 ,p_balance_type_code OUT VARCHAR2
60277 ,p_gain_or_loss_ref OUT VARCHAR2
60278
60279 --Distribution GL Account
60280 , p_source_10 IN NUMBER
60281 --Distribution Source Type
60282 , p_source_22 IN VARCHAR2
60283 --Receivable Activity Type
60284 , p_source_23 IN VARCHAR2
60285 --Distribution Line Identifier
60286 , p_source_24 IN NUMBER
60287 --Distribution Type
60288 , p_source_25 IN VARCHAR2
60289 --Exchange Date
60290 , p_source_28 IN DATE
60291 --Exchange Rate
60292 , p_source_29 IN NUMBER
60293 --Exchange Rate Type
60294 , p_source_30 IN VARCHAR2
60295 --Applied To Document Accounting Amount
60296 , p_source_31 IN NUMBER
60297 --Transaction Distribution Identifier
60298 , p_source_36 IN NUMBER
60299 --Transaction Distribution Type
60300 , p_source_37 IN VARCHAR2
60301 --Receipt Applied To Application Identifier
60302 , p_source_60 IN NUMBER
60303 --Transaction Entity Code
60304 , p_source_61 IN VARCHAR2
60305 --Transaction Identifier
60306 , p_source_62 IN NUMBER
60307 --Applying Document Currency Code
60308 , p_source_63 IN VARCHAR2
60309 --Distribution Party Identifier
60310 , p_source_65 IN NUMBER
60311 --Distribution Party Site Id
60312 , p_source_66 IN NUMBER
60313 --Distribution Party Type
60314 , p_source_67 IN VARCHAR2
60315 --Distribution Multi Fund Additional Entry
60316 , p_source_71 IN VARCHAR2
60317 --DIST_ENT_AMT_FROM
60318 , p_source_74 IN NUMBER
60319 )
60320 IS
60321
60322 l_component_type VARCHAR2(80);
60323 l_component_code VARCHAR2(30);
60324 l_component_type_code VARCHAR2(1);
60325 l_component_appl_id INTEGER;
60326 l_amb_context_code VARCHAR2(30);
60327 l_entity_code VARCHAR2(30);
60328 l_event_class_code VARCHAR2(30);
60329 l_ae_header_id NUMBER;
60330 l_event_type_code VARCHAR2(30);
60331 l_line_definition_code VARCHAR2(30);
60332 l_line_definition_owner_code VARCHAR2(1);
60333 --
60334 -- adr variables
60335 l_segment VARCHAR2(30);
60336 l_ccid NUMBER;
60337 l_adr_transaction_coa_id NUMBER;
60338 l_adr_accounting_coa_id NUMBER;
60339 l_adr_flexfield_segment_code VARCHAR2(30);
60340 l_adr_flex_value_set_id NUMBER;
60341 l_adr_value_type_code VARCHAR2(30);
60342 l_adr_value_combination_id NUMBER;
60343 l_adr_value_segment_code VARCHAR2(30);
60344
60345 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
60346 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
60347 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
60348 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
60349
60353 l_acc_rev_flag VARCHAR2(1);
60350 -- 4262811 Variables ------------------------------------------------------------------------------------------
60351 l_entered_amt_idx NUMBER;
60352 l_accted_amt_idx NUMBER;
60354 l_accrual_line_num NUMBER;
60355 l_tmp_amt NUMBER;
60356 l_acc_rev_natural_side_code VARCHAR2(1);
60357
60358 l_num_entries NUMBER;
60359 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
60360 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
60361 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
60362 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
60363 l_recog_line_1 NUMBER;
60364 l_recog_line_2 NUMBER;
60365
60366 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
60367 l_bflow_applied_to_amt NUMBER; -- 5132302
60368 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
60369
60370 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
60371
60372 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
60373 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
60374
60375 ---------------------------------------------------------------------------------------------------------------
60376
60377
60378 --
60379 -- bulk performance
60380 --
60381 l_balance_type_code VARCHAR2(1);
60382 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
60383 l_log_module VARCHAR2(240);
60384
60385 --
60386 -- Upgrade strategy
60387 --
60388 l_actual_upg_option VARCHAR2(1);
60389 l_enc_upg_option VARCHAR2(1);
60390
60391 --
60392 BEGIN
60393 --
60394 IF g_log_enabled THEN
60395 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_126';
60396 END IF;
60397 --
60398 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
60399
60400 trace
60401 (p_msg => 'BEGIN of AcctLineType_126'
60402 ,p_level => C_LEVEL_PROCEDURE
60403 ,p_module => l_log_module);
60404
60405 END IF;
60406 --
60407 l_component_type := 'AMB_JLT';
60408 l_component_code := 'RCT_PMT_NET';
60409 l_component_type_code := 'S';
60410 l_component_appl_id := 222;
60411 l_amb_context_code := 'DEFAULT';
60412 l_entity_code := 'RECEIPTS';
60413 l_event_class_code := 'RECEIPT';
60414 l_event_type_code := 'RECEIPT_ALL';
60415 l_line_definition_owner_code := 'S';
60416 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
60417 --
60418 l_balance_type_code := 'A';
60419 l_segment := NULL;
60420 l_ccid := NULL;
60421 l_adr_transaction_coa_id := NULL;
60422 l_adr_accounting_coa_id := NULL;
60423 l_adr_flexfield_segment_code := NULL;
60424 l_adr_flex_value_set_id := NULL;
60425 l_adr_value_type_code := NULL;
60426 l_adr_value_combination_id := NULL;
60427 l_adr_value_segment_code := NULL;
60428
60429 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
60430 l_bflow_class_code := ''; -- 4219869 Business Flow
60431 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
60432 l_budgetary_control_flag := 'N';
60433
60434 l_bflow_applied_to_amt_idx := NULL; -- 5132302
60435 l_bflow_applied_to_amt := NULL; -- 5132302
60436 l_entered_amt_idx := NULL; -- 4262811
60437 l_accted_amt_idx := NULL; -- 4262811
60438 l_acc_rev_flag := NULL; -- 4262811
60439 l_accrual_line_num := NULL; -- 4262811
60440 l_tmp_amt := NULL; -- 4262811
60441 --
60442
60443 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
60444 l_balance_type_code <> 'B' THEN
60445 IF (NVL(p_source_22,'
60446 ') = 'OTHER_ACC' OR
60447 NVL(p_source_22,'
60448 ') = 'ACTIVITY') AND
60449 NVL(p_source_23,'
60450 ') = 'NETTING' AND
60451 NVL(p_source_71,'
60452 ') = 'N'
60453 THEN
60454
60455 --
60456 XLA_AE_LINES_PKG.SetNewLine;
60457
60458 p_balance_type_code := l_balance_type_code;
60459 -- set the flag so later we will know whether the gain loss line needs to be created
60460
60461 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
60462 p_actual_flag :='A';
60463 END IF;
60464
60465 --
60466 -- bulk performance
60467 --
60468 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
60469 p_header_num => 0); -- 4262811
60470 --
60471 -- set accounting line options
60472 --
60473 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
60474 p_natural_side_code => 'C'
60475 , p_gain_or_loss_flag => 'N'
60476 , p_gl_transfer_mode_code => 'S'
60477 , p_acct_entry_type_code => 'A'
60478 , p_switch_side_flag => 'Y'
60479 , p_merge_duplicate_code => 'A'
60480 );
60481 --
60482 l_acc_rev_natural_side_code := 'D'; -- 4262811
60483 --
60484 --
60488 (p_component_type => l_component_type
60485 -- set accounting line type info
60486 --
60487 xla_ae_lines_pkg.SetAcctLineType
60489 ,p_event_type_code => l_event_type_code
60490 ,p_line_definition_owner_code => l_line_definition_owner_code
60491 ,p_line_definition_code => l_line_definition_code
60492 ,p_accounting_line_code => l_component_code
60493 ,p_accounting_line_type_code => l_component_type_code
60494 ,p_accounting_line_appl_id => l_component_appl_id
60495 ,p_amb_context_code => l_amb_context_code
60496 ,p_entity_code => l_entity_code
60497 ,p_event_class_code => l_event_class_code);
60498 --
60499 -- set accounting class
60500 --
60501 xla_ae_lines_pkg.SetAcctClass(
60502 p_accounting_class_code => 'PMT_NET'
60503 , p_ae_header_id => l_ae_header_id
60504 );
60505
60506 --
60507 -- set rounding class
60508 --
60509 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
60510 'RECEIVABLE';
60511
60512 --
60513 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
60514 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
60515 --
60516 -- bulk performance
60517 --
60518 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
60519
60520 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
60521 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
60522
60523 -- 4955764
60524 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
60525 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
60526
60527 -- 4458381 Public Sector Enh
60528
60529 --
60530 -- set accounting attributes for the line type
60531 --
60532 l_entered_amt_idx := 8;
60533 l_accted_amt_idx := 13;
60534 l_bflow_applied_to_amt_idx := NULL; -- 5132302
60535 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
60536 l_rec_acct_attrs.array_num_value(1) := p_source_60;
60537 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
60538 l_rec_acct_attrs.array_char_value(2) := p_source_37;
60539 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
60540 l_rec_acct_attrs.array_char_value(3) := p_source_61;
60541 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
60542 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
60543 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
60544 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
60545 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
60546 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
60547 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
60548 l_rec_acct_attrs.array_char_value(7) := p_source_25;
60549 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
60550 l_rec_acct_attrs.array_num_value(8) := p_source_74;
60551 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
60552 l_rec_acct_attrs.array_char_value(9) := p_source_63;
60553 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
60554 l_rec_acct_attrs.array_date_value(10) := p_source_28;
60555 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
60556 l_rec_acct_attrs.array_num_value(11) := p_source_29;
60557 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
60558 l_rec_acct_attrs.array_char_value(12) := p_source_30;
60559 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
60560 l_rec_acct_attrs.array_num_value(13) := p_source_31;
60561 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
60562 l_rec_acct_attrs.array_num_value(14) := p_source_65;
60563 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
60564 l_rec_acct_attrs.array_num_value(15) := p_source_66;
60565 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
60566 l_rec_acct_attrs.array_char_value(16) := p_source_67;
60567
60568 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
60569 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
60570
60571 ---------------------------------------------------------------------------------------------------------------
60572 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
60573 ---------------------------------------------------------------------------------------------------------------
60574 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
60575
60576 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
60577 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
60578
60579 IF xla_accounting_cache_pkg.GetValueChar
60580 (p_source_code => 'LEDGER_CATEGORY_CODE'
60581 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
60582 AND l_bflow_method_code = 'PRIOR_ENTRY'
60586 )
60583 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
60584 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
60585 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
60587 THEN
60588 xla_ae_lines_pkg.BflowUpgEntry
60589 (p_business_method_code => l_bflow_method_code
60590 ,p_business_class_code => l_bflow_class_code
60591 ,p_balance_type => l_balance_type_code);
60592 ELSE
60593 NULL;
60594 -- No business flow processing for business flow method of NONE.
60595 END IF;
60596
60597 --
60598 -- call analytical criteria
60599 --
60600
60601 --
60602 -- call description
60603 --
60604 -- No description or it is inherited.
60605 --
60606 -- call ADRs
60607 -- Bug 4922099
60608 --
60609 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
60610 (NVL(l_actual_upg_option, 'N') = 'O') OR
60611 (NVL(l_enc_upg_option, 'N') = 'O')
60612 )
60613 THEN
60614 NULL;
60615 --
60616 --
60617
60618 l_ccid := AcctDerRule_11(
60619 p_application_id => p_application_id
60620 , p_ae_header_id => l_ae_header_id
60621 , p_source_10 => p_source_10
60622 , x_transaction_coa_id => l_adr_transaction_coa_id
60623 , x_accounting_coa_id => l_adr_accounting_coa_id
60624 , x_value_type_code => l_adr_value_type_code
60625 , p_side => 'NA'
60626 );
60627
60628 xla_ae_lines_pkg.set_ccid(
60629 p_code_combination_id => l_ccid
60630 , p_value_type_code => l_adr_value_type_code
60631 , p_transaction_coa_id => l_adr_transaction_coa_id
60632 , p_accounting_coa_id => l_adr_accounting_coa_id
60633 , p_adr_code => 'DIST_CCID'
60634 , p_adr_type_code => 'S'
60635 , p_component_type => l_component_type
60636 , p_component_code => l_component_code
60637 , p_component_type_code => l_component_type_code
60638 , p_component_appl_id => l_component_appl_id
60639 , p_amb_context_code => l_amb_context_code
60640 , p_side => 'NA'
60641 );
60642
60643
60644 --
60645 --
60646 END IF;
60647 --
60648 -- Bug 4922099
60649 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
60650 (NVL(l_enc_upg_option, 'N') = 'O')
60651 ) AND
60652 (l_bflow_method_code = 'PRIOR_ENTRY')
60653 )
60654 THEN
60655 IF
60656 --
60657 1 = 2
60658 --
60659 THEN
60660 xla_accounting_err_pkg.build_message
60661 (p_appli_s_name => 'XLA'
60662 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
60663 ,p_token_1 => 'LINE_NUMBER'
60664 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
60665 ,p_token_2 => 'LINE_TYPE_NAME'
60666 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
60667 l_component_type
60668 ,l_component_code
60669 ,l_component_type_code
60670 ,l_component_appl_id
60671 ,l_amb_context_code
60672 ,l_entity_code
60673 ,l_event_class_code
60674 )
60675 ,p_token_3 => 'OWNER'
60676 ,p_value_3 => xla_lookups_pkg.get_meaning(
60677 p_lookup_type => 'XLA_OWNER_TYPE'
60678 ,p_lookup_code => l_component_type_code
60679 )
60680 ,p_token_4 => 'PRODUCT_NAME'
60681 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
60682 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
60683 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
60684 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
60685 ,p_ae_header_id => NULL
60686 );
60687
60688 IF (C_LEVEL_ERROR>= g_log_level) THEN
60689 trace
60690 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
60691 ,p_level => C_LEVEL_ERROR
60692 ,p_module => l_log_module);
60696 --
60693 END IF;
60694 END IF;
60695 END IF;
60697 --
60698 ------------------------------------------------------------------------------------------------
60699 -- 4219869 Business Flow
60700 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
60701 -- Prior Entry. Currently, the following code is always generated.
60702 ------------------------------------------------------------------------------------------------
60703 XLA_AE_LINES_PKG.ValidateCurrentLine;
60704
60705 ------------------------------------------------------------------------------------
60706 -- 4219869 Business Flow
60707 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
60708 ------------------------------------------------------------------------------------
60709 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
60710
60711 ----------------------------------------------------------------------------------
60712 -- 4219869 Business Flow
60713 -- Update journal entry status -- Need to generate this within IF <condition>
60714 ----------------------------------------------------------------------------------
60715 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
60716 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
60717 ,p_balance_type_code => l_balance_type_code
60718 );
60719
60720 -------------------------------------------------------------------------------------------
60721 -- 4262811 - Generate the Accrual Reversal lines
60722 -------------------------------------------------------------------------------------------
60723 BEGIN
60724 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
60725 (g_array_event(p_event_id).array_value_num('header_index'));
60726 IF l_acc_rev_flag IS NULL THEN
60727 l_acc_rev_flag := 'N';
60728 END IF;
60729 EXCEPTION
60730 WHEN OTHERS THEN
60731 l_acc_rev_flag := 'N';
60732 END;
60733 --
60734 IF (l_acc_rev_flag = 'Y') THEN
60735
60736 -- 4645092 ------------------------------------------------------------------------------
60737 -- To allow MPA report to determine if it should generate report process
60738 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
60739 ------------------------------------------------------------------------------------------
60740
60741 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
60742 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
60743 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
60744 -- call ADRs
60745 -- Bug 4922099
60746 --
60747 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
60748 (NVL(l_actual_upg_option, 'N') = 'O') OR
60749 (NVL(l_enc_upg_option, 'N') = 'O')
60750 )
60751 THEN
60752 NULL;
60753 --
60754 --
60755
60756 l_ccid := AcctDerRule_11(
60757 p_application_id => p_application_id
60758 , p_ae_header_id => l_ae_header_id
60759 , p_source_10 => p_source_10
60760 , x_transaction_coa_id => l_adr_transaction_coa_id
60761 , x_accounting_coa_id => l_adr_accounting_coa_id
60762 , x_value_type_code => l_adr_value_type_code
60763 , p_side => 'NA'
60764 );
60765
60766 xla_ae_lines_pkg.set_ccid(
60767 p_code_combination_id => l_ccid
60768 , p_value_type_code => l_adr_value_type_code
60769 , p_transaction_coa_id => l_adr_transaction_coa_id
60770 , p_accounting_coa_id => l_adr_accounting_coa_id
60771 , p_adr_code => 'DIST_CCID'
60772 , p_adr_type_code => 'S'
60773 , p_component_type => l_component_type
60774 , p_component_code => l_component_code
60775 , p_component_type_code => l_component_type_code
60776 , p_component_appl_id => l_component_appl_id
60777 , p_amb_context_code => l_amb_context_code
60778 , p_side => 'NA'
60779 );
60780
60781
60782 --
60783 --
60784 END IF;
60785
60786 --
60787 -- Update the line information that should be overwritten
60788 --
60789 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
60790 p_header_num => 1);
60791 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
60792
60793 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
60794
60795 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
60796 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
60797 END IF;
60798
60799 --
60800 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
60801 --
60802 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
60803 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
60804 ELSE
60805 ---------------------------------------------------------------------------------------------------
60806 -- 4262811a Switch Sign
60810 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60807 ---------------------------------------------------------------------------------------------------
60808 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
60809 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
60811 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
60812 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60813 -- 5132302
60814 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
60815 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60816
60817 END IF;
60818
60819 -- 4955764
60820 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
60821 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
60822
60823
60824 XLA_AE_LINES_PKG.ValidateCurrentLine;
60825 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
60826
60827 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
60828 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
60829 ,p_balance_type_code => l_balance_type_code);
60830
60831 END IF;
60832
60833 -----------------------------------------------------------------------------------------
60834 -- 4262811 Multiperiod Accounting
60835 -----------------------------------------------------------------------------------------
60836 -- No MPA option is assigned.
60837
60838
60839 END IF;
60840 END IF;
60841 --
60842
60843 --
60844 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
60845 trace
60846 (p_msg => 'END of AcctLineType_126'
60847 ,p_level => C_LEVEL_PROCEDURE
60848 ,p_module => l_log_module);
60849 END IF;
60850 --
60851 EXCEPTION
60852 WHEN xla_exceptions_pkg.application_exception THEN
60853 RAISE;
60854 WHEN OTHERS THEN
60855 xla_exceptions_pkg.raise_message
60856 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_126');
60857 END AcctLineType_126;
60858 --
60859
60860 ---------------------------------------
60861 --
60862 -- PRIVATE FUNCTION
60863 -- AcctLineType_127
60864 --
60865 ---------------------------------------
60866 PROCEDURE AcctLineType_127 (
60867 p_application_id IN NUMBER
60868 ,p_event_id IN NUMBER
60869 ,p_calculate_acctd_flag IN VARCHAR2
60870 ,p_calculate_g_l_flag IN VARCHAR2
60871 ,p_actual_flag IN OUT VARCHAR2
60872 ,p_balance_type_code OUT VARCHAR2
60873 ,p_gain_or_loss_ref OUT VARCHAR2
60874
60875 --Distribution GL Account
60876 , p_source_10 IN NUMBER
60877 --Distribution Source Type
60878 , p_source_22 IN VARCHAR2
60879 --Receivable Activity Type
60880 , p_source_23 IN VARCHAR2
60881 --Distribution Line Identifier
60882 , p_source_24 IN NUMBER
60883 --Distribution Type
60884 , p_source_25 IN VARCHAR2
60885 --Exchange Date
60886 , p_source_28 IN DATE
60887 --Exchange Rate
60888 , p_source_29 IN NUMBER
60889 --Exchange Rate Type
60890 , p_source_30 IN VARCHAR2
60891 --Transaction Distribution Identifier
60892 , p_source_36 IN NUMBER
60893 --Transaction Distribution Type
60894 , p_source_37 IN VARCHAR2
60895 --Receipt Applied To Application Identifier
60896 , p_source_60 IN NUMBER
60897 --Transaction Entity Code
60898 , p_source_61 IN VARCHAR2
60899 --Transaction Identifier
60900 , p_source_62 IN NUMBER
60901 --Applying Document Currency Code
60902 , p_source_63 IN VARCHAR2
60903 --Distribution Party Identifier
60904 , p_source_65 IN NUMBER
60905 --Distribution Party Site Id
60906 , p_source_66 IN NUMBER
60907 --Distribution Party Type
60908 , p_source_67 IN VARCHAR2
60909 --Distribution Multi Fund Additional Entry
60910 , p_source_71 IN VARCHAR2
60911 --DIST_ENT_AMT_FROM
60912 , p_source_74 IN NUMBER
60913 --Accounting Amount
60914 , p_source_75 IN NUMBER
60915 )
60916 IS
60917
60918 l_component_type VARCHAR2(80);
60919 l_component_code VARCHAR2(30);
60920 l_component_type_code VARCHAR2(1);
60921 l_component_appl_id INTEGER;
60922 l_amb_context_code VARCHAR2(30);
60923 l_entity_code VARCHAR2(30);
60924 l_event_class_code VARCHAR2(30);
60925 l_ae_header_id NUMBER;
60926 l_event_type_code VARCHAR2(30);
60927 l_line_definition_code VARCHAR2(30);
60928 l_line_definition_owner_code VARCHAR2(1);
60929 --
60930 -- adr variables
60931 l_segment VARCHAR2(30);
60932 l_ccid NUMBER;
60933 l_adr_transaction_coa_id NUMBER;
60934 l_adr_accounting_coa_id NUMBER;
60935 l_adr_flexfield_segment_code VARCHAR2(30);
60936 l_adr_flex_value_set_id NUMBER;
60937 l_adr_value_type_code VARCHAR2(30);
60938 l_adr_value_combination_id NUMBER;
60942 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
60939 l_adr_value_segment_code VARCHAR2(30);
60940
60941 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
60943 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
60944 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
60945
60946 -- 4262811 Variables ------------------------------------------------------------------------------------------
60947 l_entered_amt_idx NUMBER;
60948 l_accted_amt_idx NUMBER;
60949 l_acc_rev_flag VARCHAR2(1);
60950 l_accrual_line_num NUMBER;
60951 l_tmp_amt NUMBER;
60952 l_acc_rev_natural_side_code VARCHAR2(1);
60953
60954 l_num_entries NUMBER;
60955 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
60956 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
60957 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
60958 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
60959 l_recog_line_1 NUMBER;
60960 l_recog_line_2 NUMBER;
60961
60962 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
60963 l_bflow_applied_to_amt NUMBER; -- 5132302
60964 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
60965
60966 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
60967
60968 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
60969 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
60970
60971 ---------------------------------------------------------------------------------------------------------------
60972
60973
60974 --
60975 -- bulk performance
60976 --
60977 l_balance_type_code VARCHAR2(1);
60978 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
60979 l_log_module VARCHAR2(240);
60980
60981 --
60982 -- Upgrade strategy
60983 --
60984 l_actual_upg_option VARCHAR2(1);
60985 l_enc_upg_option VARCHAR2(1);
60986
60987 --
60988 BEGIN
60989 --
60990 IF g_log_enabled THEN
60991 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_127';
60992 END IF;
60993 --
60994 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
60995
60996 trace
60997 (p_msg => 'BEGIN of AcctLineType_127'
60998 ,p_level => C_LEVEL_PROCEDURE
60999 ,p_module => l_log_module);
61000
61001 END IF;
61002 --
61003 l_component_type := 'AMB_JLT';
61004 l_component_code := 'RCT_PREPAYMENT';
61005 l_component_type_code := 'S';
61006 l_component_appl_id := 222;
61007 l_amb_context_code := 'DEFAULT';
61008 l_entity_code := 'RECEIPTS';
61009 l_event_class_code := 'RECEIPT';
61010 l_event_type_code := 'RECEIPT_ALL';
61011 l_line_definition_owner_code := 'S';
61012 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
61013 --
61014 l_balance_type_code := 'A';
61015 l_segment := NULL;
61016 l_ccid := NULL;
61017 l_adr_transaction_coa_id := NULL;
61018 l_adr_accounting_coa_id := NULL;
61019 l_adr_flexfield_segment_code := NULL;
61020 l_adr_flex_value_set_id := NULL;
61021 l_adr_value_type_code := NULL;
61022 l_adr_value_combination_id := NULL;
61023 l_adr_value_segment_code := NULL;
61024
61025 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
61026 l_bflow_class_code := ''; -- 4219869 Business Flow
61027 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
61028 l_budgetary_control_flag := 'N';
61029
61030 l_bflow_applied_to_amt_idx := NULL; -- 5132302
61031 l_bflow_applied_to_amt := NULL; -- 5132302
61032 l_entered_amt_idx := NULL; -- 4262811
61033 l_accted_amt_idx := NULL; -- 4262811
61034 l_acc_rev_flag := NULL; -- 4262811
61035 l_accrual_line_num := NULL; -- 4262811
61036 l_tmp_amt := NULL; -- 4262811
61037 --
61038
61039 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
61040 l_balance_type_code <> 'B' THEN
61041 IF NVL(p_source_22,'
61042 ') = 'OTHER ACC' AND
61043 NVL(p_source_23,'
61044 ') = 'PREPAYMENT' AND
61045 NVL(p_source_71,'
61046 ') = 'N'
61047 THEN
61048
61049 --
61050 XLA_AE_LINES_PKG.SetNewLine;
61051
61052 p_balance_type_code := l_balance_type_code;
61053 -- set the flag so later we will know whether the gain loss line needs to be created
61054
61055 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
61056 p_actual_flag :='A';
61057 END IF;
61058
61059 --
61060 -- bulk performance
61061 --
61062 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
61063 p_header_num => 0); -- 4262811
61064 --
61065 -- set accounting line options
61066 --
61067 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
61068 p_natural_side_code => 'C'
61072 , p_switch_side_flag => 'Y'
61069 , p_gain_or_loss_flag => 'N'
61070 , p_gl_transfer_mode_code => 'S'
61071 , p_acct_entry_type_code => 'A'
61073 , p_merge_duplicate_code => 'A'
61074 );
61075 --
61076 l_acc_rev_natural_side_code := 'D'; -- 4262811
61077 --
61078 --
61079 -- set accounting line type info
61080 --
61081 xla_ae_lines_pkg.SetAcctLineType
61082 (p_component_type => l_component_type
61083 ,p_event_type_code => l_event_type_code
61084 ,p_line_definition_owner_code => l_line_definition_owner_code
61085 ,p_line_definition_code => l_line_definition_code
61086 ,p_accounting_line_code => l_component_code
61087 ,p_accounting_line_type_code => l_component_type_code
61088 ,p_accounting_line_appl_id => l_component_appl_id
61089 ,p_amb_context_code => l_amb_context_code
61090 ,p_entity_code => l_entity_code
61091 ,p_event_class_code => l_event_class_code);
61092 --
61093 -- set accounting class
61094 --
61095 xla_ae_lines_pkg.SetAcctClass(
61096 p_accounting_class_code => 'PREPAY'
61097 , p_ae_header_id => l_ae_header_id
61098 );
61099
61100 --
61101 -- set rounding class
61102 --
61103 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
61104 'RECEIVABLE';
61105
61106 --
61107 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
61108 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
61109 --
61110 -- bulk performance
61111 --
61112 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
61113
61114 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
61115 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
61116
61117 -- 4955764
61118 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
61119 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
61120
61121 -- 4458381 Public Sector Enh
61122
61123 --
61124 -- set accounting attributes for the line type
61125 --
61126 l_entered_amt_idx := 8;
61127 l_accted_amt_idx := 13;
61128 l_bflow_applied_to_amt_idx := NULL; -- 5132302
61129 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
61130 l_rec_acct_attrs.array_num_value(1) := p_source_60;
61131 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
61132 l_rec_acct_attrs.array_char_value(2) := p_source_37;
61133 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
61134 l_rec_acct_attrs.array_char_value(3) := p_source_61;
61135 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
61136 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
61137 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
61138 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
61139 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
61140 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
61141 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
61142 l_rec_acct_attrs.array_char_value(7) := p_source_25;
61143 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
61144 l_rec_acct_attrs.array_num_value(8) := p_source_74;
61145 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
61146 l_rec_acct_attrs.array_char_value(9) := p_source_63;
61147 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
61148 l_rec_acct_attrs.array_date_value(10) := p_source_28;
61149 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
61150 l_rec_acct_attrs.array_num_value(11) := p_source_29;
61151 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
61152 l_rec_acct_attrs.array_char_value(12) := p_source_30;
61153 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
61154 l_rec_acct_attrs.array_num_value(13) := p_source_75;
61155 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
61156 l_rec_acct_attrs.array_num_value(14) := p_source_65;
61157 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
61158 l_rec_acct_attrs.array_num_value(15) := p_source_66;
61159 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
61160 l_rec_acct_attrs.array_char_value(16) := p_source_67;
61161
61162 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
61163 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
61164
61165 ---------------------------------------------------------------------------------------------------------------
61166 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
61167 ---------------------------------------------------------------------------------------------------------------
61168 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
61169
61173 IF xla_accounting_cache_pkg.GetValueChar
61170 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
61171 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
61172
61174 (p_source_code => 'LEDGER_CATEGORY_CODE'
61175 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
61176 AND l_bflow_method_code = 'PRIOR_ENTRY'
61177 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
61178 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
61179 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
61180 )
61181 THEN
61182 xla_ae_lines_pkg.BflowUpgEntry
61183 (p_business_method_code => l_bflow_method_code
61184 ,p_business_class_code => l_bflow_class_code
61185 ,p_balance_type => l_balance_type_code);
61186 ELSE
61187 NULL;
61188 -- No business flow processing for business flow method of NONE.
61189 END IF;
61190
61191 --
61192 -- call analytical criteria
61193 --
61194
61195 --
61196 -- call description
61197 --
61198 -- No description or it is inherited.
61199 --
61200 -- call ADRs
61201 -- Bug 4922099
61202 --
61203 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
61204 (NVL(l_actual_upg_option, 'N') = 'O') OR
61205 (NVL(l_enc_upg_option, 'N') = 'O')
61206 )
61207 THEN
61208 NULL;
61209 --
61210 --
61211
61212 l_ccid := AcctDerRule_11(
61213 p_application_id => p_application_id
61214 , p_ae_header_id => l_ae_header_id
61215 , p_source_10 => p_source_10
61216 , x_transaction_coa_id => l_adr_transaction_coa_id
61217 , x_accounting_coa_id => l_adr_accounting_coa_id
61218 , x_value_type_code => l_adr_value_type_code
61219 , p_side => 'NA'
61220 );
61221
61222 xla_ae_lines_pkg.set_ccid(
61223 p_code_combination_id => l_ccid
61224 , p_value_type_code => l_adr_value_type_code
61225 , p_transaction_coa_id => l_adr_transaction_coa_id
61226 , p_accounting_coa_id => l_adr_accounting_coa_id
61227 , p_adr_code => 'DIST_CCID'
61228 , p_adr_type_code => 'S'
61229 , p_component_type => l_component_type
61230 , p_component_code => l_component_code
61231 , p_component_type_code => l_component_type_code
61232 , p_component_appl_id => l_component_appl_id
61233 , p_amb_context_code => l_amb_context_code
61234 , p_side => 'NA'
61235 );
61236
61237
61238 --
61239 --
61240 END IF;
61241 --
61242 -- Bug 4922099
61243 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
61244 (NVL(l_enc_upg_option, 'N') = 'O')
61245 ) AND
61246 (l_bflow_method_code = 'PRIOR_ENTRY')
61247 )
61248 THEN
61249 IF
61250 --
61251 1 = 2
61252 --
61253 THEN
61254 xla_accounting_err_pkg.build_message
61255 (p_appli_s_name => 'XLA'
61256 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
61257 ,p_token_1 => 'LINE_NUMBER'
61258 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
61259 ,p_token_2 => 'LINE_TYPE_NAME'
61260 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
61261 l_component_type
61262 ,l_component_code
61263 ,l_component_type_code
61264 ,l_component_appl_id
61265 ,l_amb_context_code
61266 ,l_entity_code
61267 ,l_event_class_code
61268 )
61269 ,p_token_3 => 'OWNER'
61270 ,p_value_3 => xla_lookups_pkg.get_meaning(
61271 p_lookup_type => 'XLA_OWNER_TYPE'
61272 ,p_lookup_code => l_component_type_code
61273 )
61274 ,p_token_4 => 'PRODUCT_NAME'
61275 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
61276 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
61277 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
61281
61278 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
61279 ,p_ae_header_id => NULL
61280 );
61282 IF (C_LEVEL_ERROR>= g_log_level) THEN
61283 trace
61284 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
61285 ,p_level => C_LEVEL_ERROR
61286 ,p_module => l_log_module);
61287 END IF;
61288 END IF;
61289 END IF;
61290 --
61291 --
61292 ------------------------------------------------------------------------------------------------
61293 -- 4219869 Business Flow
61294 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
61295 -- Prior Entry. Currently, the following code is always generated.
61296 ------------------------------------------------------------------------------------------------
61297 XLA_AE_LINES_PKG.ValidateCurrentLine;
61298
61299 ------------------------------------------------------------------------------------
61300 -- 4219869 Business Flow
61301 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
61302 ------------------------------------------------------------------------------------
61303 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
61304
61305 ----------------------------------------------------------------------------------
61306 -- 4219869 Business Flow
61307 -- Update journal entry status -- Need to generate this within IF <condition>
61308 ----------------------------------------------------------------------------------
61309 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
61310 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
61311 ,p_balance_type_code => l_balance_type_code
61312 );
61313
61314 -------------------------------------------------------------------------------------------
61315 -- 4262811 - Generate the Accrual Reversal lines
61316 -------------------------------------------------------------------------------------------
61317 BEGIN
61318 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
61319 (g_array_event(p_event_id).array_value_num('header_index'));
61320 IF l_acc_rev_flag IS NULL THEN
61321 l_acc_rev_flag := 'N';
61322 END IF;
61323 EXCEPTION
61324 WHEN OTHERS THEN
61325 l_acc_rev_flag := 'N';
61326 END;
61327 --
61328 IF (l_acc_rev_flag = 'Y') THEN
61329
61330 -- 4645092 ------------------------------------------------------------------------------
61331 -- To allow MPA report to determine if it should generate report process
61332 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
61333 ------------------------------------------------------------------------------------------
61334
61335 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
61336 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
61337 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
61338 -- call ADRs
61339 -- Bug 4922099
61340 --
61341 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
61342 (NVL(l_actual_upg_option, 'N') = 'O') OR
61343 (NVL(l_enc_upg_option, 'N') = 'O')
61344 )
61345 THEN
61346 NULL;
61347 --
61348 --
61349
61350 l_ccid := AcctDerRule_11(
61351 p_application_id => p_application_id
61352 , p_ae_header_id => l_ae_header_id
61353 , p_source_10 => p_source_10
61354 , x_transaction_coa_id => l_adr_transaction_coa_id
61355 , x_accounting_coa_id => l_adr_accounting_coa_id
61356 , x_value_type_code => l_adr_value_type_code
61357 , p_side => 'NA'
61358 );
61359
61360 xla_ae_lines_pkg.set_ccid(
61361 p_code_combination_id => l_ccid
61362 , p_value_type_code => l_adr_value_type_code
61363 , p_transaction_coa_id => l_adr_transaction_coa_id
61364 , p_accounting_coa_id => l_adr_accounting_coa_id
61365 , p_adr_code => 'DIST_CCID'
61366 , p_adr_type_code => 'S'
61367 , p_component_type => l_component_type
61368 , p_component_code => l_component_code
61369 , p_component_type_code => l_component_type_code
61370 , p_component_appl_id => l_component_appl_id
61371 , p_amb_context_code => l_amb_context_code
61372 , p_side => 'NA'
61373 );
61374
61375
61376 --
61377 --
61378 END IF;
61379
61380 --
61381 -- Update the line information that should be overwritten
61382 --
61383 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
61384 p_header_num => 1);
61385 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
61386
61387 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
61388
61389 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
61390 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
61391 END IF;
61392
61393 --
61397 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
61394 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
61395 --
61396 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
61398 ELSE
61399 ---------------------------------------------------------------------------------------------------
61400 -- 4262811a Switch Sign
61401 ---------------------------------------------------------------------------------------------------
61402 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
61403 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
61404 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61405 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
61406 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61407 -- 5132302
61408 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
61409 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61410
61411 END IF;
61412
61413 -- 4955764
61414 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
61415 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
61416
61417
61418 XLA_AE_LINES_PKG.ValidateCurrentLine;
61419 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
61420
61421 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
61422 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
61423 ,p_balance_type_code => l_balance_type_code);
61424
61425 END IF;
61426
61427 -----------------------------------------------------------------------------------------
61428 -- 4262811 Multiperiod Accounting
61429 -----------------------------------------------------------------------------------------
61430 -- No MPA option is assigned.
61431
61432
61433 END IF;
61434 END IF;
61435 --
61436
61437 --
61438 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
61439 trace
61440 (p_msg => 'END of AcctLineType_127'
61441 ,p_level => C_LEVEL_PROCEDURE
61442 ,p_module => l_log_module);
61443 END IF;
61444 --
61445 EXCEPTION
61446 WHEN xla_exceptions_pkg.application_exception THEN
61447 RAISE;
61448 WHEN OTHERS THEN
61449 xla_exceptions_pkg.raise_message
61450 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_127');
61451 END AcctLineType_127;
61452 --
61453
61454 ---------------------------------------
61455 --
61456 -- PRIVATE FUNCTION
61457 -- AcctLineType_128
61458 --
61459 ---------------------------------------
61460 PROCEDURE AcctLineType_128 (
61461 p_application_id IN NUMBER
61462 ,p_event_id IN NUMBER
61463 ,p_calculate_acctd_flag IN VARCHAR2
61464 ,p_calculate_g_l_flag IN VARCHAR2
61465 ,p_actual_flag IN OUT VARCHAR2
61466 ,p_balance_type_code OUT VARCHAR2
61467 ,p_gain_or_loss_ref OUT VARCHAR2
61468
61469 --Distribution GL Account
61470 , p_source_10 IN NUMBER
61471 --Distribution Source Type
61472 , p_source_22 IN VARCHAR2
61473 --Receivable Activity Type
61474 , p_source_23 IN VARCHAR2
61475 --Distribution Line Identifier
61476 , p_source_24 IN NUMBER
61477 --Distribution Type
61478 , p_source_25 IN VARCHAR2
61479 --Exchange Date
61480 , p_source_28 IN DATE
61481 --Exchange Rate
61482 , p_source_29 IN NUMBER
61483 --Exchange Rate Type
61484 , p_source_30 IN VARCHAR2
61485 --Transaction Distribution Identifier
61486 , p_source_36 IN NUMBER
61487 --Transaction Distribution Type
61488 , p_source_37 IN VARCHAR2
61489 --Receipt Applied To Application Identifier
61490 , p_source_60 IN NUMBER
61491 --Transaction Entity Code
61492 , p_source_61 IN VARCHAR2
61493 --Transaction Identifier
61494 , p_source_62 IN NUMBER
61495 --Applying Document Currency Code
61496 , p_source_63 IN VARCHAR2
61497 --Distribution Party Identifier
61498 , p_source_65 IN NUMBER
61499 --Distribution Party Site Id
61500 , p_source_66 IN NUMBER
61501 --Distribution Party Type
61502 , p_source_67 IN VARCHAR2
61503 --Distribution Multi Fund Additional Entry
61504 , p_source_71 IN VARCHAR2
61505 --DIST_ENT_AMT_FROM
61506 , p_source_74 IN NUMBER
61507 --Accounting Amount
61508 , p_source_75 IN NUMBER
61509 )
61510 IS
61511
61512 l_component_type VARCHAR2(80);
61513 l_component_code VARCHAR2(30);
61514 l_component_type_code VARCHAR2(1);
61515 l_component_appl_id INTEGER;
61516 l_amb_context_code VARCHAR2(30);
61517 l_entity_code VARCHAR2(30);
61518 l_event_class_code VARCHAR2(30);
61519 l_ae_header_id NUMBER;
61520 l_event_type_code VARCHAR2(30);
61521 l_line_definition_code VARCHAR2(30);
61525 l_segment VARCHAR2(30);
61522 l_line_definition_owner_code VARCHAR2(1);
61523 --
61524 -- adr variables
61526 l_ccid NUMBER;
61527 l_adr_transaction_coa_id NUMBER;
61528 l_adr_accounting_coa_id NUMBER;
61529 l_adr_flexfield_segment_code VARCHAR2(30);
61530 l_adr_flex_value_set_id NUMBER;
61531 l_adr_value_type_code VARCHAR2(30);
61532 l_adr_value_combination_id NUMBER;
61533 l_adr_value_segment_code VARCHAR2(30);
61534
61535 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
61536 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
61537 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
61538 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
61539
61540 -- 4262811 Variables ------------------------------------------------------------------------------------------
61541 l_entered_amt_idx NUMBER;
61542 l_accted_amt_idx NUMBER;
61543 l_acc_rev_flag VARCHAR2(1);
61544 l_accrual_line_num NUMBER;
61545 l_tmp_amt NUMBER;
61546 l_acc_rev_natural_side_code VARCHAR2(1);
61547
61548 l_num_entries NUMBER;
61549 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
61550 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
61551 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
61552 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
61553 l_recog_line_1 NUMBER;
61554 l_recog_line_2 NUMBER;
61555
61556 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
61557 l_bflow_applied_to_amt NUMBER; -- 5132302
61558 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
61559
61560 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
61561
61562 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
61563 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
61564
61565 ---------------------------------------------------------------------------------------------------------------
61566
61567
61568 --
61569 -- bulk performance
61570 --
61571 l_balance_type_code VARCHAR2(1);
61572 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
61573 l_log_module VARCHAR2(240);
61574
61575 --
61576 -- Upgrade strategy
61577 --
61578 l_actual_upg_option VARCHAR2(1);
61579 l_enc_upg_option VARCHAR2(1);
61580
61581 --
61582 BEGIN
61583 --
61584 IF g_log_enabled THEN
61585 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_128';
61586 END IF;
61587 --
61588 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
61589
61590 trace
61591 (p_msg => 'BEGIN of AcctLineType_128'
61592 ,p_level => C_LEVEL_PROCEDURE
61593 ,p_module => l_log_module);
61594
61595 END IF;
61596 --
61597 l_component_type := 'AMB_JLT';
61598 l_component_code := 'RCT_REFUND';
61599 l_component_type_code := 'S';
61600 l_component_appl_id := 222;
61601 l_amb_context_code := 'DEFAULT';
61602 l_entity_code := 'RECEIPTS';
61603 l_event_class_code := 'RECEIPT';
61604 l_event_type_code := 'RECEIPT_ALL';
61605 l_line_definition_owner_code := 'S';
61606 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
61607 --
61608 l_balance_type_code := 'A';
61609 l_segment := NULL;
61610 l_ccid := NULL;
61611 l_adr_transaction_coa_id := NULL;
61612 l_adr_accounting_coa_id := NULL;
61613 l_adr_flexfield_segment_code := NULL;
61614 l_adr_flex_value_set_id := NULL;
61615 l_adr_value_type_code := NULL;
61616 l_adr_value_combination_id := NULL;
61617 l_adr_value_segment_code := NULL;
61618
61619 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
61620 l_bflow_class_code := ''; -- 4219869 Business Flow
61621 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
61622 l_budgetary_control_flag := 'N';
61623
61624 l_bflow_applied_to_amt_idx := NULL; -- 5132302
61625 l_bflow_applied_to_amt := NULL; -- 5132302
61626 l_entered_amt_idx := NULL; -- 4262811
61627 l_accted_amt_idx := NULL; -- 4262811
61628 l_acc_rev_flag := NULL; -- 4262811
61629 l_accrual_line_num := NULL; -- 4262811
61630 l_tmp_amt := NULL; -- 4262811
61631 --
61632
61633 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
61634 l_balance_type_code <> 'B' THEN
61635 IF (NVL(p_source_22,'
61636 ') = 'ACTIVITY' AND
61637 NVL(p_source_23,'
61638 ') = 'CCREFUND' AND
61639 NVL(p_source_71,'
61640 ') = 'N') OR
61641 (NVL(p_source_22,'
61642 ') = 'ACTIVITY' AND
61643 NVL(p_source_23,'
61644 ') = 'CM_REFUND' AND
61645 NVL(p_source_71,'
61646 ') = 'N')
61647 THEN
61648
61649 --
61650 XLA_AE_LINES_PKG.SetNewLine;
61651
61655 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
61652 p_balance_type_code := l_balance_type_code;
61653 -- set the flag so later we will know whether the gain loss line needs to be created
61654
61656 p_actual_flag :='A';
61657 END IF;
61658
61659 --
61660 -- bulk performance
61661 --
61662 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
61663 p_header_num => 0); -- 4262811
61664 --
61665 -- set accounting line options
61666 --
61667 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
61668 p_natural_side_code => 'C'
61669 , p_gain_or_loss_flag => 'N'
61670 , p_gl_transfer_mode_code => 'S'
61671 , p_acct_entry_type_code => 'A'
61672 , p_switch_side_flag => 'Y'
61673 , p_merge_duplicate_code => 'A'
61674 );
61675 --
61676 l_acc_rev_natural_side_code := 'D'; -- 4262811
61677 --
61678 --
61679 -- set accounting line type info
61680 --
61681 xla_ae_lines_pkg.SetAcctLineType
61682 (p_component_type => l_component_type
61683 ,p_event_type_code => l_event_type_code
61684 ,p_line_definition_owner_code => l_line_definition_owner_code
61685 ,p_line_definition_code => l_line_definition_code
61686 ,p_accounting_line_code => l_component_code
61687 ,p_accounting_line_type_code => l_component_type_code
61688 ,p_accounting_line_appl_id => l_component_appl_id
61689 ,p_amb_context_code => l_amb_context_code
61690 ,p_entity_code => l_entity_code
61691 ,p_event_class_code => l_event_class_code);
61692 --
61693 -- set accounting class
61694 --
61695 xla_ae_lines_pkg.SetAcctClass(
61696 p_accounting_class_code => 'REFUND'
61697 , p_ae_header_id => l_ae_header_id
61698 );
61699
61700 --
61701 -- set rounding class
61702 --
61703 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
61704 'RECEIVABLE';
61705
61706 --
61707 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
61708 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
61709 --
61710 -- bulk performance
61711 --
61712 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
61713
61714 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
61715 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
61716
61717 -- 4955764
61718 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
61719 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
61720
61721 -- 4458381 Public Sector Enh
61722
61723 --
61724 -- set accounting attributes for the line type
61725 --
61726 l_entered_amt_idx := 8;
61727 l_accted_amt_idx := 13;
61728 l_bflow_applied_to_amt_idx := NULL; -- 5132302
61729 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
61730 l_rec_acct_attrs.array_num_value(1) := p_source_60;
61731 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
61732 l_rec_acct_attrs.array_char_value(2) := p_source_37;
61733 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
61734 l_rec_acct_attrs.array_char_value(3) := p_source_61;
61735 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
61736 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
61737 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
61738 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
61739 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
61740 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
61741 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
61742 l_rec_acct_attrs.array_char_value(7) := p_source_25;
61743 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
61744 l_rec_acct_attrs.array_num_value(8) := p_source_74;
61745 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
61746 l_rec_acct_attrs.array_char_value(9) := p_source_63;
61747 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
61748 l_rec_acct_attrs.array_date_value(10) := p_source_28;
61749 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
61750 l_rec_acct_attrs.array_num_value(11) := p_source_29;
61751 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
61752 l_rec_acct_attrs.array_char_value(12) := p_source_30;
61753 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
61754 l_rec_acct_attrs.array_num_value(13) := p_source_75;
61755 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
61756 l_rec_acct_attrs.array_num_value(14) := p_source_65;
61757 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
61758 l_rec_acct_attrs.array_num_value(15) := p_source_66;
61759 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
61760 l_rec_acct_attrs.array_char_value(16) := p_source_67;
61761
61765 ---------------------------------------------------------------------------------------------------------------
61762 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
61763 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
61764
61766 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
61767 ---------------------------------------------------------------------------------------------------------------
61768 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
61769
61770 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
61771 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
61772
61773 IF xla_accounting_cache_pkg.GetValueChar
61774 (p_source_code => 'LEDGER_CATEGORY_CODE'
61775 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
61776 AND l_bflow_method_code = 'PRIOR_ENTRY'
61777 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
61778 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
61779 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
61780 )
61781 THEN
61782 xla_ae_lines_pkg.BflowUpgEntry
61783 (p_business_method_code => l_bflow_method_code
61784 ,p_business_class_code => l_bflow_class_code
61785 ,p_balance_type => l_balance_type_code);
61786 ELSE
61787 NULL;
61788 -- No business flow processing for business flow method of NONE.
61789 END IF;
61790
61791 --
61792 -- call analytical criteria
61793 --
61794
61795 --
61796 -- call description
61797 --
61798 -- No description or it is inherited.
61799 --
61800 -- call ADRs
61801 -- Bug 4922099
61802 --
61803 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
61804 (NVL(l_actual_upg_option, 'N') = 'O') OR
61805 (NVL(l_enc_upg_option, 'N') = 'O')
61806 )
61807 THEN
61808 NULL;
61809 --
61810 --
61811
61812 l_ccid := AcctDerRule_11(
61813 p_application_id => p_application_id
61814 , p_ae_header_id => l_ae_header_id
61815 , p_source_10 => p_source_10
61816 , x_transaction_coa_id => l_adr_transaction_coa_id
61817 , x_accounting_coa_id => l_adr_accounting_coa_id
61818 , x_value_type_code => l_adr_value_type_code
61819 , p_side => 'NA'
61820 );
61821
61822 xla_ae_lines_pkg.set_ccid(
61823 p_code_combination_id => l_ccid
61824 , p_value_type_code => l_adr_value_type_code
61825 , p_transaction_coa_id => l_adr_transaction_coa_id
61826 , p_accounting_coa_id => l_adr_accounting_coa_id
61827 , p_adr_code => 'DIST_CCID'
61828 , p_adr_type_code => 'S'
61829 , p_component_type => l_component_type
61830 , p_component_code => l_component_code
61831 , p_component_type_code => l_component_type_code
61832 , p_component_appl_id => l_component_appl_id
61833 , p_amb_context_code => l_amb_context_code
61834 , p_side => 'NA'
61835 );
61836
61837
61838 --
61839 --
61840 END IF;
61841 --
61842 -- Bug 4922099
61843 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
61844 (NVL(l_enc_upg_option, 'N') = 'O')
61845 ) AND
61846 (l_bflow_method_code = 'PRIOR_ENTRY')
61847 )
61848 THEN
61849 IF
61850 --
61851 1 = 2
61852 --
61853 THEN
61854 xla_accounting_err_pkg.build_message
61855 (p_appli_s_name => 'XLA'
61856 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
61857 ,p_token_1 => 'LINE_NUMBER'
61858 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
61859 ,p_token_2 => 'LINE_TYPE_NAME'
61860 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
61861 l_component_type
61862 ,l_component_code
61863 ,l_component_type_code
61864 ,l_component_appl_id
61865 ,l_amb_context_code
61866 ,l_entity_code
61867 ,l_event_class_code
61868 )
61869 ,p_token_3 => 'OWNER'
61870 ,p_value_3 => xla_lookups_pkg.get_meaning(
61871 p_lookup_type => 'XLA_OWNER_TYPE'
61872 ,p_lookup_code => l_component_type_code
61876 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
61873 )
61874 ,p_token_4 => 'PRODUCT_NAME'
61875 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
61877 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
61878 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
61879 ,p_ae_header_id => NULL
61880 );
61881
61882 IF (C_LEVEL_ERROR>= g_log_level) THEN
61883 trace
61884 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
61885 ,p_level => C_LEVEL_ERROR
61886 ,p_module => l_log_module);
61887 END IF;
61888 END IF;
61889 END IF;
61890 --
61891 --
61892 ------------------------------------------------------------------------------------------------
61893 -- 4219869 Business Flow
61894 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
61895 -- Prior Entry. Currently, the following code is always generated.
61896 ------------------------------------------------------------------------------------------------
61897 XLA_AE_LINES_PKG.ValidateCurrentLine;
61898
61899 ------------------------------------------------------------------------------------
61900 -- 4219869 Business Flow
61901 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
61902 ------------------------------------------------------------------------------------
61903 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
61904
61905 ----------------------------------------------------------------------------------
61906 -- 4219869 Business Flow
61907 -- Update journal entry status -- Need to generate this within IF <condition>
61908 ----------------------------------------------------------------------------------
61909 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
61910 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
61911 ,p_balance_type_code => l_balance_type_code
61912 );
61913
61914 -------------------------------------------------------------------------------------------
61915 -- 4262811 - Generate the Accrual Reversal lines
61916 -------------------------------------------------------------------------------------------
61917 BEGIN
61918 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
61919 (g_array_event(p_event_id).array_value_num('header_index'));
61920 IF l_acc_rev_flag IS NULL THEN
61921 l_acc_rev_flag := 'N';
61922 END IF;
61923 EXCEPTION
61924 WHEN OTHERS THEN
61925 l_acc_rev_flag := 'N';
61926 END;
61927 --
61928 IF (l_acc_rev_flag = 'Y') THEN
61929
61930 -- 4645092 ------------------------------------------------------------------------------
61931 -- To allow MPA report to determine if it should generate report process
61932 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
61933 ------------------------------------------------------------------------------------------
61934
61935 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
61936 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
61937 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
61938 -- call ADRs
61939 -- Bug 4922099
61940 --
61941 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
61942 (NVL(l_actual_upg_option, 'N') = 'O') OR
61943 (NVL(l_enc_upg_option, 'N') = 'O')
61944 )
61945 THEN
61946 NULL;
61947 --
61948 --
61949
61950 l_ccid := AcctDerRule_11(
61951 p_application_id => p_application_id
61952 , p_ae_header_id => l_ae_header_id
61953 , p_source_10 => p_source_10
61954 , x_transaction_coa_id => l_adr_transaction_coa_id
61955 , x_accounting_coa_id => l_adr_accounting_coa_id
61956 , x_value_type_code => l_adr_value_type_code
61957 , p_side => 'NA'
61958 );
61959
61960 xla_ae_lines_pkg.set_ccid(
61961 p_code_combination_id => l_ccid
61962 , p_value_type_code => l_adr_value_type_code
61963 , p_transaction_coa_id => l_adr_transaction_coa_id
61964 , p_accounting_coa_id => l_adr_accounting_coa_id
61965 , p_adr_code => 'DIST_CCID'
61966 , p_adr_type_code => 'S'
61967 , p_component_type => l_component_type
61968 , p_component_code => l_component_code
61969 , p_component_type_code => l_component_type_code
61970 , p_component_appl_id => l_component_appl_id
61971 , p_amb_context_code => l_amb_context_code
61972 , p_side => 'NA'
61973 );
61974
61975
61976 --
61977 --
61978 END IF;
61979
61980 --
61981 -- Update the line information that should be overwritten
61982 --
61983 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
61987 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
61984 p_header_num => 1);
61985 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
61986
61988
61989 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
61990 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
61991 END IF;
61992
61993 --
61994 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
61995 --
61996 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
61997 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
61998 ELSE
61999 ---------------------------------------------------------------------------------------------------
62000 -- 4262811a Switch Sign
62001 ---------------------------------------------------------------------------------------------------
62002 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
62003 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
62004 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62005 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
62006 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62007 -- 5132302
62008 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
62009 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62010
62011 END IF;
62012
62013 -- 4955764
62014 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
62015 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
62016
62017
62018 XLA_AE_LINES_PKG.ValidateCurrentLine;
62019 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
62020
62021 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
62022 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
62023 ,p_balance_type_code => l_balance_type_code);
62024
62025 END IF;
62026
62027 -----------------------------------------------------------------------------------------
62028 -- 4262811 Multiperiod Accounting
62029 -----------------------------------------------------------------------------------------
62030 -- No MPA option is assigned.
62031
62032
62033 END IF;
62034 END IF;
62035 --
62036
62037 --
62038 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
62039 trace
62040 (p_msg => 'END of AcctLineType_128'
62041 ,p_level => C_LEVEL_PROCEDURE
62042 ,p_module => l_log_module);
62043 END IF;
62044 --
62045 EXCEPTION
62046 WHEN xla_exceptions_pkg.application_exception THEN
62047 RAISE;
62048 WHEN OTHERS THEN
62049 xla_exceptions_pkg.raise_message
62050 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_128');
62051 END AcctLineType_128;
62052 --
62053
62054 ---------------------------------------
62055 --
62056 -- PRIVATE FUNCTION
62057 -- AcctLineType_129
62058 --
62059 ---------------------------------------
62060 PROCEDURE AcctLineType_129 (
62061 p_application_id IN NUMBER
62062 ,p_event_id IN NUMBER
62063 ,p_calculate_acctd_flag IN VARCHAR2
62064 ,p_calculate_g_l_flag IN VARCHAR2
62065 ,p_actual_flag IN OUT VARCHAR2
62066 ,p_balance_type_code OUT VARCHAR2
62067 ,p_gain_or_loss_ref OUT VARCHAR2
62068
62069 --Distribution GL Account
62070 , p_source_10 IN NUMBER
62071 --Distribution Source Type
62072 , p_source_22 IN VARCHAR2
62073 --Distribution Line Identifier
62074 , p_source_24 IN NUMBER
62075 --Distribution Type
62076 , p_source_25 IN VARCHAR2
62077 --Exchange Date
62078 , p_source_28 IN DATE
62079 --Exchange Rate
62080 , p_source_29 IN NUMBER
62081 --Exchange Rate Type
62082 , p_source_30 IN VARCHAR2
62083 --Transaction Distribution Identifier
62084 , p_source_36 IN NUMBER
62085 --Transaction Distribution Type
62086 , p_source_37 IN VARCHAR2
62087 --Receipt Applied To Application Identifier
62088 , p_source_60 IN NUMBER
62089 --Transaction Entity Code
62090 , p_source_61 IN VARCHAR2
62091 --Transaction Identifier
62092 , p_source_62 IN NUMBER
62093 --Applying Document Currency Code
62094 , p_source_63 IN VARCHAR2
62095 --Distribution Party Identifier
62096 , p_source_65 IN NUMBER
62097 --Distribution Party Site Id
62098 , p_source_66 IN NUMBER
62099 --Distribution Party Type
62100 , p_source_67 IN VARCHAR2
62101 --Distribution Multi Fund Additional Entry
62102 , p_source_71 IN VARCHAR2
62103 --DIST_ENT_AMT_FROM
62104 , p_source_74 IN NUMBER
62105 --Accounting Amount
62106 , p_source_75 IN NUMBER
62107 --Distribution Source Table
62111
62108 , p_source_77 IN VARCHAR2
62109 )
62110 IS
62112 l_component_type VARCHAR2(80);
62113 l_component_code VARCHAR2(30);
62114 l_component_type_code VARCHAR2(1);
62115 l_component_appl_id INTEGER;
62116 l_amb_context_code VARCHAR2(30);
62117 l_entity_code VARCHAR2(30);
62118 l_event_class_code VARCHAR2(30);
62119 l_ae_header_id NUMBER;
62120 l_event_type_code VARCHAR2(30);
62121 l_line_definition_code VARCHAR2(30);
62122 l_line_definition_owner_code VARCHAR2(1);
62123 --
62124 -- adr variables
62125 l_segment VARCHAR2(30);
62126 l_ccid NUMBER;
62127 l_adr_transaction_coa_id NUMBER;
62128 l_adr_accounting_coa_id NUMBER;
62129 l_adr_flexfield_segment_code VARCHAR2(30);
62130 l_adr_flex_value_set_id NUMBER;
62131 l_adr_value_type_code VARCHAR2(30);
62132 l_adr_value_combination_id NUMBER;
62133 l_adr_value_segment_code VARCHAR2(30);
62134
62135 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
62136 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
62137 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
62138 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
62139
62140 -- 4262811 Variables ------------------------------------------------------------------------------------------
62141 l_entered_amt_idx NUMBER;
62142 l_accted_amt_idx NUMBER;
62143 l_acc_rev_flag VARCHAR2(1);
62144 l_accrual_line_num NUMBER;
62145 l_tmp_amt NUMBER;
62146 l_acc_rev_natural_side_code VARCHAR2(1);
62147
62148 l_num_entries NUMBER;
62149 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
62150 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
62151 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
62152 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
62153 l_recog_line_1 NUMBER;
62154 l_recog_line_2 NUMBER;
62155
62156 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
62157 l_bflow_applied_to_amt NUMBER; -- 5132302
62158 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
62159
62160 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
62161
62162 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
62163 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
62164
62165 ---------------------------------------------------------------------------------------------------------------
62166
62167
62168 --
62169 -- bulk performance
62170 --
62171 l_balance_type_code VARCHAR2(1);
62172 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
62173 l_log_module VARCHAR2(240);
62174
62175 --
62176 -- Upgrade strategy
62177 --
62178 l_actual_upg_option VARCHAR2(1);
62179 l_enc_upg_option VARCHAR2(1);
62180
62181 --
62182 BEGIN
62183 --
62184 IF g_log_enabled THEN
62185 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_129';
62186 END IF;
62187 --
62188 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
62189
62190 trace
62191 (p_msg => 'BEGIN of AcctLineType_129'
62192 ,p_level => C_LEVEL_PROCEDURE
62193 ,p_module => l_log_module);
62194
62195 END IF;
62196 --
62197 l_component_type := 'AMB_JLT';
62198 l_component_code := 'RCT_REMIT';
62199 l_component_type_code := 'S';
62200 l_component_appl_id := 222;
62201 l_amb_context_code := 'DEFAULT';
62202 l_entity_code := 'RECEIPTS';
62203 l_event_class_code := 'RECEIPT';
62204 l_event_type_code := 'RECEIPT_ALL';
62205 l_line_definition_owner_code := 'S';
62206 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
62207 --
62208 l_balance_type_code := 'A';
62209 l_segment := NULL;
62210 l_ccid := NULL;
62211 l_adr_transaction_coa_id := NULL;
62212 l_adr_accounting_coa_id := NULL;
62213 l_adr_flexfield_segment_code := NULL;
62214 l_adr_flex_value_set_id := NULL;
62215 l_adr_value_type_code := NULL;
62216 l_adr_value_combination_id := NULL;
62217 l_adr_value_segment_code := NULL;
62218
62219 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
62220 l_bflow_class_code := ''; -- 4219869 Business Flow
62221 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
62222 l_budgetary_control_flag := 'N';
62223
62224 l_bflow_applied_to_amt_idx := NULL; -- 5132302
62225 l_bflow_applied_to_amt := NULL; -- 5132302
62226 l_entered_amt_idx := NULL; -- 4262811
62227 l_accted_amt_idx := NULL; -- 4262811
62228 l_acc_rev_flag := NULL; -- 4262811
62229 l_accrual_line_num := NULL; -- 4262811
62230 l_tmp_amt := NULL; -- 4262811
62231 --
62232
62236 ') = 'REMITTANCE' AND
62233 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
62234 l_balance_type_code <> 'B' THEN
62235 IF NVL(p_source_22,'
62237 NVL(p_source_77,'
62238 ') = 'CRH' AND
62239 NVL(p_source_71,'
62240 ') = 'N'
62241 THEN
62242
62243 --
62244 XLA_AE_LINES_PKG.SetNewLine;
62245
62246 p_balance_type_code := l_balance_type_code;
62247 -- set the flag so later we will know whether the gain loss line needs to be created
62248
62249 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
62250 p_actual_flag :='A';
62251 END IF;
62252
62253 --
62254 -- bulk performance
62255 --
62256 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
62257 p_header_num => 0); -- 4262811
62258 --
62259 -- set accounting line options
62260 --
62261 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
62262 p_natural_side_code => 'C'
62263 , p_gain_or_loss_flag => 'N'
62264 , p_gl_transfer_mode_code => 'S'
62265 , p_acct_entry_type_code => 'A'
62266 , p_switch_side_flag => 'Y'
62267 , p_merge_duplicate_code => 'A'
62268 );
62269 --
62270 l_acc_rev_natural_side_code := 'D'; -- 4262811
62271 --
62272 --
62273 -- set accounting line type info
62274 --
62275 xla_ae_lines_pkg.SetAcctLineType
62276 (p_component_type => l_component_type
62277 ,p_event_type_code => l_event_type_code
62278 ,p_line_definition_owner_code => l_line_definition_owner_code
62279 ,p_line_definition_code => l_line_definition_code
62280 ,p_accounting_line_code => l_component_code
62281 ,p_accounting_line_type_code => l_component_type_code
62282 ,p_accounting_line_appl_id => l_component_appl_id
62283 ,p_amb_context_code => l_amb_context_code
62284 ,p_entity_code => l_entity_code
62285 ,p_event_class_code => l_event_class_code);
62286 --
62287 -- set accounting class
62288 --
62289 xla_ae_lines_pkg.SetAcctClass(
62290 p_accounting_class_code => 'REMITTANCE'
62291 , p_ae_header_id => l_ae_header_id
62292 );
62293
62294 --
62295 -- set rounding class
62296 --
62297 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
62298 'RECEIVABLE';
62299
62300 --
62301 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
62302 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
62303 --
62304 -- bulk performance
62305 --
62306 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
62307
62308 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
62309 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
62310
62311 -- 4955764
62312 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
62313 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
62314
62315 -- 4458381 Public Sector Enh
62316
62317 --
62318 -- set accounting attributes for the line type
62319 --
62320 l_entered_amt_idx := 8;
62321 l_accted_amt_idx := 13;
62322 l_bflow_applied_to_amt_idx := NULL; -- 5132302
62323 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
62324 l_rec_acct_attrs.array_num_value(1) := p_source_60;
62325 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
62326 l_rec_acct_attrs.array_char_value(2) := p_source_37;
62327 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
62328 l_rec_acct_attrs.array_char_value(3) := p_source_61;
62329 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
62330 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
62331 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
62332 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
62333 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
62334 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
62335 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
62336 l_rec_acct_attrs.array_char_value(7) := p_source_25;
62337 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
62338 l_rec_acct_attrs.array_num_value(8) := p_source_74;
62339 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
62340 l_rec_acct_attrs.array_char_value(9) := p_source_63;
62341 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
62342 l_rec_acct_attrs.array_date_value(10) := p_source_28;
62343 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
62344 l_rec_acct_attrs.array_num_value(11) := p_source_29;
62345 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
62346 l_rec_acct_attrs.array_char_value(12) := p_source_30;
62347 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
62348 l_rec_acct_attrs.array_num_value(13) := p_source_75;
62352 l_rec_acct_attrs.array_num_value(15) := p_source_66;
62349 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
62350 l_rec_acct_attrs.array_num_value(14) := p_source_65;
62351 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
62353 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
62354 l_rec_acct_attrs.array_char_value(16) := p_source_67;
62355
62356 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
62357 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
62358
62359 ---------------------------------------------------------------------------------------------------------------
62360 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
62361 ---------------------------------------------------------------------------------------------------------------
62362 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
62363
62364 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
62365 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
62366
62367 IF xla_accounting_cache_pkg.GetValueChar
62368 (p_source_code => 'LEDGER_CATEGORY_CODE'
62369 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
62370 AND l_bflow_method_code = 'PRIOR_ENTRY'
62371 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
62372 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
62373 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
62374 )
62375 THEN
62376 xla_ae_lines_pkg.BflowUpgEntry
62377 (p_business_method_code => l_bflow_method_code
62378 ,p_business_class_code => l_bflow_class_code
62379 ,p_balance_type => l_balance_type_code);
62380 ELSE
62381 NULL;
62382 -- No business flow processing for business flow method of NONE.
62383 END IF;
62384
62385 --
62386 -- call analytical criteria
62387 --
62388
62389 --
62390 -- call description
62391 --
62392 -- No description or it is inherited.
62393 --
62394 -- call ADRs
62395 -- Bug 4922099
62396 --
62397 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
62398 (NVL(l_actual_upg_option, 'N') = 'O') OR
62399 (NVL(l_enc_upg_option, 'N') = 'O')
62400 )
62401 THEN
62402 NULL;
62403 --
62404 --
62405
62406 l_ccid := AcctDerRule_11(
62407 p_application_id => p_application_id
62408 , p_ae_header_id => l_ae_header_id
62409 , p_source_10 => p_source_10
62410 , x_transaction_coa_id => l_adr_transaction_coa_id
62411 , x_accounting_coa_id => l_adr_accounting_coa_id
62412 , x_value_type_code => l_adr_value_type_code
62413 , p_side => 'NA'
62414 );
62415
62416 xla_ae_lines_pkg.set_ccid(
62417 p_code_combination_id => l_ccid
62418 , p_value_type_code => l_adr_value_type_code
62419 , p_transaction_coa_id => l_adr_transaction_coa_id
62420 , p_accounting_coa_id => l_adr_accounting_coa_id
62421 , p_adr_code => 'DIST_CCID'
62422 , p_adr_type_code => 'S'
62423 , p_component_type => l_component_type
62424 , p_component_code => l_component_code
62425 , p_component_type_code => l_component_type_code
62426 , p_component_appl_id => l_component_appl_id
62427 , p_amb_context_code => l_amb_context_code
62428 , p_side => 'NA'
62429 );
62430
62431
62432 --
62433 --
62434 END IF;
62435 --
62436 -- Bug 4922099
62437 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
62438 (NVL(l_enc_upg_option, 'N') = 'O')
62439 ) AND
62440 (l_bflow_method_code = 'PRIOR_ENTRY')
62441 )
62442 THEN
62443 IF
62444 --
62445 1 = 2
62446 --
62447 THEN
62448 xla_accounting_err_pkg.build_message
62449 (p_appli_s_name => 'XLA'
62450 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
62451 ,p_token_1 => 'LINE_NUMBER'
62452 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
62453 ,p_token_2 => 'LINE_TYPE_NAME'
62454 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
62455 l_component_type
62456 ,l_component_code
62457 ,l_component_type_code
62458 ,l_component_appl_id
62459 ,l_amb_context_code
62460 ,l_entity_code
62461 ,l_event_class_code
62462 )
62466 ,p_lookup_code => l_component_type_code
62463 ,p_token_3 => 'OWNER'
62464 ,p_value_3 => xla_lookups_pkg.get_meaning(
62465 p_lookup_type => 'XLA_OWNER_TYPE'
62467 )
62468 ,p_token_4 => 'PRODUCT_NAME'
62469 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
62470 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
62471 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
62472 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
62473 ,p_ae_header_id => NULL
62474 );
62475
62476 IF (C_LEVEL_ERROR>= g_log_level) THEN
62477 trace
62478 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
62479 ,p_level => C_LEVEL_ERROR
62480 ,p_module => l_log_module);
62481 END IF;
62482 END IF;
62483 END IF;
62484 --
62485 --
62486 ------------------------------------------------------------------------------------------------
62487 -- 4219869 Business Flow
62488 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
62489 -- Prior Entry. Currently, the following code is always generated.
62490 ------------------------------------------------------------------------------------------------
62491 XLA_AE_LINES_PKG.ValidateCurrentLine;
62492
62493 ------------------------------------------------------------------------------------
62494 -- 4219869 Business Flow
62495 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
62496 ------------------------------------------------------------------------------------
62497 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
62498
62499 ----------------------------------------------------------------------------------
62500 -- 4219869 Business Flow
62501 -- Update journal entry status -- Need to generate this within IF <condition>
62502 ----------------------------------------------------------------------------------
62503 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
62504 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
62505 ,p_balance_type_code => l_balance_type_code
62506 );
62507
62508 -------------------------------------------------------------------------------------------
62509 -- 4262811 - Generate the Accrual Reversal lines
62510 -------------------------------------------------------------------------------------------
62511 BEGIN
62512 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
62513 (g_array_event(p_event_id).array_value_num('header_index'));
62514 IF l_acc_rev_flag IS NULL THEN
62515 l_acc_rev_flag := 'N';
62516 END IF;
62517 EXCEPTION
62518 WHEN OTHERS THEN
62519 l_acc_rev_flag := 'N';
62520 END;
62521 --
62522 IF (l_acc_rev_flag = 'Y') THEN
62523
62524 -- 4645092 ------------------------------------------------------------------------------
62525 -- To allow MPA report to determine if it should generate report process
62526 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
62527 ------------------------------------------------------------------------------------------
62528
62529 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
62530 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
62531 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
62532 -- call ADRs
62533 -- Bug 4922099
62534 --
62535 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
62536 (NVL(l_actual_upg_option, 'N') = 'O') OR
62537 (NVL(l_enc_upg_option, 'N') = 'O')
62538 )
62539 THEN
62540 NULL;
62541 --
62542 --
62543
62544 l_ccid := AcctDerRule_11(
62545 p_application_id => p_application_id
62546 , p_ae_header_id => l_ae_header_id
62547 , p_source_10 => p_source_10
62548 , x_transaction_coa_id => l_adr_transaction_coa_id
62549 , x_accounting_coa_id => l_adr_accounting_coa_id
62550 , x_value_type_code => l_adr_value_type_code
62551 , p_side => 'NA'
62552 );
62553
62554 xla_ae_lines_pkg.set_ccid(
62555 p_code_combination_id => l_ccid
62556 , p_value_type_code => l_adr_value_type_code
62557 , p_transaction_coa_id => l_adr_transaction_coa_id
62558 , p_accounting_coa_id => l_adr_accounting_coa_id
62559 , p_adr_code => 'DIST_CCID'
62560 , p_adr_type_code => 'S'
62561 , p_component_type => l_component_type
62562 , p_component_code => l_component_code
62563 , p_component_type_code => l_component_type_code
62564 , p_component_appl_id => l_component_appl_id
62568
62565 , p_amb_context_code => l_amb_context_code
62566 , p_side => 'NA'
62567 );
62569
62570 --
62571 --
62572 END IF;
62573
62574 --
62575 -- Update the line information that should be overwritten
62576 --
62577 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
62578 p_header_num => 1);
62579 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
62580
62581 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
62582
62583 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
62584 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
62585 END IF;
62586
62587 --
62588 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
62589 --
62590 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
62591 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
62592 ELSE
62593 ---------------------------------------------------------------------------------------------------
62594 -- 4262811a Switch Sign
62595 ---------------------------------------------------------------------------------------------------
62596 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
62597 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
62598 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62599 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
62600 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62601 -- 5132302
62602 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
62603 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62604
62605 END IF;
62606
62607 -- 4955764
62608 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
62609 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
62610
62611
62612 XLA_AE_LINES_PKG.ValidateCurrentLine;
62613 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
62614
62615 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
62616 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
62617 ,p_balance_type_code => l_balance_type_code);
62618
62619 END IF;
62620
62621 -----------------------------------------------------------------------------------------
62622 -- 4262811 Multiperiod Accounting
62623 -----------------------------------------------------------------------------------------
62624 -- No MPA option is assigned.
62625
62626
62627 END IF;
62628 END IF;
62629 --
62630
62631 --
62632 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
62633 trace
62634 (p_msg => 'END of AcctLineType_129'
62635 ,p_level => C_LEVEL_PROCEDURE
62636 ,p_module => l_log_module);
62637 END IF;
62638 --
62639 EXCEPTION
62640 WHEN xla_exceptions_pkg.application_exception THEN
62641 RAISE;
62642 WHEN OTHERS THEN
62643 xla_exceptions_pkg.raise_message
62644 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_129');
62645 END AcctLineType_129;
62646 --
62647
62648 ---------------------------------------
62649 --
62650 -- PRIVATE FUNCTION
62651 -- AcctLineType_130
62652 --
62653 ---------------------------------------
62654 PROCEDURE AcctLineType_130 (
62655 p_application_id IN NUMBER
62656 ,p_event_id IN NUMBER
62657 ,p_calculate_acctd_flag IN VARCHAR2
62658 ,p_calculate_g_l_flag IN VARCHAR2
62659 ,p_actual_flag IN OUT VARCHAR2
62660 ,p_balance_type_code OUT VARCHAR2
62661 ,p_gain_or_loss_ref OUT VARCHAR2
62662
62663 --Distribution GL Account
62664 , p_source_10 IN NUMBER
62665 --Distribution Source Type
62666 , p_source_22 IN VARCHAR2
62667 --Distribution Line Identifier
62668 , p_source_24 IN NUMBER
62669 --Distribution Type
62670 , p_source_25 IN VARCHAR2
62671 --Exchange Date
62672 , p_source_28 IN DATE
62673 --Exchange Rate
62674 , p_source_29 IN NUMBER
62675 --Exchange Rate Type
62676 , p_source_30 IN VARCHAR2
62677 --Transaction Distribution Identifier
62678 , p_source_36 IN NUMBER
62679 --Transaction Distribution Type
62680 , p_source_37 IN VARCHAR2
62681 --Receipt Applied To Application Identifier
62682 , p_source_60 IN NUMBER
62683 --Transaction Entity Code
62684 , p_source_61 IN VARCHAR2
62685 --Transaction Identifier
62686 , p_source_62 IN NUMBER
62687 --Applying Document Currency Code
62688 , p_source_63 IN VARCHAR2
62689 --Distribution Party Identifier
62690 , p_source_65 IN NUMBER
62694 , p_source_67 IN VARCHAR2
62691 --Distribution Party Site Id
62692 , p_source_66 IN NUMBER
62693 --Distribution Party Type
62695 --Distribution Multi Fund Additional Entry
62696 , p_source_71 IN VARCHAR2
62697 --DIST_ENT_AMT_FROM
62698 , p_source_74 IN NUMBER
62699 --Accounting Amount
62700 , p_source_75 IN NUMBER
62701 --Distribution Source Table
62702 , p_source_77 IN VARCHAR2
62703 )
62704 IS
62705
62706 l_component_type VARCHAR2(80);
62707 l_component_code VARCHAR2(30);
62708 l_component_type_code VARCHAR2(1);
62709 l_component_appl_id INTEGER;
62710 l_amb_context_code VARCHAR2(30);
62711 l_entity_code VARCHAR2(30);
62712 l_event_class_code VARCHAR2(30);
62713 l_ae_header_id NUMBER;
62714 l_event_type_code VARCHAR2(30);
62715 l_line_definition_code VARCHAR2(30);
62716 l_line_definition_owner_code VARCHAR2(1);
62717 --
62718 -- adr variables
62719 l_segment VARCHAR2(30);
62720 l_ccid NUMBER;
62721 l_adr_transaction_coa_id NUMBER;
62722 l_adr_accounting_coa_id NUMBER;
62723 l_adr_flexfield_segment_code VARCHAR2(30);
62724 l_adr_flex_value_set_id NUMBER;
62725 l_adr_value_type_code VARCHAR2(30);
62726 l_adr_value_combination_id NUMBER;
62727 l_adr_value_segment_code VARCHAR2(30);
62728
62729 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
62730 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
62731 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
62732 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
62733
62734 -- 4262811 Variables ------------------------------------------------------------------------------------------
62735 l_entered_amt_idx NUMBER;
62736 l_accted_amt_idx NUMBER;
62737 l_acc_rev_flag VARCHAR2(1);
62738 l_accrual_line_num NUMBER;
62739 l_tmp_amt NUMBER;
62740 l_acc_rev_natural_side_code VARCHAR2(1);
62741
62742 l_num_entries NUMBER;
62743 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
62744 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
62745 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
62746 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
62747 l_recog_line_1 NUMBER;
62748 l_recog_line_2 NUMBER;
62749
62750 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
62751 l_bflow_applied_to_amt NUMBER; -- 5132302
62752 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
62753
62754 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
62755
62756 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
62757 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
62758
62759 ---------------------------------------------------------------------------------------------------------------
62760
62761
62762 --
62763 -- bulk performance
62764 --
62765 l_balance_type_code VARCHAR2(1);
62766 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
62767 l_log_module VARCHAR2(240);
62768
62769 --
62770 -- Upgrade strategy
62771 --
62772 l_actual_upg_option VARCHAR2(1);
62773 l_enc_upg_option VARCHAR2(1);
62774
62775 --
62776 BEGIN
62777 --
62778 IF g_log_enabled THEN
62779 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_130';
62780 END IF;
62781 --
62782 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
62783
62784 trace
62785 (p_msg => 'BEGIN of AcctLineType_130'
62786 ,p_level => C_LEVEL_PROCEDURE
62787 ,p_module => l_log_module);
62788
62789 END IF;
62790 --
62791 l_component_type := 'AMB_JLT';
62792 l_component_code := 'RCT_REMIT_BR';
62793 l_component_type_code := 'S';
62794 l_component_appl_id := 222;
62795 l_amb_context_code := 'DEFAULT';
62796 l_entity_code := 'RECEIPTS';
62797 l_event_class_code := 'RECEIPT';
62798 l_event_type_code := 'RECEIPT_ALL';
62799 l_line_definition_owner_code := 'S';
62800 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
62801 --
62802 l_balance_type_code := 'A';
62803 l_segment := NULL;
62804 l_ccid := NULL;
62805 l_adr_transaction_coa_id := NULL;
62806 l_adr_accounting_coa_id := NULL;
62807 l_adr_flexfield_segment_code := NULL;
62808 l_adr_flex_value_set_id := NULL;
62809 l_adr_value_type_code := NULL;
62810 l_adr_value_combination_id := NULL;
62811 l_adr_value_segment_code := NULL;
62812
62813 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
62814 l_bflow_class_code := ''; -- 4219869 Business Flow
62815 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
62816 l_budgetary_control_flag := 'N';
62817
62818 l_bflow_applied_to_amt_idx := NULL; -- 5132302
62819 l_bflow_applied_to_amt := NULL; -- 5132302
62823 l_accrual_line_num := NULL; -- 4262811
62820 l_entered_amt_idx := NULL; -- 4262811
62821 l_accted_amt_idx := NULL; -- 4262811
62822 l_acc_rev_flag := NULL; -- 4262811
62824 l_tmp_amt := NULL; -- 4262811
62825 --
62826
62827 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
62828 l_balance_type_code <> 'B' THEN
62829 IF NVL(p_source_22,'
62830 ') = 'REMITTANCE' AND
62831 NVL(p_source_77,'
62832 ') = 'RA' AND
62833 NVL(p_source_71,'
62834 ') = 'N'
62835 THEN
62836
62837 --
62838 XLA_AE_LINES_PKG.SetNewLine;
62839
62840 p_balance_type_code := l_balance_type_code;
62841 -- set the flag so later we will know whether the gain loss line needs to be created
62842
62843 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
62844 p_actual_flag :='A';
62845 END IF;
62846
62847 --
62848 -- bulk performance
62849 --
62850 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
62851 p_header_num => 0); -- 4262811
62852 --
62853 -- set accounting line options
62854 --
62855 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
62856 p_natural_side_code => 'C'
62857 , p_gain_or_loss_flag => 'N'
62858 , p_gl_transfer_mode_code => 'S'
62859 , p_acct_entry_type_code => 'A'
62860 , p_switch_side_flag => 'Y'
62861 , p_merge_duplicate_code => 'A'
62862 );
62863 --
62864 l_acc_rev_natural_side_code := 'D'; -- 4262811
62865 --
62866 --
62867 -- set accounting line type info
62868 --
62869 xla_ae_lines_pkg.SetAcctLineType
62870 (p_component_type => l_component_type
62871 ,p_event_type_code => l_event_type_code
62872 ,p_line_definition_owner_code => l_line_definition_owner_code
62873 ,p_line_definition_code => l_line_definition_code
62874 ,p_accounting_line_code => l_component_code
62875 ,p_accounting_line_type_code => l_component_type_code
62876 ,p_accounting_line_appl_id => l_component_appl_id
62877 ,p_amb_context_code => l_amb_context_code
62878 ,p_entity_code => l_entity_code
62879 ,p_event_class_code => l_event_class_code);
62880 --
62881 -- set accounting class
62882 --
62883 xla_ae_lines_pkg.SetAcctClass(
62884 p_accounting_class_code => 'REM_BR'
62885 , p_ae_header_id => l_ae_header_id
62886 );
62887
62888 --
62889 -- set rounding class
62890 --
62891 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
62892 'RECEIVABLE';
62893
62894 --
62895 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
62896 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
62897 --
62898 -- bulk performance
62899 --
62900 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
62901
62902 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
62903 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
62904
62905 -- 4955764
62906 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
62907 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
62908
62909 -- 4458381 Public Sector Enh
62910
62911 --
62912 -- set accounting attributes for the line type
62913 --
62914 l_entered_amt_idx := 8;
62915 l_accted_amt_idx := 13;
62916 l_bflow_applied_to_amt_idx := NULL; -- 5132302
62917 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
62918 l_rec_acct_attrs.array_num_value(1) := p_source_60;
62919 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
62920 l_rec_acct_attrs.array_char_value(2) := p_source_37;
62921 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
62922 l_rec_acct_attrs.array_char_value(3) := p_source_61;
62923 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
62924 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
62925 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
62926 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
62927 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
62928 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
62929 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
62930 l_rec_acct_attrs.array_char_value(7) := p_source_25;
62931 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
62932 l_rec_acct_attrs.array_num_value(8) := p_source_74;
62933 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
62934 l_rec_acct_attrs.array_char_value(9) := p_source_63;
62935 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
62936 l_rec_acct_attrs.array_date_value(10) := p_source_28;
62937 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
62938 l_rec_acct_attrs.array_num_value(11) := p_source_29;
62939 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
62943 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
62940 l_rec_acct_attrs.array_char_value(12) := p_source_30;
62941 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
62942 l_rec_acct_attrs.array_num_value(13) := p_source_75;
62944 l_rec_acct_attrs.array_num_value(14) := p_source_65;
62945 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
62946 l_rec_acct_attrs.array_num_value(15) := p_source_66;
62947 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
62948 l_rec_acct_attrs.array_char_value(16) := p_source_67;
62949
62950 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
62951 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
62952
62953 ---------------------------------------------------------------------------------------------------------------
62954 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
62955 ---------------------------------------------------------------------------------------------------------------
62956 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
62957
62958 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
62959 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
62960
62961 IF xla_accounting_cache_pkg.GetValueChar
62962 (p_source_code => 'LEDGER_CATEGORY_CODE'
62963 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
62964 AND l_bflow_method_code = 'PRIOR_ENTRY'
62965 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
62966 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
62967 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
62968 )
62969 THEN
62970 xla_ae_lines_pkg.BflowUpgEntry
62971 (p_business_method_code => l_bflow_method_code
62972 ,p_business_class_code => l_bflow_class_code
62973 ,p_balance_type => l_balance_type_code);
62974 ELSE
62975 NULL;
62976 -- No business flow processing for business flow method of NONE.
62977 END IF;
62978
62979 --
62980 -- call analytical criteria
62981 --
62982
62983 --
62984 -- call description
62985 --
62986 -- No description or it is inherited.
62987 --
62988 -- call ADRs
62989 -- Bug 4922099
62990 --
62991 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
62992 (NVL(l_actual_upg_option, 'N') = 'O') OR
62993 (NVL(l_enc_upg_option, 'N') = 'O')
62994 )
62995 THEN
62996 NULL;
62997 --
62998 --
62999
63000 l_ccid := AcctDerRule_11(
63001 p_application_id => p_application_id
63002 , p_ae_header_id => l_ae_header_id
63003 , p_source_10 => p_source_10
63004 , x_transaction_coa_id => l_adr_transaction_coa_id
63005 , x_accounting_coa_id => l_adr_accounting_coa_id
63006 , x_value_type_code => l_adr_value_type_code
63007 , p_side => 'NA'
63008 );
63009
63010 xla_ae_lines_pkg.set_ccid(
63011 p_code_combination_id => l_ccid
63012 , p_value_type_code => l_adr_value_type_code
63013 , p_transaction_coa_id => l_adr_transaction_coa_id
63014 , p_accounting_coa_id => l_adr_accounting_coa_id
63015 , p_adr_code => 'DIST_CCID'
63016 , p_adr_type_code => 'S'
63017 , p_component_type => l_component_type
63018 , p_component_code => l_component_code
63019 , p_component_type_code => l_component_type_code
63020 , p_component_appl_id => l_component_appl_id
63021 , p_amb_context_code => l_amb_context_code
63022 , p_side => 'NA'
63023 );
63024
63025
63026 --
63027 --
63028 END IF;
63029 --
63030 -- Bug 4922099
63031 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
63032 (NVL(l_enc_upg_option, 'N') = 'O')
63033 ) AND
63034 (l_bflow_method_code = 'PRIOR_ENTRY')
63035 )
63036 THEN
63037 IF
63038 --
63039 1 = 2
63040 --
63041 THEN
63042 xla_accounting_err_pkg.build_message
63043 (p_appli_s_name => 'XLA'
63044 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
63045 ,p_token_1 => 'LINE_NUMBER'
63046 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
63047 ,p_token_2 => 'LINE_TYPE_NAME'
63048 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
63049 l_component_type
63050 ,l_component_code
63051 ,l_component_type_code
63052 ,l_component_appl_id
63053 ,l_amb_context_code
63057 ,p_token_3 => 'OWNER'
63054 ,l_entity_code
63055 ,l_event_class_code
63056 )
63058 ,p_value_3 => xla_lookups_pkg.get_meaning(
63059 p_lookup_type => 'XLA_OWNER_TYPE'
63060 ,p_lookup_code => l_component_type_code
63061 )
63062 ,p_token_4 => 'PRODUCT_NAME'
63063 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
63064 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
63065 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
63066 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
63067 ,p_ae_header_id => NULL
63068 );
63069
63070 IF (C_LEVEL_ERROR>= g_log_level) THEN
63071 trace
63072 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
63073 ,p_level => C_LEVEL_ERROR
63074 ,p_module => l_log_module);
63075 END IF;
63076 END IF;
63077 END IF;
63078 --
63079 --
63080 ------------------------------------------------------------------------------------------------
63081 -- 4219869 Business Flow
63082 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
63083 -- Prior Entry. Currently, the following code is always generated.
63084 ------------------------------------------------------------------------------------------------
63085 XLA_AE_LINES_PKG.ValidateCurrentLine;
63086
63087 ------------------------------------------------------------------------------------
63088 -- 4219869 Business Flow
63089 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
63090 ------------------------------------------------------------------------------------
63091 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
63092
63093 ----------------------------------------------------------------------------------
63094 -- 4219869 Business Flow
63095 -- Update journal entry status -- Need to generate this within IF <condition>
63096 ----------------------------------------------------------------------------------
63097 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
63098 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
63099 ,p_balance_type_code => l_balance_type_code
63100 );
63101
63102 -------------------------------------------------------------------------------------------
63103 -- 4262811 - Generate the Accrual Reversal lines
63104 -------------------------------------------------------------------------------------------
63105 BEGIN
63106 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
63107 (g_array_event(p_event_id).array_value_num('header_index'));
63108 IF l_acc_rev_flag IS NULL THEN
63109 l_acc_rev_flag := 'N';
63110 END IF;
63111 EXCEPTION
63112 WHEN OTHERS THEN
63113 l_acc_rev_flag := 'N';
63114 END;
63115 --
63116 IF (l_acc_rev_flag = 'Y') THEN
63117
63118 -- 4645092 ------------------------------------------------------------------------------
63119 -- To allow MPA report to determine if it should generate report process
63120 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
63121 ------------------------------------------------------------------------------------------
63122
63123 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
63124 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
63125 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
63126 -- call ADRs
63127 -- Bug 4922099
63128 --
63129 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
63130 (NVL(l_actual_upg_option, 'N') = 'O') OR
63131 (NVL(l_enc_upg_option, 'N') = 'O')
63132 )
63133 THEN
63134 NULL;
63135 --
63136 --
63137
63138 l_ccid := AcctDerRule_11(
63139 p_application_id => p_application_id
63140 , p_ae_header_id => l_ae_header_id
63141 , p_source_10 => p_source_10
63142 , x_transaction_coa_id => l_adr_transaction_coa_id
63143 , x_accounting_coa_id => l_adr_accounting_coa_id
63144 , x_value_type_code => l_adr_value_type_code
63145 , p_side => 'NA'
63146 );
63147
63148 xla_ae_lines_pkg.set_ccid(
63149 p_code_combination_id => l_ccid
63150 , p_value_type_code => l_adr_value_type_code
63151 , p_transaction_coa_id => l_adr_transaction_coa_id
63152 , p_accounting_coa_id => l_adr_accounting_coa_id
63153 , p_adr_code => 'DIST_CCID'
63154 , p_adr_type_code => 'S'
63158 , p_component_appl_id => l_component_appl_id
63155 , p_component_type => l_component_type
63156 , p_component_code => l_component_code
63157 , p_component_type_code => l_component_type_code
63159 , p_amb_context_code => l_amb_context_code
63160 , p_side => 'NA'
63161 );
63162
63163
63164 --
63165 --
63166 END IF;
63167
63168 --
63169 -- Update the line information that should be overwritten
63170 --
63171 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
63172 p_header_num => 1);
63173 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
63174
63175 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
63176
63177 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
63178 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
63179 END IF;
63180
63181 --
63182 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
63183 --
63184 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
63185 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
63186 ELSE
63187 ---------------------------------------------------------------------------------------------------
63188 -- 4262811a Switch Sign
63189 ---------------------------------------------------------------------------------------------------
63190 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
63191 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
63192 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63193 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
63194 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63195 -- 5132302
63196 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
63197 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63198
63199 END IF;
63200
63201 -- 4955764
63202 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
63203 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
63204
63205
63206 XLA_AE_LINES_PKG.ValidateCurrentLine;
63207 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
63208
63209 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
63210 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
63211 ,p_balance_type_code => l_balance_type_code);
63212
63213 END IF;
63214
63215 -----------------------------------------------------------------------------------------
63216 -- 4262811 Multiperiod Accounting
63217 -----------------------------------------------------------------------------------------
63218 -- No MPA option is assigned.
63219
63220
63221 END IF;
63222 END IF;
63223 --
63224
63225 --
63226 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
63227 trace
63228 (p_msg => 'END of AcctLineType_130'
63229 ,p_level => C_LEVEL_PROCEDURE
63230 ,p_module => l_log_module);
63231 END IF;
63232 --
63233 EXCEPTION
63234 WHEN xla_exceptions_pkg.application_exception THEN
63235 RAISE;
63236 WHEN OTHERS THEN
63237 xla_exceptions_pkg.raise_message
63238 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_130');
63239 END AcctLineType_130;
63240 --
63241
63242 ---------------------------------------
63243 --
63244 -- PRIVATE FUNCTION
63245 -- AcctLineType_131
63246 --
63247 ---------------------------------------
63248 PROCEDURE AcctLineType_131 (
63249 p_application_id IN NUMBER
63250 ,p_event_id IN NUMBER
63251 ,p_calculate_acctd_flag IN VARCHAR2
63252 ,p_calculate_g_l_flag IN VARCHAR2
63253 ,p_actual_flag IN OUT VARCHAR2
63254 ,p_balance_type_code OUT VARCHAR2
63255 ,p_gain_or_loss_ref OUT VARCHAR2
63256
63257 --Distribution GL Account
63258 , p_source_10 IN NUMBER
63259 --Distribution Source Type
63260 , p_source_22 IN VARCHAR2
63261 --Distribution Line Identifier
63262 , p_source_24 IN NUMBER
63263 --Distribution Type
63264 , p_source_25 IN VARCHAR2
63265 --Entered Amount
63266 , p_source_26 IN NUMBER
63267 --Currency Code
63268 , p_source_27 IN VARCHAR2
63269 --Applied To Document Accounting Amount
63270 , p_source_31 IN NUMBER
63271 --Transaction Distribution Identifier
63272 , p_source_36 IN NUMBER
63273 --Transaction Distribution Type
63274 , p_source_37 IN VARCHAR2
63275 --Applied To Document Exchange Date
63276 , p_source_59 IN DATE
63277 --Receipt Applied To Application Identifier
63281 --Transaction Identifier
63278 , p_source_60 IN NUMBER
63279 --Transaction Entity Code
63280 , p_source_61 IN VARCHAR2
63282 , p_source_62 IN NUMBER
63283 --Applied To Document Exchange Rate
63284 , p_source_64 IN NUMBER
63285 --Distribution Party Identifier
63286 , p_source_65 IN NUMBER
63287 --Distribution Party Site Id
63288 , p_source_66 IN NUMBER
63289 --Distribution Party Type
63290 , p_source_67 IN VARCHAR2
63291 --Distribution Multi Fund Additional Entry
63292 , p_source_71 IN VARCHAR2
63293 --Applied To Document Exchange Rate Type
63294 , p_source_76 IN VARCHAR2
63295 )
63296 IS
63297
63298 l_component_type VARCHAR2(80);
63299 l_component_code VARCHAR2(30);
63300 l_component_type_code VARCHAR2(1);
63301 l_component_appl_id INTEGER;
63302 l_amb_context_code VARCHAR2(30);
63303 l_entity_code VARCHAR2(30);
63304 l_event_class_code VARCHAR2(30);
63305 l_ae_header_id NUMBER;
63306 l_event_type_code VARCHAR2(30);
63307 l_line_definition_code VARCHAR2(30);
63308 l_line_definition_owner_code VARCHAR2(1);
63309 --
63310 -- adr variables
63311 l_segment VARCHAR2(30);
63312 l_ccid NUMBER;
63313 l_adr_transaction_coa_id NUMBER;
63314 l_adr_accounting_coa_id NUMBER;
63315 l_adr_flexfield_segment_code VARCHAR2(30);
63316 l_adr_flex_value_set_id NUMBER;
63317 l_adr_value_type_code VARCHAR2(30);
63318 l_adr_value_combination_id NUMBER;
63319 l_adr_value_segment_code VARCHAR2(30);
63320
63321 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
63322 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
63323 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
63324 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
63325
63326 -- 4262811 Variables ------------------------------------------------------------------------------------------
63327 l_entered_amt_idx NUMBER;
63328 l_accted_amt_idx NUMBER;
63329 l_acc_rev_flag VARCHAR2(1);
63330 l_accrual_line_num NUMBER;
63331 l_tmp_amt NUMBER;
63332 l_acc_rev_natural_side_code VARCHAR2(1);
63333
63334 l_num_entries NUMBER;
63335 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
63336 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
63337 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
63338 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
63339 l_recog_line_1 NUMBER;
63340 l_recog_line_2 NUMBER;
63341
63342 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
63343 l_bflow_applied_to_amt NUMBER; -- 5132302
63344 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
63345
63346 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
63347
63348 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
63349 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
63350
63351 ---------------------------------------------------------------------------------------------------------------
63352
63353
63354 --
63355 -- bulk performance
63356 --
63357 l_balance_type_code VARCHAR2(1);
63358 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
63359 l_log_module VARCHAR2(240);
63360
63361 --
63362 -- Upgrade strategy
63363 --
63364 l_actual_upg_option VARCHAR2(1);
63365 l_enc_upg_option VARCHAR2(1);
63366
63367 --
63368 BEGIN
63369 --
63370 IF g_log_enabled THEN
63371 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_131';
63372 END IF;
63373 --
63374 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
63375
63376 trace
63377 (p_msg => 'BEGIN of AcctLineType_131'
63378 ,p_level => C_LEVEL_PROCEDURE
63379 ,p_module => l_log_module);
63380
63381 END IF;
63382 --
63383 l_component_type := 'AMB_JLT';
63384 l_component_code := 'RCT_TAX';
63385 l_component_type_code := 'S';
63386 l_component_appl_id := 222;
63387 l_amb_context_code := 'DEFAULT';
63388 l_entity_code := 'RECEIPTS';
63389 l_event_class_code := 'RECEIPT';
63390 l_event_type_code := 'RECEIPT_ALL';
63391 l_line_definition_owner_code := 'S';
63392 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
63393 --
63394 l_balance_type_code := 'A';
63395 l_segment := NULL;
63396 l_ccid := NULL;
63397 l_adr_transaction_coa_id := NULL;
63398 l_adr_accounting_coa_id := NULL;
63399 l_adr_flexfield_segment_code := NULL;
63400 l_adr_flex_value_set_id := NULL;
63401 l_adr_value_type_code := NULL;
63402 l_adr_value_combination_id := NULL;
63403 l_adr_value_segment_code := NULL;
63404
63405 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
63406 l_bflow_class_code := ''; -- 4219869 Business Flow
63410 l_bflow_applied_to_amt_idx := NULL; -- 5132302
63407 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
63408 l_budgetary_control_flag := 'N';
63409
63411 l_bflow_applied_to_amt := NULL; -- 5132302
63412 l_entered_amt_idx := NULL; -- 4262811
63413 l_accted_amt_idx := NULL; -- 4262811
63414 l_acc_rev_flag := NULL; -- 4262811
63415 l_accrual_line_num := NULL; -- 4262811
63416 l_tmp_amt := NULL; -- 4262811
63417 --
63418
63419 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
63420 l_balance_type_code <> 'B' THEN
63421 IF NVL(p_source_22,'
63422 ') = 'TAX' AND
63423 NVL(p_source_71,'
63424 ') = 'N'
63425 THEN
63426
63427 --
63428 XLA_AE_LINES_PKG.SetNewLine;
63429
63430 p_balance_type_code := l_balance_type_code;
63431 -- set the flag so later we will know whether the gain loss line needs to be created
63432
63433 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
63434 p_actual_flag :='A';
63435 END IF;
63436
63437 --
63438 -- bulk performance
63439 --
63440 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
63441 p_header_num => 0); -- 4262811
63442 --
63443 -- set accounting line options
63444 --
63445 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
63446 p_natural_side_code => 'C'
63447 , p_gain_or_loss_flag => 'N'
63448 , p_gl_transfer_mode_code => 'S'
63449 , p_acct_entry_type_code => 'A'
63450 , p_switch_side_flag => 'Y'
63451 , p_merge_duplicate_code => 'A'
63452 );
63453 --
63454 l_acc_rev_natural_side_code := 'D'; -- 4262811
63455 --
63456 --
63457 -- set accounting line type info
63458 --
63459 xla_ae_lines_pkg.SetAcctLineType
63460 (p_component_type => l_component_type
63461 ,p_event_type_code => l_event_type_code
63462 ,p_line_definition_owner_code => l_line_definition_owner_code
63463 ,p_line_definition_code => l_line_definition_code
63464 ,p_accounting_line_code => l_component_code
63465 ,p_accounting_line_type_code => l_component_type_code
63466 ,p_accounting_line_appl_id => l_component_appl_id
63467 ,p_amb_context_code => l_amb_context_code
63468 ,p_entity_code => l_entity_code
63469 ,p_event_class_code => l_event_class_code);
63470 --
63471 -- set accounting class
63472 --
63473 xla_ae_lines_pkg.SetAcctClass(
63474 p_accounting_class_code => 'TAX'
63475 , p_ae_header_id => l_ae_header_id
63476 );
63477
63478 --
63479 -- set rounding class
63480 --
63481 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
63482 'RECEIVABLE';
63483
63484 --
63485 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
63486 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
63487 --
63488 -- bulk performance
63489 --
63490 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
63491
63492 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
63493 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
63494
63495 -- 4955764
63496 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
63497 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
63498
63499 -- 4458381 Public Sector Enh
63500
63501 --
63502 -- set accounting attributes for the line type
63503 --
63504 l_entered_amt_idx := 8;
63505 l_accted_amt_idx := 13;
63506 l_bflow_applied_to_amt_idx := NULL; -- 5132302
63507 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
63508 l_rec_acct_attrs.array_num_value(1) := p_source_60;
63509 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
63510 l_rec_acct_attrs.array_char_value(2) := p_source_37;
63511 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
63512 l_rec_acct_attrs.array_char_value(3) := p_source_61;
63513 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
63514 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
63515 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
63516 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
63517 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
63518 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
63519 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
63520 l_rec_acct_attrs.array_char_value(7) := p_source_25;
63521 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
63522 l_rec_acct_attrs.array_num_value(8) := p_source_26;
63523 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
63524 l_rec_acct_attrs.array_char_value(9) := p_source_27;
63525 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
63526 l_rec_acct_attrs.array_date_value(10) := p_source_59;
63530 l_rec_acct_attrs.array_char_value(12) := p_source_76;
63527 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
63528 l_rec_acct_attrs.array_num_value(11) := p_source_64;
63529 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
63531 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
63532 l_rec_acct_attrs.array_num_value(13) := p_source_31;
63533 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
63534 l_rec_acct_attrs.array_num_value(14) := p_source_65;
63535 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
63536 l_rec_acct_attrs.array_num_value(15) := p_source_66;
63537 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
63538 l_rec_acct_attrs.array_char_value(16) := p_source_67;
63539
63540 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
63541 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
63542
63543 ---------------------------------------------------------------------------------------------------------------
63544 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
63545 ---------------------------------------------------------------------------------------------------------------
63546 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
63547
63548 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
63549 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
63550
63551 IF xla_accounting_cache_pkg.GetValueChar
63552 (p_source_code => 'LEDGER_CATEGORY_CODE'
63553 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
63554 AND l_bflow_method_code = 'PRIOR_ENTRY'
63555 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
63556 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
63557 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
63558 )
63559 THEN
63560 xla_ae_lines_pkg.BflowUpgEntry
63561 (p_business_method_code => l_bflow_method_code
63562 ,p_business_class_code => l_bflow_class_code
63563 ,p_balance_type => l_balance_type_code);
63564 ELSE
63565 NULL;
63566 -- No business flow processing for business flow method of NONE.
63567 END IF;
63568
63569 --
63570 -- call analytical criteria
63571 --
63572
63573 --
63574 -- call description
63575 --
63576 -- No description or it is inherited.
63577 --
63578 -- call ADRs
63579 -- Bug 4922099
63580 --
63581 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
63582 (NVL(l_actual_upg_option, 'N') = 'O') OR
63583 (NVL(l_enc_upg_option, 'N') = 'O')
63584 )
63585 THEN
63586 NULL;
63587 --
63588 --
63589
63590 l_ccid := AcctDerRule_11(
63591 p_application_id => p_application_id
63592 , p_ae_header_id => l_ae_header_id
63593 , p_source_10 => p_source_10
63594 , x_transaction_coa_id => l_adr_transaction_coa_id
63595 , x_accounting_coa_id => l_adr_accounting_coa_id
63596 , x_value_type_code => l_adr_value_type_code
63597 , p_side => 'NA'
63598 );
63599
63600 xla_ae_lines_pkg.set_ccid(
63601 p_code_combination_id => l_ccid
63602 , p_value_type_code => l_adr_value_type_code
63603 , p_transaction_coa_id => l_adr_transaction_coa_id
63604 , p_accounting_coa_id => l_adr_accounting_coa_id
63605 , p_adr_code => 'DIST_CCID'
63606 , p_adr_type_code => 'S'
63607 , p_component_type => l_component_type
63608 , p_component_code => l_component_code
63609 , p_component_type_code => l_component_type_code
63610 , p_component_appl_id => l_component_appl_id
63611 , p_amb_context_code => l_amb_context_code
63612 , p_side => 'NA'
63613 );
63614
63615
63616 --
63617 --
63618 END IF;
63619 --
63620 -- Bug 4922099
63621 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
63622 (NVL(l_enc_upg_option, 'N') = 'O')
63623 ) AND
63624 (l_bflow_method_code = 'PRIOR_ENTRY')
63625 )
63626 THEN
63627 IF
63628 --
63629 1 = 2
63630 --
63631 THEN
63632 xla_accounting_err_pkg.build_message
63633 (p_appli_s_name => 'XLA'
63634 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
63635 ,p_token_1 => 'LINE_NUMBER'
63636 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
63637 ,p_token_2 => 'LINE_TYPE_NAME'
63638 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
63639 l_component_type
63640 ,l_component_code
63641 ,l_component_type_code
63645 ,l_event_class_code
63642 ,l_component_appl_id
63643 ,l_amb_context_code
63644 ,l_entity_code
63646 )
63647 ,p_token_3 => 'OWNER'
63648 ,p_value_3 => xla_lookups_pkg.get_meaning(
63649 p_lookup_type => 'XLA_OWNER_TYPE'
63650 ,p_lookup_code => l_component_type_code
63651 )
63652 ,p_token_4 => 'PRODUCT_NAME'
63653 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
63654 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
63655 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
63656 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
63657 ,p_ae_header_id => NULL
63658 );
63659
63660 IF (C_LEVEL_ERROR>= g_log_level) THEN
63661 trace
63662 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
63663 ,p_level => C_LEVEL_ERROR
63664 ,p_module => l_log_module);
63665 END IF;
63666 END IF;
63667 END IF;
63668 --
63669 --
63670 ------------------------------------------------------------------------------------------------
63671 -- 4219869 Business Flow
63672 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
63673 -- Prior Entry. Currently, the following code is always generated.
63674 ------------------------------------------------------------------------------------------------
63675 XLA_AE_LINES_PKG.ValidateCurrentLine;
63676
63677 ------------------------------------------------------------------------------------
63678 -- 4219869 Business Flow
63679 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
63680 ------------------------------------------------------------------------------------
63681 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
63682
63683 ----------------------------------------------------------------------------------
63684 -- 4219869 Business Flow
63685 -- Update journal entry status -- Need to generate this within IF <condition>
63686 ----------------------------------------------------------------------------------
63687 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
63688 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
63689 ,p_balance_type_code => l_balance_type_code
63690 );
63691
63692 -------------------------------------------------------------------------------------------
63693 -- 4262811 - Generate the Accrual Reversal lines
63694 -------------------------------------------------------------------------------------------
63695 BEGIN
63696 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
63697 (g_array_event(p_event_id).array_value_num('header_index'));
63698 IF l_acc_rev_flag IS NULL THEN
63699 l_acc_rev_flag := 'N';
63700 END IF;
63701 EXCEPTION
63702 WHEN OTHERS THEN
63703 l_acc_rev_flag := 'N';
63704 END;
63705 --
63706 IF (l_acc_rev_flag = 'Y') THEN
63707
63708 -- 4645092 ------------------------------------------------------------------------------
63709 -- To allow MPA report to determine if it should generate report process
63710 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
63711 ------------------------------------------------------------------------------------------
63712
63713 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
63714 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
63715 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
63716 -- call ADRs
63717 -- Bug 4922099
63718 --
63719 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
63720 (NVL(l_actual_upg_option, 'N') = 'O') OR
63721 (NVL(l_enc_upg_option, 'N') = 'O')
63722 )
63723 THEN
63724 NULL;
63725 --
63726 --
63727
63728 l_ccid := AcctDerRule_11(
63729 p_application_id => p_application_id
63730 , p_ae_header_id => l_ae_header_id
63731 , p_source_10 => p_source_10
63732 , x_transaction_coa_id => l_adr_transaction_coa_id
63733 , x_accounting_coa_id => l_adr_accounting_coa_id
63734 , x_value_type_code => l_adr_value_type_code
63735 , p_side => 'NA'
63736 );
63737
63738 xla_ae_lines_pkg.set_ccid(
63739 p_code_combination_id => l_ccid
63743 , p_adr_code => 'DIST_CCID'
63740 , p_value_type_code => l_adr_value_type_code
63741 , p_transaction_coa_id => l_adr_transaction_coa_id
63742 , p_accounting_coa_id => l_adr_accounting_coa_id
63744 , p_adr_type_code => 'S'
63745 , p_component_type => l_component_type
63746 , p_component_code => l_component_code
63747 , p_component_type_code => l_component_type_code
63748 , p_component_appl_id => l_component_appl_id
63749 , p_amb_context_code => l_amb_context_code
63750 , p_side => 'NA'
63751 );
63752
63753
63754 --
63755 --
63756 END IF;
63757
63758 --
63759 -- Update the line information that should be overwritten
63760 --
63761 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
63762 p_header_num => 1);
63763 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
63764
63765 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
63766
63767 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
63768 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
63769 END IF;
63770
63771 --
63772 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
63773 --
63774 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
63775 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
63776 ELSE
63777 ---------------------------------------------------------------------------------------------------
63778 -- 4262811a Switch Sign
63779 ---------------------------------------------------------------------------------------------------
63780 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
63781 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
63782 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63783 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
63784 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63785 -- 5132302
63786 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
63787 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63788
63789 END IF;
63790
63791 -- 4955764
63792 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
63793 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
63794
63795
63796 XLA_AE_LINES_PKG.ValidateCurrentLine;
63797 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
63798
63799 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
63800 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
63801 ,p_balance_type_code => l_balance_type_code);
63802
63803 END IF;
63804
63805 -----------------------------------------------------------------------------------------
63806 -- 4262811 Multiperiod Accounting
63807 -----------------------------------------------------------------------------------------
63808 -- No MPA option is assigned.
63809
63810
63811 END IF;
63812 END IF;
63813 --
63814
63815 --
63816 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
63817 trace
63818 (p_msg => 'END of AcctLineType_131'
63819 ,p_level => C_LEVEL_PROCEDURE
63820 ,p_module => l_log_module);
63821 END IF;
63822 --
63823 EXCEPTION
63824 WHEN xla_exceptions_pkg.application_exception THEN
63825 RAISE;
63826 WHEN OTHERS THEN
63827 xla_exceptions_pkg.raise_message
63828 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_131');
63829 END AcctLineType_131;
63830 --
63831
63832 ---------------------------------------
63833 --
63834 -- PRIVATE FUNCTION
63835 -- AcctLineType_132
63836 --
63837 ---------------------------------------
63838 PROCEDURE AcctLineType_132 (
63839 p_application_id IN NUMBER
63840 ,p_event_id IN NUMBER
63841 ,p_calculate_acctd_flag IN VARCHAR2
63842 ,p_calculate_g_l_flag IN VARCHAR2
63843 ,p_actual_flag IN OUT VARCHAR2
63844 ,p_balance_type_code OUT VARCHAR2
63845 ,p_gain_or_loss_ref OUT VARCHAR2
63846
63847 --Remittance Bank Account Unapplied Account
63848 , p_source_18 IN NUMBER
63849 --Distribution Source Type
63850 , p_source_22 IN VARCHAR2
63851 --Receivable Activity Type
63852 , p_source_23 IN VARCHAR2
63853 --Distribution Line Identifier
63854 , p_source_24 IN NUMBER
63855 --Distribution Type
63856 , p_source_25 IN VARCHAR2
63857 --Exchange Date
63858 , p_source_28 IN DATE
63859 --Exchange Rate
63860 , p_source_29 IN NUMBER
63864 , p_source_36 IN NUMBER
63861 --Exchange Rate Type
63862 , p_source_30 IN VARCHAR2
63863 --Transaction Distribution Identifier
63865 --Transaction Distribution Type
63866 , p_source_37 IN VARCHAR2
63867 --Receipt Applied To Application Identifier
63868 , p_source_60 IN NUMBER
63869 --Transaction Entity Code
63870 , p_source_61 IN VARCHAR2
63871 --Transaction Identifier
63872 , p_source_62 IN NUMBER
63873 --Applying Document Currency Code
63874 , p_source_63 IN VARCHAR2
63875 --Distribution Party Type
63876 , p_source_67 IN VARCHAR2
63877 --Distribution Multi Fund Additional Entry
63878 , p_source_71 IN VARCHAR2
63879 --DIST_ENT_AMT_FROM
63880 , p_source_74 IN NUMBER
63881 --Accounting Amount
63882 , p_source_75 IN NUMBER
63883 --Distribution Source Table
63884 , p_source_77 IN VARCHAR2
63885 --Receipt Pay From Customer
63886 , p_source_78 IN NUMBER
63887 --Receipt Customer Site Use Identifier
63888 , p_source_79 IN NUMBER
63889 )
63890 IS
63891
63892 l_component_type VARCHAR2(80);
63893 l_component_code VARCHAR2(30);
63894 l_component_type_code VARCHAR2(1);
63895 l_component_appl_id INTEGER;
63896 l_amb_context_code VARCHAR2(30);
63897 l_entity_code VARCHAR2(30);
63898 l_event_class_code VARCHAR2(30);
63899 l_ae_header_id NUMBER;
63900 l_event_type_code VARCHAR2(30);
63901 l_line_definition_code VARCHAR2(30);
63902 l_line_definition_owner_code VARCHAR2(1);
63903 --
63904 -- adr variables
63905 l_segment VARCHAR2(30);
63906 l_ccid NUMBER;
63907 l_adr_transaction_coa_id NUMBER;
63908 l_adr_accounting_coa_id NUMBER;
63909 l_adr_flexfield_segment_code VARCHAR2(30);
63910 l_adr_flex_value_set_id NUMBER;
63911 l_adr_value_type_code VARCHAR2(30);
63912 l_adr_value_combination_id NUMBER;
63913 l_adr_value_segment_code VARCHAR2(30);
63914
63915 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
63916 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
63917 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
63918 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
63919
63920 -- 4262811 Variables ------------------------------------------------------------------------------------------
63921 l_entered_amt_idx NUMBER;
63922 l_accted_amt_idx NUMBER;
63923 l_acc_rev_flag VARCHAR2(1);
63924 l_accrual_line_num NUMBER;
63925 l_tmp_amt NUMBER;
63926 l_acc_rev_natural_side_code VARCHAR2(1);
63927
63928 l_num_entries NUMBER;
63929 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
63930 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
63931 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
63932 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
63933 l_recog_line_1 NUMBER;
63934 l_recog_line_2 NUMBER;
63935
63936 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
63937 l_bflow_applied_to_amt NUMBER; -- 5132302
63938 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
63939
63940 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
63941
63942 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
63943 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
63944
63945 ---------------------------------------------------------------------------------------------------------------
63946
63947
63948 --
63949 -- bulk performance
63950 --
63951 l_balance_type_code VARCHAR2(1);
63952 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
63953 l_log_module VARCHAR2(240);
63954
63955 --
63956 -- Upgrade strategy
63957 --
63958 l_actual_upg_option VARCHAR2(1);
63959 l_enc_upg_option VARCHAR2(1);
63960
63961 --
63962 BEGIN
63963 --
63964 IF g_log_enabled THEN
63965 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_132';
63966 END IF;
63967 --
63968 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
63969
63970 trace
63971 (p_msg => 'BEGIN of AcctLineType_132'
63972 ,p_level => C_LEVEL_PROCEDURE
63973 ,p_module => l_log_module);
63974
63975 END IF;
63976 --
63977 l_component_type := 'AMB_JLT';
63978 l_component_code := 'RCT_UNAPP';
63979 l_component_type_code := 'S';
63980 l_component_appl_id := 222;
63981 l_amb_context_code := 'DEFAULT';
63982 l_entity_code := 'RECEIPTS';
63983 l_event_class_code := 'RECEIPT';
63984 l_event_type_code := 'RECEIPT_ALL';
63985 l_line_definition_owner_code := 'S';
63986 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
63987 --
63988 l_balance_type_code := 'A';
63989 l_segment := NULL;
63990 l_ccid := NULL;
63991 l_adr_transaction_coa_id := NULL;
63992 l_adr_accounting_coa_id := NULL;
63993 l_adr_flexfield_segment_code := NULL;
63997 l_adr_value_segment_code := NULL;
63994 l_adr_flex_value_set_id := NULL;
63995 l_adr_value_type_code := NULL;
63996 l_adr_value_combination_id := NULL;
63998
63999 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
64000 l_bflow_class_code := ''; -- 4219869 Business Flow
64001 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
64002 l_budgetary_control_flag := 'N';
64003
64004 l_bflow_applied_to_amt_idx := NULL; -- 5132302
64005 l_bflow_applied_to_amt := NULL; -- 5132302
64006 l_entered_amt_idx := NULL; -- 4262811
64007 l_accted_amt_idx := NULL; -- 4262811
64008 l_acc_rev_flag := NULL; -- 4262811
64009 l_accrual_line_num := NULL; -- 4262811
64010 l_tmp_amt := NULL; -- 4262811
64011 --
64012
64013 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
64014 l_balance_type_code <> 'B' THEN
64015 IF (NVL(p_source_22,'
64016 ') = 'OTHER ACC' AND
64017 NVL(p_source_23,'
64018 ') = 'CLAIM_INVESTIGATION' AND
64019 NVL(p_source_71,'
64020 ') = 'N') OR
64021 (NVL(p_source_22,'
64022 ') = 'FACTOR' AND
64023 NVL(p_source_77,'
64024 ') = 'RA' AND
64025 NVL(p_source_71,'
64026 ') = 'N') OR
64027 (NVL(p_source_22,'
64028 ') = 'OTHER ACC' AND
64029 NVL(p_source_71,'
64030 ') = 'N' AND
64031 NVL(p_source_23,'
64032 ') = 'NETTING') OR
64033 (NVL(p_source_22,'
64034 ') = 'OTHER ACC' AND
64035 NVL(p_source_71,'
64036 ') = 'N' AND
64037 NVL(p_source_23,'
64038 ') = 'PREPAYMENT') OR
64039 (NVL(p_source_22,'
64040 ') = 'ACTIVITY' AND
64041 NVL(p_source_71,'
64042 ') = 'N' AND
64043 NVL(p_source_23,'
64044 ') = 'CCREFUND') OR
64045 (NVL(p_source_22,'
64046 ') = 'REMITTANCE' AND
64047 NVL(p_source_71,'
64048 ') = 'N' AND
64049 NVL(p_source_77,'
64050 ') = 'RA') OR
64051 (NVL(p_source_22,'
64052 ') = 'ACTIVITY' AND
64053 NVL(p_source_71,'
64054 ') = 'N' AND
64055 NVL(p_source_23,'
64056 ') = 'WRITEOFF') OR
64057 (NVL(p_source_22,'
64058 ') = 'ACTIVITY' AND
64059 NVL(p_source_71,'
64060 ') = 'N' AND
64061 NVL(p_source_23,'
64062 ') = 'CM_REFUND') OR
64063 (NVL(p_source_22,'
64064 ') = 'ACTIVITY' AND
64065 NVL(p_source_23,'
64066 ') = 'ADJUST' AND
64067 NVL(p_source_71,'
64068 ') = 'N') OR
64069 (NVL(p_source_22,'
64070 ') = 'ACTIVITY' AND
64071 NVL(p_source_71,'
64072 ') = 'N' AND
64073 NVL(p_source_23,'
64074 ') = 'CC_CHARGEBACK') OR
64075 (NVL(p_source_22,'
64076 ') = 'ACTIVITY' AND
64077 NVL(p_source_71,'
64078 ') = 'N' AND
64079 NVL(p_source_23,'
64080 ') = 'NETTING')
64081 THEN
64082
64083 --
64084 XLA_AE_LINES_PKG.SetNewLine;
64085
64086 p_balance_type_code := l_balance_type_code;
64087 -- set the flag so later we will know whether the gain loss line needs to be created
64088
64089 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
64090 p_actual_flag :='A';
64091 END IF;
64092
64093 --
64094 -- bulk performance
64095 --
64096 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
64097 p_header_num => 0); -- 4262811
64098 --
64099 -- set accounting line options
64100 --
64101 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
64102 p_natural_side_code => 'D'
64103 , p_gain_or_loss_flag => 'N'
64104 , p_gl_transfer_mode_code => 'S'
64105 , p_acct_entry_type_code => 'A'
64106 , p_switch_side_flag => 'Y'
64107 , p_merge_duplicate_code => 'A'
64108 );
64109 --
64110 l_acc_rev_natural_side_code := 'C'; -- 4262811
64111 --
64112 --
64113 -- set accounting line type info
64114 --
64115 xla_ae_lines_pkg.SetAcctLineType
64116 (p_component_type => l_component_type
64117 ,p_event_type_code => l_event_type_code
64118 ,p_line_definition_owner_code => l_line_definition_owner_code
64119 ,p_line_definition_code => l_line_definition_code
64120 ,p_accounting_line_code => l_component_code
64121 ,p_accounting_line_type_code => l_component_type_code
64122 ,p_accounting_line_appl_id => l_component_appl_id
64123 ,p_amb_context_code => l_amb_context_code
64124 ,p_entity_code => l_entity_code
64125 ,p_event_class_code => l_event_class_code);
64126 --
64127 -- set accounting class
64128 --
64129 xla_ae_lines_pkg.SetAcctClass(
64130 p_accounting_class_code => 'UNAPP'
64131 , p_ae_header_id => l_ae_header_id
64132 );
64133
64134 --
64135 -- set rounding class
64136 --
64137 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
64138 'RECEIVABLE';
64139
64140 --
64141 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
64142 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
64143 --
64144 -- bulk performance
64145 --
64149 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
64146 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
64147
64148 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
64150
64151 -- 4955764
64152 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
64153 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
64154
64155 -- 4458381 Public Sector Enh
64156
64157 --
64158 -- set accounting attributes for the line type
64159 --
64160 l_entered_amt_idx := 8;
64161 l_accted_amt_idx := 13;
64162 l_bflow_applied_to_amt_idx := NULL; -- 5132302
64163 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
64164 l_rec_acct_attrs.array_num_value(1) := p_source_60;
64165 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
64166 l_rec_acct_attrs.array_char_value(2) := p_source_37;
64167 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
64168 l_rec_acct_attrs.array_char_value(3) := p_source_61;
64169 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
64170 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
64171 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
64172 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
64173 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
64174 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
64175 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
64176 l_rec_acct_attrs.array_char_value(7) := p_source_25;
64177 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
64178 l_rec_acct_attrs.array_num_value(8) := p_source_74;
64179 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
64180 l_rec_acct_attrs.array_char_value(9) := p_source_63;
64181 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
64182 l_rec_acct_attrs.array_date_value(10) := p_source_28;
64183 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
64184 l_rec_acct_attrs.array_num_value(11) := p_source_29;
64185 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
64186 l_rec_acct_attrs.array_char_value(12) := p_source_30;
64187 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
64188 l_rec_acct_attrs.array_num_value(13) := p_source_75;
64189 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
64190 l_rec_acct_attrs.array_num_value(14) := p_source_78;
64191 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
64192 l_rec_acct_attrs.array_num_value(15) := p_source_79;
64193 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
64194 l_rec_acct_attrs.array_char_value(16) := p_source_67;
64195
64196 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
64197 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
64198
64199 ---------------------------------------------------------------------------------------------------------------
64200 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
64201 ---------------------------------------------------------------------------------------------------------------
64202 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
64203
64204 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
64205 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
64206
64207 IF xla_accounting_cache_pkg.GetValueChar
64208 (p_source_code => 'LEDGER_CATEGORY_CODE'
64209 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
64210 AND l_bflow_method_code = 'PRIOR_ENTRY'
64211 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
64212 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
64213 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
64214 )
64215 THEN
64216 xla_ae_lines_pkg.BflowUpgEntry
64217 (p_business_method_code => l_bflow_method_code
64218 ,p_business_class_code => l_bflow_class_code
64219 ,p_balance_type => l_balance_type_code);
64220 ELSE
64221 NULL;
64222 -- No business flow processing for business flow method of NONE.
64223 END IF;
64224
64225 --
64226 -- call analytical criteria
64227 --
64228
64229 --
64230 -- call description
64231 --
64232 -- No description or it is inherited.
64233 --
64234 -- call ADRs
64235 -- Bug 4922099
64236 --
64237 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
64238 (NVL(l_actual_upg_option, 'N') = 'O') OR
64239 (NVL(l_enc_upg_option, 'N') = 'O')
64240 )
64241 THEN
64242 NULL;
64243 --
64244 --
64245
64246 l_ccid := AcctDerRule_31(
64247 p_application_id => p_application_id
64248 , p_ae_header_id => l_ae_header_id
64249 , p_source_18 => p_source_18
64250 , x_transaction_coa_id => l_adr_transaction_coa_id
64251 , x_accounting_coa_id => l_adr_accounting_coa_id
64252 , x_value_type_code => l_adr_value_type_code
64256 xla_ae_lines_pkg.set_ccid(
64253 , p_side => 'NA'
64254 );
64255
64257 p_code_combination_id => l_ccid
64258 , p_value_type_code => l_adr_value_type_code
64259 , p_transaction_coa_id => l_adr_transaction_coa_id
64260 , p_accounting_coa_id => l_adr_accounting_coa_id
64261 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
64262 , p_adr_type_code => 'S'
64263 , p_component_type => l_component_type
64264 , p_component_code => l_component_code
64265 , p_component_type_code => l_component_type_code
64266 , p_component_appl_id => l_component_appl_id
64267 , p_amb_context_code => l_amb_context_code
64268 , p_side => 'NA'
64269 );
64270
64271
64272 --
64273 --
64274 END IF;
64275 --
64276 -- Bug 4922099
64277 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
64278 (NVL(l_enc_upg_option, 'N') = 'O')
64279 ) AND
64280 (l_bflow_method_code = 'PRIOR_ENTRY')
64281 )
64282 THEN
64283 IF
64284 --
64285 1 = 2
64286 --
64287 THEN
64288 xla_accounting_err_pkg.build_message
64289 (p_appli_s_name => 'XLA'
64290 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
64291 ,p_token_1 => 'LINE_NUMBER'
64292 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
64293 ,p_token_2 => 'LINE_TYPE_NAME'
64294 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
64295 l_component_type
64296 ,l_component_code
64297 ,l_component_type_code
64298 ,l_component_appl_id
64299 ,l_amb_context_code
64300 ,l_entity_code
64301 ,l_event_class_code
64302 )
64303 ,p_token_3 => 'OWNER'
64304 ,p_value_3 => xla_lookups_pkg.get_meaning(
64305 p_lookup_type => 'XLA_OWNER_TYPE'
64306 ,p_lookup_code => l_component_type_code
64307 )
64308 ,p_token_4 => 'PRODUCT_NAME'
64309 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
64310 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
64311 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
64312 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
64313 ,p_ae_header_id => NULL
64314 );
64315
64316 IF (C_LEVEL_ERROR>= g_log_level) THEN
64317 trace
64318 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
64319 ,p_level => C_LEVEL_ERROR
64320 ,p_module => l_log_module);
64321 END IF;
64322 END IF;
64323 END IF;
64324 --
64325 --
64326 ------------------------------------------------------------------------------------------------
64327 -- 4219869 Business Flow
64328 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
64329 -- Prior Entry. Currently, the following code is always generated.
64330 ------------------------------------------------------------------------------------------------
64331 XLA_AE_LINES_PKG.ValidateCurrentLine;
64332
64333 ------------------------------------------------------------------------------------
64334 -- 4219869 Business Flow
64335 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
64336 ------------------------------------------------------------------------------------
64337 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
64338
64339 ----------------------------------------------------------------------------------
64340 -- 4219869 Business Flow
64341 -- Update journal entry status -- Need to generate this within IF <condition>
64342 ----------------------------------------------------------------------------------
64343 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
64344 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
64345 ,p_balance_type_code => l_balance_type_code
64346 );
64347
64348 -------------------------------------------------------------------------------------------
64352 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
64349 -- 4262811 - Generate the Accrual Reversal lines
64350 -------------------------------------------------------------------------------------------
64351 BEGIN
64353 (g_array_event(p_event_id).array_value_num('header_index'));
64354 IF l_acc_rev_flag IS NULL THEN
64355 l_acc_rev_flag := 'N';
64356 END IF;
64357 EXCEPTION
64358 WHEN OTHERS THEN
64359 l_acc_rev_flag := 'N';
64360 END;
64361 --
64362 IF (l_acc_rev_flag = 'Y') THEN
64363
64364 -- 4645092 ------------------------------------------------------------------------------
64365 -- To allow MPA report to determine if it should generate report process
64366 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
64367 ------------------------------------------------------------------------------------------
64368
64369 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
64370 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
64371 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
64372 -- call ADRs
64373 -- Bug 4922099
64374 --
64375 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
64376 (NVL(l_actual_upg_option, 'N') = 'O') OR
64377 (NVL(l_enc_upg_option, 'N') = 'O')
64378 )
64379 THEN
64380 NULL;
64381 --
64382 --
64383
64384 l_ccid := AcctDerRule_31(
64385 p_application_id => p_application_id
64386 , p_ae_header_id => l_ae_header_id
64387 , p_source_18 => p_source_18
64388 , x_transaction_coa_id => l_adr_transaction_coa_id
64389 , x_accounting_coa_id => l_adr_accounting_coa_id
64390 , x_value_type_code => l_adr_value_type_code
64391 , p_side => 'NA'
64392 );
64393
64394 xla_ae_lines_pkg.set_ccid(
64395 p_code_combination_id => l_ccid
64396 , p_value_type_code => l_adr_value_type_code
64397 , p_transaction_coa_id => l_adr_transaction_coa_id
64398 , p_accounting_coa_id => l_adr_accounting_coa_id
64399 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
64400 , p_adr_type_code => 'S'
64401 , p_component_type => l_component_type
64402 , p_component_code => l_component_code
64403 , p_component_type_code => l_component_type_code
64404 , p_component_appl_id => l_component_appl_id
64405 , p_amb_context_code => l_amb_context_code
64406 , p_side => 'NA'
64407 );
64408
64409
64410 --
64411 --
64412 END IF;
64413
64414 --
64415 -- Update the line information that should be overwritten
64416 --
64417 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
64418 p_header_num => 1);
64419 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
64420
64421 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
64422
64423 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
64424 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
64425 END IF;
64426
64427 --
64428 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
64429 --
64430 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
64431 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
64432 ELSE
64433 ---------------------------------------------------------------------------------------------------
64434 -- 4262811a Switch Sign
64435 ---------------------------------------------------------------------------------------------------
64436 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
64437 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
64438 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64439 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
64440 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64441 -- 5132302
64442 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
64443 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64444
64445 END IF;
64446
64447 -- 4955764
64448 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
64449 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
64450
64451
64452 XLA_AE_LINES_PKG.ValidateCurrentLine;
64453 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
64454
64455 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
64456 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
64460
64457 ,p_balance_type_code => l_balance_type_code);
64458
64459 END IF;
64461 -----------------------------------------------------------------------------------------
64462 -- 4262811 Multiperiod Accounting
64463 -----------------------------------------------------------------------------------------
64464 -- No MPA option is assigned.
64465
64466
64467 END IF;
64468 END IF;
64469 --
64470
64471 --
64472 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
64473 trace
64474 (p_msg => 'END of AcctLineType_132'
64475 ,p_level => C_LEVEL_PROCEDURE
64476 ,p_module => l_log_module);
64477 END IF;
64478 --
64479 EXCEPTION
64480 WHEN xla_exceptions_pkg.application_exception THEN
64481 RAISE;
64482 WHEN OTHERS THEN
64483 xla_exceptions_pkg.raise_message
64484 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_132');
64485 END AcctLineType_132;
64486 --
64487
64488 ---------------------------------------
64489 --
64490 -- PRIVATE FUNCTION
64491 -- AcctLineType_133
64492 --
64493 ---------------------------------------
64494 PROCEDURE AcctLineType_133 (
64495 p_application_id IN NUMBER
64496 ,p_event_id IN NUMBER
64497 ,p_calculate_acctd_flag IN VARCHAR2
64498 ,p_calculate_g_l_flag IN VARCHAR2
64499 ,p_actual_flag IN OUT VARCHAR2
64500 ,p_balance_type_code OUT VARCHAR2
64501 ,p_gain_or_loss_ref OUT VARCHAR2
64502
64503 --Remittance Bank Account Unapplied Account
64504 , p_source_18 IN NUMBER
64505 --Distribution Source Type
64506 , p_source_22 IN VARCHAR2
64507 --Distribution Line Identifier
64508 , p_source_24 IN NUMBER
64509 --Distribution Type
64510 , p_source_25 IN VARCHAR2
64511 --Exchange Date
64512 , p_source_28 IN DATE
64513 --Exchange Rate
64514 , p_source_29 IN NUMBER
64515 --Exchange Rate Type
64516 , p_source_30 IN VARCHAR2
64517 --Transaction Distribution Identifier
64518 , p_source_36 IN NUMBER
64519 --Transaction Distribution Type
64520 , p_source_37 IN VARCHAR2
64521 --Receipt Applied To Application Identifier
64522 , p_source_60 IN NUMBER
64523 --Transaction Entity Code
64524 , p_source_61 IN VARCHAR2
64525 --Transaction Identifier
64526 , p_source_62 IN NUMBER
64527 --Applying Document Currency Code
64528 , p_source_63 IN VARCHAR2
64529 --Distribution Party Type
64530 , p_source_67 IN VARCHAR2
64531 --Distribution Multi Fund Additional Entry
64532 , p_source_71 IN VARCHAR2
64533 --DIST_ENT_AMT_FROM
64534 , p_source_74 IN NUMBER
64535 --Accounting Amount
64536 , p_source_75 IN NUMBER
64537 --Distribution Source Table
64538 , p_source_77 IN VARCHAR2
64539 --Receipt Pay From Customer
64540 , p_source_78 IN NUMBER
64541 --Receipt Customer Site Use Identifier
64542 , p_source_79 IN NUMBER
64543 --Receipt Application Status
64544 , p_source_80 IN VARCHAR2
64545 )
64546 IS
64547
64548 l_component_type VARCHAR2(80);
64549 l_component_code VARCHAR2(30);
64550 l_component_type_code VARCHAR2(1);
64551 l_component_appl_id INTEGER;
64552 l_amb_context_code VARCHAR2(30);
64553 l_entity_code VARCHAR2(30);
64554 l_event_class_code VARCHAR2(30);
64555 l_ae_header_id NUMBER;
64556 l_event_type_code VARCHAR2(30);
64557 l_line_definition_code VARCHAR2(30);
64558 l_line_definition_owner_code VARCHAR2(1);
64559 --
64560 -- adr variables
64561 l_segment VARCHAR2(30);
64562 l_ccid NUMBER;
64563 l_adr_transaction_coa_id NUMBER;
64564 l_adr_accounting_coa_id NUMBER;
64565 l_adr_flexfield_segment_code VARCHAR2(30);
64566 l_adr_flex_value_set_id NUMBER;
64567 l_adr_value_type_code VARCHAR2(30);
64568 l_adr_value_combination_id NUMBER;
64569 l_adr_value_segment_code VARCHAR2(30);
64570
64571 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
64572 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
64573 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
64574 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
64575
64576 -- 4262811 Variables ------------------------------------------------------------------------------------------
64577 l_entered_amt_idx NUMBER;
64578 l_accted_amt_idx NUMBER;
64579 l_acc_rev_flag VARCHAR2(1);
64580 l_accrual_line_num NUMBER;
64581 l_tmp_amt NUMBER;
64582 l_acc_rev_natural_side_code VARCHAR2(1);
64583
64584 l_num_entries NUMBER;
64585 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
64586 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
64587 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
64588 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
64589 l_recog_line_1 NUMBER;
64590 l_recog_line_2 NUMBER;
64591
64592 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
64593 l_bflow_applied_to_amt NUMBER; -- 5132302
64597
64594 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
64595
64596 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
64598 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
64599 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
64600
64601 ---------------------------------------------------------------------------------------------------------------
64602
64603
64604 --
64605 -- bulk performance
64606 --
64607 l_balance_type_code VARCHAR2(1);
64608 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
64609 l_log_module VARCHAR2(240);
64610
64611 --
64612 -- Upgrade strategy
64613 --
64614 l_actual_upg_option VARCHAR2(1);
64615 l_enc_upg_option VARCHAR2(1);
64616
64617 --
64618 BEGIN
64619 --
64620 IF g_log_enabled THEN
64621 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_133';
64622 END IF;
64623 --
64624 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
64625
64626 trace
64627 (p_msg => 'BEGIN of AcctLineType_133'
64628 ,p_level => C_LEVEL_PROCEDURE
64629 ,p_module => l_log_module);
64630
64631 END IF;
64632 --
64633 l_component_type := 'AMB_JLT';
64634 l_component_code := 'RCT_UNAPP_DEBIT';
64635 l_component_type_code := 'S';
64636 l_component_appl_id := 222;
64637 l_amb_context_code := 'DEFAULT';
64638 l_entity_code := 'RECEIPTS';
64639 l_event_class_code := 'RECEIPT';
64640 l_event_type_code := 'RECEIPT_ALL';
64641 l_line_definition_owner_code := 'S';
64642 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
64643 --
64644 l_balance_type_code := 'A';
64645 l_segment := NULL;
64646 l_ccid := NULL;
64647 l_adr_transaction_coa_id := NULL;
64648 l_adr_accounting_coa_id := NULL;
64649 l_adr_flexfield_segment_code := NULL;
64650 l_adr_flex_value_set_id := NULL;
64651 l_adr_value_type_code := NULL;
64652 l_adr_value_combination_id := NULL;
64653 l_adr_value_segment_code := NULL;
64654
64655 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
64656 l_bflow_class_code := ''; -- 4219869 Business Flow
64657 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
64658 l_budgetary_control_flag := 'N';
64659
64660 l_bflow_applied_to_amt_idx := NULL; -- 5132302
64661 l_bflow_applied_to_amt := NULL; -- 5132302
64662 l_entered_amt_idx := NULL; -- 4262811
64663 l_accted_amt_idx := NULL; -- 4262811
64664 l_acc_rev_flag := NULL; -- 4262811
64665 l_accrual_line_num := NULL; -- 4262811
64666 l_tmp_amt := NULL; -- 4262811
64667 --
64668
64669 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
64670 l_balance_type_code <> 'B' THEN
64671 IF ((NVL(p_source_22,'
64672 ') = 'REC' AND
64673 NVL(p_source_71,'
64674 ') = 'N') OR
64675 (NVL(p_source_71,'
64676 ') = 'N' AND
64677 NVL(p_source_22,'
64678 ') = 'CASH') OR
64679 (NVL(p_source_71,'
64680 ') = 'N' AND
64681 NVL(p_source_22,'
64682 ') = 'CONFIRMATION') OR
64683 (NVL(p_source_71,'
64684 ') = 'N' AND
64685 NVL(p_source_22,'
64686 ') = 'CURR_ROUND') OR
64687 (NVL(p_source_71,'
64688 ') = 'N' AND
64689 NVL(p_source_22,'
64690 ') = 'DEFERRED_TAX') OR
64691 (NVL(p_source_71,'
64692 ') = 'N' AND
64693 NVL(p_source_77,'
64694 ') = 'CRH' AND
64695 NVL(p_source_22,'
64696 ') = 'FACTOR') OR
64697 (NVL(p_source_71,'
64698 ') = 'N' AND
64699 NVL(p_source_22,'
64700 ') = 'ACC') OR
64701 (NVL(p_source_71,'
64702 ') = 'N' AND
64703 NVL(p_source_22,'
64704 ') = 'REMITTANCE' AND
64705 NVL(p_source_77,'
64706 ') = 'CRH') OR
64707 (NVL(p_source_71,'
64708 ') = 'N' AND
64709 NVL(p_source_22,'
64710 ') = 'SHORT_TERM_DEBT') OR
64711 (NVL(p_source_71,'
64712 ') = 'N' AND
64713 NVL(p_source_22,'
64714 ') = 'TAX') OR
64715 (NVL(p_source_71,'
64716 ') = 'N' AND
64717 NVL(p_source_22,'
64718 ') = 'UNID') OR
64719 (NVL(p_source_71,'
64720 ') = 'N' AND
64721 NVL(p_source_22,'
64722 ') = 'BANK_CHARGES') OR
64723 (NVL(p_source_71,'
64724 ') = 'N' AND
64725 NVL(p_source_22,'
64726 ') = 'EDISC') OR
64727 (NVL(p_source_71,'
64728 ') = 'N' AND
64729 NVL(p_source_22,'
64730 ') = 'UNEDISC')
64731 ) AND NVL(p_source_80,'
64732 ') <> 'UNID'
64733 THEN
64734
64735 --
64736 XLA_AE_LINES_PKG.SetNewLine;
64737
64738 p_balance_type_code := l_balance_type_code;
64739 -- set the flag so later we will know whether the gain loss line needs to be created
64740
64741 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
64742 p_actual_flag :='A';
64743 END IF;
64744
64745 --
64746 -- bulk performance
64747 --
64748 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
64749 p_header_num => 0); -- 4262811
64750 --
64754 p_natural_side_code => 'D'
64751 -- set accounting line options
64752 --
64753 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
64755 , p_gain_or_loss_flag => 'N'
64756 , p_gl_transfer_mode_code => 'S'
64757 , p_acct_entry_type_code => 'A'
64758 , p_switch_side_flag => 'Y'
64759 , p_merge_duplicate_code => 'A'
64760 );
64761 --
64762 l_acc_rev_natural_side_code := 'C'; -- 4262811
64763 --
64764 --
64765 -- set accounting line type info
64766 --
64767 xla_ae_lines_pkg.SetAcctLineType
64768 (p_component_type => l_component_type
64769 ,p_event_type_code => l_event_type_code
64770 ,p_line_definition_owner_code => l_line_definition_owner_code
64771 ,p_line_definition_code => l_line_definition_code
64772 ,p_accounting_line_code => l_component_code
64773 ,p_accounting_line_type_code => l_component_type_code
64774 ,p_accounting_line_appl_id => l_component_appl_id
64775 ,p_amb_context_code => l_amb_context_code
64776 ,p_entity_code => l_entity_code
64777 ,p_event_class_code => l_event_class_code);
64778 --
64779 -- set accounting class
64780 --
64781 xla_ae_lines_pkg.SetAcctClass(
64782 p_accounting_class_code => 'UNAPP'
64783 , p_ae_header_id => l_ae_header_id
64784 );
64785
64786 --
64787 -- set rounding class
64788 --
64789 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
64790 'RECEIVABLE';
64791
64792 --
64793 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
64794 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
64795 --
64796 -- bulk performance
64797 --
64798 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
64799
64800 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
64801 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
64802
64803 -- 4955764
64804 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
64805 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
64806
64807 -- 4458381 Public Sector Enh
64808
64809 --
64810 -- set accounting attributes for the line type
64811 --
64812 l_entered_amt_idx := 8;
64813 l_accted_amt_idx := 13;
64814 l_bflow_applied_to_amt_idx := NULL; -- 5132302
64815 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
64816 l_rec_acct_attrs.array_num_value(1) := p_source_60;
64817 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
64818 l_rec_acct_attrs.array_char_value(2) := p_source_37;
64819 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
64820 l_rec_acct_attrs.array_char_value(3) := p_source_61;
64821 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
64822 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
64823 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
64824 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
64825 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
64826 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
64827 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
64828 l_rec_acct_attrs.array_char_value(7) := p_source_25;
64829 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
64830 l_rec_acct_attrs.array_num_value(8) := p_source_74;
64831 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
64832 l_rec_acct_attrs.array_char_value(9) := p_source_63;
64833 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
64834 l_rec_acct_attrs.array_date_value(10) := p_source_28;
64835 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
64836 l_rec_acct_attrs.array_num_value(11) := p_source_29;
64837 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
64838 l_rec_acct_attrs.array_char_value(12) := p_source_30;
64839 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
64840 l_rec_acct_attrs.array_num_value(13) := p_source_75;
64841 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
64842 l_rec_acct_attrs.array_num_value(14) := p_source_78;
64843 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
64844 l_rec_acct_attrs.array_num_value(15) := p_source_79;
64845 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
64846 l_rec_acct_attrs.array_char_value(16) := p_source_67;
64847
64848 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
64849 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
64850
64851 ---------------------------------------------------------------------------------------------------------------
64852 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
64853 ---------------------------------------------------------------------------------------------------------------
64857 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
64854 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
64855
64856 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
64858
64859 IF xla_accounting_cache_pkg.GetValueChar
64860 (p_source_code => 'LEDGER_CATEGORY_CODE'
64861 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
64862 AND l_bflow_method_code = 'PRIOR_ENTRY'
64863 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
64864 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
64865 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
64866 )
64867 THEN
64868 xla_ae_lines_pkg.BflowUpgEntry
64869 (p_business_method_code => l_bflow_method_code
64870 ,p_business_class_code => l_bflow_class_code
64871 ,p_balance_type => l_balance_type_code);
64872 ELSE
64873 NULL;
64874 -- No business flow processing for business flow method of NONE.
64875 END IF;
64876
64877 --
64878 -- call analytical criteria
64879 --
64880
64881 --
64882 -- call description
64883 --
64884 -- No description or it is inherited.
64885 --
64886 -- call ADRs
64887 -- Bug 4922099
64888 --
64889 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
64890 (NVL(l_actual_upg_option, 'N') = 'O') OR
64891 (NVL(l_enc_upg_option, 'N') = 'O')
64892 )
64893 THEN
64894 NULL;
64895 --
64896 --
64897
64898 l_ccid := AcctDerRule_31(
64899 p_application_id => p_application_id
64900 , p_ae_header_id => l_ae_header_id
64901 , p_source_18 => p_source_18
64902 , x_transaction_coa_id => l_adr_transaction_coa_id
64903 , x_accounting_coa_id => l_adr_accounting_coa_id
64904 , x_value_type_code => l_adr_value_type_code
64905 , p_side => 'NA'
64906 );
64907
64908 xla_ae_lines_pkg.set_ccid(
64909 p_code_combination_id => l_ccid
64910 , p_value_type_code => l_adr_value_type_code
64911 , p_transaction_coa_id => l_adr_transaction_coa_id
64912 , p_accounting_coa_id => l_adr_accounting_coa_id
64913 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
64914 , p_adr_type_code => 'S'
64915 , p_component_type => l_component_type
64916 , p_component_code => l_component_code
64917 , p_component_type_code => l_component_type_code
64918 , p_component_appl_id => l_component_appl_id
64919 , p_amb_context_code => l_amb_context_code
64920 , p_side => 'NA'
64921 );
64922
64923
64924 --
64925 --
64926 END IF;
64927 --
64928 -- Bug 4922099
64929 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
64930 (NVL(l_enc_upg_option, 'N') = 'O')
64931 ) AND
64932 (l_bflow_method_code = 'PRIOR_ENTRY')
64933 )
64934 THEN
64935 IF
64936 --
64937 1 = 2
64938 --
64939 THEN
64940 xla_accounting_err_pkg.build_message
64941 (p_appli_s_name => 'XLA'
64942 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
64943 ,p_token_1 => 'LINE_NUMBER'
64944 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
64945 ,p_token_2 => 'LINE_TYPE_NAME'
64946 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
64947 l_component_type
64948 ,l_component_code
64949 ,l_component_type_code
64950 ,l_component_appl_id
64951 ,l_amb_context_code
64952 ,l_entity_code
64953 ,l_event_class_code
64954 )
64955 ,p_token_3 => 'OWNER'
64956 ,p_value_3 => xla_lookups_pkg.get_meaning(
64957 p_lookup_type => 'XLA_OWNER_TYPE'
64958 ,p_lookup_code => l_component_type_code
64959 )
64960 ,p_token_4 => 'PRODUCT_NAME'
64961 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
64962 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
64966 );
64963 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
64964 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
64965 ,p_ae_header_id => NULL
64967
64968 IF (C_LEVEL_ERROR>= g_log_level) THEN
64969 trace
64970 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
64971 ,p_level => C_LEVEL_ERROR
64972 ,p_module => l_log_module);
64973 END IF;
64974 END IF;
64975 END IF;
64976 --
64977 --
64978 ------------------------------------------------------------------------------------------------
64979 -- 4219869 Business Flow
64980 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
64981 -- Prior Entry. Currently, the following code is always generated.
64982 ------------------------------------------------------------------------------------------------
64983 XLA_AE_LINES_PKG.ValidateCurrentLine;
64984
64985 ------------------------------------------------------------------------------------
64986 -- 4219869 Business Flow
64987 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
64988 ------------------------------------------------------------------------------------
64989 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
64990
64991 ----------------------------------------------------------------------------------
64992 -- 4219869 Business Flow
64993 -- Update journal entry status -- Need to generate this within IF <condition>
64994 ----------------------------------------------------------------------------------
64995 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
64996 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
64997 ,p_balance_type_code => l_balance_type_code
64998 );
64999
65000 -------------------------------------------------------------------------------------------
65001 -- 4262811 - Generate the Accrual Reversal lines
65002 -------------------------------------------------------------------------------------------
65003 BEGIN
65004 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
65005 (g_array_event(p_event_id).array_value_num('header_index'));
65006 IF l_acc_rev_flag IS NULL THEN
65007 l_acc_rev_flag := 'N';
65008 END IF;
65009 EXCEPTION
65010 WHEN OTHERS THEN
65011 l_acc_rev_flag := 'N';
65012 END;
65013 --
65014 IF (l_acc_rev_flag = 'Y') THEN
65015
65016 -- 4645092 ------------------------------------------------------------------------------
65017 -- To allow MPA report to determine if it should generate report process
65018 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
65019 ------------------------------------------------------------------------------------------
65020
65021 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
65022 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
65023 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
65024 -- call ADRs
65025 -- Bug 4922099
65026 --
65027 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
65028 (NVL(l_actual_upg_option, 'N') = 'O') OR
65029 (NVL(l_enc_upg_option, 'N') = 'O')
65030 )
65031 THEN
65032 NULL;
65033 --
65034 --
65035
65036 l_ccid := AcctDerRule_31(
65037 p_application_id => p_application_id
65038 , p_ae_header_id => l_ae_header_id
65039 , p_source_18 => p_source_18
65040 , x_transaction_coa_id => l_adr_transaction_coa_id
65041 , x_accounting_coa_id => l_adr_accounting_coa_id
65042 , x_value_type_code => l_adr_value_type_code
65043 , p_side => 'NA'
65044 );
65045
65046 xla_ae_lines_pkg.set_ccid(
65047 p_code_combination_id => l_ccid
65048 , p_value_type_code => l_adr_value_type_code
65049 , p_transaction_coa_id => l_adr_transaction_coa_id
65050 , p_accounting_coa_id => l_adr_accounting_coa_id
65051 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
65052 , p_adr_type_code => 'S'
65053 , p_component_type => l_component_type
65054 , p_component_code => l_component_code
65055 , p_component_type_code => l_component_type_code
65056 , p_component_appl_id => l_component_appl_id
65057 , p_amb_context_code => l_amb_context_code
65058 , p_side => 'NA'
65059 );
65060
65061
65062 --
65063 --
65064 END IF;
65065
65066 --
65067 -- Update the line information that should be overwritten
65068 --
65069 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
65070 p_header_num => 1);
65071 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
65072
65073 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
65074
65075 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
65079 --
65076 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
65077 END IF;
65078
65080 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
65081 --
65082 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
65083 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
65084 ELSE
65085 ---------------------------------------------------------------------------------------------------
65086 -- 4262811a Switch Sign
65087 ---------------------------------------------------------------------------------------------------
65088 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
65089 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
65090 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65091 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
65092 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65093 -- 5132302
65094 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
65095 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65096
65097 END IF;
65098
65099 -- 4955764
65100 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
65101 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
65102
65103
65104 XLA_AE_LINES_PKG.ValidateCurrentLine;
65105 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
65106
65107 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
65108 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
65109 ,p_balance_type_code => l_balance_type_code);
65110
65111 END IF;
65112
65113 -----------------------------------------------------------------------------------------
65114 -- 4262811 Multiperiod Accounting
65115 -----------------------------------------------------------------------------------------
65116 -- No MPA option is assigned.
65117
65118
65119 END IF;
65120 END IF;
65121 --
65122
65123 --
65124 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
65125 trace
65126 (p_msg => 'END of AcctLineType_133'
65127 ,p_level => C_LEVEL_PROCEDURE
65128 ,p_module => l_log_module);
65129 END IF;
65130 --
65131 EXCEPTION
65132 WHEN xla_exceptions_pkg.application_exception THEN
65133 RAISE;
65134 WHEN OTHERS THEN
65135 xla_exceptions_pkg.raise_message
65136 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_133');
65137 END AcctLineType_133;
65138 --
65139
65140 ---------------------------------------
65141 --
65142 -- PRIVATE FUNCTION
65143 -- AcctLineType_134
65144 --
65145 ---------------------------------------
65146 PROCEDURE AcctLineType_134 (
65147 p_application_id IN NUMBER
65148 ,p_event_id IN NUMBER
65149 ,p_calculate_acctd_flag IN VARCHAR2
65150 ,p_calculate_g_l_flag IN VARCHAR2
65151 ,p_actual_flag IN OUT VARCHAR2
65152 ,p_balance_type_code OUT VARCHAR2
65153 ,p_gain_or_loss_ref OUT VARCHAR2
65154
65155 --Remittance Bank Account Unapplied Account
65156 , p_source_18 IN NUMBER
65157 --Distribution Source Type
65158 , p_source_22 IN VARCHAR2
65159 --Distribution Line Identifier
65160 , p_source_24 IN NUMBER
65161 --Distribution Type
65162 , p_source_25 IN VARCHAR2
65163 --Exchange Date
65164 , p_source_28 IN DATE
65165 --Exchange Rate
65166 , p_source_29 IN NUMBER
65167 --Exchange Rate Type
65168 , p_source_30 IN VARCHAR2
65169 --Transaction Distribution Identifier
65170 , p_source_36 IN NUMBER
65171 --Transaction Distribution Type
65172 , p_source_37 IN VARCHAR2
65173 --Receipt Applied To Application Identifier
65174 , p_source_60 IN NUMBER
65175 --Transaction Entity Code
65176 , p_source_61 IN VARCHAR2
65177 --Transaction Identifier
65178 , p_source_62 IN NUMBER
65179 --Applying Document Currency Code
65180 , p_source_63 IN VARCHAR2
65181 --Distribution Party Identifier
65182 , p_source_65 IN NUMBER
65183 --Distribution Party Site Id
65184 , p_source_66 IN NUMBER
65185 --Distribution Party Type
65186 , p_source_67 IN VARCHAR2
65187 --DIST_ENT_AMT_FROM
65188 , p_source_74 IN NUMBER
65189 --Accounting Amount
65190 , p_source_75 IN NUMBER
65191 )
65192 IS
65193
65194 l_component_type VARCHAR2(80);
65195 l_component_code VARCHAR2(30);
65196 l_component_type_code VARCHAR2(1);
65197 l_component_appl_id INTEGER;
65198 l_amb_context_code VARCHAR2(30);
65199 l_entity_code VARCHAR2(30);
65200 l_event_class_code VARCHAR2(30);
65201 l_ae_header_id NUMBER;
65202 l_event_type_code VARCHAR2(30);
65206 -- adr variables
65203 l_line_definition_code VARCHAR2(30);
65204 l_line_definition_owner_code VARCHAR2(1);
65205 --
65207 l_segment VARCHAR2(30);
65208 l_ccid NUMBER;
65209 l_adr_transaction_coa_id NUMBER;
65210 l_adr_accounting_coa_id NUMBER;
65211 l_adr_flexfield_segment_code VARCHAR2(30);
65212 l_adr_flex_value_set_id NUMBER;
65213 l_adr_value_type_code VARCHAR2(30);
65214 l_adr_value_combination_id NUMBER;
65215 l_adr_value_segment_code VARCHAR2(30);
65216
65217 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
65218 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
65219 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
65220 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
65221
65222 -- 4262811 Variables ------------------------------------------------------------------------------------------
65223 l_entered_amt_idx NUMBER;
65224 l_accted_amt_idx NUMBER;
65225 l_acc_rev_flag VARCHAR2(1);
65226 l_accrual_line_num NUMBER;
65227 l_tmp_amt NUMBER;
65228 l_acc_rev_natural_side_code VARCHAR2(1);
65229
65230 l_num_entries NUMBER;
65231 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
65232 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
65233 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
65234 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
65235 l_recog_line_1 NUMBER;
65236 l_recog_line_2 NUMBER;
65237
65238 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
65239 l_bflow_applied_to_amt NUMBER; -- 5132302
65240 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
65241
65242 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
65243
65244 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
65245 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
65246
65247 ---------------------------------------------------------------------------------------------------------------
65248
65249
65250 --
65251 -- bulk performance
65252 --
65253 l_balance_type_code VARCHAR2(1);
65254 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
65255 l_log_module VARCHAR2(240);
65256
65257 --
65258 -- Upgrade strategy
65259 --
65260 l_actual_upg_option VARCHAR2(1);
65261 l_enc_upg_option VARCHAR2(1);
65262
65263 --
65264 BEGIN
65265 --
65266 IF g_log_enabled THEN
65267 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_134';
65268 END IF;
65269 --
65270 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
65271
65272 trace
65273 (p_msg => 'BEGIN of AcctLineType_134'
65274 ,p_level => C_LEVEL_PROCEDURE
65275 ,p_module => l_log_module);
65276
65277 END IF;
65278 --
65279 l_component_type := 'AMB_JLT';
65280 l_component_code := 'RCT_UNAPP_GAIN_LOSS_DEBIT';
65281 l_component_type_code := 'S';
65282 l_component_appl_id := 222;
65283 l_amb_context_code := 'DEFAULT';
65284 l_entity_code := 'RECEIPTS';
65285 l_event_class_code := 'RECEIPT';
65286 l_event_type_code := 'RECEIPT_ALL';
65287 l_line_definition_owner_code := 'S';
65288 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
65289 --
65290 l_balance_type_code := 'A';
65291 l_segment := NULL;
65292 l_ccid := NULL;
65293 l_adr_transaction_coa_id := NULL;
65294 l_adr_accounting_coa_id := NULL;
65295 l_adr_flexfield_segment_code := NULL;
65296 l_adr_flex_value_set_id := NULL;
65297 l_adr_value_type_code := NULL;
65298 l_adr_value_combination_id := NULL;
65299 l_adr_value_segment_code := NULL;
65300
65301 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
65302 l_bflow_class_code := ''; -- 4219869 Business Flow
65303 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
65304 l_budgetary_control_flag := 'N';
65305
65306 l_bflow_applied_to_amt_idx := NULL; -- 5132302
65307 l_bflow_applied_to_amt := NULL; -- 5132302
65308 l_entered_amt_idx := NULL; -- 4262811
65309 l_accted_amt_idx := NULL; -- 4262811
65310 l_acc_rev_flag := NULL; -- 4262811
65311 l_accrual_line_num := NULL; -- 4262811
65312 l_tmp_amt := NULL; -- 4262811
65313 --
65314
65315 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
65316 l_balance_type_code <> 'B' THEN
65317 IF (NVL(p_source_22,'
65318 ') = 'EXCH_LOSS') OR
65319 (NVL(p_source_22,'
65320 ') = 'EXCH_GAIN')
65321 THEN
65322
65323 --
65324 XLA_AE_LINES_PKG.SetNewLine;
65325
65326 p_balance_type_code := l_balance_type_code;
65327 -- set the flag so later we will know whether the gain loss line needs to be created
65328
65329 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
65330 p_actual_flag :='A';
65331 END IF;
65332
65336 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
65333 --
65334 -- bulk performance
65335 --
65337 p_header_num => 0); -- 4262811
65338 --
65339 -- set accounting line options
65340 --
65341 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
65342 p_natural_side_code => 'D'
65343 , p_gain_or_loss_flag => 'N'
65344 , p_gl_transfer_mode_code => 'S'
65345 , p_acct_entry_type_code => 'A'
65346 , p_switch_side_flag => 'Y'
65347 , p_merge_duplicate_code => 'A'
65348 );
65349 --
65350 l_acc_rev_natural_side_code := 'C'; -- 4262811
65351 --
65352 --
65353 -- set accounting line type info
65354 --
65355 xla_ae_lines_pkg.SetAcctLineType
65356 (p_component_type => l_component_type
65357 ,p_event_type_code => l_event_type_code
65358 ,p_line_definition_owner_code => l_line_definition_owner_code
65359 ,p_line_definition_code => l_line_definition_code
65360 ,p_accounting_line_code => l_component_code
65361 ,p_accounting_line_type_code => l_component_type_code
65362 ,p_accounting_line_appl_id => l_component_appl_id
65363 ,p_amb_context_code => l_amb_context_code
65364 ,p_entity_code => l_entity_code
65365 ,p_event_class_code => l_event_class_code);
65366 --
65367 -- set accounting class
65368 --
65369 xla_ae_lines_pkg.SetAcctClass(
65370 p_accounting_class_code => 'UNAPP'
65371 , p_ae_header_id => l_ae_header_id
65372 );
65373
65374 --
65375 -- set rounding class
65376 --
65377 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
65378 'RECEIVABLE';
65379
65380 --
65381 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
65382 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
65383 --
65384 -- bulk performance
65385 --
65386 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
65387
65388 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
65389 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
65390
65391 -- 4955764
65392 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
65393 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
65394
65395 -- 4458381 Public Sector Enh
65396
65397 --
65398 -- set accounting attributes for the line type
65399 --
65400 l_entered_amt_idx := 8;
65401 l_accted_amt_idx := 13;
65402 l_bflow_applied_to_amt_idx := NULL; -- 5132302
65403 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
65404 l_rec_acct_attrs.array_num_value(1) := p_source_60;
65405 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
65406 l_rec_acct_attrs.array_char_value(2) := p_source_37;
65407 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
65408 l_rec_acct_attrs.array_char_value(3) := p_source_61;
65409 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
65410 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
65411 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
65412 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
65413 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
65414 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
65415 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
65416 l_rec_acct_attrs.array_char_value(7) := p_source_25;
65417 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
65418 l_rec_acct_attrs.array_num_value(8) := p_source_74;
65419 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
65420 l_rec_acct_attrs.array_char_value(9) := p_source_63;
65421 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
65422 l_rec_acct_attrs.array_date_value(10) := p_source_28;
65423 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
65424 l_rec_acct_attrs.array_num_value(11) := p_source_29;
65425 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
65426 l_rec_acct_attrs.array_char_value(12) := p_source_30;
65427 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
65428 l_rec_acct_attrs.array_num_value(13) := p_source_75;
65429 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
65430 l_rec_acct_attrs.array_num_value(14) := p_source_65;
65431 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
65432 l_rec_acct_attrs.array_num_value(15) := p_source_66;
65433 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
65434 l_rec_acct_attrs.array_char_value(16) := p_source_67;
65435
65436 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
65437 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
65438
65439 ---------------------------------------------------------------------------------------------------------------
65443
65440 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
65441 ---------------------------------------------------------------------------------------------------------------
65442 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
65444 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
65445 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
65446
65447 IF xla_accounting_cache_pkg.GetValueChar
65448 (p_source_code => 'LEDGER_CATEGORY_CODE'
65449 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
65450 AND l_bflow_method_code = 'PRIOR_ENTRY'
65451 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
65452 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
65453 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
65454 )
65455 THEN
65456 xla_ae_lines_pkg.BflowUpgEntry
65457 (p_business_method_code => l_bflow_method_code
65458 ,p_business_class_code => l_bflow_class_code
65459 ,p_balance_type => l_balance_type_code);
65460 ELSE
65461 NULL;
65462 -- No business flow processing for business flow method of NONE.
65463 END IF;
65464
65465 --
65466 -- call analytical criteria
65467 --
65468
65469 --
65470 -- call description
65471 --
65472 -- No description or it is inherited.
65473 --
65474 -- call ADRs
65475 -- Bug 4922099
65476 --
65477 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
65478 (NVL(l_actual_upg_option, 'N') = 'O') OR
65479 (NVL(l_enc_upg_option, 'N') = 'O')
65480 )
65481 THEN
65482 NULL;
65483 --
65484 --
65485
65486 l_ccid := AcctDerRule_31(
65487 p_application_id => p_application_id
65488 , p_ae_header_id => l_ae_header_id
65489 , p_source_18 => p_source_18
65490 , x_transaction_coa_id => l_adr_transaction_coa_id
65491 , x_accounting_coa_id => l_adr_accounting_coa_id
65492 , x_value_type_code => l_adr_value_type_code
65493 , p_side => 'NA'
65494 );
65495
65496 xla_ae_lines_pkg.set_ccid(
65497 p_code_combination_id => l_ccid
65498 , p_value_type_code => l_adr_value_type_code
65499 , p_transaction_coa_id => l_adr_transaction_coa_id
65500 , p_accounting_coa_id => l_adr_accounting_coa_id
65501 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
65502 , p_adr_type_code => 'S'
65503 , p_component_type => l_component_type
65504 , p_component_code => l_component_code
65505 , p_component_type_code => l_component_type_code
65506 , p_component_appl_id => l_component_appl_id
65507 , p_amb_context_code => l_amb_context_code
65508 , p_side => 'NA'
65509 );
65510
65511
65512 --
65513 --
65514 END IF;
65515 --
65516 -- Bug 4922099
65517 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
65518 (NVL(l_enc_upg_option, 'N') = 'O')
65519 ) AND
65520 (l_bflow_method_code = 'PRIOR_ENTRY')
65521 )
65522 THEN
65523 IF
65524 --
65525 1 = 2
65526 --
65527 THEN
65528 xla_accounting_err_pkg.build_message
65529 (p_appli_s_name => 'XLA'
65530 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
65531 ,p_token_1 => 'LINE_NUMBER'
65532 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
65533 ,p_token_2 => 'LINE_TYPE_NAME'
65534 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
65535 l_component_type
65536 ,l_component_code
65537 ,l_component_type_code
65538 ,l_component_appl_id
65539 ,l_amb_context_code
65540 ,l_entity_code
65541 ,l_event_class_code
65542 )
65543 ,p_token_3 => 'OWNER'
65544 ,p_value_3 => xla_lookups_pkg.get_meaning(
65545 p_lookup_type => 'XLA_OWNER_TYPE'
65546 ,p_lookup_code => l_component_type_code
65547 )
65548 ,p_token_4 => 'PRODUCT_NAME'
65552 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
65549 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
65550 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
65551 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
65553 ,p_ae_header_id => NULL
65554 );
65555
65556 IF (C_LEVEL_ERROR>= g_log_level) THEN
65557 trace
65558 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
65559 ,p_level => C_LEVEL_ERROR
65560 ,p_module => l_log_module);
65561 END IF;
65562 END IF;
65563 END IF;
65564 --
65565 --
65566 ------------------------------------------------------------------------------------------------
65567 -- 4219869 Business Flow
65568 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
65569 -- Prior Entry. Currently, the following code is always generated.
65570 ------------------------------------------------------------------------------------------------
65571 XLA_AE_LINES_PKG.ValidateCurrentLine;
65572
65573 ------------------------------------------------------------------------------------
65574 -- 4219869 Business Flow
65575 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
65576 ------------------------------------------------------------------------------------
65577 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
65578
65579 ----------------------------------------------------------------------------------
65580 -- 4219869 Business Flow
65581 -- Update journal entry status -- Need to generate this within IF <condition>
65582 ----------------------------------------------------------------------------------
65583 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
65584 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
65585 ,p_balance_type_code => l_balance_type_code
65586 );
65587
65588 -------------------------------------------------------------------------------------------
65589 -- 4262811 - Generate the Accrual Reversal lines
65590 -------------------------------------------------------------------------------------------
65591 BEGIN
65592 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
65593 (g_array_event(p_event_id).array_value_num('header_index'));
65594 IF l_acc_rev_flag IS NULL THEN
65595 l_acc_rev_flag := 'N';
65596 END IF;
65597 EXCEPTION
65598 WHEN OTHERS THEN
65599 l_acc_rev_flag := 'N';
65600 END;
65601 --
65602 IF (l_acc_rev_flag = 'Y') THEN
65603
65604 -- 4645092 ------------------------------------------------------------------------------
65605 -- To allow MPA report to determine if it should generate report process
65606 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
65607 ------------------------------------------------------------------------------------------
65608
65609 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
65610 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
65611 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
65612 -- call ADRs
65613 -- Bug 4922099
65614 --
65615 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
65616 (NVL(l_actual_upg_option, 'N') = 'O') OR
65617 (NVL(l_enc_upg_option, 'N') = 'O')
65618 )
65619 THEN
65620 NULL;
65621 --
65622 --
65623
65624 l_ccid := AcctDerRule_31(
65625 p_application_id => p_application_id
65626 , p_ae_header_id => l_ae_header_id
65627 , p_source_18 => p_source_18
65628 , x_transaction_coa_id => l_adr_transaction_coa_id
65629 , x_accounting_coa_id => l_adr_accounting_coa_id
65630 , x_value_type_code => l_adr_value_type_code
65631 , p_side => 'NA'
65632 );
65633
65634 xla_ae_lines_pkg.set_ccid(
65635 p_code_combination_id => l_ccid
65636 , p_value_type_code => l_adr_value_type_code
65637 , p_transaction_coa_id => l_adr_transaction_coa_id
65638 , p_accounting_coa_id => l_adr_accounting_coa_id
65639 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
65640 , p_adr_type_code => 'S'
65641 , p_component_type => l_component_type
65642 , p_component_code => l_component_code
65643 , p_component_type_code => l_component_type_code
65644 , p_component_appl_id => l_component_appl_id
65645 , p_amb_context_code => l_amb_context_code
65646 , p_side => 'NA'
65647 );
65648
65649
65650 --
65651 --
65652 END IF;
65653
65654 --
65655 -- Update the line information that should be overwritten
65656 --
65657 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
65658 p_header_num => 1);
65659 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
65660
65664 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
65661 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
65662
65663 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
65665 END IF;
65666
65667 --
65668 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
65669 --
65670 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
65671 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
65672 ELSE
65673 ---------------------------------------------------------------------------------------------------
65674 -- 4262811a Switch Sign
65675 ---------------------------------------------------------------------------------------------------
65676 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
65677 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
65678 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65679 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
65680 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65681 -- 5132302
65682 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
65683 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65684
65685 END IF;
65686
65687 -- 4955764
65688 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
65689 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
65690
65691
65692 XLA_AE_LINES_PKG.ValidateCurrentLine;
65693 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
65694
65695 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
65696 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
65697 ,p_balance_type_code => l_balance_type_code);
65698
65699 END IF;
65700
65701 -----------------------------------------------------------------------------------------
65702 -- 4262811 Multiperiod Accounting
65703 -----------------------------------------------------------------------------------------
65704 -- No MPA option is assigned.
65705
65706
65707 END IF;
65708 END IF;
65709 --
65710
65711 --
65712 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
65713 trace
65714 (p_msg => 'END of AcctLineType_134'
65715 ,p_level => C_LEVEL_PROCEDURE
65716 ,p_module => l_log_module);
65717 END IF;
65718 --
65719 EXCEPTION
65720 WHEN xla_exceptions_pkg.application_exception THEN
65721 RAISE;
65722 WHEN OTHERS THEN
65723 xla_exceptions_pkg.raise_message
65724 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_134');
65725 END AcctLineType_134;
65726 --
65727
65728 ---------------------------------------
65729 --
65730 -- PRIVATE FUNCTION
65731 -- AcctLineType_135
65732 --
65733 ---------------------------------------
65734 PROCEDURE AcctLineType_135 (
65735 p_application_id IN NUMBER
65736 ,p_event_id IN NUMBER
65737 ,p_calculate_acctd_flag IN VARCHAR2
65738 ,p_calculate_g_l_flag IN VARCHAR2
65739 ,p_actual_flag IN OUT VARCHAR2
65740 ,p_balance_type_code OUT VARCHAR2
65741 ,p_gain_or_loss_ref OUT VARCHAR2
65742
65743 --Remittance Bank Account Unearned Account
65744 , p_source_7 IN NUMBER
65745 --Transaction Distribution GL Account
65746 , p_source_21 IN NUMBER
65747 --Distribution Source Type
65748 , p_source_22 IN VARCHAR2
65749 --Distribution Line Identifier
65750 , p_source_24 IN NUMBER
65751 --Distribution Type
65752 , p_source_25 IN VARCHAR2
65753 --Entered Amount
65754 , p_source_26 IN NUMBER
65755 --Currency Code
65756 , p_source_27 IN VARCHAR2
65757 --Applied To Document Accounting Amount
65758 , p_source_31 IN NUMBER
65759 --Transaction Distribution Identifier
65760 , p_source_36 IN NUMBER
65761 --Transaction Distribution Type
65762 , p_source_37 IN VARCHAR2
65763 --Applied To Document Exchange Date
65764 , p_source_59 IN DATE
65765 --Receipt Applied To Application Identifier
65766 , p_source_60 IN NUMBER
65767 --Transaction Entity Code
65768 , p_source_61 IN VARCHAR2
65769 --Transaction Identifier
65770 , p_source_62 IN NUMBER
65771 --Applied To Document Exchange Rate
65772 , p_source_64 IN NUMBER
65773 --Distribution Party Identifier
65774 , p_source_65 IN NUMBER
65775 --Distribution Party Site Id
65776 , p_source_66 IN NUMBER
65777 --Distribution Party Type
65778 , p_source_67 IN VARCHAR2
65779 --Distribution Multi Fund Additional Entry
65780 , p_source_71 IN VARCHAR2
65781 --Applied To Document Exchange Rate Type
65782 , p_source_76 IN VARCHAR2
65783 )
65784 IS
65788 l_component_type_code VARCHAR2(1);
65785
65786 l_component_type VARCHAR2(80);
65787 l_component_code VARCHAR2(30);
65789 l_component_appl_id INTEGER;
65790 l_amb_context_code VARCHAR2(30);
65791 l_entity_code VARCHAR2(30);
65792 l_event_class_code VARCHAR2(30);
65793 l_ae_header_id NUMBER;
65794 l_event_type_code VARCHAR2(30);
65795 l_line_definition_code VARCHAR2(30);
65796 l_line_definition_owner_code VARCHAR2(1);
65797 --
65798 -- adr variables
65799 l_segment VARCHAR2(30);
65800 l_ccid NUMBER;
65801 l_adr_transaction_coa_id NUMBER;
65802 l_adr_accounting_coa_id NUMBER;
65803 l_adr_flexfield_segment_code VARCHAR2(30);
65804 l_adr_flex_value_set_id NUMBER;
65805 l_adr_value_type_code VARCHAR2(30);
65806 l_adr_value_combination_id NUMBER;
65807 l_adr_value_segment_code VARCHAR2(30);
65808
65809 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
65810 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
65811 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
65812 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
65813
65814 -- 4262811 Variables ------------------------------------------------------------------------------------------
65815 l_entered_amt_idx NUMBER;
65816 l_accted_amt_idx NUMBER;
65817 l_acc_rev_flag VARCHAR2(1);
65818 l_accrual_line_num NUMBER;
65819 l_tmp_amt NUMBER;
65820 l_acc_rev_natural_side_code VARCHAR2(1);
65821
65822 l_num_entries NUMBER;
65823 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
65824 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
65825 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
65826 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
65827 l_recog_line_1 NUMBER;
65828 l_recog_line_2 NUMBER;
65829
65830 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
65831 l_bflow_applied_to_amt NUMBER; -- 5132302
65832 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
65833
65834 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
65835
65836 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
65837 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
65838
65839 ---------------------------------------------------------------------------------------------------------------
65840
65841
65842 --
65843 -- bulk performance
65844 --
65845 l_balance_type_code VARCHAR2(1);
65846 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
65847 l_log_module VARCHAR2(240);
65848
65849 --
65850 -- Upgrade strategy
65851 --
65852 l_actual_upg_option VARCHAR2(1);
65853 l_enc_upg_option VARCHAR2(1);
65854
65855 --
65856 BEGIN
65857 --
65858 IF g_log_enabled THEN
65859 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_135';
65860 END IF;
65861 --
65862 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
65863
65864 trace
65865 (p_msg => 'BEGIN of AcctLineType_135'
65866 ,p_level => C_LEVEL_PROCEDURE
65867 ,p_module => l_log_module);
65868
65869 END IF;
65870 --
65871 l_component_type := 'AMB_JLT';
65872 l_component_code := 'RCT_UNEDISC';
65873 l_component_type_code := 'S';
65874 l_component_appl_id := 222;
65875 l_amb_context_code := 'DEFAULT';
65876 l_entity_code := 'RECEIPTS';
65877 l_event_class_code := 'RECEIPT';
65878 l_event_type_code := 'RECEIPT_ALL';
65879 l_line_definition_owner_code := 'S';
65880 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
65881 --
65882 l_balance_type_code := 'A';
65883 l_segment := NULL;
65884 l_ccid := NULL;
65885 l_adr_transaction_coa_id := NULL;
65886 l_adr_accounting_coa_id := NULL;
65887 l_adr_flexfield_segment_code := NULL;
65888 l_adr_flex_value_set_id := NULL;
65889 l_adr_value_type_code := NULL;
65890 l_adr_value_combination_id := NULL;
65891 l_adr_value_segment_code := NULL;
65892
65893 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
65894 l_bflow_class_code := ''; -- 4219869 Business Flow
65895 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
65896 l_budgetary_control_flag := 'N';
65897
65898 l_bflow_applied_to_amt_idx := NULL; -- 5132302
65899 l_bflow_applied_to_amt := NULL; -- 5132302
65900 l_entered_amt_idx := NULL; -- 4262811
65901 l_accted_amt_idx := NULL; -- 4262811
65902 l_acc_rev_flag := NULL; -- 4262811
65903 l_accrual_line_num := NULL; -- 4262811
65904 l_tmp_amt := NULL; -- 4262811
65905 --
65906
65907 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
65908 l_balance_type_code <> 'B' THEN
65912 ') = 'N'
65909 IF NVL(p_source_22,'
65910 ') = 'UNEDISC' AND
65911 NVL(p_source_71,'
65913 THEN
65914
65915 --
65916 XLA_AE_LINES_PKG.SetNewLine;
65917
65918 p_balance_type_code := l_balance_type_code;
65919 -- set the flag so later we will know whether the gain loss line needs to be created
65920
65921 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
65922 p_actual_flag :='A';
65923 END IF;
65924
65925 --
65926 -- bulk performance
65927 --
65928 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
65929 p_header_num => 0); -- 4262811
65930 --
65931 -- set accounting line options
65932 --
65933 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
65934 p_natural_side_code => 'C'
65935 , p_gain_or_loss_flag => 'N'
65936 , p_gl_transfer_mode_code => 'S'
65937 , p_acct_entry_type_code => 'A'
65938 , p_switch_side_flag => 'Y'
65939 , p_merge_duplicate_code => 'A'
65940 );
65941 --
65942 l_acc_rev_natural_side_code := 'D'; -- 4262811
65943 --
65944 --
65945 -- set accounting line type info
65946 --
65947 xla_ae_lines_pkg.SetAcctLineType
65948 (p_component_type => l_component_type
65949 ,p_event_type_code => l_event_type_code
65950 ,p_line_definition_owner_code => l_line_definition_owner_code
65951 ,p_line_definition_code => l_line_definition_code
65952 ,p_accounting_line_code => l_component_code
65953 ,p_accounting_line_type_code => l_component_type_code
65954 ,p_accounting_line_appl_id => l_component_appl_id
65955 ,p_amb_context_code => l_amb_context_code
65956 ,p_entity_code => l_entity_code
65957 ,p_event_class_code => l_event_class_code);
65958 --
65959 -- set accounting class
65960 --
65961 xla_ae_lines_pkg.SetAcctClass(
65962 p_accounting_class_code => 'UNEDISC'
65963 , p_ae_header_id => l_ae_header_id
65964 );
65965
65966 --
65967 -- set rounding class
65968 --
65969 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
65970 'RECEIVABLE';
65971
65972 --
65973 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
65974 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
65975 --
65976 -- bulk performance
65977 --
65978 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
65979
65980 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
65981 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
65982
65983 -- 4955764
65984 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
65985 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
65986
65987 -- 4458381 Public Sector Enh
65988
65989 --
65990 -- set accounting attributes for the line type
65991 --
65992 l_entered_amt_idx := 8;
65993 l_accted_amt_idx := 13;
65994 l_bflow_applied_to_amt_idx := NULL; -- 5132302
65995 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
65996 l_rec_acct_attrs.array_num_value(1) := p_source_60;
65997 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
65998 l_rec_acct_attrs.array_char_value(2) := p_source_37;
65999 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
66000 l_rec_acct_attrs.array_char_value(3) := p_source_61;
66001 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
66002 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
66003 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
66004 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
66005 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
66006 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
66007 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
66008 l_rec_acct_attrs.array_char_value(7) := p_source_25;
66009 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
66010 l_rec_acct_attrs.array_num_value(8) := p_source_26;
66011 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
66012 l_rec_acct_attrs.array_char_value(9) := p_source_27;
66013 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
66014 l_rec_acct_attrs.array_date_value(10) := p_source_59;
66015 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
66016 l_rec_acct_attrs.array_num_value(11) := p_source_64;
66017 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
66018 l_rec_acct_attrs.array_char_value(12) := p_source_76;
66019 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
66020 l_rec_acct_attrs.array_num_value(13) := p_source_31;
66021 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
66022 l_rec_acct_attrs.array_num_value(14) := p_source_65;
66023 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
66027
66024 l_rec_acct_attrs.array_num_value(15) := p_source_66;
66025 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
66026 l_rec_acct_attrs.array_char_value(16) := p_source_67;
66028 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
66029 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
66030
66031 ---------------------------------------------------------------------------------------------------------------
66032 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
66033 ---------------------------------------------------------------------------------------------------------------
66034 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
66035
66036 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
66037 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
66038
66039 IF xla_accounting_cache_pkg.GetValueChar
66040 (p_source_code => 'LEDGER_CATEGORY_CODE'
66041 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
66042 AND l_bflow_method_code = 'PRIOR_ENTRY'
66043 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
66044 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
66045 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
66046 )
66047 THEN
66048 xla_ae_lines_pkg.BflowUpgEntry
66049 (p_business_method_code => l_bflow_method_code
66050 ,p_business_class_code => l_bflow_class_code
66051 ,p_balance_type => l_balance_type_code);
66052 ELSE
66053 NULL;
66054 -- No business flow processing for business flow method of NONE.
66055 END IF;
66056
66057 --
66058 -- call analytical criteria
66059 --
66060
66061 --
66062 -- call description
66063 --
66064
66065 xla_ae_lines_pkg.SetLineDescription(
66066 p_ae_header_id => l_ae_header_id
66067 ,p_description => Description_1 (
66068 p_application_id => p_application_id
66069 , p_ae_header_id => l_ae_header_id
66070 )
66071 );
66072
66073
66074 --
66075 -- call ADRs
66076 -- Bug 4922099
66077 --
66078 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
66079 (NVL(l_actual_upg_option, 'N') = 'O') OR
66080 (NVL(l_enc_upg_option, 'N') = 'O')
66081 )
66082 THEN
66083 NULL;
66084 --
66085 --
66086
66087 l_ccid := AcctDerRule_34(
66088 p_application_id => p_application_id
66089 , p_ae_header_id => l_ae_header_id
66090 , p_source_21 => p_source_21
66091 , x_transaction_coa_id => l_adr_transaction_coa_id
66092 , x_accounting_coa_id => l_adr_accounting_coa_id
66093 , x_value_type_code => l_adr_value_type_code
66094 , p_side => 'NA'
66095 );
66096
66097 xla_ae_lines_pkg.set_ccid(
66098 p_code_combination_id => l_ccid
66099 , p_value_type_code => l_adr_value_type_code
66100 , p_transaction_coa_id => l_adr_transaction_coa_id
66101 , p_accounting_coa_id => l_adr_accounting_coa_id
66102 , p_adr_code => 'TRX_DIST_CCID'
66103 , p_adr_type_code => 'S'
66104 , p_component_type => l_component_type
66105 , p_component_code => l_component_code
66106 , p_component_type_code => l_component_type_code
66107 , p_component_appl_id => l_component_appl_id
66108 , p_amb_context_code => l_amb_context_code
66109 , p_side => 'NA'
66110 );
66111
66112
66113 l_segment := AcctDerRule_8(
66114 p_application_id => p_application_id
66115 , p_ae_header_id => l_ae_header_id
66116 , p_source_7 => p_source_7
66117 , x_transaction_coa_id => l_adr_transaction_coa_id
66118 , x_accounting_coa_id => l_adr_accounting_coa_id
66119 , x_flexfield_segment_code => l_adr_flexfield_segment_code
66120 , x_flex_value_set_id => l_adr_flex_value_set_id
66121 , x_value_type_code => l_adr_value_type_code
66122 , x_value_combination_id => l_adr_value_combination_id
66123 , x_value_segment_code => l_adr_value_segment_code
66124 , p_side => 'NA'
66125 , p_override_seg_flag => 'Y'
66126 );
66127
66128 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
66129
66130 xla_ae_lines_pkg.set_segment(
66131 p_to_segment_code => 'GL_ACCOUNT'
66132 , p_segment_value => l_segment
66133 , p_from_segment_code => l_adr_value_segment_code
66134 , p_from_combination_id => l_adr_value_combination_id
66135 , p_value_type_code => l_adr_value_type_code
66136 , p_transaction_coa_id => l_adr_transaction_coa_id
66137 , p_accounting_coa_id => l_adr_accounting_coa_id
66138 , p_flexfield_segment_code => l_adr_flexfield_segment_code
66139 , p_flex_value_set_id => l_adr_flex_value_set_id
66140 , p_adr_code => 'MFAR_RCT_UNEARNED_NATURAL_SEG'
66141 , p_adr_type_code => 'S'
66145 , p_component_appl_id => l_component_appl_id
66142 , p_component_type => l_component_type
66143 , p_component_code => l_component_code
66144 , p_component_type_code => l_component_type_code
66146 , p_amb_context_code => l_amb_context_code
66147 , p_entity_code => 'RECEIPTS'
66148 , p_event_class_code => 'RECEIPT'
66149 , p_side => 'NA'
66150 );
66151
66152 END IF;
66153
66154 --
66155 --
66156 END IF;
66157 --
66158 -- Bug 4922099
66159 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
66160 (NVL(l_enc_upg_option, 'N') = 'O')
66161 ) AND
66162 (l_bflow_method_code = 'PRIOR_ENTRY')
66163 )
66164 THEN
66165 IF
66166 --
66167 1 = 2
66168 --
66169 THEN
66170 xla_accounting_err_pkg.build_message
66171 (p_appli_s_name => 'XLA'
66172 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
66173 ,p_token_1 => 'LINE_NUMBER'
66174 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
66175 ,p_token_2 => 'LINE_TYPE_NAME'
66176 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
66177 l_component_type
66178 ,l_component_code
66179 ,l_component_type_code
66180 ,l_component_appl_id
66181 ,l_amb_context_code
66182 ,l_entity_code
66183 ,l_event_class_code
66184 )
66185 ,p_token_3 => 'OWNER'
66186 ,p_value_3 => xla_lookups_pkg.get_meaning(
66187 p_lookup_type => 'XLA_OWNER_TYPE'
66188 ,p_lookup_code => l_component_type_code
66189 )
66190 ,p_token_4 => 'PRODUCT_NAME'
66191 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
66192 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
66193 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
66194 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
66195 ,p_ae_header_id => NULL
66196 );
66197
66198 IF (C_LEVEL_ERROR>= g_log_level) THEN
66199 trace
66200 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
66201 ,p_level => C_LEVEL_ERROR
66202 ,p_module => l_log_module);
66203 END IF;
66204 END IF;
66205 END IF;
66206 --
66207 --
66208 ------------------------------------------------------------------------------------------------
66209 -- 4219869 Business Flow
66210 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
66211 -- Prior Entry. Currently, the following code is always generated.
66212 ------------------------------------------------------------------------------------------------
66213 XLA_AE_LINES_PKG.ValidateCurrentLine;
66214
66215 ------------------------------------------------------------------------------------
66216 -- 4219869 Business Flow
66217 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
66218 ------------------------------------------------------------------------------------
66219 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
66220
66221 ----------------------------------------------------------------------------------
66222 -- 4219869 Business Flow
66223 -- Update journal entry status -- Need to generate this within IF <condition>
66224 ----------------------------------------------------------------------------------
66225 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
66226 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
66227 ,p_balance_type_code => l_balance_type_code
66228 );
66229
66230 -------------------------------------------------------------------------------------------
66231 -- 4262811 - Generate the Accrual Reversal lines
66232 -------------------------------------------------------------------------------------------
66233 BEGIN
66234 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
66235 (g_array_event(p_event_id).array_value_num('header_index'));
66239 EXCEPTION
66236 IF l_acc_rev_flag IS NULL THEN
66237 l_acc_rev_flag := 'N';
66238 END IF;
66240 WHEN OTHERS THEN
66241 l_acc_rev_flag := 'N';
66242 END;
66243 --
66244 IF (l_acc_rev_flag = 'Y') THEN
66245
66246 -- 4645092 ------------------------------------------------------------------------------
66247 -- To allow MPA report to determine if it should generate report process
66248 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
66249 ------------------------------------------------------------------------------------------
66250
66251 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
66252 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
66253 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
66254 -- call ADRs
66255 -- Bug 4922099
66256 --
66257 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
66258 (NVL(l_actual_upg_option, 'N') = 'O') OR
66259 (NVL(l_enc_upg_option, 'N') = 'O')
66260 )
66261 THEN
66262 NULL;
66263 --
66264 --
66265
66266 l_ccid := AcctDerRule_34(
66267 p_application_id => p_application_id
66268 , p_ae_header_id => l_ae_header_id
66269 , p_source_21 => p_source_21
66270 , x_transaction_coa_id => l_adr_transaction_coa_id
66271 , x_accounting_coa_id => l_adr_accounting_coa_id
66272 , x_value_type_code => l_adr_value_type_code
66273 , p_side => 'NA'
66274 );
66275
66276 xla_ae_lines_pkg.set_ccid(
66277 p_code_combination_id => l_ccid
66278 , p_value_type_code => l_adr_value_type_code
66279 , p_transaction_coa_id => l_adr_transaction_coa_id
66280 , p_accounting_coa_id => l_adr_accounting_coa_id
66281 , p_adr_code => 'TRX_DIST_CCID'
66282 , p_adr_type_code => 'S'
66283 , p_component_type => l_component_type
66284 , p_component_code => l_component_code
66285 , p_component_type_code => l_component_type_code
66286 , p_component_appl_id => l_component_appl_id
66287 , p_amb_context_code => l_amb_context_code
66288 , p_side => 'NA'
66289 );
66290
66291
66292 l_segment := AcctDerRule_8(
66293 p_application_id => p_application_id
66294 , p_ae_header_id => l_ae_header_id
66295 , p_source_7 => p_source_7
66296 , x_transaction_coa_id => l_adr_transaction_coa_id
66297 , x_accounting_coa_id => l_adr_accounting_coa_id
66298 , x_flexfield_segment_code => l_adr_flexfield_segment_code
66299 , x_flex_value_set_id => l_adr_flex_value_set_id
66300 , x_value_type_code => l_adr_value_type_code
66301 , x_value_combination_id => l_adr_value_combination_id
66302 , x_value_segment_code => l_adr_value_segment_code
66303 , p_side => 'NA'
66304 , p_override_seg_flag => 'Y'
66305 );
66306
66307 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
66308
66309 xla_ae_lines_pkg.set_segment(
66310 p_to_segment_code => 'GL_ACCOUNT'
66311 , p_segment_value => l_segment
66312 , p_from_segment_code => l_adr_value_segment_code
66313 , p_from_combination_id => l_adr_value_combination_id
66314 , p_value_type_code => l_adr_value_type_code
66315 , p_transaction_coa_id => l_adr_transaction_coa_id
66316 , p_accounting_coa_id => l_adr_accounting_coa_id
66317 , p_flexfield_segment_code => l_adr_flexfield_segment_code
66318 , p_flex_value_set_id => l_adr_flex_value_set_id
66319 , p_adr_code => 'MFAR_RCT_UNEARNED_NATURAL_SEG'
66320 , p_adr_type_code => 'S'
66321 , p_component_type => l_component_type
66322 , p_component_code => l_component_code
66323 , p_component_type_code => l_component_type_code
66324 , p_component_appl_id => l_component_appl_id
66325 , p_amb_context_code => l_amb_context_code
66326 , p_entity_code => 'RECEIPTS'
66327 , p_event_class_code => 'RECEIPT'
66328 , p_side => 'NA'
66329 );
66330
66331 END IF;
66332
66333 --
66334 --
66335 END IF;
66336
66337 --
66338 -- Update the line information that should be overwritten
66339 --
66340 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
66341 p_header_num => 1);
66342 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
66343
66344 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
66345
66346 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
66347 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
66348 END IF;
66349
66350 --
66351 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
66352 --
66353 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
66357 -- 4262811a Switch Sign
66354 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
66355 ELSE
66356 ---------------------------------------------------------------------------------------------------
66358 ---------------------------------------------------------------------------------------------------
66359 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
66360 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
66361 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
66362 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
66363 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
66364 -- 5132302
66365 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
66366 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
66367
66368 END IF;
66369
66370 -- 4955764
66371 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
66372 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
66373
66374
66375 XLA_AE_LINES_PKG.ValidateCurrentLine;
66376 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
66377
66378 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
66379 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
66380 ,p_balance_type_code => l_balance_type_code);
66381
66382 END IF;
66383
66384 -----------------------------------------------------------------------------------------
66385 -- 4262811 Multiperiod Accounting
66386 -----------------------------------------------------------------------------------------
66387 -- No MPA option is assigned.
66388
66389
66390 END IF;
66391 END IF;
66392 --
66393
66394 --
66395 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
66396 trace
66397 (p_msg => 'END of AcctLineType_135'
66398 ,p_level => C_LEVEL_PROCEDURE
66399 ,p_module => l_log_module);
66400 END IF;
66401 --
66402 EXCEPTION
66403 WHEN xla_exceptions_pkg.application_exception THEN
66404 RAISE;
66405 WHEN OTHERS THEN
66406 xla_exceptions_pkg.raise_message
66407 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_135');
66408 END AcctLineType_135;
66409 --
66410
66411 ---------------------------------------
66412 --
66413 -- PRIVATE FUNCTION
66414 -- AcctLineType_136
66415 --
66416 ---------------------------------------
66417 PROCEDURE AcctLineType_136 (
66418 p_application_id IN NUMBER
66419 ,p_event_id IN NUMBER
66420 ,p_calculate_acctd_flag IN VARCHAR2
66421 ,p_calculate_g_l_flag IN VARCHAR2
66422 ,p_actual_flag IN OUT VARCHAR2
66423 ,p_balance_type_code OUT VARCHAR2
66424 ,p_gain_or_loss_ref OUT VARCHAR2
66425
66426 --Distribution GL Account
66427 , p_source_10 IN NUMBER
66428 --Distribution Source Type
66429 , p_source_22 IN VARCHAR2
66430 --Distribution Line Identifier
66431 , p_source_24 IN NUMBER
66432 --Distribution Type
66433 , p_source_25 IN VARCHAR2
66434 --Exchange Date
66435 , p_source_28 IN DATE
66436 --Exchange Rate
66437 , p_source_29 IN NUMBER
66438 --Exchange Rate Type
66439 , p_source_30 IN VARCHAR2
66440 --Transaction Distribution Identifier
66441 , p_source_36 IN NUMBER
66442 --Transaction Distribution Type
66443 , p_source_37 IN VARCHAR2
66444 --Receipt Applied To Application Identifier
66445 , p_source_60 IN NUMBER
66446 --Transaction Entity Code
66447 , p_source_61 IN VARCHAR2
66448 --Transaction Identifier
66449 , p_source_62 IN NUMBER
66450 --Applying Document Currency Code
66451 , p_source_63 IN VARCHAR2
66452 --Distribution Party Identifier
66453 , p_source_65 IN NUMBER
66454 --Distribution Party Site Id
66455 , p_source_66 IN NUMBER
66456 --Distribution Party Type
66457 , p_source_67 IN VARCHAR2
66458 --Distribution Multi Fund Additional Entry
66459 , p_source_71 IN VARCHAR2
66460 --DIST_ENT_AMT_FROM
66461 , p_source_74 IN NUMBER
66462 --Accounting Amount
66463 , p_source_75 IN NUMBER
66464 )
66465 IS
66466
66467 l_component_type VARCHAR2(80);
66468 l_component_code VARCHAR2(30);
66469 l_component_type_code VARCHAR2(1);
66470 l_component_appl_id INTEGER;
66471 l_amb_context_code VARCHAR2(30);
66472 l_entity_code VARCHAR2(30);
66473 l_event_class_code VARCHAR2(30);
66474 l_ae_header_id NUMBER;
66475 l_event_type_code VARCHAR2(30);
66476 l_line_definition_code VARCHAR2(30);
66477 l_line_definition_owner_code VARCHAR2(1);
66478 --
66479 -- adr variables
66480 l_segment VARCHAR2(30);
66481 l_ccid NUMBER;
66485 l_adr_flex_value_set_id NUMBER;
66482 l_adr_transaction_coa_id NUMBER;
66483 l_adr_accounting_coa_id NUMBER;
66484 l_adr_flexfield_segment_code VARCHAR2(30);
66486 l_adr_value_type_code VARCHAR2(30);
66487 l_adr_value_combination_id NUMBER;
66488 l_adr_value_segment_code VARCHAR2(30);
66489
66490 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
66491 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
66492 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
66493 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
66494
66495 -- 4262811 Variables ------------------------------------------------------------------------------------------
66496 l_entered_amt_idx NUMBER;
66497 l_accted_amt_idx NUMBER;
66498 l_acc_rev_flag VARCHAR2(1);
66499 l_accrual_line_num NUMBER;
66500 l_tmp_amt NUMBER;
66501 l_acc_rev_natural_side_code VARCHAR2(1);
66502
66503 l_num_entries NUMBER;
66504 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
66505 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
66506 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
66507 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
66508 l_recog_line_1 NUMBER;
66509 l_recog_line_2 NUMBER;
66510
66511 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
66512 l_bflow_applied_to_amt NUMBER; -- 5132302
66513 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
66514
66515 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
66516
66517 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
66518 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
66519
66520 ---------------------------------------------------------------------------------------------------------------
66521
66522
66523 --
66524 -- bulk performance
66525 --
66526 l_balance_type_code VARCHAR2(1);
66527 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
66528 l_log_module VARCHAR2(240);
66529
66530 --
66531 -- Upgrade strategy
66532 --
66533 l_actual_upg_option VARCHAR2(1);
66534 l_enc_upg_option VARCHAR2(1);
66535
66536 --
66537 BEGIN
66538 --
66539 IF g_log_enabled THEN
66540 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_136';
66541 END IF;
66542 --
66543 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
66544
66545 trace
66546 (p_msg => 'BEGIN of AcctLineType_136'
66547 ,p_level => C_LEVEL_PROCEDURE
66548 ,p_module => l_log_module);
66549
66550 END IF;
66551 --
66552 l_component_type := 'AMB_JLT';
66553 l_component_code := 'RCT_UNID';
66554 l_component_type_code := 'S';
66555 l_component_appl_id := 222;
66556 l_amb_context_code := 'DEFAULT';
66557 l_entity_code := 'RECEIPTS';
66558 l_event_class_code := 'RECEIPT';
66559 l_event_type_code := 'RECEIPT_ALL';
66560 l_line_definition_owner_code := 'S';
66561 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
66562 --
66563 l_balance_type_code := 'A';
66564 l_segment := NULL;
66565 l_ccid := NULL;
66566 l_adr_transaction_coa_id := NULL;
66567 l_adr_accounting_coa_id := NULL;
66568 l_adr_flexfield_segment_code := NULL;
66569 l_adr_flex_value_set_id := NULL;
66570 l_adr_value_type_code := NULL;
66571 l_adr_value_combination_id := NULL;
66572 l_adr_value_segment_code := NULL;
66573
66574 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
66575 l_bflow_class_code := ''; -- 4219869 Business Flow
66576 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
66577 l_budgetary_control_flag := 'N';
66578
66579 l_bflow_applied_to_amt_idx := NULL; -- 5132302
66580 l_bflow_applied_to_amt := NULL; -- 5132302
66581 l_entered_amt_idx := NULL; -- 4262811
66582 l_accted_amt_idx := NULL; -- 4262811
66583 l_acc_rev_flag := NULL; -- 4262811
66584 l_accrual_line_num := NULL; -- 4262811
66585 l_tmp_amt := NULL; -- 4262811
66586 --
66587
66588 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
66589 l_balance_type_code <> 'B' THEN
66590 IF NVL(p_source_22,'
66591 ') = 'UNID' AND
66592 NVL(p_source_71,'
66593 ') = 'N'
66594 THEN
66595
66596 --
66597 XLA_AE_LINES_PKG.SetNewLine;
66598
66599 p_balance_type_code := l_balance_type_code;
66600 -- set the flag so later we will know whether the gain loss line needs to be created
66601
66602 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
66603 p_actual_flag :='A';
66604 END IF;
66605
66606 --
66607 -- bulk performance
66608 --
66609 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
66610 p_header_num => 0); -- 4262811
66611 --
66615 p_natural_side_code => 'C'
66612 -- set accounting line options
66613 --
66614 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
66616 , p_gain_or_loss_flag => 'N'
66617 , p_gl_transfer_mode_code => 'S'
66618 , p_acct_entry_type_code => 'A'
66619 , p_switch_side_flag => 'Y'
66620 , p_merge_duplicate_code => 'A'
66621 );
66622 --
66623 l_acc_rev_natural_side_code := 'D'; -- 4262811
66624 --
66625 --
66626 -- set accounting line type info
66627 --
66628 xla_ae_lines_pkg.SetAcctLineType
66629 (p_component_type => l_component_type
66630 ,p_event_type_code => l_event_type_code
66631 ,p_line_definition_owner_code => l_line_definition_owner_code
66632 ,p_line_definition_code => l_line_definition_code
66633 ,p_accounting_line_code => l_component_code
66634 ,p_accounting_line_type_code => l_component_type_code
66635 ,p_accounting_line_appl_id => l_component_appl_id
66636 ,p_amb_context_code => l_amb_context_code
66637 ,p_entity_code => l_entity_code
66638 ,p_event_class_code => l_event_class_code);
66639 --
66640 -- set accounting class
66641 --
66642 xla_ae_lines_pkg.SetAcctClass(
66643 p_accounting_class_code => 'UNID'
66644 , p_ae_header_id => l_ae_header_id
66645 );
66646
66647 --
66648 -- set rounding class
66649 --
66650 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
66651 'RECEIVABLE';
66652
66653 --
66654 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
66655 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
66656 --
66657 -- bulk performance
66658 --
66659 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
66660
66661 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
66662 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
66663
66664 -- 4955764
66665 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
66666 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
66667
66668 -- 4458381 Public Sector Enh
66669
66670 --
66671 -- set accounting attributes for the line type
66672 --
66673 l_entered_amt_idx := 8;
66674 l_accted_amt_idx := 13;
66675 l_bflow_applied_to_amt_idx := NULL; -- 5132302
66676 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
66677 l_rec_acct_attrs.array_num_value(1) := p_source_60;
66678 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
66679 l_rec_acct_attrs.array_char_value(2) := p_source_37;
66680 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
66681 l_rec_acct_attrs.array_char_value(3) := p_source_61;
66682 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
66683 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
66684 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
66685 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
66686 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
66687 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
66688 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
66689 l_rec_acct_attrs.array_char_value(7) := p_source_25;
66690 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
66691 l_rec_acct_attrs.array_num_value(8) := p_source_74;
66692 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
66693 l_rec_acct_attrs.array_char_value(9) := p_source_63;
66694 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
66695 l_rec_acct_attrs.array_date_value(10) := p_source_28;
66696 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
66697 l_rec_acct_attrs.array_num_value(11) := p_source_29;
66698 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
66699 l_rec_acct_attrs.array_char_value(12) := p_source_30;
66700 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
66701 l_rec_acct_attrs.array_num_value(13) := p_source_75;
66702 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
66703 l_rec_acct_attrs.array_num_value(14) := p_source_65;
66704 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
66705 l_rec_acct_attrs.array_num_value(15) := p_source_66;
66706 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
66707 l_rec_acct_attrs.array_char_value(16) := p_source_67;
66708
66709 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
66710 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
66711
66712 ---------------------------------------------------------------------------------------------------------------
66713 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
66714 ---------------------------------------------------------------------------------------------------------------
66715 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
66716
66720 IF xla_accounting_cache_pkg.GetValueChar
66717 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
66718 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
66719
66721 (p_source_code => 'LEDGER_CATEGORY_CODE'
66722 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
66723 AND l_bflow_method_code = 'PRIOR_ENTRY'
66724 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
66725 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
66726 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
66727 )
66728 THEN
66729 xla_ae_lines_pkg.BflowUpgEntry
66730 (p_business_method_code => l_bflow_method_code
66731 ,p_business_class_code => l_bflow_class_code
66732 ,p_balance_type => l_balance_type_code);
66733 ELSE
66734 NULL;
66735 -- No business flow processing for business flow method of NONE.
66736 END IF;
66737
66738 --
66739 -- call analytical criteria
66740 --
66741
66742 --
66743 -- call description
66744 --
66745 -- No description or it is inherited.
66746 --
66747 -- call ADRs
66748 -- Bug 4922099
66749 --
66750 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
66751 (NVL(l_actual_upg_option, 'N') = 'O') OR
66752 (NVL(l_enc_upg_option, 'N') = 'O')
66753 )
66754 THEN
66755 NULL;
66756 --
66757 --
66758
66759 l_ccid := AcctDerRule_11(
66760 p_application_id => p_application_id
66761 , p_ae_header_id => l_ae_header_id
66762 , p_source_10 => p_source_10
66763 , x_transaction_coa_id => l_adr_transaction_coa_id
66764 , x_accounting_coa_id => l_adr_accounting_coa_id
66765 , x_value_type_code => l_adr_value_type_code
66766 , p_side => 'NA'
66767 );
66768
66769 xla_ae_lines_pkg.set_ccid(
66770 p_code_combination_id => l_ccid
66771 , p_value_type_code => l_adr_value_type_code
66772 , p_transaction_coa_id => l_adr_transaction_coa_id
66773 , p_accounting_coa_id => l_adr_accounting_coa_id
66774 , p_adr_code => 'DIST_CCID'
66775 , p_adr_type_code => 'S'
66776 , p_component_type => l_component_type
66777 , p_component_code => l_component_code
66778 , p_component_type_code => l_component_type_code
66779 , p_component_appl_id => l_component_appl_id
66780 , p_amb_context_code => l_amb_context_code
66781 , p_side => 'NA'
66782 );
66783
66784
66785 --
66786 --
66787 END IF;
66788 --
66789 -- Bug 4922099
66790 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
66791 (NVL(l_enc_upg_option, 'N') = 'O')
66792 ) AND
66793 (l_bflow_method_code = 'PRIOR_ENTRY')
66794 )
66795 THEN
66796 IF
66797 --
66798 1 = 2
66799 --
66800 THEN
66801 xla_accounting_err_pkg.build_message
66802 (p_appli_s_name => 'XLA'
66803 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
66804 ,p_token_1 => 'LINE_NUMBER'
66805 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
66806 ,p_token_2 => 'LINE_TYPE_NAME'
66807 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
66808 l_component_type
66809 ,l_component_code
66810 ,l_component_type_code
66811 ,l_component_appl_id
66812 ,l_amb_context_code
66813 ,l_entity_code
66814 ,l_event_class_code
66815 )
66816 ,p_token_3 => 'OWNER'
66817 ,p_value_3 => xla_lookups_pkg.get_meaning(
66818 p_lookup_type => 'XLA_OWNER_TYPE'
66819 ,p_lookup_code => l_component_type_code
66820 )
66821 ,p_token_4 => 'PRODUCT_NAME'
66822 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
66823 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
66824 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
66828
66825 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
66826 ,p_ae_header_id => NULL
66827 );
66829 IF (C_LEVEL_ERROR>= g_log_level) THEN
66830 trace
66831 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
66832 ,p_level => C_LEVEL_ERROR
66833 ,p_module => l_log_module);
66834 END IF;
66835 END IF;
66836 END IF;
66837 --
66838 --
66839 ------------------------------------------------------------------------------------------------
66840 -- 4219869 Business Flow
66841 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
66842 -- Prior Entry. Currently, the following code is always generated.
66843 ------------------------------------------------------------------------------------------------
66844 XLA_AE_LINES_PKG.ValidateCurrentLine;
66845
66846 ------------------------------------------------------------------------------------
66847 -- 4219869 Business Flow
66848 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
66849 ------------------------------------------------------------------------------------
66850 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
66851
66852 ----------------------------------------------------------------------------------
66853 -- 4219869 Business Flow
66854 -- Update journal entry status -- Need to generate this within IF <condition>
66855 ----------------------------------------------------------------------------------
66856 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
66857 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
66858 ,p_balance_type_code => l_balance_type_code
66859 );
66860
66861 -------------------------------------------------------------------------------------------
66862 -- 4262811 - Generate the Accrual Reversal lines
66863 -------------------------------------------------------------------------------------------
66864 BEGIN
66865 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
66866 (g_array_event(p_event_id).array_value_num('header_index'));
66867 IF l_acc_rev_flag IS NULL THEN
66868 l_acc_rev_flag := 'N';
66869 END IF;
66870 EXCEPTION
66871 WHEN OTHERS THEN
66872 l_acc_rev_flag := 'N';
66873 END;
66874 --
66875 IF (l_acc_rev_flag = 'Y') THEN
66876
66877 -- 4645092 ------------------------------------------------------------------------------
66878 -- To allow MPA report to determine if it should generate report process
66879 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
66880 ------------------------------------------------------------------------------------------
66881
66882 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
66883 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
66884 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
66885 -- call ADRs
66886 -- Bug 4922099
66887 --
66888 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
66889 (NVL(l_actual_upg_option, 'N') = 'O') OR
66890 (NVL(l_enc_upg_option, 'N') = 'O')
66891 )
66892 THEN
66893 NULL;
66894 --
66895 --
66896
66897 l_ccid := AcctDerRule_11(
66898 p_application_id => p_application_id
66899 , p_ae_header_id => l_ae_header_id
66900 , p_source_10 => p_source_10
66901 , x_transaction_coa_id => l_adr_transaction_coa_id
66902 , x_accounting_coa_id => l_adr_accounting_coa_id
66903 , x_value_type_code => l_adr_value_type_code
66904 , p_side => 'NA'
66905 );
66906
66907 xla_ae_lines_pkg.set_ccid(
66908 p_code_combination_id => l_ccid
66909 , p_value_type_code => l_adr_value_type_code
66910 , p_transaction_coa_id => l_adr_transaction_coa_id
66911 , p_accounting_coa_id => l_adr_accounting_coa_id
66912 , p_adr_code => 'DIST_CCID'
66913 , p_adr_type_code => 'S'
66914 , p_component_type => l_component_type
66915 , p_component_code => l_component_code
66916 , p_component_type_code => l_component_type_code
66917 , p_component_appl_id => l_component_appl_id
66918 , p_amb_context_code => l_amb_context_code
66919 , p_side => 'NA'
66920 );
66921
66922
66923 --
66924 --
66925 END IF;
66926
66927 --
66928 -- Update the line information that should be overwritten
66929 --
66930 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
66931 p_header_num => 1);
66932 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
66933
66934 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
66935
66936 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
66940 --
66937 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
66938 END IF;
66939
66941 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
66942 --
66943 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
66944 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
66945 ELSE
66946 ---------------------------------------------------------------------------------------------------
66947 -- 4262811a Switch Sign
66948 ---------------------------------------------------------------------------------------------------
66949 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
66950 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
66951 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
66952 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
66953 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
66954 -- 5132302
66955 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
66956 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
66957
66958 END IF;
66959
66960 -- 4955764
66961 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
66962 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
66963
66964
66965 XLA_AE_LINES_PKG.ValidateCurrentLine;
66966 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
66967
66968 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
66969 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
66970 ,p_balance_type_code => l_balance_type_code);
66971
66972 END IF;
66973
66974 -----------------------------------------------------------------------------------------
66975 -- 4262811 Multiperiod Accounting
66976 -----------------------------------------------------------------------------------------
66977 -- No MPA option is assigned.
66978
66979
66980 END IF;
66981 END IF;
66982 --
66983
66984 --
66985 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
66986 trace
66987 (p_msg => 'END of AcctLineType_136'
66988 ,p_level => C_LEVEL_PROCEDURE
66989 ,p_module => l_log_module);
66990 END IF;
66991 --
66992 EXCEPTION
66993 WHEN xla_exceptions_pkg.application_exception THEN
66994 RAISE;
66995 WHEN OTHERS THEN
66996 xla_exceptions_pkg.raise_message
66997 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_136');
66998 END AcctLineType_136;
66999 --
67000
67001 ---------------------------------------
67002 --
67003 -- PRIVATE FUNCTION
67004 -- AcctLineType_137
67005 --
67006 ---------------------------------------
67007 PROCEDURE AcctLineType_137 (
67008 p_application_id IN NUMBER
67009 ,p_event_id IN NUMBER
67010 ,p_calculate_acctd_flag IN VARCHAR2
67011 ,p_calculate_g_l_flag IN VARCHAR2
67012 ,p_actual_flag IN OUT VARCHAR2
67013 ,p_balance_type_code OUT VARCHAR2
67014 ,p_gain_or_loss_ref OUT VARCHAR2
67015
67016 --Distribution GL Account
67017 , p_source_10 IN NUMBER
67018 --Distribution Source Type
67019 , p_source_22 IN VARCHAR2
67020 --Receivable Activity Type
67021 , p_source_23 IN VARCHAR2
67022 --Distribution Line Identifier
67023 , p_source_24 IN NUMBER
67024 --Distribution Type
67025 , p_source_25 IN VARCHAR2
67026 --Exchange Date
67027 , p_source_28 IN DATE
67028 --Exchange Rate
67029 , p_source_29 IN NUMBER
67030 --Exchange Rate Type
67031 , p_source_30 IN VARCHAR2
67032 --Transaction Distribution Identifier
67033 , p_source_36 IN NUMBER
67034 --Transaction Distribution Type
67035 , p_source_37 IN VARCHAR2
67036 --Receipt Applied To Application Identifier
67037 , p_source_60 IN NUMBER
67038 --Transaction Entity Code
67039 , p_source_61 IN VARCHAR2
67040 --Transaction Identifier
67041 , p_source_62 IN NUMBER
67042 --Applying Document Currency Code
67043 , p_source_63 IN VARCHAR2
67044 --Distribution Party Identifier
67045 , p_source_65 IN NUMBER
67046 --Distribution Party Site Id
67047 , p_source_66 IN NUMBER
67048 --Distribution Party Type
67049 , p_source_67 IN VARCHAR2
67050 --Distribution Multi Fund Additional Entry
67051 , p_source_71 IN VARCHAR2
67052 --DIST_ENT_AMT_FROM
67053 , p_source_74 IN NUMBER
67054 --Accounting Amount
67055 , p_source_75 IN NUMBER
67056 )
67057 IS
67058
67059 l_component_type VARCHAR2(80);
67060 l_component_code VARCHAR2(30);
67061 l_component_type_code VARCHAR2(1);
67062 l_component_appl_id INTEGER;
67063 l_amb_context_code VARCHAR2(30);
67067 l_event_type_code VARCHAR2(30);
67064 l_entity_code VARCHAR2(30);
67065 l_event_class_code VARCHAR2(30);
67066 l_ae_header_id NUMBER;
67068 l_line_definition_code VARCHAR2(30);
67069 l_line_definition_owner_code VARCHAR2(1);
67070 --
67071 -- adr variables
67072 l_segment VARCHAR2(30);
67073 l_ccid NUMBER;
67074 l_adr_transaction_coa_id NUMBER;
67075 l_adr_accounting_coa_id NUMBER;
67076 l_adr_flexfield_segment_code VARCHAR2(30);
67077 l_adr_flex_value_set_id NUMBER;
67078 l_adr_value_type_code VARCHAR2(30);
67079 l_adr_value_combination_id NUMBER;
67080 l_adr_value_segment_code VARCHAR2(30);
67081
67082 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
67083 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
67084 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
67085 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
67086
67087 -- 4262811 Variables ------------------------------------------------------------------------------------------
67088 l_entered_amt_idx NUMBER;
67089 l_accted_amt_idx NUMBER;
67090 l_acc_rev_flag VARCHAR2(1);
67091 l_accrual_line_num NUMBER;
67092 l_tmp_amt NUMBER;
67093 l_acc_rev_natural_side_code VARCHAR2(1);
67094
67095 l_num_entries NUMBER;
67096 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
67097 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
67098 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
67099 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
67100 l_recog_line_1 NUMBER;
67101 l_recog_line_2 NUMBER;
67102
67103 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
67104 l_bflow_applied_to_amt NUMBER; -- 5132302
67105 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
67106
67107 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
67108
67109 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
67110 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
67111
67112 ---------------------------------------------------------------------------------------------------------------
67113
67114
67115 --
67116 -- bulk performance
67117 --
67118 l_balance_type_code VARCHAR2(1);
67119 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
67120 l_log_module VARCHAR2(240);
67121
67122 --
67123 -- Upgrade strategy
67124 --
67125 l_actual_upg_option VARCHAR2(1);
67126 l_enc_upg_option VARCHAR2(1);
67127
67128 --
67129 BEGIN
67130 --
67131 IF g_log_enabled THEN
67132 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_137';
67133 END IF;
67134 --
67135 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67136
67137 trace
67138 (p_msg => 'BEGIN of AcctLineType_137'
67139 ,p_level => C_LEVEL_PROCEDURE
67140 ,p_module => l_log_module);
67141
67142 END IF;
67143 --
67144 l_component_type := 'AMB_JLT';
67145 l_component_code := 'RCT_WRITEOFF';
67146 l_component_type_code := 'S';
67147 l_component_appl_id := 222;
67148 l_amb_context_code := 'DEFAULT';
67149 l_entity_code := 'RECEIPTS';
67150 l_event_class_code := 'RECEIPT';
67151 l_event_type_code := 'RECEIPT_ALL';
67152 l_line_definition_owner_code := 'S';
67153 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
67154 --
67155 l_balance_type_code := 'A';
67156 l_segment := NULL;
67157 l_ccid := NULL;
67158 l_adr_transaction_coa_id := NULL;
67159 l_adr_accounting_coa_id := NULL;
67160 l_adr_flexfield_segment_code := NULL;
67161 l_adr_flex_value_set_id := NULL;
67162 l_adr_value_type_code := NULL;
67163 l_adr_value_combination_id := NULL;
67164 l_adr_value_segment_code := NULL;
67165
67166 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
67167 l_bflow_class_code := ''; -- 4219869 Business Flow
67168 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
67169 l_budgetary_control_flag := 'N';
67170
67171 l_bflow_applied_to_amt_idx := NULL; -- 5132302
67172 l_bflow_applied_to_amt := NULL; -- 5132302
67173 l_entered_amt_idx := NULL; -- 4262811
67174 l_accted_amt_idx := NULL; -- 4262811
67175 l_acc_rev_flag := NULL; -- 4262811
67176 l_accrual_line_num := NULL; -- 4262811
67177 l_tmp_amt := NULL; -- 4262811
67178 --
67179
67180 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
67181 l_balance_type_code <> 'B' THEN
67182 IF NVL(p_source_22,'
67183 ') = 'ACTIVITY' AND
67184 NVL(p_source_23,'
67185 ') = 'WRITEOFF' AND
67186 NVL(p_source_71,'
67187 ') = 'N'
67188 THEN
67189
67190 --
67191 XLA_AE_LINES_PKG.SetNewLine;
67192
67193 p_balance_type_code := l_balance_type_code;
67197 p_actual_flag :='A';
67194 -- set the flag so later we will know whether the gain loss line needs to be created
67195
67196 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
67198 END IF;
67199
67200 --
67201 -- bulk performance
67202 --
67203 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
67204 p_header_num => 0); -- 4262811
67205 --
67206 -- set accounting line options
67207 --
67208 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
67209 p_natural_side_code => 'C'
67210 , p_gain_or_loss_flag => 'N'
67211 , p_gl_transfer_mode_code => 'S'
67212 , p_acct_entry_type_code => 'A'
67213 , p_switch_side_flag => 'Y'
67214 , p_merge_duplicate_code => 'A'
67215 );
67216 --
67217 l_acc_rev_natural_side_code := 'D'; -- 4262811
67218 --
67219 --
67220 -- set accounting line type info
67221 --
67222 xla_ae_lines_pkg.SetAcctLineType
67223 (p_component_type => l_component_type
67224 ,p_event_type_code => l_event_type_code
67225 ,p_line_definition_owner_code => l_line_definition_owner_code
67226 ,p_line_definition_code => l_line_definition_code
67227 ,p_accounting_line_code => l_component_code
67228 ,p_accounting_line_type_code => l_component_type_code
67229 ,p_accounting_line_appl_id => l_component_appl_id
67230 ,p_amb_context_code => l_amb_context_code
67231 ,p_entity_code => l_entity_code
67232 ,p_event_class_code => l_event_class_code);
67233 --
67234 -- set accounting class
67235 --
67236 xla_ae_lines_pkg.SetAcctClass(
67237 p_accounting_class_code => 'WRITE_OFF'
67238 , p_ae_header_id => l_ae_header_id
67239 );
67240
67241 --
67242 -- set rounding class
67243 --
67244 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
67245 'RECEIVABLE';
67246
67247 --
67248 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
67249 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
67250 --
67251 -- bulk performance
67252 --
67253 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
67254
67255 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
67256 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
67257
67258 -- 4955764
67259 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
67260 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
67261
67262 -- 4458381 Public Sector Enh
67263
67264 --
67265 -- set accounting attributes for the line type
67266 --
67267 l_entered_amt_idx := 8;
67268 l_accted_amt_idx := 13;
67269 l_bflow_applied_to_amt_idx := NULL; -- 5132302
67270 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
67271 l_rec_acct_attrs.array_num_value(1) := p_source_60;
67272 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
67273 l_rec_acct_attrs.array_char_value(2) := p_source_37;
67274 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
67275 l_rec_acct_attrs.array_char_value(3) := p_source_61;
67276 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
67277 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_36);
67278 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
67279 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_62);
67280 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
67281 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_24);
67282 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
67283 l_rec_acct_attrs.array_char_value(7) := p_source_25;
67284 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
67285 l_rec_acct_attrs.array_num_value(8) := p_source_74;
67286 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
67287 l_rec_acct_attrs.array_char_value(9) := p_source_63;
67288 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
67289 l_rec_acct_attrs.array_date_value(10) := p_source_28;
67290 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
67291 l_rec_acct_attrs.array_num_value(11) := p_source_29;
67292 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
67293 l_rec_acct_attrs.array_char_value(12) := p_source_30;
67294 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
67295 l_rec_acct_attrs.array_num_value(13) := p_source_75;
67296 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
67297 l_rec_acct_attrs.array_num_value(14) := p_source_65;
67298 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
67299 l_rec_acct_attrs.array_num_value(15) := p_source_66;
67300 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
67301 l_rec_acct_attrs.array_char_value(16) := p_source_67;
67302
67303 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
67307 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
67304 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
67305
67306 ---------------------------------------------------------------------------------------------------------------
67308 ---------------------------------------------------------------------------------------------------------------
67309 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
67310
67311 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
67312 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
67313
67314 IF xla_accounting_cache_pkg.GetValueChar
67315 (p_source_code => 'LEDGER_CATEGORY_CODE'
67316 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
67317 AND l_bflow_method_code = 'PRIOR_ENTRY'
67318 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
67319 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
67320 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
67321 )
67322 THEN
67323 xla_ae_lines_pkg.BflowUpgEntry
67324 (p_business_method_code => l_bflow_method_code
67325 ,p_business_class_code => l_bflow_class_code
67326 ,p_balance_type => l_balance_type_code);
67327 ELSE
67328 NULL;
67329 -- No business flow processing for business flow method of NONE.
67330 END IF;
67331
67332 --
67333 -- call analytical criteria
67334 --
67335
67336 --
67337 -- call description
67338 --
67339 -- No description or it is inherited.
67340 --
67341 -- call ADRs
67342 -- Bug 4922099
67343 --
67344 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
67345 (NVL(l_actual_upg_option, 'N') = 'O') OR
67346 (NVL(l_enc_upg_option, 'N') = 'O')
67347 )
67348 THEN
67349 NULL;
67350 --
67351 --
67352
67353 l_ccid := AcctDerRule_11(
67354 p_application_id => p_application_id
67355 , p_ae_header_id => l_ae_header_id
67356 , p_source_10 => p_source_10
67357 , x_transaction_coa_id => l_adr_transaction_coa_id
67358 , x_accounting_coa_id => l_adr_accounting_coa_id
67359 , x_value_type_code => l_adr_value_type_code
67360 , p_side => 'NA'
67361 );
67362
67363 xla_ae_lines_pkg.set_ccid(
67364 p_code_combination_id => l_ccid
67365 , p_value_type_code => l_adr_value_type_code
67366 , p_transaction_coa_id => l_adr_transaction_coa_id
67367 , p_accounting_coa_id => l_adr_accounting_coa_id
67368 , p_adr_code => 'DIST_CCID'
67369 , p_adr_type_code => 'S'
67370 , p_component_type => l_component_type
67371 , p_component_code => l_component_code
67372 , p_component_type_code => l_component_type_code
67373 , p_component_appl_id => l_component_appl_id
67374 , p_amb_context_code => l_amb_context_code
67375 , p_side => 'NA'
67376 );
67377
67378
67379 --
67380 --
67381 END IF;
67382 --
67383 -- Bug 4922099
67384 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
67385 (NVL(l_enc_upg_option, 'N') = 'O')
67386 ) AND
67387 (l_bflow_method_code = 'PRIOR_ENTRY')
67388 )
67389 THEN
67390 IF
67391 --
67392 1 = 2
67393 --
67394 THEN
67395 xla_accounting_err_pkg.build_message
67396 (p_appli_s_name => 'XLA'
67397 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
67398 ,p_token_1 => 'LINE_NUMBER'
67399 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
67400 ,p_token_2 => 'LINE_TYPE_NAME'
67401 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
67402 l_component_type
67403 ,l_component_code
67404 ,l_component_type_code
67405 ,l_component_appl_id
67406 ,l_amb_context_code
67407 ,l_entity_code
67408 ,l_event_class_code
67409 )
67410 ,p_token_3 => 'OWNER'
67411 ,p_value_3 => xla_lookups_pkg.get_meaning(
67412 p_lookup_type => 'XLA_OWNER_TYPE'
67413 ,p_lookup_code => l_component_type_code
67417 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
67414 )
67415 ,p_token_4 => 'PRODUCT_NAME'
67416 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
67418 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
67419 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
67420 ,p_ae_header_id => NULL
67421 );
67422
67423 IF (C_LEVEL_ERROR>= g_log_level) THEN
67424 trace
67425 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
67426 ,p_level => C_LEVEL_ERROR
67427 ,p_module => l_log_module);
67428 END IF;
67429 END IF;
67430 END IF;
67431 --
67432 --
67433 ------------------------------------------------------------------------------------------------
67434 -- 4219869 Business Flow
67435 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
67436 -- Prior Entry. Currently, the following code is always generated.
67437 ------------------------------------------------------------------------------------------------
67438 XLA_AE_LINES_PKG.ValidateCurrentLine;
67439
67440 ------------------------------------------------------------------------------------
67441 -- 4219869 Business Flow
67442 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
67443 ------------------------------------------------------------------------------------
67444 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
67445
67446 ----------------------------------------------------------------------------------
67447 -- 4219869 Business Flow
67448 -- Update journal entry status -- Need to generate this within IF <condition>
67449 ----------------------------------------------------------------------------------
67450 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
67451 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
67452 ,p_balance_type_code => l_balance_type_code
67453 );
67454
67455 -------------------------------------------------------------------------------------------
67456 -- 4262811 - Generate the Accrual Reversal lines
67457 -------------------------------------------------------------------------------------------
67458 BEGIN
67459 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
67460 (g_array_event(p_event_id).array_value_num('header_index'));
67461 IF l_acc_rev_flag IS NULL THEN
67462 l_acc_rev_flag := 'N';
67463 END IF;
67464 EXCEPTION
67465 WHEN OTHERS THEN
67466 l_acc_rev_flag := 'N';
67467 END;
67468 --
67469 IF (l_acc_rev_flag = 'Y') THEN
67470
67471 -- 4645092 ------------------------------------------------------------------------------
67472 -- To allow MPA report to determine if it should generate report process
67473 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
67474 ------------------------------------------------------------------------------------------
67475
67476 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
67477 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
67478 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
67479 -- call ADRs
67480 -- Bug 4922099
67481 --
67482 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
67483 (NVL(l_actual_upg_option, 'N') = 'O') OR
67484 (NVL(l_enc_upg_option, 'N') = 'O')
67485 )
67486 THEN
67487 NULL;
67488 --
67489 --
67490
67491 l_ccid := AcctDerRule_11(
67492 p_application_id => p_application_id
67493 , p_ae_header_id => l_ae_header_id
67494 , p_source_10 => p_source_10
67495 , x_transaction_coa_id => l_adr_transaction_coa_id
67496 , x_accounting_coa_id => l_adr_accounting_coa_id
67497 , x_value_type_code => l_adr_value_type_code
67498 , p_side => 'NA'
67499 );
67500
67501 xla_ae_lines_pkg.set_ccid(
67502 p_code_combination_id => l_ccid
67503 , p_value_type_code => l_adr_value_type_code
67504 , p_transaction_coa_id => l_adr_transaction_coa_id
67505 , p_accounting_coa_id => l_adr_accounting_coa_id
67506 , p_adr_code => 'DIST_CCID'
67507 , p_adr_type_code => 'S'
67508 , p_component_type => l_component_type
67509 , p_component_code => l_component_code
67510 , p_component_type_code => l_component_type_code
67511 , p_component_appl_id => l_component_appl_id
67512 , p_amb_context_code => l_amb_context_code
67513 , p_side => 'NA'
67514 );
67515
67516
67517 --
67518 --
67519 END IF;
67520
67521 --
67522 -- Update the line information that should be overwritten
67523 --
67527
67524 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
67525 p_header_num => 1);
67526 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
67528 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
67529
67530 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
67531 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
67532 END IF;
67533
67534 --
67535 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
67536 --
67537 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
67538 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
67539 ELSE
67540 ---------------------------------------------------------------------------------------------------
67541 -- 4262811a Switch Sign
67542 ---------------------------------------------------------------------------------------------------
67543 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
67544 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
67545 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
67546 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
67547 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
67548 -- 5132302
67549 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
67550 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
67551
67552 END IF;
67553
67554 -- 4955764
67555 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
67556 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
67557
67558
67559 XLA_AE_LINES_PKG.ValidateCurrentLine;
67560 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
67561
67562 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
67563 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
67564 ,p_balance_type_code => l_balance_type_code);
67565
67566 END IF;
67567
67568 -----------------------------------------------------------------------------------------
67569 -- 4262811 Multiperiod Accounting
67570 -----------------------------------------------------------------------------------------
67571 -- No MPA option is assigned.
67572
67573
67574 END IF;
67575 END IF;
67576 --
67577
67578 --
67579 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67580 trace
67581 (p_msg => 'END of AcctLineType_137'
67582 ,p_level => C_LEVEL_PROCEDURE
67583 ,p_module => l_log_module);
67584 END IF;
67585 --
67586 EXCEPTION
67587 WHEN xla_exceptions_pkg.application_exception THEN
67588 RAISE;
67589 WHEN OTHERS THEN
67590 xla_exceptions_pkg.raise_message
67591 (p_location => 'XLA_00222_AAD_S_000009_PKG.AcctLineType_137');
67592 END AcctLineType_137;
67593 --
67594
67595 ---------------------------------------
67596 --
67597 -- PRIVATE PROCEDURE
67598 -- insert_sources_138
67599 --
67600 ----------------------------------------
67601 --
67602 PROCEDURE insert_sources_138(
67603 p_target_ledger_id IN NUMBER
67604 , p_language IN VARCHAR2
67605 , p_sla_ledger_id IN NUMBER
67606 , p_pad_start_date IN DATE
67607 , p_pad_end_date IN DATE
67608 )
67609 IS
67610
67611 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'ADJUSTMENT_ALL';
67612 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'ADJUSTMENT';
67613 p_apps_owner VARCHAR2(30);
67614 l_log_module VARCHAR2(240);
67615 BEGIN
67616 IF g_log_enabled THEN
67617 l_log_module := C_DEFAULT_MODULE||'.insert_sources_138';
67618 END IF;
67619 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67620
67621 trace
67622 (p_msg => 'BEGIN of insert_sources_138'
67623 ,p_level => C_LEVEL_PROCEDURE
67624 ,p_module => l_log_module);
67625
67626 END IF;
67627
67628 -- select APPS owner
67629 SELECT oracle_username
67630 INTO p_apps_owner
67631 FROM fnd_oracle_userid
67632 WHERE read_only_flag = 'U'
67633 ;
67634
67635 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67636 trace
67637 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
67638 ' - p_language = '||p_language||
67639 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
67640 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
67641 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
67642 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
67643 ,p_level => C_LEVEL_STATEMENT
67647
67644 ,p_module => l_log_module);
67645 END IF;
67646
67648 --
67649 INSERT INTO xla_diag_sources --hdr2
67650 (
67651 event_id
67652 , ledger_id
67653 , sla_ledger_id
67654 , description_language
67655 , object_name
67656 , object_type_code
67657 , line_number
67658 , source_application_id
67659 , source_type_code
67660 , source_code
67661 , source_value
67662 , source_meaning
67663 , created_by
67664 , creation_date
67665 , last_update_date
67666 , last_updated_by
67667 , last_update_login
67668 , program_update_date
67669 , program_application_id
67670 , program_id
67671 , request_id
67672 )
67673 SELECT
67674 event_id
67675 , p_target_ledger_id
67676 , p_sla_ledger_id
67677 , p_language
67678 , object_name
67679 , object_type_code
67680 , line_number
67681 , source_application_id
67682 , source_type_code
67683 , source_code
67684 , SUBSTR(source_value ,1,1996)
67685 , SUBSTR(source_meaning ,1,200)
67686 , xla_environment_pkg.g_Usr_Id
67687 , TRUNC(SYSDATE)
67688 , TRUNC(SYSDATE)
67689 , xla_environment_pkg.g_Usr_Id
67690 , xla_environment_pkg.g_Login_Id
67691 , TRUNC(SYSDATE)
67692 , xla_environment_pkg.g_Prog_Appl_Id
67693 , xla_environment_pkg.g_Prog_Id
67694 , xla_environment_pkg.g_Req_Id
67695 FROM (
67696 SELECT xet.event_id event_id
67697 , 0 line_number
67698 , CASE r
67699 WHEN 1 THEN 'AR_TRANSACTIONS_S_V'
67700 WHEN 2 THEN 'AR_RECEIVABLES_TRX_ACT_S_V'
67701 WHEN 3 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
67702 WHEN 4 THEN 'AR_BILL_TO_SITE_USES_S_V'
67703 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
67704 WHEN 6 THEN 'AR_ADJUSTMENTS_H_V'
67705 WHEN 7 THEN 'AR_ADJUSTMENTS_H_V'
67706 WHEN 8 THEN 'AR_ADJUSTMENTS_H_V'
67707
67708 ELSE null
67709 END object_name
67710 , CASE r
67711 WHEN 1 THEN 'HEADER'
67712 WHEN 2 THEN 'HEADER'
67713 WHEN 3 THEN 'HEADER'
67714 WHEN 4 THEN 'HEADER'
67715 WHEN 5 THEN 'HEADER'
67716 WHEN 6 THEN 'HEADER'
67717 WHEN 7 THEN 'HEADER'
67718 WHEN 8 THEN 'HEADER'
67719
67720 ELSE null
67721 END object_type_code
67722 , CASE r
67723 WHEN 1 THEN '222'
67724 WHEN 2 THEN '222'
67725 WHEN 3 THEN '222'
67726 WHEN 4 THEN '222'
67727 WHEN 5 THEN '222'
67728 WHEN 6 THEN '222'
67729 WHEN 7 THEN '222'
67730 WHEN 8 THEN '222'
67731
67732 ELSE null
67733 END source_application_id
67734 , 'S' source_type_code
67735 , CASE r
67736 WHEN 1 THEN 'TRX_RECEIVABLE_CCID'
67737 WHEN 2 THEN 'REC_ACT_TYPE'
67738 WHEN 3 THEN 'BILL_CUST_ACCOUNT_ID'
67739 WHEN 4 THEN 'BILL_USES_SITE_USE_ID'
67740 WHEN 5 THEN 'XLA_PARTY_TYPE'
67741 WHEN 6 THEN 'ADJ_DOC_SEQUENCE_CATEGORY'
67742 WHEN 7 THEN 'ADJ_DOC_SEQUENCE_ID'
67743 WHEN 8 THEN 'ADJ_DOC_SEQUENCE_VALUE'
67744
67745 ELSE null
67746 END source_code
67747 , CASE r
67748 WHEN 1 THEN TO_CHAR(h7.TRX_RECEIVABLE_CCID)
67749 WHEN 2 THEN TO_CHAR(h6.REC_ACT_TYPE)
67750 WHEN 3 THEN TO_CHAR(h2.BILL_CUST_ACCOUNT_ID)
67751 WHEN 4 THEN TO_CHAR(h3.BILL_USES_SITE_USE_ID)
67752 WHEN 5 THEN TO_CHAR(h7.XLA_PARTY_TYPE)
67753 WHEN 6 THEN TO_CHAR(h1.ADJ_DOC_SEQUENCE_CATEGORY)
67754 WHEN 7 THEN TO_CHAR(h1.ADJ_DOC_SEQUENCE_ID)
67755 WHEN 8 THEN TO_CHAR(h1.ADJ_DOC_SEQUENCE_VALUE)
67756
67757 ELSE null
67758 END source_value
67759 , null source_meaning
67760 FROM xla_events_gt xet
67761 , AR_ADJUSTMENTS_H_V h1
67762 , AR_BILL_TO_CUSTOMERS_S_V h2
67763 , AR_BILL_TO_SITE_USES_S_V h3
67764 , AR_RECEIVABLES_TRX_ACT_S_V h6
67765 , AR_TRANSACTIONS_S_V h7
67766 ,(select rownum r from all_objects where rownum <= 8 and owner = p_apps_owner)
67767 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
67768 AND xet.event_class_code = C_EVENT_CLASS_CODE
67769 AND h1.event_id = xet.event_id
67770 AND h2.event_id = h1.event_id
67771 AND h3.event_id = h1.event_id
67772 AND h6.event_id (+) = h1.event_id
67773 AND h7.event_id = h1.event_id
67774
67775 )
67776 ;
67777 --
67778 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67779
67780 trace
67781 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
67785 END IF;
67782 ,p_level => C_LEVEL_STATEMENT
67783 ,p_module => l_log_module);
67784
67786 --
67787
67788
67789
67790 --
67791 INSERT INTO xla_diag_sources --line2
67792 (
67793 event_id
67794 , ledger_id
67795 , sla_ledger_id
67796 , description_language
67797 , object_name
67798 , object_type_code
67799 , line_number
67800 , source_application_id
67801 , source_type_code
67802 , source_code
67803 , source_value
67804 , source_meaning
67805 , created_by
67806 , creation_date
67807 , last_update_date
67808 , last_updated_by
67809 , last_update_login
67810 , program_update_date
67811 , program_application_id
67812 , program_id
67813 , request_id
67814 )
67815 SELECT event_id
67816 , p_target_ledger_id
67817 , p_sla_ledger_id
67818 , p_language
67819 , object_name
67820 , object_type_code
67821 , line_number
67822 , source_application_id
67823 , source_type_code
67824 , source_code
67825 , SUBSTR(source_value,1,1996)
67826 , SUBSTR(source_meaning ,1,200)
67827 , xla_environment_pkg.g_Usr_Id
67828 , TRUNC(SYSDATE)
67829 , TRUNC(SYSDATE)
67830 , xla_environment_pkg.g_Usr_Id
67831 , xla_environment_pkg.g_Login_Id
67832 , TRUNC(SYSDATE)
67833 , xla_environment_pkg.g_Prog_Appl_Id
67834 , xla_environment_pkg.g_Prog_Id
67835 , xla_environment_pkg.g_Req_Id
67836 FROM (
67837 SELECT xet.event_id event_id
67838 , l5.line_number line_number
67839 , CASE r
67840 WHEN 1 THEN 'AR_DISTRIBUTIONS_L_V'
67841 WHEN 2 THEN 'AR_DISTRIBUTIONS_L_V'
67842 WHEN 3 THEN 'AR_DISTRIBUTIONS_L_V'
67843 WHEN 4 THEN 'AR_DISTRIBUTIONS_L_V'
67844 WHEN 5 THEN 'AR_DISTRIBUTIONS_L_V'
67845 WHEN 6 THEN 'AR_DISTRIBUTIONS_L_V'
67846 WHEN 7 THEN 'AR_DISTRIBUTIONS_BASE_V'
67847 WHEN 8 THEN 'AR_DISTRIBUTIONS_BASE_V'
67848 WHEN 9 THEN 'AR_DISTRIBUTIONS_BASE_V'
67849 WHEN 10 THEN 'AR_DISTRIBUTIONS_BASE_V'
67850
67851 ELSE null
67852 END object_name
67853 , CASE r
67854 WHEN 1 THEN 'LINE'
67855 WHEN 2 THEN 'LINE'
67856 WHEN 3 THEN 'LINE'
67857 WHEN 4 THEN 'LINE'
67858 WHEN 5 THEN 'LINE'
67859 WHEN 6 THEN 'LINE'
67860 WHEN 7 THEN 'LINE'
67861 WHEN 8 THEN 'LINE'
67862 WHEN 9 THEN 'LINE'
67863 WHEN 10 THEN 'LINE'
67864
67865 ELSE null
67866 END object_type_code
67867 , CASE r
67868 WHEN 1 THEN '222'
67869 WHEN 2 THEN '222'
67870 WHEN 3 THEN '222'
67871 WHEN 4 THEN '222'
67872 WHEN 5 THEN '222'
67873 WHEN 6 THEN '222'
67874 WHEN 7 THEN '222'
67875 WHEN 8 THEN '222'
67876 WHEN 9 THEN '222'
67877 WHEN 10 THEN '222'
67878
67879 ELSE null
67880 END source_application_id
67881 , 'S' source_type_code
67882 , CASE r
67883 WHEN 1 THEN 'DIST_CODE_COMBINATION_ID'
67884 WHEN 2 THEN 'DIST_SOURCE_TYPE'
67885 WHEN 3 THEN 'DIST_LINE_ID'
67886 WHEN 4 THEN 'DISTRIBUTION_TYPE'
67887 WHEN 5 THEN 'DIST_ENT_AMT'
67888 WHEN 6 THEN 'DIST_CURRENCY_CODE'
67889 WHEN 7 THEN 'DIST_CUR_CONVERSION_DATE'
67890 WHEN 8 THEN 'DIST_CUR_CONVERSION_RATE'
67891 WHEN 9 THEN 'DIST_CUR_CONVERSION_TYPE'
67892 WHEN 10 THEN 'DIST_TO_ACCTD_AMT'
67893
67894 ELSE null
67895 END source_code
67896 , CASE r
67897 WHEN 1 THEN TO_CHAR(l5.DIST_CODE_COMBINATION_ID)
67898 WHEN 2 THEN TO_CHAR(l5.DIST_SOURCE_TYPE)
67899 WHEN 3 THEN TO_CHAR(l5.DIST_LINE_ID)
67900 WHEN 4 THEN TO_CHAR(l5.DISTRIBUTION_TYPE)
67901 WHEN 5 THEN TO_CHAR(l5.DIST_ENT_AMT)
67902 WHEN 6 THEN TO_CHAR(l5.DIST_CURRENCY_CODE)
67903 WHEN 7 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_DATE)
67904 WHEN 8 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_RATE)
67905 WHEN 9 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_TYPE)
67906 WHEN 10 THEN TO_CHAR(l4.DIST_TO_ACCTD_AMT)
67907
67908 ELSE null
67909 END source_value
67910 , null source_meaning
67911 FROM xla_events_gt xet
67912 , AR_DISTRIBUTIONS_BASE_V l4
67913 , AR_DISTRIBUTIONS_L_V l5
67914 , (select rownum r from all_objects where rownum <= 10 and owner = p_apps_owner)
67915 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
67919 AND l5.line_number = l4.line_number
67916 AND xet.event_class_code = C_EVENT_CLASS_CODE
67917 AND l4.event_id = xet.event_id
67918 AND l5.event_id = l4.event_id
67920
67921 )
67922 ;
67923 --
67924 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67925
67926 trace
67927 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
67928 ,p_level => C_LEVEL_STATEMENT
67929 ,p_module => l_log_module);
67930
67931 END IF;
67932
67933
67934 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67935 trace
67936 (p_msg => 'END of insert_sources_138'
67937 ,p_level => C_LEVEL_PROCEDURE
67938 ,p_module => l_log_module);
67939 END IF;
67940 EXCEPTION
67941 WHEN xla_exceptions_pkg.application_exception THEN
67942 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
67943 trace
67944 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
67945 ,p_level => C_LEVEL_EXCEPTION
67946 ,p_module => l_log_module);
67947 END IF;
67948 RAISE;
67949 WHEN OTHERS THEN
67950 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
67951 trace
67952 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
67953 ,p_level => C_LEVEL_EXCEPTION
67954 ,p_module => l_log_module);
67955 END IF;
67956 xla_exceptions_pkg.raise_message
67957 (p_location => 'XLA_00222_AAD_S_000009_PKG.insert_sources_138');
67958 END insert_sources_138;
67959 --
67960
67961 ---------------------------------------
67962 --
67963 -- PRIVATE FUNCTION
67964 -- EventClass_138
67965 --
67966 ----------------------------------------
67967 --
67968 FUNCTION EventClass_138
67969 (p_application_id IN NUMBER
67970 ,p_base_ledger_id IN NUMBER
67971 ,p_target_ledger_id IN NUMBER
67972 ,p_language IN VARCHAR2
67973 ,p_currency_code IN VARCHAR2
67974 ,p_sla_ledger_id IN NUMBER
67975 ,p_pad_start_date IN DATE
67976 ,p_pad_end_date IN DATE
67977 ,p_primary_ledger_id IN NUMBER)
67978 RETURN BOOLEAN IS
67979 --
67980 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'ADJUSTMENT_ALL';
67981 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'ADJUSTMENT';
67982
67983 l_calculate_acctd_flag VARCHAR2(1) :='N';
67984 l_calculate_g_l_flag VARCHAR2(1) :='Y';
67985 --
67986 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67987 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67988 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
67989 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
67990 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67991 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
67992 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
67993 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67994 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
67995 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
67996 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67997 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67998 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67999 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
68000 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
68001 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
68002 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
68003 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
68004 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
68005 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
68006 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
68007 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
68008 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
68009 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
68010 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
68011 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
68012
68013 l_event_id NUMBER;
68014 l_previous_event_id NUMBER;
68015 l_first_event_id NUMBER;
68016 l_last_event_id NUMBER;
68017
68018 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
68019 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
68020 --
68021 --
68022 l_result BOOLEAN := TRUE;
68023 l_rows NUMBER := 1000;
68024 l_event_type_name VARCHAR2(80) := 'All';
68025 l_event_class_name VARCHAR2(80) := 'Adjustment';
68026 l_description VARCHAR2(4000);
68027 l_transaction_reversal NUMBER;
68028 l_ae_header_id NUMBER;
68032 l_acct_reversal_source VARCHAR2(30);
68029 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
68030 l_log_module VARCHAR2(240);
68031 --
68033 l_trx_reversal_source VARCHAR2(30);
68034
68035 l_continue_with_lines BOOLEAN := TRUE;
68036 --
68037 l_acc_rev_gl_date_source DATE; -- 4262811
68038 --
68039 type t_array_event_id is table of number index by binary_integer;
68040
68041 l_rec_array_event t_rec_array_event;
68042 l_null_rec_array_event t_rec_array_event;
68043 l_array_ae_header_id xla_number_array_type;
68044 l_actual_flag VARCHAR2(1) := NULL;
68045 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
68046 l_balance_type_code VARCHAR2(1) :=NULL;
68047 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
68048
68049 --
68050 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
68051 --
68052
68053 TYPE t_array_source_8 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_RECEIVABLE_CCID%TYPE INDEX BY BINARY_INTEGER;
68054 TYPE t_array_source_23 IS TABLE OF AR_RECEIVABLES_TRX_ACT_S_V.REC_ACT_TYPE%TYPE INDEX BY BINARY_INTEGER;
68055 TYPE t_array_source_32 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
68056 TYPE t_array_source_33 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
68057 TYPE t_array_source_34 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
68058 TYPE t_array_source_81 IS TABLE OF AR_ADJUSTMENTS_H_V.ADJ_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
68059 TYPE t_array_source_82 IS TABLE OF AR_ADJUSTMENTS_H_V.ADJ_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
68060 TYPE t_array_source_83 IS TABLE OF AR_ADJUSTMENTS_H_V.ADJ_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
68061
68062 TYPE t_array_source_10 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
68063 TYPE t_array_source_22 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
68064 TYPE t_array_source_24 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
68065 TYPE t_array_source_25 IS TABLE OF AR_DISTRIBUTIONS_L_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
68066 TYPE t_array_source_26 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT%TYPE INDEX BY BINARY_INTEGER;
68067 TYPE t_array_source_27 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
68068 TYPE t_array_source_28 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
68069 TYPE t_array_source_29 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
68070 TYPE t_array_source_30 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
68071 TYPE t_array_source_31 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
68072
68073 l_array_source_8 t_array_source_8;
68074 l_array_source_23 t_array_source_23;
68075 l_array_source_32 t_array_source_32;
68076 l_array_source_33 t_array_source_33;
68077 l_array_source_34 t_array_source_34;
68078 l_array_source_81 t_array_source_81;
68079 l_array_source_82 t_array_source_82;
68080 l_array_source_83 t_array_source_83;
68081
68082 l_array_source_10 t_array_source_10;
68083 l_array_source_22 t_array_source_22;
68084 l_array_source_24 t_array_source_24;
68085 l_array_source_25 t_array_source_25;
68086 l_array_source_26 t_array_source_26;
68087 l_array_source_27 t_array_source_27;
68088 l_array_source_28 t_array_source_28;
68089 l_array_source_29 t_array_source_29;
68090 l_array_source_30 t_array_source_30;
68091 l_array_source_31 t_array_source_31;
68092
68093 --
68094 CURSOR header_cur
68095 IS
68096 SELECT /*+ leading(xet) cardinality(xet,1) */
68097 -- Event Class Code: ADJUSTMENT
68098 xet.entity_id
68099 ,xet.legal_entity_id
68100 ,xet.entity_code
68101 ,xet.transaction_number
68102 ,xet.event_id
68103 ,xet.event_class_code
68104 ,xet.event_type_code
68105 ,xet.event_number
68106 ,xet.event_date
68107 ,xet.transaction_date
68108 ,xet.reference_num_1
68109 ,xet.reference_num_2
68110 ,xet.reference_num_3
68111 ,xet.reference_num_4
68112 ,xet.reference_char_1
68113 ,xet.reference_char_2
68114 ,xet.reference_char_3
68115 ,xet.reference_char_4
68116 ,xet.reference_date_1
68117 ,xet.reference_date_2
68118 ,xet.reference_date_3
68119 ,xet.reference_date_4
68120 ,xet.event_created_by
68121 ,xet.budgetary_control_flag
68122 , h7.TRX_RECEIVABLE_CCID source_8
68123 , h6.REC_ACT_TYPE source_23
68124 , h2.BILL_CUST_ACCOUNT_ID source_32
68125 , h3.BILL_USES_SITE_USE_ID source_33
68126 , h7.XLA_PARTY_TYPE source_34
68127 , h1.ADJ_DOC_SEQUENCE_CATEGORY source_81
68128 , h1.ADJ_DOC_SEQUENCE_ID source_82
68129 , h1.ADJ_DOC_SEQUENCE_VALUE source_83
68130 FROM xla_events_gt xet
68131 , AR_ADJUSTMENTS_H_V h1
68132 , AR_BILL_TO_CUSTOMERS_S_V h2
68133 , AR_BILL_TO_SITE_USES_S_V h3
68134 , AR_RECEIVABLES_TRX_ACT_S_V h6
68135 , AR_TRANSACTIONS_S_V h7
68136 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
68137 and xet.event_class_code = C_EVENT_CLASS_CODE
68141 AND h6.event_id (+) = h1.event_id
68138 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
68139 AND h2.event_id = h1.event_id
68140 AND h3.event_id = h1.event_id
68142 AND h7.event_id = h1.event_id
68143
68144 ORDER BY event_id
68145 ;
68146
68147
68148 --
68149 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
68150 IS
68151 SELECT /*+ leading(xet) cardinality(xet,1) */
68152 -- Event Class Code: ADJUSTMENT
68153 xet.entity_id
68154 ,xet.legal_entity_id
68155 ,xet.entity_code
68156 ,xet.transaction_number
68157 ,xet.event_id
68158 ,xet.event_class_code
68159 ,xet.event_type_code
68160 ,xet.event_number
68161 ,xet.event_date
68162 ,xet.transaction_date
68163 ,xet.reference_num_1
68164 ,xet.reference_num_2
68165 ,xet.reference_num_3
68166 ,xet.reference_num_4
68167 ,xet.reference_char_1
68168 ,xet.reference_char_2
68169 ,xet.reference_char_3
68170 ,xet.reference_char_4
68171 ,xet.reference_date_1
68172 ,xet.reference_date_2
68173 ,xet.reference_date_3
68174 ,xet.reference_date_4
68175 ,xet.event_created_by
68176 ,xet.budgetary_control_flag
68177 , l4.LINE_NUMBER
68178 , l5.DIST_CODE_COMBINATION_ID source_10
68179 , l5.DIST_SOURCE_TYPE source_22
68180 , l5.DIST_LINE_ID source_24
68181 , l5.DISTRIBUTION_TYPE source_25
68182 , l5.DIST_ENT_AMT source_26
68183 , l5.DIST_CURRENCY_CODE source_27
68184 , l4.DIST_CUR_CONVERSION_DATE source_28
68185 , l4.DIST_CUR_CONVERSION_RATE source_29
68186 , l4.DIST_CUR_CONVERSION_TYPE source_30
68187 , l4.DIST_TO_ACCTD_AMT source_31
68188 FROM xla_events_gt xet
68189 , AR_DISTRIBUTIONS_BASE_V l4
68190 , AR_DISTRIBUTIONS_L_V l5
68191 WHERE xet.event_id between x_first_event_id and x_last_event_id
68192 and xet.event_date between p_pad_start_date and p_pad_end_date
68193 and xet.event_class_code = C_EVENT_CLASS_CODE
68194 and xet.event_status_code <> 'N' AND l4.event_id = xet.event_id
68195 AND l5.event_id = l4.event_id
68196 AND l5.line_number = l4.line_number
68197 ;
68198
68199 --
68200 BEGIN
68201 IF g_log_enabled THEN
68202 l_log_module := C_DEFAULT_MODULE||'.EventClass_138';
68203 END IF;
68204 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
68205 trace
68206 (p_msg => 'BEGIN of EventClass_138'
68207 ,p_level => C_LEVEL_PROCEDURE
68208 ,p_module => l_log_module);
68209 END IF;
68210
68211 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
68212 trace
68213 (p_msg => 'p_application_id = '||p_application_id||
68214 ' - p_base_ledger_id = '||p_base_ledger_id||
68215 ' - p_target_ledger_id = '||p_target_ledger_id||
68216 ' - p_language = '||p_language||
68217 ' - p_currency_code = '||p_currency_code||
68218 ' - p_sla_ledger_id = '||p_sla_ledger_id
68219 ,p_level => C_LEVEL_STATEMENT
68220 ,p_module => l_log_module);
68221 END IF;
68222 --
68223 -- initialze arrays
68224 --
68225 g_array_event.DELETE;
68226 l_rec_array_event := l_null_rec_array_event;
68227 --
68228 --------------------------------------
68229 -- 4262811 Initialze MPA Line Number
68230 --------------------------------------
68231 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
68232
68233 --
68234
68235 --
68236 OPEN header_cur;
68237 --
68238 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
68239 trace
68240 (p_msg => 'SQL - FETCH header_cur'
68241 ,p_level => C_LEVEL_STATEMENT
68242 ,p_module => l_log_module);
68243 END IF;
68244 --
68245 LOOP
68246 FETCH header_cur BULK COLLECT INTO
68247 l_array_entity_id
68248 , l_array_legal_entity_id
68249 , l_array_entity_code
68250 , l_array_transaction_num
68251 , l_array_event_id
68252 , l_array_class_code
68253 , l_array_event_type
68254 , l_array_event_number
68255 , l_array_event_date
68256 , l_array_transaction_date
68257 , l_array_reference_num_1
68258 , l_array_reference_num_2
68259 , l_array_reference_num_3
68260 , l_array_reference_num_4
68261 , l_array_reference_char_1
68262 , l_array_reference_char_2
68263 , l_array_reference_char_3
68264 , l_array_reference_char_4
68265 , l_array_reference_date_1
68266 , l_array_reference_date_2
68267 , l_array_reference_date_3
68268 , l_array_reference_date_4
68269 , l_array_event_created_by
68270 , l_array_budgetary_control_flag
68271 , l_array_source_8
68272 , l_array_source_23
68273 , l_array_source_32
68274 , l_array_source_33
68275 , l_array_source_34
68276 , l_array_source_81
68277 , l_array_source_82
68278 , l_array_source_83
68279 LIMIT l_rows;
68280 --
68281 IF (C_LEVEL_EVENT >= g_log_level) THEN
68282 trace
68283 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
68284 ,p_level => C_LEVEL_EVENT
68285 ,p_module => l_log_module);
68286 END IF;
68287 --
68288 EXIT WHEN l_array_entity_id.COUNT = 0;
68289
68290 -- initialize arrays
68291 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
68295 -- Bug 4458708
68292 XLA_AE_LINES_PKG.g_rec_lines := NULL;
68293
68294 --
68296 --
68297 XLA_AE_LINES_PKG.g_LineNumber := 0;
68298
68299
68300 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
68301 g_last_hdr_idx := l_array_event_id.LAST;
68302 --
68303 -- loop for the headers. Each iteration is for each header extract row
68304 -- fetched in header cursor
68305 --
68306 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
68307
68308 --
68309 -- set event info as cache for other routines to refer event attributes
68310 --
68311 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
68312 (p_application_id => p_application_id
68313 ,p_primary_ledger_id => p_primary_ledger_id
68314 ,p_base_ledger_id => p_base_ledger_id
68315 ,p_target_ledger_id => p_target_ledger_id
68316 ,p_entity_id => l_array_entity_id(hdr_idx)
68317 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
68318 ,p_entity_code => l_array_entity_code(hdr_idx)
68319 ,p_transaction_num => l_array_transaction_num(hdr_idx)
68320 ,p_event_id => l_array_event_id(hdr_idx)
68321 ,p_event_class_code => l_array_class_code(hdr_idx)
68322 ,p_event_type_code => l_array_event_type(hdr_idx)
68323 ,p_event_number => l_array_event_number(hdr_idx)
68324 ,p_event_date => l_array_event_date(hdr_idx)
68325 ,p_transaction_date => l_array_transaction_date(hdr_idx)
68326 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
68327 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
68328 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
68329 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
68330 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
68331 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
68332 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
68333 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
68334 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
68335 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
68336 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
68337 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
68338 ,p_event_created_by => l_array_event_created_by(hdr_idx)
68339 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
68340
68341 --
68342 -- set the status of entry to C_VALID (0)
68343 --
68344 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
68345
68346 --
68347 -- initialize a row for ae header
68348 --
68349 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
68350
68351 l_event_id := l_array_event_id(hdr_idx);
68352
68353 --
68354 -- storing the hdr_idx for event. May be used by line cursor.
68355 --
68356 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
68357
68358 --
68359 -- store sources from header extract. This can be improved to
68360 -- store only those sources from header extract that may be used in lines
68361 --
68362
68363 g_array_event(l_event_id).array_value_num('source_8') := l_array_source_8(hdr_idx);
68364 g_array_event(l_event_id).array_value_char('source_23') := l_array_source_23(hdr_idx);
68365 g_array_event(l_event_id).array_value_num('source_32') := l_array_source_32(hdr_idx);
68366 g_array_event(l_event_id).array_value_num('source_33') := l_array_source_33(hdr_idx);
68367 g_array_event(l_event_id).array_value_char('source_34') := l_array_source_34(hdr_idx);
68368 g_array_event(l_event_id).array_value_char('source_81') := l_array_source_81(hdr_idx);
68369 g_array_event(l_event_id).array_value_num('source_82') := l_array_source_82(hdr_idx);
68370 g_array_event(l_event_id).array_value_num('source_83') := l_array_source_83(hdr_idx);
68371
68372 --
68373 -- initilaize the status of ae headers for diffrent balance types
68374 -- the status is initialised to C_NOT_CREATED (2)
68375 --
68376 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
68377 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
68378 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
68379
68380 --
68381 -- call api to validate and store accounting attributes for header
68382 --
68383
68384 ------------------------------------------------------------
68385 -- Accrual Reversal : to get date for Standard Source (NONE)
68386 ------------------------------------------------------------
68387 l_acc_rev_gl_date_source := NULL;
68388
68389 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
68390 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_81');
68391 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
68392 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_82');
68393 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
68394 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_83');
68395 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
68396 l_rec_acct_attrs.array_date_value(4) :=
68397 xla_ae_sources_pkg.GetSystemSourceDate(
68398 p_source_code => 'XLA_EVENT_DATE'
68402
68399 , p_source_type_code => 'Y'
68400 , p_source_application_id => 602
68401 );
68403
68404 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
68405
68406 XLA_AE_HEADER_PKG.SetJeCategoryName;
68407
68408 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
68409 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
68410 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
68411 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
68412 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
68413
68414
68415 -- No header level analytical criteria
68416
68417 --
68418 --accounting attribute enhancement, bug 3612931
68419 --
68420 l_trx_reversal_source := SUBSTR(NULL, 1,30);
68421
68422 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
68423 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
68424
68425 xla_accounting_err_pkg.build_message
68426 (p_appli_s_name => 'XLA'
68427 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
68428 ,p_token_1 => 'ACCT_ATTR_NAME'
68429 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
68430 ,p_token_2 => 'PRODUCT_NAME'
68431 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
68432 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
68433 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
68434 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
68435
68436 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
68437 --
68438 -- following sets the accounting attributes needed to reverse
68439 -- accounting for a distributeion
68440 --
68441 xla_ae_lines_pkg.SetTrxReversalAttrs
68442 (p_event_id => l_event_id
68443 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
68444 ,p_trx_reversal_source => l_trx_reversal_source);
68445
68446 END IF;
68447
68448
68449 ----------------------------------------------------------------
68450 -- 4262811 - update the header statuses to invalid in need be
68451 ----------------------------------------------------------------
68452 --
68453 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
68454
68455
68456 -----------------------------------------------
68457 -- No accrual reversal for the event class/type
68458 -----------------------------------------------
68459 ----------------------------------------------------------------
68460
68461 --
68462 -- this ends the header loop iteration for one bulk fetch
68463 --
68464 END LOOP;
68465
68466 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
68467 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
68468
68469 --
68470 -- insert dummy rows into lines gt table that were created due to
68471 -- transaction reversals
68472 --
68473 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
68474 l_result := XLA_AE_LINES_PKG.InsertLines;
68475 END IF;
68476
68477 --
68478 -- reset the temp_line_num for each set of events fetched from header
68479 -- cursor rather than doing it for each new event in line cursor
68480 -- Bug 3939231
68481 --
68482 xla_ae_lines_pkg.g_temp_line_num := 0;
68483
68484
68485
68486 --
68487 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
68488 --
68489 --
68490 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
68491
68492 trace
68493 (p_msg => 'SQL - FETCH line_cur'
68494 ,p_level => C_LEVEL_STATEMENT
68495 ,p_module => l_log_module);
68496
68497 END IF;
68498 --
68499 --
68500 LOOP
68501 --
68502 FETCH line_cur BULK COLLECT INTO
68503 l_array_entity_id
68504 , l_array_legal_entity_id
68505 , l_array_entity_code
68506 , l_array_transaction_num
68507 , l_array_event_id
68508 , l_array_class_code
68509 , l_array_event_type
68510 , l_array_event_number
68511 , l_array_event_date
68512 , l_array_transaction_date
68513 , l_array_reference_num_1
68514 , l_array_reference_num_2
68515 , l_array_reference_num_3
68516 , l_array_reference_num_4
68517 , l_array_reference_char_1
68518 , l_array_reference_char_2
68519 , l_array_reference_char_3
68520 , l_array_reference_char_4
68521 , l_array_reference_date_1
68522 , l_array_reference_date_2
68523 , l_array_reference_date_3
68524 , l_array_reference_date_4
68525 , l_array_event_created_by
68526 , l_array_budgetary_control_flag
68527 , l_array_extract_line_num
68528 , l_array_source_10
68529 , l_array_source_22
68530 , l_array_source_24
68531 , l_array_source_25
68532 , l_array_source_26
68533 , l_array_source_27
68534 , l_array_source_28
68535 , l_array_source_29
68536 , l_array_source_30
68537 , l_array_source_31
68538 LIMIT l_rows;
68542 trace
68539
68540 --
68541 IF (C_LEVEL_EVENT >= g_log_level) THEN
68543 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
68544 ,p_level => C_LEVEL_EVENT
68545 ,p_module => l_log_module);
68546 END IF;
68547 --
68548 EXIT WHEN l_array_entity_id.count = 0;
68549
68550 XLA_AE_LINES_PKG.g_rec_lines := null;
68551
68552 --
68553 -- Bug 4458708
68554 --
68555 XLA_AE_LINES_PKG.g_LineNumber := 0;
68556 --
68557 --
68558
68559 FOR Idx IN 1..l_array_event_id.count LOOP
68560 --
68561 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
68562 --
68563 l_event_id := l_array_event_id(idx); -- 5648433
68564
68565 --
68566 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
68567 --
68568
68569 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
68570 (g_array_event(l_event_id).array_value_num('header_index'))
68571 ,'N'
68572 ) <> 'Y'
68573 THEN
68574 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
68575 trace
68576 (p_msg => 'Trancaction revesal option is not Y '
68577 ,p_level => C_LEVEL_STATEMENT
68578 ,p_module => l_log_module);
68579 END IF;
68580
68581 --
68582 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
68583 --
68584 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
68585 --
68586 -- set event info as cache for other routines to refer event attributes
68587 --
68588
68589 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
68590 l_previous_event_id := l_event_id;
68591
68592 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
68593 (p_application_id => p_application_id
68594 ,p_primary_ledger_id => p_primary_ledger_id
68595 ,p_base_ledger_id => p_base_ledger_id
68596 ,p_target_ledger_id => p_target_ledger_id
68597 ,p_entity_id => l_array_entity_id(Idx)
68598 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
68599 ,p_entity_code => l_array_entity_code(Idx)
68600 ,p_transaction_num => l_array_transaction_num(Idx)
68601 ,p_event_id => l_array_event_id(Idx)
68602 ,p_event_class_code => l_array_class_code(Idx)
68603 ,p_event_type_code => l_array_event_type(Idx)
68604 ,p_event_number => l_array_event_number(Idx)
68605 ,p_event_date => l_array_event_date(Idx)
68606 ,p_transaction_date => l_array_transaction_date(Idx)
68607 ,p_reference_num_1 => l_array_reference_num_1(Idx)
68608 ,p_reference_num_2 => l_array_reference_num_2(Idx)
68609 ,p_reference_num_3 => l_array_reference_num_3(Idx)
68610 ,p_reference_num_4 => l_array_reference_num_4(Idx)
68611 ,p_reference_char_1 => l_array_reference_char_1(Idx)
68612 ,p_reference_char_2 => l_array_reference_char_2(Idx)
68613 ,p_reference_char_3 => l_array_reference_char_3(Idx)
68614 ,p_reference_char_4 => l_array_reference_char_4(Idx)
68615 ,p_reference_date_1 => l_array_reference_date_1(Idx)
68616 ,p_reference_date_2 => l_array_reference_date_2(Idx)
68617 ,p_reference_date_3 => l_array_reference_date_3(Idx)
68618 ,p_reference_date_4 => l_array_reference_date_4(Idx)
68619 ,p_event_created_by => l_array_event_created_by(Idx)
68620 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
68621 --
68622 END IF;
68623
68624
68625
68626 --
68627 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
68628
68629 l_acct_reversal_source := SUBSTR(NULL, 1,30);
68630
68631 IF l_continue_with_lines THEN
68632 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
68633 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
68634
68635 xla_accounting_err_pkg.build_message
68636 (p_appli_s_name => 'XLA'
68637 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
68638 ,p_token_1 => 'LINE_NUMBER'
68639 ,p_value_1 => l_array_extract_line_num(Idx)
68640 ,p_token_2 => 'PRODUCT_NAME'
68641 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
68642 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
68643 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
68644 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
68645
68646 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
68647 --
68648 -- following sets the accounting attributes needed to reverse
68649 -- accounting for a distributeion
68650 --
68651
68652 --
68653 -- 5217187
68654 --
68655 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
68656 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
68660
68657 g_array_event(l_event_id).array_value_num('header_index'));
68658 --
68659 --
68661 -- No reversal code generated
68662
68663 xla_ae_lines_pkg.SetAcctReversalAttrs
68664 (p_event_id => l_event_id
68665 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
68666 ,p_calculate_acctd_flag => l_calculate_acctd_flag
68667 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
68668 END IF;
68669
68670 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
68671 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
68672
68673 --
68674 AcctLineType_35 (
68675 p_application_id => p_application_id
68676 ,p_event_id => l_event_id
68677 ,p_calculate_acctd_flag => l_calculate_acctd_flag
68678 ,p_calculate_g_l_flag => l_calculate_g_l_flag
68679 ,p_actual_flag => l_actual_flag
68680 ,p_balance_type_code => l_balance_type_code
68681 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
68682
68683 , p_source_10 => l_array_source_10(Idx)
68684 , p_source_22 => l_array_source_22(Idx)
68685 , p_source_23 => g_array_event(l_event_id).array_value_char('source_23')
68686 , p_source_24 => l_array_source_24(Idx)
68687 , p_source_25 => l_array_source_25(Idx)
68688 , p_source_26 => l_array_source_26(Idx)
68689 , p_source_27 => l_array_source_27(Idx)
68690 , p_source_28 => l_array_source_28(Idx)
68691 , p_source_29 => l_array_source_29(Idx)
68692 , p_source_30 => l_array_source_30(Idx)
68693 , p_source_31 => l_array_source_31(Idx)
68694 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
68695 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
68696 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
68697 );
68698 If(l_balance_type_code = 'A') THEN
68699 l_actual_gain_loss_ref := l_gain_or_loss_ref;
68700 END IF;
68701
68702 --
68703
68704
68705 --
68706 AcctLineType_36 (
68707 p_application_id => p_application_id
68708 ,p_event_id => l_event_id
68709 ,p_calculate_acctd_flag => l_calculate_acctd_flag
68710 ,p_calculate_g_l_flag => l_calculate_g_l_flag
68711 ,p_actual_flag => l_actual_flag
68712 ,p_balance_type_code => l_balance_type_code
68713 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
68714
68715 , p_source_10 => l_array_source_10(Idx)
68716 , p_source_22 => l_array_source_22(Idx)
68717 , p_source_23 => g_array_event(l_event_id).array_value_char('source_23')
68718 , p_source_24 => l_array_source_24(Idx)
68719 , p_source_25 => l_array_source_25(Idx)
68720 , p_source_26 => l_array_source_26(Idx)
68721 , p_source_27 => l_array_source_27(Idx)
68722 , p_source_28 => l_array_source_28(Idx)
68723 , p_source_29 => l_array_source_29(Idx)
68724 , p_source_30 => l_array_source_30(Idx)
68725 , p_source_31 => l_array_source_31(Idx)
68726 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
68727 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
68728 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
68729 );
68730 If(l_balance_type_code = 'A') THEN
68731 l_actual_gain_loss_ref := l_gain_or_loss_ref;
68732 END IF;
68733
68734 --
68735
68736
68737 --
68738 AcctLineType_37 (
68739 p_application_id => p_application_id
68740 ,p_event_id => l_event_id
68741 ,p_calculate_acctd_flag => l_calculate_acctd_flag
68742 ,p_calculate_g_l_flag => l_calculate_g_l_flag
68743 ,p_actual_flag => l_actual_flag
68744 ,p_balance_type_code => l_balance_type_code
68745 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
68746
68747 , p_source_10 => l_array_source_10(Idx)
68748 , p_source_22 => l_array_source_22(Idx)
68749 , p_source_24 => l_array_source_24(Idx)
68750 , p_source_25 => l_array_source_25(Idx)
68751 , p_source_26 => l_array_source_26(Idx)
68752 , p_source_27 => l_array_source_27(Idx)
68753 , p_source_28 => l_array_source_28(Idx)
68754 , p_source_29 => l_array_source_29(Idx)
68755 , p_source_30 => l_array_source_30(Idx)
68756 , p_source_31 => l_array_source_31(Idx)
68757 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
68758 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
68759 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
68760 );
68761 If(l_balance_type_code = 'A') THEN
68762 l_actual_gain_loss_ref := l_gain_or_loss_ref;
68763 END IF;
68764
68765 --
68766
68767
68768 --
68769 AcctLineType_38 (
68770 p_application_id => p_application_id
68771 ,p_event_id => l_event_id
68772 ,p_calculate_acctd_flag => l_calculate_acctd_flag
68773 ,p_calculate_g_l_flag => l_calculate_g_l_flag
68774 ,p_actual_flag => l_actual_flag
68775 ,p_balance_type_code => l_balance_type_code
68776 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
68777
68778 , p_source_10 => l_array_source_10(Idx)
68779 , p_source_22 => l_array_source_22(Idx)
68780 , p_source_24 => l_array_source_24(Idx)
68781 , p_source_25 => l_array_source_25(Idx)
68782 , p_source_26 => l_array_source_26(Idx)
68783 , p_source_27 => l_array_source_27(Idx)
68784 , p_source_28 => l_array_source_28(Idx)
68785 , p_source_29 => l_array_source_29(Idx)
68786 , p_source_30 => l_array_source_30(Idx)
68787 , p_source_31 => l_array_source_31(Idx)
68788 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
68792 If(l_balance_type_code = 'A') THEN
68789 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
68790 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
68791 );
68793 l_actual_gain_loss_ref := l_gain_or_loss_ref;
68794 END IF;
68795
68796 --
68797
68798
68799 --
68800 AcctLineType_87 (
68801 p_application_id => p_application_id
68802 ,p_event_id => l_event_id
68803 ,p_calculate_acctd_flag => l_calculate_acctd_flag
68804 ,p_calculate_g_l_flag => l_calculate_g_l_flag
68805 ,p_actual_flag => l_actual_flag
68806 ,p_balance_type_code => l_balance_type_code
68807 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
68808
68809 , p_source_8 => g_array_event(l_event_id).array_value_num('source_8')
68810 , p_source_10 => l_array_source_10(Idx)
68811 , p_source_22 => l_array_source_22(Idx)
68812 , p_source_23 => g_array_event(l_event_id).array_value_char('source_23')
68813 , p_source_24 => l_array_source_24(Idx)
68814 , p_source_25 => l_array_source_25(Idx)
68815 , p_source_26 => l_array_source_26(Idx)
68816 , p_source_27 => l_array_source_27(Idx)
68817 , p_source_28 => l_array_source_28(Idx)
68818 , p_source_29 => l_array_source_29(Idx)
68819 , p_source_30 => l_array_source_30(Idx)
68820 , p_source_31 => l_array_source_31(Idx)
68821 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
68822 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
68823 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
68824 );
68825 If(l_balance_type_code = 'A') THEN
68826 l_actual_gain_loss_ref := l_gain_or_loss_ref;
68827 END IF;
68828
68829 --
68830
68831 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
68832 -- or secondary ledger that has different currency with primary
68833 -- or alc that is calculated by sla
68834 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
68835 (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'))
68836
68837 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
68838 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
68839 AND (l_actual_flag = 'A')) THEN
68840 XLA_AE_LINES_PKG.CreateGainOrLossLines(
68841 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
68842 ,p_application_id => p_application_id
68843 ,p_amb_context_code => 'DEFAULT'
68844 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
68845 ,p_event_class_code => C_EVENT_CLASS_CODE
68846 ,p_event_type_code => C_EVENT_TYPE_CODE
68847
68848 ,p_gain_ccid => -1
68849 ,p_loss_ccid => -1
68850
68851 ,p_actual_flag => l_actual_flag
68852 ,p_enc_flag => null
68853 ,p_actual_g_l_ref => l_actual_gain_loss_ref
68854 ,p_enc_g_l_ref => null
68855 );
68856 END IF;
68857 END IF;
68858 END IF;
68859
68860 ELSE
68861 --
68862 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
68863 --
68864 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
68865 trace
68866 (p_msg => 'Trancaction revesal option is Y'
68867 ,p_level => C_LEVEL_STATEMENT
68868 ,p_module => l_log_module);
68869 END IF;
68870 END IF;
68871
68872 END LOOP;
68873 l_result := XLA_AE_LINES_PKG.InsertLines ;
68874 end loop;
68875 close line_cur;
68876
68877
68878 --
68879 -- insert headers into xla_ae_headers_gt table
68880 --
68881 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
68882
68883 -- insert into errors table here.
68884
68885 END LOOP;
68886
68887 --
68888 -- 4865292
68889 --
68890 -- Compare g_hdr_extract_count with event count in
68891 -- CreateHeadersAndLines.
68892 --
68893 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
68894
68895 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
68896 trace (p_msg => '# rows extracted from header extract objects '
68897 || ' (running total): '
68898 || g_hdr_extract_count
68899 ,p_level => C_LEVEL_STATEMENT
68900 ,p_module => l_log_module);
68901 END IF;
68902
68903 CLOSE header_cur;
68904 --
68905
68906 --
68907 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
68908 trace
68909 (p_msg => 'END of EventClass_138'
68910 ,p_level => C_LEVEL_PROCEDURE
68911 ,p_module => l_log_module);
68912 END IF;
68913 --
68914 RETURN l_result;
68915 EXCEPTION
68916 WHEN xla_exceptions_pkg.application_exception THEN
68917
68918 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
68919
68920
68921 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
68922
68923 RAISE;
68924
68925 WHEN NO_DATA_FOUND THEN
68926
68927 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
68928 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
68929
68930 FOR header_record IN header_cur
68931 LOOP
68932 l_array_header_events(header_record.event_id) := header_record.event_id;
68933 END LOOP;
68934
68938 fnd_file.put_line(fnd_file.LOG, ' ');
68935 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
68936 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
68937
68939 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
68940 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
68941 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
68942
68943 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
68944 LOOP
68945 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
68946 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
68947 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
68948 END IF;
68949 END LOOP;
68950
68951 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
68952 fnd_file.put_line(fnd_file.LOG, ' ');
68953
68954
68955 xla_exceptions_pkg.raise_message
68956 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_138');
68957
68958
68959 WHEN OTHERS THEN
68960 xla_exceptions_pkg.raise_message
68961 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_138');
68962 END EventClass_138;
68963 --
68964
68965 ---------------------------------------
68966 --
68967 -- PRIVATE PROCEDURE
68968 -- insert_sources_139
68969 --
68970 ----------------------------------------
68971 --
68972 PROCEDURE insert_sources_139(
68973 p_target_ledger_id IN NUMBER
68974 , p_language IN VARCHAR2
68975 , p_sla_ledger_id IN NUMBER
68976 , p_pad_start_date IN DATE
68977 , p_pad_end_date IN DATE
68978 )
68979 IS
68980
68981 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'CHARGEBACK_ALL';
68982 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'CHARGEBACK';
68983 p_apps_owner VARCHAR2(30);
68984 l_log_module VARCHAR2(240);
68985 BEGIN
68986 IF g_log_enabled THEN
68987 l_log_module := C_DEFAULT_MODULE||'.insert_sources_139';
68988 END IF;
68989 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
68990
68991 trace
68992 (p_msg => 'BEGIN of insert_sources_139'
68993 ,p_level => C_LEVEL_PROCEDURE
68994 ,p_module => l_log_module);
68995
68996 END IF;
68997
68998 -- select APPS owner
68999 SELECT oracle_username
69000 INTO p_apps_owner
69001 FROM fnd_oracle_userid
69002 WHERE read_only_flag = 'U'
69003 ;
69004
69005 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
69006 trace
69007 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
69008 ' - p_language = '||p_language||
69009 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
69010 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
69011 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
69012 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
69013 ,p_level => C_LEVEL_STATEMENT
69014 ,p_module => l_log_module);
69015 END IF;
69016
69017
69018 --
69019 INSERT INTO xla_diag_sources --hdr2
69020 (
69021 event_id
69022 , ledger_id
69023 , sla_ledger_id
69024 , description_language
69025 , object_name
69026 , object_type_code
69027 , line_number
69028 , source_application_id
69029 , source_type_code
69030 , source_code
69031 , source_value
69032 , source_meaning
69033 , created_by
69034 , creation_date
69035 , last_update_date
69036 , last_updated_by
69037 , last_update_login
69038 , program_update_date
69039 , program_application_id
69040 , program_id
69041 , request_id
69042 )
69043 SELECT
69044 event_id
69045 , p_target_ledger_id
69046 , p_sla_ledger_id
69047 , p_language
69048 , object_name
69049 , object_type_code
69050 , line_number
69051 , source_application_id
69052 , source_type_code
69053 , source_code
69054 , SUBSTR(source_value ,1,1996)
69055 , SUBSTR(source_meaning ,1,200)
69056 , xla_environment_pkg.g_Usr_Id
69057 , TRUNC(SYSDATE)
69058 , TRUNC(SYSDATE)
69059 , xla_environment_pkg.g_Usr_Id
69060 , xla_environment_pkg.g_Login_Id
69061 , TRUNC(SYSDATE)
69062 , xla_environment_pkg.g_Prog_Appl_Id
69063 , xla_environment_pkg.g_Prog_Id
69064 , xla_environment_pkg.g_Req_Id
69065 FROM (
69066 SELECT xet.event_id event_id
69067 , 0 line_number
69068 , CASE r
69069 WHEN 1 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
69070 WHEN 2 THEN 'AR_BILL_TO_SITE_USES_S_V'
69071 WHEN 3 THEN 'AR_TRANSACTIONS_S_V'
69072 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
69073 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
69077 ELSE null
69074 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
69075 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
69076
69078 END object_name
69079 , CASE r
69080 WHEN 1 THEN 'HEADER'
69081 WHEN 2 THEN 'HEADER'
69082 WHEN 3 THEN 'HEADER'
69083 WHEN 4 THEN 'HEADER'
69084 WHEN 5 THEN 'HEADER'
69085 WHEN 6 THEN 'HEADER'
69086 WHEN 7 THEN 'HEADER'
69087
69088 ELSE null
69089 END object_type_code
69090 , CASE r
69091 WHEN 1 THEN '222'
69092 WHEN 2 THEN '222'
69093 WHEN 3 THEN '222'
69094 WHEN 4 THEN '222'
69095 WHEN 5 THEN '222'
69096 WHEN 6 THEN '222'
69097 WHEN 7 THEN '222'
69098
69099 ELSE null
69100 END source_application_id
69101 , 'S' source_type_code
69102 , CASE r
69103 WHEN 1 THEN 'BILL_CUST_ACCOUNT_ID'
69104 WHEN 2 THEN 'BILL_USES_SITE_USE_ID'
69105 WHEN 3 THEN 'XLA_PARTY_TYPE'
69106 WHEN 4 THEN 'TRX_INVOICE_CURRENCY_CODE'
69107 WHEN 5 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
69108 WHEN 6 THEN 'TRX_DOC_SEQUENCE_ID'
69109 WHEN 7 THEN 'TRX_DOC_SEQUENCE_VALUE'
69110
69111 ELSE null
69112 END source_code
69113 , CASE r
69114 WHEN 1 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
69115 WHEN 2 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
69116 WHEN 3 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
69117 WHEN 4 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
69118 WHEN 5 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
69119 WHEN 6 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
69120 WHEN 7 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
69121
69122 ELSE null
69123 END source_value
69124 , null source_meaning
69125 FROM xla_events_gt xet
69126 , AR_BILL_TO_CUSTOMERS_S_V h1
69127 , AR_BILL_TO_SITE_USES_S_V h2
69128 , AR_TRANSACTIONS_S_V h5
69129 ,(select rownum r from all_objects where rownum <= 7 and owner = p_apps_owner)
69130 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
69131 AND xet.event_class_code = C_EVENT_CLASS_CODE
69132 AND h1.event_id = xet.event_id
69133 AND h2.event_id = h1.event_id
69134 AND h5.event_id = h1.event_id
69135
69136 )
69137 ;
69138 --
69139 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
69140
69141 trace
69142 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
69143 ,p_level => C_LEVEL_STATEMENT
69144 ,p_module => l_log_module);
69145
69146 END IF;
69147 --
69148
69149
69150
69151 --
69152 INSERT INTO xla_diag_sources --line2
69153 (
69154 event_id
69155 , ledger_id
69156 , sla_ledger_id
69157 , description_language
69158 , object_name
69159 , object_type_code
69160 , line_number
69161 , source_application_id
69162 , source_type_code
69163 , source_code
69164 , source_value
69165 , source_meaning
69166 , created_by
69167 , creation_date
69168 , last_update_date
69169 , last_updated_by
69170 , last_update_login
69171 , program_update_date
69172 , program_application_id
69173 , program_id
69174 , request_id
69175 )
69176 SELECT event_id
69177 , p_target_ledger_id
69178 , p_sla_ledger_id
69179 , p_language
69180 , object_name
69181 , object_type_code
69182 , line_number
69183 , source_application_id
69184 , source_type_code
69185 , source_code
69186 , SUBSTR(source_value,1,1996)
69187 , SUBSTR(source_meaning ,1,200)
69188 , xla_environment_pkg.g_Usr_Id
69189 , TRUNC(SYSDATE)
69190 , TRUNC(SYSDATE)
69191 , xla_environment_pkg.g_Usr_Id
69192 , xla_environment_pkg.g_Login_Id
69193 , TRUNC(SYSDATE)
69194 , xla_environment_pkg.g_Prog_Appl_Id
69195 , xla_environment_pkg.g_Prog_Id
69196 , xla_environment_pkg.g_Req_Id
69197 FROM (
69198 SELECT xet.event_id event_id
69199 , l4.line_number line_number
69200 , CASE r
69201 WHEN 1 THEN 'AR_CUST_TRX_LINES_L_V'
69202 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
69203 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
69204 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
69205 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
69206 WHEN 6 THEN 'AR_CUST_TRX_LINES_BASE_V'
69207 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
69208 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
69212 END object_name
69209 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
69210
69211 ELSE null
69213 , CASE r
69214 WHEN 1 THEN 'LINE'
69215 WHEN 2 THEN 'LINE'
69216 WHEN 3 THEN 'LINE'
69217 WHEN 4 THEN 'LINE'
69218 WHEN 5 THEN 'LINE'
69219 WHEN 6 THEN 'LINE'
69220 WHEN 7 THEN 'LINE'
69221 WHEN 8 THEN 'LINE'
69222 WHEN 9 THEN 'LINE'
69223
69224 ELSE null
69225 END object_type_code
69226 , CASE r
69227 WHEN 1 THEN '222'
69228 WHEN 2 THEN '222'
69229 WHEN 3 THEN '222'
69230 WHEN 4 THEN '222'
69231 WHEN 5 THEN '222'
69232 WHEN 6 THEN '222'
69233 WHEN 7 THEN '222'
69234 WHEN 8 THEN '222'
69235 WHEN 9 THEN '222'
69236
69237 ELSE null
69238 END source_application_id
69239 , 'S' source_type_code
69240 , CASE r
69241 WHEN 1 THEN 'TRX_LINE_DIST_CCID'
69242 WHEN 2 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
69243 WHEN 3 THEN 'TRX_LINE_DIST_ID'
69244 WHEN 4 THEN 'TRX_DISTRIBUTION_TYPE'
69245 WHEN 5 THEN 'TRX_LINE_DIST_AMT'
69246 WHEN 6 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
69247 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
69248 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
69249 WHEN 9 THEN 'TRX_LINE_ACCTD_AMT'
69250
69251 ELSE null
69252 END source_code
69253 , CASE r
69254 WHEN 1 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
69255 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
69256 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
69257 WHEN 4 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
69258 WHEN 5 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
69259 WHEN 6 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
69260 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
69261 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
69262 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
69263
69264 ELSE null
69265 END source_value
69266 , null source_meaning
69267 FROM xla_events_gt xet
69268 , AR_CUST_TRX_LINES_BASE_V l3
69269 , AR_CUST_TRX_LINES_L_V l4
69270 , (select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
69271 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
69272 AND xet.event_class_code = C_EVENT_CLASS_CODE
69273 AND l3.event_id = xet.event_id
69274 AND l4.event_id = l3.event_id
69275 AND l4.line_number = l3.line_number
69276
69277 )
69278 ;
69279 --
69280 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
69281
69282 trace
69283 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
69284 ,p_level => C_LEVEL_STATEMENT
69285 ,p_module => l_log_module);
69286
69287 END IF;
69288
69289
69290 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
69291 trace
69292 (p_msg => 'END of insert_sources_139'
69293 ,p_level => C_LEVEL_PROCEDURE
69294 ,p_module => l_log_module);
69295 END IF;
69296 EXCEPTION
69297 WHEN xla_exceptions_pkg.application_exception THEN
69298 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
69299 trace
69300 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
69301 ,p_level => C_LEVEL_EXCEPTION
69302 ,p_module => l_log_module);
69303 END IF;
69304 RAISE;
69305 WHEN OTHERS THEN
69306 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
69307 trace
69308 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
69309 ,p_level => C_LEVEL_EXCEPTION
69310 ,p_module => l_log_module);
69311 END IF;
69312 xla_exceptions_pkg.raise_message
69313 (p_location => 'XLA_00222_AAD_S_000009_PKG.insert_sources_139');
69314 END insert_sources_139;
69315 --
69316
69317 ---------------------------------------
69318 --
69319 -- PRIVATE FUNCTION
69320 -- EventClass_139
69321 --
69322 ----------------------------------------
69323 --
69324 FUNCTION EventClass_139
69325 (p_application_id IN NUMBER
69326 ,p_base_ledger_id IN NUMBER
69327 ,p_target_ledger_id IN NUMBER
69328 ,p_language IN VARCHAR2
69329 ,p_currency_code IN VARCHAR2
69330 ,p_sla_ledger_id IN NUMBER
69331 ,p_pad_start_date IN DATE
69332 ,p_pad_end_date IN DATE
69333 ,p_primary_ledger_id IN NUMBER)
69334 RETURN BOOLEAN IS
69335 --
69339 l_calculate_acctd_flag VARCHAR2(1) :='N';
69336 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'CHARGEBACK_ALL';
69337 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'CHARGEBACK';
69338
69340 l_calculate_g_l_flag VARCHAR2(1) :='N';
69341 --
69342 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69343 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69344 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
69345 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
69346 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69347 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
69348 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
69349 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69350 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
69351 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
69352 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69353 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69354 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69355 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69356 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
69357 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
69358 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
69359 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
69360 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
69361 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
69362 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
69363 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
69364 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
69365 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
69366 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
69367 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
69368
69369 l_event_id NUMBER;
69370 l_previous_event_id NUMBER;
69371 l_first_event_id NUMBER;
69372 l_last_event_id NUMBER;
69373
69374 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
69375 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
69376 --
69377 --
69378 l_result BOOLEAN := TRUE;
69379 l_rows NUMBER := 1000;
69380 l_event_type_name VARCHAR2(80) := 'All';
69381 l_event_class_name VARCHAR2(80) := 'Chargeback';
69382 l_description VARCHAR2(4000);
69383 l_transaction_reversal NUMBER;
69384 l_ae_header_id NUMBER;
69385 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
69386 l_log_module VARCHAR2(240);
69387 --
69388 l_acct_reversal_source VARCHAR2(30);
69389 l_trx_reversal_source VARCHAR2(30);
69390
69391 l_continue_with_lines BOOLEAN := TRUE;
69392 --
69393 l_acc_rev_gl_date_source DATE; -- 4262811
69394 --
69395 type t_array_event_id is table of number index by binary_integer;
69396
69397 l_rec_array_event t_rec_array_event;
69398 l_null_rec_array_event t_rec_array_event;
69399 l_array_ae_header_id xla_number_array_type;
69400 l_actual_flag VARCHAR2(1) := NULL;
69401 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
69402 l_balance_type_code VARCHAR2(1) :=NULL;
69403 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
69404
69405 --
69406 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
69407 --
69408
69409 TYPE t_array_source_32 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
69410 TYPE t_array_source_33 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
69411 TYPE t_array_source_34 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
69412 TYPE t_array_source_39 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
69413 TYPE t_array_source_85 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
69414 TYPE t_array_source_86 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
69415 TYPE t_array_source_87 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
69416
69417 TYPE t_array_source_21 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
69418 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
69419 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
69420 TYPE t_array_source_37 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
69421 TYPE t_array_source_38 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
69422 TYPE t_array_source_40 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
69423 TYPE t_array_source_41 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
69427 l_array_source_32 t_array_source_32;
69424 TYPE t_array_source_42 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
69425 TYPE t_array_source_43 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
69426
69428 l_array_source_33 t_array_source_33;
69429 l_array_source_34 t_array_source_34;
69430 l_array_source_39 t_array_source_39;
69431 l_array_source_85 t_array_source_85;
69432 l_array_source_86 t_array_source_86;
69433 l_array_source_87 t_array_source_87;
69434
69435 l_array_source_21 t_array_source_21;
69436 l_array_source_35 t_array_source_35;
69437 l_array_source_36 t_array_source_36;
69438 l_array_source_37 t_array_source_37;
69439 l_array_source_38 t_array_source_38;
69440 l_array_source_40 t_array_source_40;
69441 l_array_source_41 t_array_source_41;
69442 l_array_source_42 t_array_source_42;
69443 l_array_source_43 t_array_source_43;
69444
69445 --
69446 CURSOR header_cur
69447 IS
69448 SELECT /*+ leading(xet) cardinality(xet,1) */
69449 -- Event Class Code: CHARGEBACK
69450 xet.entity_id
69451 ,xet.legal_entity_id
69452 ,xet.entity_code
69453 ,xet.transaction_number
69454 ,xet.event_id
69455 ,xet.event_class_code
69456 ,xet.event_type_code
69457 ,xet.event_number
69458 ,xet.event_date
69459 ,xet.transaction_date
69460 ,xet.reference_num_1
69461 ,xet.reference_num_2
69462 ,xet.reference_num_3
69463 ,xet.reference_num_4
69464 ,xet.reference_char_1
69465 ,xet.reference_char_2
69466 ,xet.reference_char_3
69467 ,xet.reference_char_4
69468 ,xet.reference_date_1
69469 ,xet.reference_date_2
69470 ,xet.reference_date_3
69471 ,xet.reference_date_4
69472 ,xet.event_created_by
69473 ,xet.budgetary_control_flag
69474 , h1.BILL_CUST_ACCOUNT_ID source_32
69475 , h2.BILL_USES_SITE_USE_ID source_33
69476 , h5.XLA_PARTY_TYPE source_34
69477 , h5.TRX_INVOICE_CURRENCY_CODE source_39
69478 , h5.TRX_DOC_SEQUENCE_CATEGORY source_85
69479 , h5.TRX_DOC_SEQUENCE_ID source_86
69480 , h5.TRX_DOC_SEQUENCE_VALUE source_87
69481 FROM xla_events_gt xet
69482 , AR_BILL_TO_CUSTOMERS_S_V h1
69483 , AR_BILL_TO_SITE_USES_S_V h2
69484 , AR_TRANSACTIONS_S_V h5
69485 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
69486 and xet.event_class_code = C_EVENT_CLASS_CODE
69487 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
69488 AND h2.event_id = h1.event_id
69489 AND h5.event_id = h1.event_id
69490
69491 ORDER BY event_id
69492 ;
69493
69494
69495 --
69496 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
69497 IS
69498 SELECT /*+ leading(xet) cardinality(xet,1) */
69499 -- Event Class Code: CHARGEBACK
69500 xet.entity_id
69501 ,xet.legal_entity_id
69502 ,xet.entity_code
69503 ,xet.transaction_number
69504 ,xet.event_id
69505 ,xet.event_class_code
69506 ,xet.event_type_code
69507 ,xet.event_number
69508 ,xet.event_date
69509 ,xet.transaction_date
69510 ,xet.reference_num_1
69511 ,xet.reference_num_2
69512 ,xet.reference_num_3
69513 ,xet.reference_num_4
69514 ,xet.reference_char_1
69515 ,xet.reference_char_2
69516 ,xet.reference_char_3
69517 ,xet.reference_char_4
69518 ,xet.reference_date_1
69519 ,xet.reference_date_2
69520 ,xet.reference_date_3
69521 ,xet.reference_date_4
69522 ,xet.event_created_by
69523 ,xet.budgetary_control_flag
69524 , l3.LINE_NUMBER
69525 , l4.TRX_LINE_DIST_CCID source_21
69526 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_35
69527 , l4.TRX_LINE_DIST_ID source_36
69528 , l4.TRX_DISTRIBUTION_TYPE source_37
69529 , l4.TRX_LINE_DIST_AMT source_38
69530 , l3.TRX_LINE_CUR_CONVERSION_DATE source_40
69531 , l3.TRX_LINE_CUR_CONVERSION_RATE source_41
69532 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_42
69533 , l3.TRX_LINE_ACCTD_AMT source_43
69534 FROM xla_events_gt xet
69535 , AR_CUST_TRX_LINES_BASE_V l3
69536 , AR_CUST_TRX_LINES_L_V l4
69537 WHERE xet.event_id between x_first_event_id and x_last_event_id
69538 and xet.event_date between p_pad_start_date and p_pad_end_date
69539 and xet.event_class_code = C_EVENT_CLASS_CODE
69540 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
69541 AND l4.event_id = l3.event_id
69542 AND l4.line_number = l3.line_number
69543 ;
69544
69545 --
69546 BEGIN
69547 IF g_log_enabled THEN
69548 l_log_module := C_DEFAULT_MODULE||'.EventClass_139';
69549 END IF;
69550 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
69551 trace
69552 (p_msg => 'BEGIN of EventClass_139'
69553 ,p_level => C_LEVEL_PROCEDURE
69554 ,p_module => l_log_module);
69555 END IF;
69556
69557 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
69558 trace
69559 (p_msg => 'p_application_id = '||p_application_id||
69560 ' - p_base_ledger_id = '||p_base_ledger_id||
69561 ' - p_target_ledger_id = '||p_target_ledger_id||
69562 ' - p_language = '||p_language||
69563 ' - p_currency_code = '||p_currency_code||
69567 END IF;
69564 ' - p_sla_ledger_id = '||p_sla_ledger_id
69565 ,p_level => C_LEVEL_STATEMENT
69566 ,p_module => l_log_module);
69568 --
69569 -- initialze arrays
69570 --
69571 g_array_event.DELETE;
69572 l_rec_array_event := l_null_rec_array_event;
69573 --
69574 --------------------------------------
69575 -- 4262811 Initialze MPA Line Number
69576 --------------------------------------
69577 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
69578
69579 --
69580
69581 --
69582 OPEN header_cur;
69583 --
69584 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
69585 trace
69586 (p_msg => 'SQL - FETCH header_cur'
69587 ,p_level => C_LEVEL_STATEMENT
69588 ,p_module => l_log_module);
69589 END IF;
69590 --
69591 LOOP
69592 FETCH header_cur BULK COLLECT INTO
69593 l_array_entity_id
69594 , l_array_legal_entity_id
69595 , l_array_entity_code
69596 , l_array_transaction_num
69597 , l_array_event_id
69598 , l_array_class_code
69599 , l_array_event_type
69600 , l_array_event_number
69601 , l_array_event_date
69602 , l_array_transaction_date
69603 , l_array_reference_num_1
69604 , l_array_reference_num_2
69605 , l_array_reference_num_3
69606 , l_array_reference_num_4
69607 , l_array_reference_char_1
69608 , l_array_reference_char_2
69609 , l_array_reference_char_3
69610 , l_array_reference_char_4
69611 , l_array_reference_date_1
69612 , l_array_reference_date_2
69613 , l_array_reference_date_3
69614 , l_array_reference_date_4
69615 , l_array_event_created_by
69616 , l_array_budgetary_control_flag
69617 , l_array_source_32
69618 , l_array_source_33
69619 , l_array_source_34
69620 , l_array_source_39
69621 , l_array_source_85
69622 , l_array_source_86
69623 , l_array_source_87
69624 LIMIT l_rows;
69625 --
69626 IF (C_LEVEL_EVENT >= g_log_level) THEN
69627 trace
69628 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
69629 ,p_level => C_LEVEL_EVENT
69630 ,p_module => l_log_module);
69631 END IF;
69632 --
69633 EXIT WHEN l_array_entity_id.COUNT = 0;
69634
69635 -- initialize arrays
69636 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
69637 XLA_AE_LINES_PKG.g_rec_lines := NULL;
69638
69639 --
69640 -- Bug 4458708
69641 --
69642 XLA_AE_LINES_PKG.g_LineNumber := 0;
69643
69644
69645 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
69646 g_last_hdr_idx := l_array_event_id.LAST;
69647 --
69648 -- loop for the headers. Each iteration is for each header extract row
69649 -- fetched in header cursor
69650 --
69651 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
69652
69653 --
69654 -- set event info as cache for other routines to refer event attributes
69655 --
69656 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
69657 (p_application_id => p_application_id
69658 ,p_primary_ledger_id => p_primary_ledger_id
69659 ,p_base_ledger_id => p_base_ledger_id
69660 ,p_target_ledger_id => p_target_ledger_id
69661 ,p_entity_id => l_array_entity_id(hdr_idx)
69662 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
69663 ,p_entity_code => l_array_entity_code(hdr_idx)
69664 ,p_transaction_num => l_array_transaction_num(hdr_idx)
69665 ,p_event_id => l_array_event_id(hdr_idx)
69666 ,p_event_class_code => l_array_class_code(hdr_idx)
69667 ,p_event_type_code => l_array_event_type(hdr_idx)
69668 ,p_event_number => l_array_event_number(hdr_idx)
69669 ,p_event_date => l_array_event_date(hdr_idx)
69670 ,p_transaction_date => l_array_transaction_date(hdr_idx)
69671 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
69672 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
69673 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
69674 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
69675 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
69676 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
69677 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
69678 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
69679 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
69680 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
69681 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
69682 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
69683 ,p_event_created_by => l_array_event_created_by(hdr_idx)
69684 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
69685
69686 --
69687 -- set the status of entry to C_VALID (0)
69688 --
69689 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
69690
69691 --
69692 -- initialize a row for ae header
69693 --
69694 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
69695
69696 l_event_id := l_array_event_id(hdr_idx);
69697
69698 --
69699 -- storing the hdr_idx for event. May be used by line cursor.
69700 --
69704 -- store sources from header extract. This can be improved to
69701 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
69702
69703 --
69705 -- store only those sources from header extract that may be used in lines
69706 --
69707
69708 g_array_event(l_event_id).array_value_num('source_32') := l_array_source_32(hdr_idx);
69709 g_array_event(l_event_id).array_value_num('source_33') := l_array_source_33(hdr_idx);
69710 g_array_event(l_event_id).array_value_char('source_34') := l_array_source_34(hdr_idx);
69711 g_array_event(l_event_id).array_value_char('source_39') := l_array_source_39(hdr_idx);
69712 g_array_event(l_event_id).array_value_char('source_85') := l_array_source_85(hdr_idx);
69713 g_array_event(l_event_id).array_value_num('source_86') := l_array_source_86(hdr_idx);
69714 g_array_event(l_event_id).array_value_num('source_87') := l_array_source_87(hdr_idx);
69715
69716 --
69717 -- initilaize the status of ae headers for diffrent balance types
69718 -- the status is initialised to C_NOT_CREATED (2)
69719 --
69720 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
69721 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
69722 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
69723
69724 --
69725 -- call api to validate and store accounting attributes for header
69726 --
69727
69728 ------------------------------------------------------------
69729 -- Accrual Reversal : to get date for Standard Source (NONE)
69730 ------------------------------------------------------------
69731 l_acc_rev_gl_date_source := NULL;
69732
69733 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
69734 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_85');
69735 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
69736 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_86');
69737 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
69738 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_87');
69739 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
69740 l_rec_acct_attrs.array_date_value(4) :=
69741 xla_ae_sources_pkg.GetSystemSourceDate(
69742 p_source_code => 'XLA_EVENT_DATE'
69743 , p_source_type_code => 'Y'
69744 , p_source_application_id => 602
69745 );
69746
69747
69748 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
69749
69750 XLA_AE_HEADER_PKG.SetJeCategoryName;
69751
69752 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
69753 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
69754 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
69755 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
69756 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
69757
69758
69759 -- No header level analytical criteria
69760
69761 --
69762 --accounting attribute enhancement, bug 3612931
69763 --
69764 l_trx_reversal_source := SUBSTR(NULL, 1,30);
69765
69766 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
69767 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
69768
69769 xla_accounting_err_pkg.build_message
69770 (p_appli_s_name => 'XLA'
69771 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
69772 ,p_token_1 => 'ACCT_ATTR_NAME'
69773 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
69774 ,p_token_2 => 'PRODUCT_NAME'
69775 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
69776 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
69777 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
69778 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
69779
69780 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
69781 --
69782 -- following sets the accounting attributes needed to reverse
69783 -- accounting for a distributeion
69784 --
69785 xla_ae_lines_pkg.SetTrxReversalAttrs
69786 (p_event_id => l_event_id
69787 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
69788 ,p_trx_reversal_source => l_trx_reversal_source);
69789
69790 END IF;
69791
69792
69793 ----------------------------------------------------------------
69794 -- 4262811 - update the header statuses to invalid in need be
69795 ----------------------------------------------------------------
69796 --
69797 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
69798
69799
69800 -----------------------------------------------
69801 -- No accrual reversal for the event class/type
69802 -----------------------------------------------
69803 ----------------------------------------------------------------
69804
69805 --
69806 -- this ends the header loop iteration for one bulk fetch
69807 --
69808 END LOOP;
69809
69813 --
69810 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
69811 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
69812
69814 -- insert dummy rows into lines gt table that were created due to
69815 -- transaction reversals
69816 --
69817 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
69818 l_result := XLA_AE_LINES_PKG.InsertLines;
69819 END IF;
69820
69821 --
69822 -- reset the temp_line_num for each set of events fetched from header
69823 -- cursor rather than doing it for each new event in line cursor
69824 -- Bug 3939231
69825 --
69826 xla_ae_lines_pkg.g_temp_line_num := 0;
69827
69828
69829
69830 --
69831 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
69832 --
69833 --
69834 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
69835
69836 trace
69837 (p_msg => 'SQL - FETCH line_cur'
69838 ,p_level => C_LEVEL_STATEMENT
69839 ,p_module => l_log_module);
69840
69841 END IF;
69842 --
69843 --
69844 LOOP
69845 --
69846 FETCH line_cur BULK COLLECT INTO
69847 l_array_entity_id
69848 , l_array_legal_entity_id
69849 , l_array_entity_code
69850 , l_array_transaction_num
69851 , l_array_event_id
69852 , l_array_class_code
69853 , l_array_event_type
69854 , l_array_event_number
69855 , l_array_event_date
69856 , l_array_transaction_date
69857 , l_array_reference_num_1
69858 , l_array_reference_num_2
69859 , l_array_reference_num_3
69860 , l_array_reference_num_4
69861 , l_array_reference_char_1
69862 , l_array_reference_char_2
69863 , l_array_reference_char_3
69864 , l_array_reference_char_4
69865 , l_array_reference_date_1
69866 , l_array_reference_date_2
69867 , l_array_reference_date_3
69868 , l_array_reference_date_4
69869 , l_array_event_created_by
69870 , l_array_budgetary_control_flag
69871 , l_array_extract_line_num
69872 , l_array_source_21
69873 , l_array_source_35
69874 , l_array_source_36
69875 , l_array_source_37
69876 , l_array_source_38
69877 , l_array_source_40
69878 , l_array_source_41
69879 , l_array_source_42
69880 , l_array_source_43
69881 LIMIT l_rows;
69882
69883 --
69884 IF (C_LEVEL_EVENT >= g_log_level) THEN
69885 trace
69886 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
69887 ,p_level => C_LEVEL_EVENT
69888 ,p_module => l_log_module);
69889 END IF;
69890 --
69891 EXIT WHEN l_array_entity_id.count = 0;
69892
69893 XLA_AE_LINES_PKG.g_rec_lines := null;
69894
69895 --
69896 -- Bug 4458708
69897 --
69898 XLA_AE_LINES_PKG.g_LineNumber := 0;
69899 --
69900 --
69901
69902 FOR Idx IN 1..l_array_event_id.count LOOP
69903 --
69904 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
69905 --
69906 l_event_id := l_array_event_id(idx); -- 5648433
69907
69908 --
69909 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
69910 --
69911
69912 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
69913 (g_array_event(l_event_id).array_value_num('header_index'))
69914 ,'N'
69915 ) <> 'Y'
69916 THEN
69917 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
69918 trace
69919 (p_msg => 'Trancaction revesal option is not Y '
69920 ,p_level => C_LEVEL_STATEMENT
69921 ,p_module => l_log_module);
69922 END IF;
69923
69924 --
69925 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
69926 --
69927 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
69928 --
69929 -- set event info as cache for other routines to refer event attributes
69930 --
69931
69932 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
69933 l_previous_event_id := l_event_id;
69934
69935 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
69936 (p_application_id => p_application_id
69937 ,p_primary_ledger_id => p_primary_ledger_id
69938 ,p_base_ledger_id => p_base_ledger_id
69939 ,p_target_ledger_id => p_target_ledger_id
69940 ,p_entity_id => l_array_entity_id(Idx)
69941 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
69942 ,p_entity_code => l_array_entity_code(Idx)
69943 ,p_transaction_num => l_array_transaction_num(Idx)
69944 ,p_event_id => l_array_event_id(Idx)
69945 ,p_event_class_code => l_array_class_code(Idx)
69946 ,p_event_type_code => l_array_event_type(Idx)
69947 ,p_event_number => l_array_event_number(Idx)
69948 ,p_event_date => l_array_event_date(Idx)
69949 ,p_transaction_date => l_array_transaction_date(Idx)
69950 ,p_reference_num_1 => l_array_reference_num_1(Idx)
69951 ,p_reference_num_2 => l_array_reference_num_2(Idx)
69952 ,p_reference_num_3 => l_array_reference_num_3(Idx)
69956 ,p_reference_char_3 => l_array_reference_char_3(Idx)
69953 ,p_reference_num_4 => l_array_reference_num_4(Idx)
69954 ,p_reference_char_1 => l_array_reference_char_1(Idx)
69955 ,p_reference_char_2 => l_array_reference_char_2(Idx)
69957 ,p_reference_char_4 => l_array_reference_char_4(Idx)
69958 ,p_reference_date_1 => l_array_reference_date_1(Idx)
69959 ,p_reference_date_2 => l_array_reference_date_2(Idx)
69960 ,p_reference_date_3 => l_array_reference_date_3(Idx)
69961 ,p_reference_date_4 => l_array_reference_date_4(Idx)
69962 ,p_event_created_by => l_array_event_created_by(Idx)
69963 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
69964 --
69965 END IF;
69966
69967
69968
69969 --
69970 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
69971
69972 l_acct_reversal_source := SUBSTR(NULL, 1,30);
69973
69974 IF l_continue_with_lines THEN
69975 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
69976 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
69977
69978 xla_accounting_err_pkg.build_message
69979 (p_appli_s_name => 'XLA'
69980 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
69981 ,p_token_1 => 'LINE_NUMBER'
69982 ,p_value_1 => l_array_extract_line_num(Idx)
69983 ,p_token_2 => 'PRODUCT_NAME'
69984 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
69985 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
69986 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
69987 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
69988
69989 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
69990 --
69991 -- following sets the accounting attributes needed to reverse
69992 -- accounting for a distributeion
69993 --
69994
69995 --
69996 -- 5217187
69997 --
69998 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
69999 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
70000 g_array_event(l_event_id).array_value_num('header_index'));
70001 --
70002 --
70003
70004 -- No reversal code generated
70005
70006 xla_ae_lines_pkg.SetAcctReversalAttrs
70007 (p_event_id => l_event_id
70008 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
70009 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70010 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
70011 END IF;
70012
70013 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
70014 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
70015
70016 --
70017 AcctLineType_39 (
70018 p_application_id => p_application_id
70019 ,p_event_id => l_event_id
70020 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70021 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70022 ,p_actual_flag => l_actual_flag
70023 ,p_balance_type_code => l_balance_type_code
70024 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70025
70026 , p_source_21 => l_array_source_21(Idx)
70027 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
70028 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
70029 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
70030 , p_source_35 => l_array_source_35(Idx)
70031 , p_source_36 => l_array_source_36(Idx)
70032 , p_source_37 => l_array_source_37(Idx)
70033 , p_source_38 => l_array_source_38(Idx)
70034 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
70035 , p_source_40 => l_array_source_40(Idx)
70036 , p_source_41 => l_array_source_41(Idx)
70037 , p_source_42 => l_array_source_42(Idx)
70038 , p_source_43 => l_array_source_43(Idx)
70039 );
70040 If(l_balance_type_code = 'A') THEN
70041 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70042 END IF;
70043
70044 --
70045
70046
70047 --
70048 AcctLineType_40 (
70049 p_application_id => p_application_id
70050 ,p_event_id => l_event_id
70051 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70052 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70053 ,p_actual_flag => l_actual_flag
70054 ,p_balance_type_code => l_balance_type_code
70055 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70056
70057 , p_source_21 => l_array_source_21(Idx)
70058 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
70059 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
70060 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
70061 , p_source_35 => l_array_source_35(Idx)
70062 , p_source_36 => l_array_source_36(Idx)
70063 , p_source_37 => l_array_source_37(Idx)
70064 , p_source_38 => l_array_source_38(Idx)
70065 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
70066 , p_source_40 => l_array_source_40(Idx)
70067 , p_source_41 => l_array_source_41(Idx)
70068 , p_source_42 => l_array_source_42(Idx)
70069 , p_source_43 => l_array_source_43(Idx)
70070 );
70071 If(l_balance_type_code = 'A') THEN
70072 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70076
70073 END IF;
70074
70075 --
70077 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
70078 -- or secondary ledger that has different currency with primary
70079 -- or alc that is calculated by sla
70080 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
70081 (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'))
70082
70083 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
70084 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
70085 AND (l_actual_flag = 'A')) THEN
70086 XLA_AE_LINES_PKG.CreateGainOrLossLines(
70087 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
70088 ,p_application_id => p_application_id
70089 ,p_amb_context_code => 'DEFAULT'
70090 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
70091 ,p_event_class_code => C_EVENT_CLASS_CODE
70092 ,p_event_type_code => C_EVENT_TYPE_CODE
70093
70094 ,p_gain_ccid => -1
70095 ,p_loss_ccid => -1
70096
70097 ,p_actual_flag => l_actual_flag
70098 ,p_enc_flag => null
70099 ,p_actual_g_l_ref => l_actual_gain_loss_ref
70100 ,p_enc_g_l_ref => null
70101 );
70102 END IF;
70103 END IF;
70104 END IF;
70105
70106 ELSE
70107 --
70108 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
70109 --
70110 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
70111 trace
70112 (p_msg => 'Trancaction revesal option is Y'
70113 ,p_level => C_LEVEL_STATEMENT
70114 ,p_module => l_log_module);
70115 END IF;
70116 END IF;
70117
70118 END LOOP;
70119 l_result := XLA_AE_LINES_PKG.InsertLines ;
70120 end loop;
70121 close line_cur;
70122
70123
70124 --
70125 -- insert headers into xla_ae_headers_gt table
70126 --
70127 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
70128
70129 -- insert into errors table here.
70130
70131 END LOOP;
70132
70133 --
70134 -- 4865292
70135 --
70136 -- Compare g_hdr_extract_count with event count in
70137 -- CreateHeadersAndLines.
70138 --
70139 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
70140
70141 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
70142 trace (p_msg => '# rows extracted from header extract objects '
70143 || ' (running total): '
70144 || g_hdr_extract_count
70145 ,p_level => C_LEVEL_STATEMENT
70146 ,p_module => l_log_module);
70147 END IF;
70148
70149 CLOSE header_cur;
70150 --
70151
70152 --
70153 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
70154 trace
70155 (p_msg => 'END of EventClass_139'
70156 ,p_level => C_LEVEL_PROCEDURE
70157 ,p_module => l_log_module);
70158 END IF;
70159 --
70160 RETURN l_result;
70161 EXCEPTION
70162 WHEN xla_exceptions_pkg.application_exception THEN
70163
70164 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
70165
70166
70167 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
70168
70169 RAISE;
70170
70171 WHEN NO_DATA_FOUND THEN
70172
70173 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
70174 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
70175
70176 FOR header_record IN header_cur
70177 LOOP
70178 l_array_header_events(header_record.event_id) := header_record.event_id;
70179 END LOOP;
70180
70181 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
70182 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
70183
70184 fnd_file.put_line(fnd_file.LOG, ' ');
70185 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
70186 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
70187 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
70188
70189 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
70190 LOOP
70191 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
70192 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
70193 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
70194 END IF;
70195 END LOOP;
70196
70197 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
70198 fnd_file.put_line(fnd_file.LOG, ' ');
70199
70200
70201 xla_exceptions_pkg.raise_message
70202 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_139');
70203
70204
70205 WHEN OTHERS THEN
70206 xla_exceptions_pkg.raise_message
70207 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_139');
70208 END EventClass_139;
70209 --
70210
70211 ---------------------------------------
70212 --
70213 -- PRIVATE PROCEDURE
70214 -- insert_sources_140
70218 PROCEDURE insert_sources_140(
70215 --
70216 ----------------------------------------
70217 --
70219 p_target_ledger_id IN NUMBER
70220 , p_language IN VARCHAR2
70221 , p_sla_ledger_id IN NUMBER
70222 , p_pad_start_date IN DATE
70223 , p_pad_end_date IN DATE
70224 )
70225 IS
70226
70227 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'CREDIT_MEMO_ALL';
70228 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'CREDIT_MEMO';
70229 p_apps_owner VARCHAR2(30);
70230 l_log_module VARCHAR2(240);
70231 BEGIN
70232 IF g_log_enabled THEN
70233 l_log_module := C_DEFAULT_MODULE||'.insert_sources_140';
70234 END IF;
70235 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
70236
70237 trace
70238 (p_msg => 'BEGIN of insert_sources_140'
70239 ,p_level => C_LEVEL_PROCEDURE
70240 ,p_module => l_log_module);
70241
70242 END IF;
70243
70244 -- select APPS owner
70245 SELECT oracle_username
70246 INTO p_apps_owner
70247 FROM fnd_oracle_userid
70248 WHERE read_only_flag = 'U'
70249 ;
70250
70251 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
70252 trace
70253 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
70254 ' - p_language = '||p_language||
70255 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
70256 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
70257 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
70258 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
70259 ,p_level => C_LEVEL_STATEMENT
70260 ,p_module => l_log_module);
70261 END IF;
70262
70263
70264 --
70265 INSERT INTO xla_diag_sources --hdr2
70266 (
70267 event_id
70268 , ledger_id
70269 , sla_ledger_id
70270 , description_language
70271 , object_name
70272 , object_type_code
70273 , line_number
70274 , source_application_id
70275 , source_type_code
70276 , source_code
70277 , source_value
70278 , source_meaning
70279 , created_by
70280 , creation_date
70281 , last_update_date
70282 , last_updated_by
70283 , last_update_login
70284 , program_update_date
70285 , program_application_id
70286 , program_id
70287 , request_id
70288 )
70289 SELECT
70290 event_id
70291 , p_target_ledger_id
70292 , p_sla_ledger_id
70293 , p_language
70294 , object_name
70295 , object_type_code
70296 , line_number
70297 , source_application_id
70298 , source_type_code
70299 , source_code
70300 , SUBSTR(source_value ,1,1996)
70301 , SUBSTR(source_meaning ,1,200)
70302 , xla_environment_pkg.g_Usr_Id
70303 , TRUNC(SYSDATE)
70304 , TRUNC(SYSDATE)
70305 , xla_environment_pkg.g_Usr_Id
70306 , xla_environment_pkg.g_Login_Id
70307 , TRUNC(SYSDATE)
70308 , xla_environment_pkg.g_Prog_Appl_Id
70309 , xla_environment_pkg.g_Prog_Id
70310 , xla_environment_pkg.g_Req_Id
70311 FROM (
70312 SELECT xet.event_id event_id
70313 , 0 line_number
70314 , CASE r
70315 WHEN 1 THEN 'AR_CREDIT_MEMO_H_V'
70316 WHEN 2 THEN 'AR_SYSTEM_PARAM_H_V'
70317 WHEN 3 THEN 'AR_SYSTEM_PARAM_H_V'
70318 WHEN 4 THEN 'AR_CREDIT_MEMO_H_V'
70319 WHEN 5 THEN 'AR_CREDIT_MEMO_H_V'
70320 WHEN 6 THEN 'AR_CM_BILL_TO_CUST_H_V'
70321 WHEN 7 THEN 'AR_CM_BILL_SITE_USES_H_V'
70322 WHEN 8 THEN 'AR_CREDIT_MEMO_H_V'
70323
70324 ELSE null
70325 END object_name
70326 , CASE r
70327 WHEN 1 THEN 'HEADER'
70328 WHEN 2 THEN 'HEADER'
70329 WHEN 3 THEN 'HEADER'
70330 WHEN 4 THEN 'HEADER'
70331 WHEN 5 THEN 'HEADER'
70332 WHEN 6 THEN 'HEADER'
70333 WHEN 7 THEN 'HEADER'
70334 WHEN 8 THEN 'HEADER'
70335
70336 ELSE null
70337 END object_type_code
70338 , CASE r
70339 WHEN 1 THEN '222'
70340 WHEN 2 THEN '222'
70341 WHEN 3 THEN '222'
70342 WHEN 4 THEN '222'
70343 WHEN 5 THEN '222'
70344 WHEN 6 THEN '222'
70345 WHEN 7 THEN '222'
70346 WHEN 8 THEN '222'
70347
70348 ELSE null
70349 END source_application_id
70350 , 'S' source_type_code
70351 , CASE r
70352 WHEN 1 THEN 'CM_RECEIVABLE_CCID'
70353 WHEN 2 THEN 'CODE_COMBINATION_ID_GAIN'
70354 WHEN 3 THEN 'CODE_COMBINATION_ID_LOSS'
70355 WHEN 4 THEN 'XLA_PARTY_TYPE'
70359 WHEN 8 THEN 'CM_INVOICING_RULE_ID'
70356 WHEN 5 THEN 'CM_INVOICE_CURRENCY_CODE'
70357 WHEN 6 THEN 'CM_BILL_CUST_ACCOUNT_ID'
70358 WHEN 7 THEN 'CM_BILL_USES_SITE_USE_ID'
70360
70361 ELSE null
70362 END source_code
70363 , CASE r
70364 WHEN 1 THEN TO_CHAR(h5.CM_RECEIVABLE_CCID)
70365 WHEN 2 THEN TO_CHAR(h8.CODE_COMBINATION_ID_GAIN)
70366 WHEN 3 THEN TO_CHAR(h8.CODE_COMBINATION_ID_LOSS)
70367 WHEN 4 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
70368 WHEN 5 THEN TO_CHAR(h5.CM_INVOICE_CURRENCY_CODE)
70369 WHEN 6 THEN TO_CHAR(h2.CM_BILL_CUST_ACCOUNT_ID)
70370 WHEN 7 THEN TO_CHAR(h1.CM_BILL_USES_SITE_USE_ID)
70371 WHEN 8 THEN TO_CHAR(h5.CM_INVOICING_RULE_ID)
70372
70373 ELSE null
70374 END source_value
70375 , null source_meaning
70376 FROM xla_events_gt xet
70377 , AR_CM_BILL_SITE_USES_H_V h1
70378 , AR_CM_BILL_TO_CUST_H_V h2
70379 , AR_CREDIT_MEMO_H_V h5
70380 , AR_SYSTEM_PARAM_H_V h8
70381 ,(select rownum r from all_objects where rownum <= 8 and owner = p_apps_owner)
70382 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
70383 AND xet.event_class_code = C_EVENT_CLASS_CODE
70384 AND h1.event_id = xet.event_id
70385 AND h2.event_id = h1.event_id
70386 AND h5.event_id = h1.event_id
70387 AND h8.event_id (+) = h1.event_id
70388
70389 )
70390 ;
70391 --
70392 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
70393
70394 trace
70395 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
70396 ,p_level => C_LEVEL_STATEMENT
70397 ,p_module => l_log_module);
70398
70399 END IF;
70400 --
70401
70402
70403
70404 --
70405 INSERT INTO xla_diag_sources --line2
70406 (
70407 event_id
70408 , ledger_id
70409 , sla_ledger_id
70410 , description_language
70411 , object_name
70412 , object_type_code
70413 , line_number
70414 , source_application_id
70415 , source_type_code
70416 , source_code
70417 , source_value
70418 , source_meaning
70419 , created_by
70420 , creation_date
70421 , last_update_date
70422 , last_updated_by
70423 , last_update_login
70424 , program_update_date
70425 , program_application_id
70426 , program_id
70427 , request_id
70428 )
70429 SELECT event_id
70430 , p_target_ledger_id
70431 , p_sla_ledger_id
70432 , p_language
70433 , object_name
70434 , object_type_code
70435 , line_number
70436 , source_application_id
70437 , source_type_code
70438 , source_code
70439 , SUBSTR(source_value,1,1996)
70440 , SUBSTR(source_meaning ,1,200)
70441 , xla_environment_pkg.g_Usr_Id
70442 , TRUNC(SYSDATE)
70443 , TRUNC(SYSDATE)
70444 , xla_environment_pkg.g_Usr_Id
70445 , xla_environment_pkg.g_Login_Id
70446 , TRUNC(SYSDATE)
70447 , xla_environment_pkg.g_Prog_Appl_Id
70448 , xla_environment_pkg.g_Prog_Id
70449 , xla_environment_pkg.g_Req_Id
70450 FROM (
70451 SELECT xet.event_id event_id
70452 , l3.line_number line_number
70453 , CASE r
70454 WHEN 1 THEN 'AR_CM_LINES_L_V'
70455 WHEN 2 THEN 'AR_DISTRIBUTIONS_L_V'
70456 WHEN 3 THEN 'AR_DISTRIBUTIONS_L_V'
70457 WHEN 4 THEN 'AR_RECEIVABLES_TRX_ACT_S_V'
70458 WHEN 5 THEN 'AR_DISTRIBUTIONS_L_V'
70459 WHEN 6 THEN 'AR_CM_LINES_BASE_V'
70460 WHEN 7 THEN 'AR_CM_LINES_BASE_V'
70461 WHEN 8 THEN 'AR_CM_LINES_BASE_V'
70462 WHEN 9 THEN 'AR_CM_LINES_BASE_V'
70463 WHEN 10 THEN 'AR_CM_LINES_BASE_V'
70464 WHEN 11 THEN 'AR_CM_LINES_BASE_V'
70465 WHEN 12 THEN 'AR_CM_LINES_BASE_V'
70466 WHEN 13 THEN 'AR_CM_LINES_L_V'
70467 WHEN 14 THEN 'AR_CM_LINES_L_V'
70468 WHEN 15 THEN 'AR_CM_LINES_L_V'
70469
70470 ELSE null
70471 END object_name
70472 , CASE r
70473 WHEN 1 THEN 'LINE'
70474 WHEN 2 THEN 'LINE'
70475 WHEN 3 THEN 'LINE'
70476 WHEN 4 THEN 'LINE'
70477 WHEN 5 THEN 'LINE'
70478 WHEN 6 THEN 'LINE'
70479 WHEN 7 THEN 'LINE'
70480 WHEN 8 THEN 'LINE'
70481 WHEN 9 THEN 'LINE'
70482 WHEN 10 THEN 'LINE'
70483 WHEN 11 THEN 'LINE'
70484 WHEN 12 THEN 'LINE'
70485 WHEN 13 THEN 'LINE'
70486 WHEN 14 THEN 'LINE'
70487 WHEN 15 THEN 'LINE'
70488
70489 ELSE null
70490 END object_type_code
70491 , CASE r
70495 WHEN 4 THEN '222'
70492 WHEN 1 THEN '222'
70493 WHEN 2 THEN '222'
70494 WHEN 3 THEN '222'
70496 WHEN 5 THEN '222'
70497 WHEN 6 THEN '222'
70498 WHEN 7 THEN '222'
70499 WHEN 8 THEN '222'
70500 WHEN 9 THEN '222'
70501 WHEN 10 THEN '222'
70502 WHEN 11 THEN '222'
70503 WHEN 12 THEN '222'
70504 WHEN 13 THEN '222'
70505 WHEN 14 THEN '222'
70506 WHEN 15 THEN '222'
70507
70508 ELSE null
70509 END source_application_id
70510 , 'S' source_type_code
70511 , CASE r
70512 WHEN 1 THEN 'CM_LINE_DIST_CCID'
70513 WHEN 2 THEN 'DIST_CODE_COMBINATION_ID'
70514 WHEN 3 THEN 'DIST_SOURCE_TYPE'
70515 WHEN 4 THEN 'REC_ACT_TYPE'
70516 WHEN 5 THEN 'DIST_ENT_AMT'
70517 WHEN 6 THEN 'CM_DIST_IDENTIFER'
70518 WHEN 7 THEN 'CM_DIST_TYPE'
70519 WHEN 8 THEN 'CM_LINE_CUR_CONVERSION_DATE'
70520 WHEN 9 THEN 'CM_LINE_CUR_CONVERSION_RATE'
70521 WHEN 10 THEN 'CM_LINE_CUR_CONVERSION_TYPE'
70522 WHEN 11 THEN 'GAIN_LOSS_REF'
70523 WHEN 12 THEN 'CM_LINE_ACCTD_AMT'
70524 WHEN 13 THEN 'CM_TAX_LINE_ID'
70525 WHEN 14 THEN 'CM_LINE_DIST_ACCOUNT_CLASS'
70526 WHEN 15 THEN 'CM_LINE_DIST_AMT'
70527
70528 ELSE null
70529 END source_code
70530 , CASE r
70531 WHEN 1 THEN TO_CHAR(l4.CM_LINE_DIST_CCID)
70532 WHEN 2 THEN TO_CHAR(l6.DIST_CODE_COMBINATION_ID)
70533 WHEN 3 THEN TO_CHAR(l6.DIST_SOURCE_TYPE)
70534 WHEN 4 THEN TO_CHAR(l7.REC_ACT_TYPE)
70535 WHEN 5 THEN TO_CHAR(l6.DIST_ENT_AMT)
70536 WHEN 6 THEN TO_CHAR(l3.CM_DIST_IDENTIFER)
70537 WHEN 7 THEN TO_CHAR(l3.CM_DIST_TYPE)
70538 WHEN 8 THEN TO_CHAR(l3.CM_LINE_CUR_CONVERSION_DATE)
70539 WHEN 9 THEN TO_CHAR(l3.CM_LINE_CUR_CONVERSION_RATE)
70540 WHEN 10 THEN TO_CHAR(l3.CM_LINE_CUR_CONVERSION_TYPE)
70541 WHEN 11 THEN TO_CHAR(l3.GAIN_LOSS_REF)
70542 WHEN 12 THEN TO_CHAR(l3.CM_LINE_ACCTD_AMT)
70543 WHEN 13 THEN TO_CHAR(l4.CM_TAX_LINE_ID)
70544 WHEN 14 THEN TO_CHAR(l4.CM_LINE_DIST_ACCOUNT_CLASS)
70545 WHEN 15 THEN TO_CHAR(l4.CM_LINE_DIST_AMT)
70546
70547 ELSE null
70548 END source_value
70549 , null source_meaning
70550 FROM xla_events_gt xet
70551 , AR_CM_LINES_BASE_V l3
70552 , AR_CM_LINES_L_V l4
70553 , AR_DISTRIBUTIONS_L_V l6
70554 , AR_RECEIVABLES_TRX_ACT_S_V l7
70555 , (select rownum r from all_objects where rownum <= 15 and owner = p_apps_owner)
70556 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
70557 AND xet.event_class_code = C_EVENT_CLASS_CODE
70558 AND l3.event_id = xet.event_id
70559 AND l4.event_id (+) = l3.event_id
70560 AND l4.line_number (+) = l3.line_number
70561 AND l6.event_id (+) = l3.event_id
70562 AND l6.line_number (+) = l3.line_number
70563 AND l7.event_id (+) = l3.event_id
70564 AND l7.line_number (+) = l3.line_number
70565
70566 )
70567 ;
70568 --
70569 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
70570
70571 trace
70572 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
70573 ,p_level => C_LEVEL_STATEMENT
70574 ,p_module => l_log_module);
70575
70576 END IF;
70577
70578
70579 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
70580 trace
70581 (p_msg => 'END of insert_sources_140'
70582 ,p_level => C_LEVEL_PROCEDURE
70583 ,p_module => l_log_module);
70584 END IF;
70585 EXCEPTION
70586 WHEN xla_exceptions_pkg.application_exception THEN
70587 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
70588 trace
70589 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
70590 ,p_level => C_LEVEL_EXCEPTION
70591 ,p_module => l_log_module);
70592 END IF;
70593 RAISE;
70594 WHEN OTHERS THEN
70595 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
70596 trace
70597 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
70598 ,p_level => C_LEVEL_EXCEPTION
70599 ,p_module => l_log_module);
70600 END IF;
70601 xla_exceptions_pkg.raise_message
70602 (p_location => 'XLA_00222_AAD_S_000009_PKG.insert_sources_140');
70603 END insert_sources_140;
70604 --
70605
70606 ---------------------------------------
70607 --
70608 -- PRIVATE FUNCTION
70609 -- EventClass_140
70610 --
70611 ----------------------------------------
70612 --
70613 FUNCTION EventClass_140
70617 ,p_language IN VARCHAR2
70614 (p_application_id IN NUMBER
70615 ,p_base_ledger_id IN NUMBER
70616 ,p_target_ledger_id IN NUMBER
70618 ,p_currency_code IN VARCHAR2
70619 ,p_sla_ledger_id IN NUMBER
70620 ,p_pad_start_date IN DATE
70621 ,p_pad_end_date IN DATE
70622 ,p_primary_ledger_id IN NUMBER)
70623 RETURN BOOLEAN IS
70624 --
70625 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'CREDIT_MEMO_ALL';
70626 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'CREDIT_MEMO';
70627
70628 l_calculate_acctd_flag VARCHAR2(1) :='N';
70629 l_calculate_g_l_flag VARCHAR2(1) :='Y';
70630 --
70631 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
70632 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
70633 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
70634 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
70635 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
70636 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
70637 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
70638 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
70639 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
70640 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
70641 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
70642 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
70643 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
70644 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
70645 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
70646 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
70647 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
70648 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
70649 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
70650 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
70651 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
70652 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
70653 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
70654 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
70655 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
70656 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
70657
70658 l_event_id NUMBER;
70659 l_previous_event_id NUMBER;
70660 l_first_event_id NUMBER;
70661 l_last_event_id NUMBER;
70662
70663 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
70664 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
70665 --
70666 --
70667 l_result BOOLEAN := TRUE;
70668 l_rows NUMBER := 1000;
70669 l_event_type_name VARCHAR2(80) := 'All';
70670 l_event_class_name VARCHAR2(80) := 'Credit Memo';
70671 l_description VARCHAR2(4000);
70672 l_transaction_reversal NUMBER;
70673 l_ae_header_id NUMBER;
70674 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
70675 l_log_module VARCHAR2(240);
70676 --
70677 l_acct_reversal_source VARCHAR2(30);
70678 l_trx_reversal_source VARCHAR2(30);
70679
70680 l_continue_with_lines BOOLEAN := TRUE;
70681 --
70682 l_acc_rev_gl_date_source DATE; -- 4262811
70683 --
70684 type t_array_event_id is table of number index by binary_integer;
70685
70686 l_rec_array_event t_rec_array_event;
70687 l_null_rec_array_event t_rec_array_event;
70688 l_array_ae_header_id xla_number_array_type;
70689 l_actual_flag VARCHAR2(1) := NULL;
70690 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
70691 l_balance_type_code VARCHAR2(1) :=NULL;
70692 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
70693
70694 --
70695 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
70696 --
70697
70698 TYPE t_array_source_2 IS TABLE OF AR_CREDIT_MEMO_H_V.CM_RECEIVABLE_CCID%TYPE INDEX BY BINARY_INTEGER;
70699 TYPE t_array_source_19 IS TABLE OF AR_SYSTEM_PARAM_H_V.CODE_COMBINATION_ID_GAIN%TYPE INDEX BY BINARY_INTEGER;
70700 TYPE t_array_source_20 IS TABLE OF AR_SYSTEM_PARAM_H_V.CODE_COMBINATION_ID_LOSS%TYPE INDEX BY BINARY_INTEGER;
70701 TYPE t_array_source_34 IS TABLE OF AR_CREDIT_MEMO_H_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
70702 TYPE t_array_source_46 IS TABLE OF AR_CREDIT_MEMO_H_V.CM_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
70703 TYPE t_array_source_52 IS TABLE OF AR_CM_BILL_TO_CUST_H_V.CM_BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
70704 TYPE t_array_source_53 IS TABLE OF AR_CM_BILL_SITE_USES_H_V.CM_BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
70705 TYPE t_array_source_69 IS TABLE OF AR_CREDIT_MEMO_H_V.CM_INVOICING_RULE_ID%TYPE INDEX BY BINARY_INTEGER;
70706
70710 TYPE t_array_source_23 IS TABLE OF AR_RECEIVABLES_TRX_ACT_S_V.REC_ACT_TYPE%TYPE INDEX BY BINARY_INTEGER;
70707 TYPE t_array_source_9 IS TABLE OF AR_CM_LINES_L_V.CM_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
70708 TYPE t_array_source_10 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
70709 TYPE t_array_source_22 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
70711 TYPE t_array_source_26 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT%TYPE INDEX BY BINARY_INTEGER;
70712 TYPE t_array_source_44 IS TABLE OF AR_CM_LINES_BASE_V.CM_DIST_IDENTIFER%TYPE INDEX BY BINARY_INTEGER;
70713 TYPE t_array_source_45 IS TABLE OF AR_CM_LINES_BASE_V.CM_DIST_TYPE%TYPE INDEX BY BINARY_INTEGER;
70714 TYPE t_array_source_47 IS TABLE OF AR_CM_LINES_BASE_V.CM_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
70715 TYPE t_array_source_48 IS TABLE OF AR_CM_LINES_BASE_V.CM_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
70716 TYPE t_array_source_49 IS TABLE OF AR_CM_LINES_BASE_V.CM_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
70717 TYPE t_array_source_50 IS TABLE OF AR_CM_LINES_BASE_V.GAIN_LOSS_REF%TYPE INDEX BY BINARY_INTEGER;
70718 TYPE t_array_source_51 IS TABLE OF AR_CM_LINES_BASE_V.CM_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
70719 TYPE t_array_source_54 IS TABLE OF AR_CM_LINES_L_V.CM_TAX_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
70720 TYPE t_array_source_55 IS TABLE OF AR_CM_LINES_L_V.CM_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
70721 TYPE t_array_source_56 IS TABLE OF AR_CM_LINES_L_V.CM_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
70722
70723 l_array_source_2 t_array_source_2;
70724 l_array_source_19 t_array_source_19;
70725 l_array_source_20 t_array_source_20;
70726 l_array_source_34 t_array_source_34;
70727 l_array_source_46 t_array_source_46;
70728 l_array_source_52 t_array_source_52;
70729 l_array_source_53 t_array_source_53;
70730 l_array_source_69 t_array_source_69;
70731
70732 l_array_source_9 t_array_source_9;
70733 l_array_source_10 t_array_source_10;
70734 l_array_source_22 t_array_source_22;
70735 l_array_source_23 t_array_source_23;
70736 l_array_source_26 t_array_source_26;
70737 l_array_source_44 t_array_source_44;
70738 l_array_source_45 t_array_source_45;
70739 l_array_source_47 t_array_source_47;
70740 l_array_source_48 t_array_source_48;
70741 l_array_source_49 t_array_source_49;
70742 l_array_source_50 t_array_source_50;
70743 l_array_source_51 t_array_source_51;
70744 l_array_source_54 t_array_source_54;
70745 l_array_source_55 t_array_source_55;
70746 l_array_source_56 t_array_source_56;
70747
70748 --
70749 CURSOR header_cur
70750 IS
70751 SELECT /*+ leading(xet) cardinality(xet,1) */
70752 -- Event Class Code: CREDIT_MEMO
70753 xet.entity_id
70754 ,xet.legal_entity_id
70755 ,xet.entity_code
70756 ,xet.transaction_number
70757 ,xet.event_id
70758 ,xet.event_class_code
70759 ,xet.event_type_code
70760 ,xet.event_number
70761 ,xet.event_date
70762 ,xet.transaction_date
70763 ,xet.reference_num_1
70764 ,xet.reference_num_2
70765 ,xet.reference_num_3
70766 ,xet.reference_num_4
70767 ,xet.reference_char_1
70768 ,xet.reference_char_2
70769 ,xet.reference_char_3
70770 ,xet.reference_char_4
70771 ,xet.reference_date_1
70772 ,xet.reference_date_2
70773 ,xet.reference_date_3
70774 ,xet.reference_date_4
70775 ,xet.event_created_by
70776 ,xet.budgetary_control_flag
70777 , h5.CM_RECEIVABLE_CCID source_2
70778 , h8.CODE_COMBINATION_ID_GAIN source_19
70779 , h8.CODE_COMBINATION_ID_LOSS source_20
70780 , h5.XLA_PARTY_TYPE source_34
70781 , h5.CM_INVOICE_CURRENCY_CODE source_46
70782 , h2.CM_BILL_CUST_ACCOUNT_ID source_52
70783 , h1.CM_BILL_USES_SITE_USE_ID source_53
70784 , h5.CM_INVOICING_RULE_ID source_69
70785 FROM xla_events_gt xet
70786 , AR_CM_BILL_SITE_USES_H_V h1
70787 , AR_CM_BILL_TO_CUST_H_V h2
70788 , AR_CREDIT_MEMO_H_V h5
70789 , AR_SYSTEM_PARAM_H_V h8
70790 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
70791 and xet.event_class_code = C_EVENT_CLASS_CODE
70792 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
70793 AND h2.event_id = h1.event_id
70794 AND h5.event_id = h1.event_id
70795 AND h8.event_id (+) = h1.event_id
70796
70797 ORDER BY event_id
70798 ;
70799
70800
70801 --
70802 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
70803 IS
70804 SELECT /*+ leading(xet) cardinality(xet,1) */
70805 -- Event Class Code: CREDIT_MEMO
70806 xet.entity_id
70807 ,xet.legal_entity_id
70808 ,xet.entity_code
70809 ,xet.transaction_number
70810 ,xet.event_id
70811 ,xet.event_class_code
70812 ,xet.event_type_code
70813 ,xet.event_number
70814 ,xet.event_date
70815 ,xet.transaction_date
70816 ,xet.reference_num_1
70817 ,xet.reference_num_2
70818 ,xet.reference_num_3
70819 ,xet.reference_num_4
70820 ,xet.reference_char_1
70821 ,xet.reference_char_2
70822 ,xet.reference_char_3
70823 ,xet.reference_char_4
70824 ,xet.reference_date_1
70825 ,xet.reference_date_2
70826 ,xet.reference_date_3
70827 ,xet.reference_date_4
70831 , l4.CM_LINE_DIST_CCID source_9
70828 ,xet.event_created_by
70829 ,xet.budgetary_control_flag
70830 , l3.LINE_NUMBER
70832 , l6.DIST_CODE_COMBINATION_ID source_10
70833 , l6.DIST_SOURCE_TYPE source_22
70834 , l7.REC_ACT_TYPE source_23
70835 , l6.DIST_ENT_AMT source_26
70836 , l3.CM_DIST_IDENTIFER source_44
70837 , l3.CM_DIST_TYPE source_45
70838 , l3.CM_LINE_CUR_CONVERSION_DATE source_47
70839 , l3.CM_LINE_CUR_CONVERSION_RATE source_48
70840 , l3.CM_LINE_CUR_CONVERSION_TYPE source_49
70841 , l3.GAIN_LOSS_REF source_50
70842 , l3.CM_LINE_ACCTD_AMT source_51
70843 , l4.CM_TAX_LINE_ID source_54
70844 , l4.CM_LINE_DIST_ACCOUNT_CLASS source_55
70845 , l4.CM_LINE_DIST_AMT source_56
70846 FROM xla_events_gt xet
70847 , AR_CM_LINES_BASE_V l3
70848 , AR_CM_LINES_L_V l4
70849 , AR_DISTRIBUTIONS_L_V l6
70850 , AR_RECEIVABLES_TRX_ACT_S_V l7
70851 WHERE xet.event_id between x_first_event_id and x_last_event_id
70852 and xet.event_date between p_pad_start_date and p_pad_end_date
70853 and xet.event_class_code = C_EVENT_CLASS_CODE
70854 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
70855 AND l4.event_id (+) = l3.event_id
70856 AND l4.line_number (+) = l3.line_number
70857 AND l6.event_id (+) = l3.event_id
70858 AND l6.line_number (+) = l3.line_number
70859 AND l7.event_id (+) = l3.event_id
70860 AND l7.line_number (+) = l3.line_number
70861 ;
70862
70863 --
70864 BEGIN
70865 IF g_log_enabled THEN
70866 l_log_module := C_DEFAULT_MODULE||'.EventClass_140';
70867 END IF;
70868 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
70869 trace
70870 (p_msg => 'BEGIN of EventClass_140'
70871 ,p_level => C_LEVEL_PROCEDURE
70872 ,p_module => l_log_module);
70873 END IF;
70874
70875 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
70876 trace
70877 (p_msg => 'p_application_id = '||p_application_id||
70878 ' - p_base_ledger_id = '||p_base_ledger_id||
70879 ' - p_target_ledger_id = '||p_target_ledger_id||
70880 ' - p_language = '||p_language||
70881 ' - p_currency_code = '||p_currency_code||
70882 ' - p_sla_ledger_id = '||p_sla_ledger_id
70883 ,p_level => C_LEVEL_STATEMENT
70884 ,p_module => l_log_module);
70885 END IF;
70886 --
70887 -- initialze arrays
70888 --
70889 g_array_event.DELETE;
70890 l_rec_array_event := l_null_rec_array_event;
70891 --
70892 --------------------------------------
70893 -- 4262811 Initialze MPA Line Number
70894 --------------------------------------
70895 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
70896
70897 --
70898
70899 --
70900 OPEN header_cur;
70901 --
70902 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
70903 trace
70904 (p_msg => 'SQL - FETCH header_cur'
70905 ,p_level => C_LEVEL_STATEMENT
70906 ,p_module => l_log_module);
70907 END IF;
70908 --
70909 LOOP
70910 FETCH header_cur BULK COLLECT INTO
70911 l_array_entity_id
70912 , l_array_legal_entity_id
70913 , l_array_entity_code
70914 , l_array_transaction_num
70915 , l_array_event_id
70916 , l_array_class_code
70917 , l_array_event_type
70918 , l_array_event_number
70919 , l_array_event_date
70920 , l_array_transaction_date
70921 , l_array_reference_num_1
70922 , l_array_reference_num_2
70923 , l_array_reference_num_3
70924 , l_array_reference_num_4
70925 , l_array_reference_char_1
70926 , l_array_reference_char_2
70927 , l_array_reference_char_3
70928 , l_array_reference_char_4
70929 , l_array_reference_date_1
70930 , l_array_reference_date_2
70931 , l_array_reference_date_3
70932 , l_array_reference_date_4
70933 , l_array_event_created_by
70934 , l_array_budgetary_control_flag
70935 , l_array_source_2
70936 , l_array_source_19
70937 , l_array_source_20
70938 , l_array_source_34
70939 , l_array_source_46
70940 , l_array_source_52
70941 , l_array_source_53
70942 , l_array_source_69
70943 LIMIT l_rows;
70944 --
70945 IF (C_LEVEL_EVENT >= g_log_level) THEN
70946 trace
70947 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
70948 ,p_level => C_LEVEL_EVENT
70949 ,p_module => l_log_module);
70950 END IF;
70951 --
70952 EXIT WHEN l_array_entity_id.COUNT = 0;
70953
70954 -- initialize arrays
70955 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
70956 XLA_AE_LINES_PKG.g_rec_lines := NULL;
70957
70958 --
70959 -- Bug 4458708
70960 --
70961 XLA_AE_LINES_PKG.g_LineNumber := 0;
70962
70963
70964 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
70965 g_last_hdr_idx := l_array_event_id.LAST;
70966 --
70967 -- loop for the headers. Each iteration is for each header extract row
70968 -- fetched in header cursor
70969 --
70970 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
70971
70972 --
70973 -- set event info as cache for other routines to refer event attributes
70974 --
70978 ,p_base_ledger_id => p_base_ledger_id
70975 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
70976 (p_application_id => p_application_id
70977 ,p_primary_ledger_id => p_primary_ledger_id
70979 ,p_target_ledger_id => p_target_ledger_id
70980 ,p_entity_id => l_array_entity_id(hdr_idx)
70981 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
70982 ,p_entity_code => l_array_entity_code(hdr_idx)
70983 ,p_transaction_num => l_array_transaction_num(hdr_idx)
70984 ,p_event_id => l_array_event_id(hdr_idx)
70985 ,p_event_class_code => l_array_class_code(hdr_idx)
70986 ,p_event_type_code => l_array_event_type(hdr_idx)
70987 ,p_event_number => l_array_event_number(hdr_idx)
70988 ,p_event_date => l_array_event_date(hdr_idx)
70989 ,p_transaction_date => l_array_transaction_date(hdr_idx)
70990 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
70991 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
70992 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
70993 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
70994 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
70995 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
70996 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
70997 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
70998 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
70999 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
71000 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
71001 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
71002 ,p_event_created_by => l_array_event_created_by(hdr_idx)
71003 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
71004
71005 --
71006 -- set the status of entry to C_VALID (0)
71007 --
71008 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
71009
71010 --
71011 -- initialize a row for ae header
71012 --
71013 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
71014
71015 l_event_id := l_array_event_id(hdr_idx);
71016
71017 --
71018 -- storing the hdr_idx for event. May be used by line cursor.
71019 --
71020 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
71021
71022 --
71023 -- store sources from header extract. This can be improved to
71024 -- store only those sources from header extract that may be used in lines
71025 --
71026
71027 g_array_event(l_event_id).array_value_num('source_2') := l_array_source_2(hdr_idx);
71028 g_array_event(l_event_id).array_value_num('source_19') := l_array_source_19(hdr_idx);
71029 g_array_event(l_event_id).array_value_num('source_20') := l_array_source_20(hdr_idx);
71030 g_array_event(l_event_id).array_value_char('source_34') := l_array_source_34(hdr_idx);
71031 g_array_event(l_event_id).array_value_char('source_46') := l_array_source_46(hdr_idx);
71032 g_array_event(l_event_id).array_value_num('source_52') := l_array_source_52(hdr_idx);
71033 g_array_event(l_event_id).array_value_num('source_53') := l_array_source_53(hdr_idx);
71034 g_array_event(l_event_id).array_value_num('source_69') := l_array_source_69(hdr_idx);
71035
71036 --
71037 -- initilaize the status of ae headers for diffrent balance types
71038 -- the status is initialised to C_NOT_CREATED (2)
71039 --
71040 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
71041 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
71042 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
71043
71044 --
71045 -- call api to validate and store accounting attributes for header
71046 --
71047
71048 ------------------------------------------------------------
71049 -- Accrual Reversal : to get date for Standard Source (NONE)
71050 ------------------------------------------------------------
71051 l_acc_rev_gl_date_source := NULL;
71052
71053 l_rec_acct_attrs.array_acct_attr_code(1) := 'GL_DATE';
71054 l_rec_acct_attrs.array_date_value(1) :=
71055 xla_ae_sources_pkg.GetSystemSourceDate(
71056 p_source_code => 'XLA_EVENT_DATE'
71057 , p_source_type_code => 'Y'
71058 , p_source_application_id => 602
71059 );
71060
71061
71062 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
71063
71064 XLA_AE_HEADER_PKG.SetJeCategoryName;
71065
71066 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
71067 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
71068 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
71069 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
71070 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
71071
71072
71073 -- No header level analytical criteria
71074
71075 --
71076 --accounting attribute enhancement, bug 3612931
71077 --
71078 l_trx_reversal_source := SUBSTR(NULL, 1,30);
71079
71080 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
71081 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
71082
71083 xla_accounting_err_pkg.build_message
71087 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
71084 (p_appli_s_name => 'XLA'
71085 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
71086 ,p_token_1 => 'ACCT_ATTR_NAME'
71088 ,p_token_2 => 'PRODUCT_NAME'
71089 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
71090 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
71091 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
71092 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
71093
71094 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
71095 --
71096 -- following sets the accounting attributes needed to reverse
71097 -- accounting for a distributeion
71098 --
71099 xla_ae_lines_pkg.SetTrxReversalAttrs
71100 (p_event_id => l_event_id
71101 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
71102 ,p_trx_reversal_source => l_trx_reversal_source);
71103
71104 END IF;
71105
71106
71107 ----------------------------------------------------------------
71108 -- 4262811 - update the header statuses to invalid in need be
71109 ----------------------------------------------------------------
71110 --
71111 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
71112
71113
71114 -----------------------------------------------
71115 -- No accrual reversal for the event class/type
71116 -----------------------------------------------
71117 ----------------------------------------------------------------
71118
71119 --
71120 -- this ends the header loop iteration for one bulk fetch
71121 --
71122 END LOOP;
71123
71124 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
71125 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
71126
71127 --
71128 -- insert dummy rows into lines gt table that were created due to
71129 -- transaction reversals
71130 --
71131 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
71132 l_result := XLA_AE_LINES_PKG.InsertLines;
71133 END IF;
71134
71135 --
71136 -- reset the temp_line_num for each set of events fetched from header
71137 -- cursor rather than doing it for each new event in line cursor
71138 -- Bug 3939231
71139 --
71140 xla_ae_lines_pkg.g_temp_line_num := 0;
71141
71142
71143
71144 --
71145 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
71146 --
71147 --
71148 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
71149
71150 trace
71151 (p_msg => 'SQL - FETCH line_cur'
71152 ,p_level => C_LEVEL_STATEMENT
71153 ,p_module => l_log_module);
71154
71155 END IF;
71156 --
71157 --
71158 LOOP
71159 --
71160 FETCH line_cur BULK COLLECT INTO
71161 l_array_entity_id
71162 , l_array_legal_entity_id
71163 , l_array_entity_code
71164 , l_array_transaction_num
71165 , l_array_event_id
71166 , l_array_class_code
71167 , l_array_event_type
71168 , l_array_event_number
71169 , l_array_event_date
71170 , l_array_transaction_date
71171 , l_array_reference_num_1
71172 , l_array_reference_num_2
71173 , l_array_reference_num_3
71174 , l_array_reference_num_4
71175 , l_array_reference_char_1
71176 , l_array_reference_char_2
71177 , l_array_reference_char_3
71178 , l_array_reference_char_4
71179 , l_array_reference_date_1
71180 , l_array_reference_date_2
71181 , l_array_reference_date_3
71182 , l_array_reference_date_4
71183 , l_array_event_created_by
71184 , l_array_budgetary_control_flag
71185 , l_array_extract_line_num
71186 , l_array_source_9
71187 , l_array_source_10
71188 , l_array_source_22
71189 , l_array_source_23
71190 , l_array_source_26
71191 , l_array_source_44
71192 , l_array_source_45
71193 , l_array_source_47
71194 , l_array_source_48
71195 , l_array_source_49
71196 , l_array_source_50
71197 , l_array_source_51
71198 , l_array_source_54
71199 , l_array_source_55
71200 , l_array_source_56
71201 LIMIT l_rows;
71202
71203 --
71204 IF (C_LEVEL_EVENT >= g_log_level) THEN
71205 trace
71206 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
71207 ,p_level => C_LEVEL_EVENT
71208 ,p_module => l_log_module);
71209 END IF;
71210 --
71211 EXIT WHEN l_array_entity_id.count = 0;
71212
71213 XLA_AE_LINES_PKG.g_rec_lines := null;
71214
71215 --
71216 -- Bug 4458708
71217 --
71218 XLA_AE_LINES_PKG.g_LineNumber := 0;
71219 --
71220 --
71221
71222 FOR Idx IN 1..l_array_event_id.count LOOP
71223 --
71224 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
71225 --
71226 l_event_id := l_array_event_id(idx); -- 5648433
71227
71228 --
71232 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
71229 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
71230 --
71231
71233 (g_array_event(l_event_id).array_value_num('header_index'))
71234 ,'N'
71235 ) <> 'Y'
71236 THEN
71237 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
71238 trace
71239 (p_msg => 'Trancaction revesal option is not Y '
71240 ,p_level => C_LEVEL_STATEMENT
71241 ,p_module => l_log_module);
71242 END IF;
71243
71244 --
71245 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
71246 --
71247 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
71248 --
71249 -- set event info as cache for other routines to refer event attributes
71250 --
71251
71252 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
71253 l_previous_event_id := l_event_id;
71254
71255 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
71256 (p_application_id => p_application_id
71257 ,p_primary_ledger_id => p_primary_ledger_id
71258 ,p_base_ledger_id => p_base_ledger_id
71259 ,p_target_ledger_id => p_target_ledger_id
71260 ,p_entity_id => l_array_entity_id(Idx)
71261 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
71262 ,p_entity_code => l_array_entity_code(Idx)
71263 ,p_transaction_num => l_array_transaction_num(Idx)
71264 ,p_event_id => l_array_event_id(Idx)
71265 ,p_event_class_code => l_array_class_code(Idx)
71266 ,p_event_type_code => l_array_event_type(Idx)
71267 ,p_event_number => l_array_event_number(Idx)
71268 ,p_event_date => l_array_event_date(Idx)
71269 ,p_transaction_date => l_array_transaction_date(Idx)
71270 ,p_reference_num_1 => l_array_reference_num_1(Idx)
71271 ,p_reference_num_2 => l_array_reference_num_2(Idx)
71272 ,p_reference_num_3 => l_array_reference_num_3(Idx)
71273 ,p_reference_num_4 => l_array_reference_num_4(Idx)
71274 ,p_reference_char_1 => l_array_reference_char_1(Idx)
71275 ,p_reference_char_2 => l_array_reference_char_2(Idx)
71276 ,p_reference_char_3 => l_array_reference_char_3(Idx)
71277 ,p_reference_char_4 => l_array_reference_char_4(Idx)
71278 ,p_reference_date_1 => l_array_reference_date_1(Idx)
71279 ,p_reference_date_2 => l_array_reference_date_2(Idx)
71280 ,p_reference_date_3 => l_array_reference_date_3(Idx)
71281 ,p_reference_date_4 => l_array_reference_date_4(Idx)
71282 ,p_event_created_by => l_array_event_created_by(Idx)
71283 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
71284 --
71285 END IF;
71286
71287
71288
71289 --
71290 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
71291
71292 l_acct_reversal_source := SUBSTR(NULL, 1,30);
71293
71294 IF l_continue_with_lines THEN
71295 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
71296 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
71297
71298 xla_accounting_err_pkg.build_message
71299 (p_appli_s_name => 'XLA'
71300 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
71301 ,p_token_1 => 'LINE_NUMBER'
71302 ,p_value_1 => l_array_extract_line_num(Idx)
71303 ,p_token_2 => 'PRODUCT_NAME'
71304 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
71305 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
71306 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
71307 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
71308
71309 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
71310 --
71311 -- following sets the accounting attributes needed to reverse
71312 -- accounting for a distributeion
71313 --
71314
71315 --
71316 -- 5217187
71317 --
71318 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
71319 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
71320 g_array_event(l_event_id).array_value_num('header_index'));
71321 --
71322 --
71323
71324 -- No reversal code generated
71325
71326 xla_ae_lines_pkg.SetAcctReversalAttrs
71327 (p_event_id => l_event_id
71328 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
71329 ,p_calculate_acctd_flag => l_calculate_acctd_flag
71330 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
71331 END IF;
71332
71333 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
71334 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
71335
71336 --
71337 AcctLineType_41 (
71338 p_application_id => p_application_id
71339 ,p_event_id => l_event_id
71340 ,p_calculate_acctd_flag => l_calculate_acctd_flag
71341 ,p_calculate_g_l_flag => l_calculate_g_l_flag
71345
71342 ,p_actual_flag => l_actual_flag
71343 ,p_balance_type_code => l_balance_type_code
71344 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
71346 , p_source_10 => l_array_source_10(Idx)
71347 , p_source_22 => l_array_source_22(Idx)
71348 , p_source_26 => l_array_source_26(Idx)
71349 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
71350 , p_source_44 => l_array_source_44(Idx)
71351 , p_source_45 => l_array_source_45(Idx)
71352 , p_source_46 => g_array_event(l_event_id).array_value_char('source_46')
71353 , p_source_47 => l_array_source_47(Idx)
71354 , p_source_48 => l_array_source_48(Idx)
71355 , p_source_49 => l_array_source_49(Idx)
71356 , p_source_50 => l_array_source_50(Idx)
71357 , p_source_51 => l_array_source_51(Idx)
71358 , p_source_52 => g_array_event(l_event_id).array_value_num('source_52')
71359 , p_source_53 => g_array_event(l_event_id).array_value_num('source_53')
71360 , p_source_54 => l_array_source_54(Idx)
71361 );
71362 If(l_balance_type_code = 'A') THEN
71363 l_actual_gain_loss_ref := l_gain_or_loss_ref;
71364 END IF;
71365
71366 --
71367
71368
71369 --
71370 AcctLineType_42 (
71371 p_application_id => p_application_id
71372 ,p_event_id => l_event_id
71373 ,p_calculate_acctd_flag => l_calculate_acctd_flag
71374 ,p_calculate_g_l_flag => l_calculate_g_l_flag
71375 ,p_actual_flag => l_actual_flag
71376 ,p_balance_type_code => l_balance_type_code
71377 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
71378
71379 , p_source_10 => l_array_source_10(Idx)
71380 , p_source_22 => l_array_source_22(Idx)
71381 , p_source_23 => l_array_source_23(Idx)
71382 , p_source_26 => l_array_source_26(Idx)
71383 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
71384 , p_source_44 => l_array_source_44(Idx)
71385 , p_source_45 => l_array_source_45(Idx)
71386 , p_source_46 => g_array_event(l_event_id).array_value_char('source_46')
71387 , p_source_47 => l_array_source_47(Idx)
71388 , p_source_48 => l_array_source_48(Idx)
71389 , p_source_49 => l_array_source_49(Idx)
71390 , p_source_50 => l_array_source_50(Idx)
71391 , p_source_51 => l_array_source_51(Idx)
71392 , p_source_52 => g_array_event(l_event_id).array_value_num('source_52')
71393 , p_source_53 => g_array_event(l_event_id).array_value_num('source_53')
71394 , p_source_54 => l_array_source_54(Idx)
71395 );
71396 If(l_balance_type_code = 'A') THEN
71397 l_actual_gain_loss_ref := l_gain_or_loss_ref;
71398 END IF;
71399
71400 --
71401
71402
71403 --
71404 AcctLineType_43 (
71405 p_application_id => p_application_id
71406 ,p_event_id => l_event_id
71407 ,p_calculate_acctd_flag => l_calculate_acctd_flag
71408 ,p_calculate_g_l_flag => l_calculate_g_l_flag
71409 ,p_actual_flag => l_actual_flag
71410 ,p_balance_type_code => l_balance_type_code
71411 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
71412
71413 , p_source_9 => l_array_source_9(Idx)
71414 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
71415 , p_source_44 => l_array_source_44(Idx)
71416 , p_source_45 => l_array_source_45(Idx)
71417 , p_source_46 => g_array_event(l_event_id).array_value_char('source_46')
71418 , p_source_47 => l_array_source_47(Idx)
71419 , p_source_48 => l_array_source_48(Idx)
71420 , p_source_49 => l_array_source_49(Idx)
71421 , p_source_50 => l_array_source_50(Idx)
71422 , p_source_51 => l_array_source_51(Idx)
71423 , p_source_52 => g_array_event(l_event_id).array_value_num('source_52')
71424 , p_source_53 => g_array_event(l_event_id).array_value_num('source_53')
71425 , p_source_54 => l_array_source_54(Idx)
71426 , p_source_55 => l_array_source_55(Idx)
71427 , p_source_56 => l_array_source_56(Idx)
71428 );
71429 If(l_balance_type_code = 'A') THEN
71430 l_actual_gain_loss_ref := l_gain_or_loss_ref;
71431 END IF;
71432
71433 --
71434
71435
71436 --
71437 AcctLineType_44 (
71438 p_application_id => p_application_id
71439 ,p_event_id => l_event_id
71440 ,p_calculate_acctd_flag => l_calculate_acctd_flag
71441 ,p_calculate_g_l_flag => l_calculate_g_l_flag
71442 ,p_actual_flag => l_actual_flag
71443 ,p_balance_type_code => l_balance_type_code
71444 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
71445
71446 , p_source_9 => l_array_source_9(Idx)
71447 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
71448 , p_source_44 => l_array_source_44(Idx)
71449 , p_source_45 => l_array_source_45(Idx)
71450 , p_source_46 => g_array_event(l_event_id).array_value_char('source_46')
71451 , p_source_47 => l_array_source_47(Idx)
71452 , p_source_48 => l_array_source_48(Idx)
71453 , p_source_49 => l_array_source_49(Idx)
71454 , p_source_50 => l_array_source_50(Idx)
71455 , p_source_51 => l_array_source_51(Idx)
71456 , p_source_52 => g_array_event(l_event_id).array_value_num('source_52')
71457 , p_source_53 => g_array_event(l_event_id).array_value_num('source_53')
71458 , p_source_54 => l_array_source_54(Idx)
71459 , p_source_55 => l_array_source_55(Idx)
71460 , p_source_56 => l_array_source_56(Idx)
71461 );
71462 If(l_balance_type_code = 'A') THEN
71463 l_actual_gain_loss_ref := l_gain_or_loss_ref;
71464 END IF;
71465
71466 --
71467
71468
71469 --
71470 AcctLineType_45 (
71471 p_application_id => p_application_id
71472 ,p_event_id => l_event_id
71473 ,p_calculate_acctd_flag => l_calculate_acctd_flag
71477 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
71474 ,p_calculate_g_l_flag => l_calculate_g_l_flag
71475 ,p_actual_flag => l_actual_flag
71476 ,p_balance_type_code => l_balance_type_code
71478
71479 , p_source_9 => l_array_source_9(Idx)
71480 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
71481 , p_source_44 => l_array_source_44(Idx)
71482 , p_source_45 => l_array_source_45(Idx)
71483 , p_source_46 => g_array_event(l_event_id).array_value_char('source_46')
71484 , p_source_47 => l_array_source_47(Idx)
71485 , p_source_48 => l_array_source_48(Idx)
71486 , p_source_49 => l_array_source_49(Idx)
71487 , p_source_50 => l_array_source_50(Idx)
71488 , p_source_51 => l_array_source_51(Idx)
71489 , p_source_52 => g_array_event(l_event_id).array_value_num('source_52')
71490 , p_source_53 => g_array_event(l_event_id).array_value_num('source_53')
71491 , p_source_54 => l_array_source_54(Idx)
71492 , p_source_55 => l_array_source_55(Idx)
71493 , p_source_56 => l_array_source_56(Idx)
71494 );
71495 If(l_balance_type_code = 'A') THEN
71496 l_actual_gain_loss_ref := l_gain_or_loss_ref;
71497 END IF;
71498
71499 --
71500
71501
71502 --
71503 AcctLineType_46 (
71504 p_application_id => p_application_id
71505 ,p_event_id => l_event_id
71506 ,p_calculate_acctd_flag => l_calculate_acctd_flag
71507 ,p_calculate_g_l_flag => l_calculate_g_l_flag
71508 ,p_actual_flag => l_actual_flag
71509 ,p_balance_type_code => l_balance_type_code
71510 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
71511
71512 , p_source_9 => l_array_source_9(Idx)
71513 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
71514 , p_source_44 => l_array_source_44(Idx)
71515 , p_source_45 => l_array_source_45(Idx)
71516 , p_source_46 => g_array_event(l_event_id).array_value_char('source_46')
71517 , p_source_47 => l_array_source_47(Idx)
71518 , p_source_48 => l_array_source_48(Idx)
71519 , p_source_49 => l_array_source_49(Idx)
71520 , p_source_50 => l_array_source_50(Idx)
71521 , p_source_51 => l_array_source_51(Idx)
71522 , p_source_52 => g_array_event(l_event_id).array_value_num('source_52')
71523 , p_source_53 => g_array_event(l_event_id).array_value_num('source_53')
71524 , p_source_54 => l_array_source_54(Idx)
71525 , p_source_55 => l_array_source_55(Idx)
71526 , p_source_56 => l_array_source_56(Idx)
71527 );
71528 If(l_balance_type_code = 'A') THEN
71529 l_actual_gain_loss_ref := l_gain_or_loss_ref;
71530 END IF;
71531
71532 --
71533
71534
71535 --
71536 AcctLineType_47 (
71537 p_application_id => p_application_id
71538 ,p_event_id => l_event_id
71539 ,p_calculate_acctd_flag => l_calculate_acctd_flag
71540 ,p_calculate_g_l_flag => l_calculate_g_l_flag
71541 ,p_actual_flag => l_actual_flag
71542 ,p_balance_type_code => l_balance_type_code
71543 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
71544
71545 , p_source_19 => g_array_event(l_event_id).array_value_num('source_19')
71546 , p_source_20 => g_array_event(l_event_id).array_value_num('source_20')
71547 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
71548 , p_source_44 => l_array_source_44(Idx)
71549 , p_source_45 => l_array_source_45(Idx)
71550 , p_source_50 => l_array_source_50(Idx)
71551 , p_source_51 => l_array_source_51(Idx)
71552 , p_source_52 => g_array_event(l_event_id).array_value_num('source_52')
71553 , p_source_53 => g_array_event(l_event_id).array_value_num('source_53')
71554 , p_source_54 => l_array_source_54(Idx)
71555 );
71556 If(l_balance_type_code = 'A') THEN
71557 l_actual_gain_loss_ref := l_gain_or_loss_ref;
71558 END IF;
71559
71560 --
71561
71562
71563 --
71564 AcctLineType_48 (
71565 p_application_id => p_application_id
71566 ,p_event_id => l_event_id
71567 ,p_calculate_acctd_flag => l_calculate_acctd_flag
71568 ,p_calculate_g_l_flag => l_calculate_g_l_flag
71569 ,p_actual_flag => l_actual_flag
71570 ,p_balance_type_code => l_balance_type_code
71571 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
71572
71573 , p_source_9 => l_array_source_9(Idx)
71574 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
71575 , p_source_44 => l_array_source_44(Idx)
71576 , p_source_45 => l_array_source_45(Idx)
71577 , p_source_46 => g_array_event(l_event_id).array_value_char('source_46')
71578 , p_source_47 => l_array_source_47(Idx)
71579 , p_source_48 => l_array_source_48(Idx)
71580 , p_source_49 => l_array_source_49(Idx)
71581 , p_source_50 => l_array_source_50(Idx)
71582 , p_source_51 => l_array_source_51(Idx)
71583 , p_source_52 => g_array_event(l_event_id).array_value_num('source_52')
71584 , p_source_53 => g_array_event(l_event_id).array_value_num('source_53')
71585 , p_source_54 => l_array_source_54(Idx)
71586 , p_source_55 => l_array_source_55(Idx)
71587 , p_source_56 => l_array_source_56(Idx)
71588 );
71589 If(l_balance_type_code = 'A') THEN
71590 l_actual_gain_loss_ref := l_gain_or_loss_ref;
71591 END IF;
71592
71593 --
71594
71595
71596 --
71597 AcctLineType_49 (
71598 p_application_id => p_application_id
71599 ,p_event_id => l_event_id
71600 ,p_calculate_acctd_flag => l_calculate_acctd_flag
71601 ,p_calculate_g_l_flag => l_calculate_g_l_flag
71602 ,p_actual_flag => l_actual_flag
71603 ,p_balance_type_code => l_balance_type_code
71604 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
71605
71609 , p_source_45 => l_array_source_45(Idx)
71606 , p_source_9 => l_array_source_9(Idx)
71607 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
71608 , p_source_44 => l_array_source_44(Idx)
71610 , p_source_46 => g_array_event(l_event_id).array_value_char('source_46')
71611 , p_source_47 => l_array_source_47(Idx)
71612 , p_source_48 => l_array_source_48(Idx)
71613 , p_source_49 => l_array_source_49(Idx)
71614 , p_source_50 => l_array_source_50(Idx)
71615 , p_source_51 => l_array_source_51(Idx)
71616 , p_source_52 => g_array_event(l_event_id).array_value_num('source_52')
71617 , p_source_53 => g_array_event(l_event_id).array_value_num('source_53')
71618 , p_source_54 => l_array_source_54(Idx)
71619 , p_source_55 => l_array_source_55(Idx)
71620 , p_source_56 => l_array_source_56(Idx)
71621 );
71622 If(l_balance_type_code = 'A') THEN
71623 l_actual_gain_loss_ref := l_gain_or_loss_ref;
71624 END IF;
71625
71626 --
71627
71628
71629 --
71630 AcctLineType_50 (
71631 p_application_id => p_application_id
71632 ,p_event_id => l_event_id
71633 ,p_calculate_acctd_flag => l_calculate_acctd_flag
71634 ,p_calculate_g_l_flag => l_calculate_g_l_flag
71635 ,p_actual_flag => l_actual_flag
71636 ,p_balance_type_code => l_balance_type_code
71637 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
71638
71639 , p_source_9 => l_array_source_9(Idx)
71640 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
71641 , p_source_44 => l_array_source_44(Idx)
71642 , p_source_45 => l_array_source_45(Idx)
71643 , p_source_46 => g_array_event(l_event_id).array_value_char('source_46')
71644 , p_source_47 => l_array_source_47(Idx)
71645 , p_source_48 => l_array_source_48(Idx)
71646 , p_source_49 => l_array_source_49(Idx)
71647 , p_source_50 => l_array_source_50(Idx)
71648 , p_source_51 => l_array_source_51(Idx)
71649 , p_source_52 => g_array_event(l_event_id).array_value_num('source_52')
71650 , p_source_53 => g_array_event(l_event_id).array_value_num('source_53')
71651 , p_source_54 => l_array_source_54(Idx)
71652 , p_source_55 => l_array_source_55(Idx)
71653 , p_source_56 => l_array_source_56(Idx)
71654 );
71655 If(l_balance_type_code = 'A') THEN
71656 l_actual_gain_loss_ref := l_gain_or_loss_ref;
71657 END IF;
71658
71659 --
71660
71661
71662 --
71663 AcctLineType_88 (
71664 p_application_id => p_application_id
71665 ,p_event_id => l_event_id
71666 ,p_calculate_acctd_flag => l_calculate_acctd_flag
71667 ,p_calculate_g_l_flag => l_calculate_g_l_flag
71668 ,p_actual_flag => l_actual_flag
71669 ,p_balance_type_code => l_balance_type_code
71670 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
71671
71672 , p_source_2 => g_array_event(l_event_id).array_value_num('source_2')
71673 , p_source_9 => l_array_source_9(Idx)
71674 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
71675 , p_source_44 => l_array_source_44(Idx)
71676 , p_source_45 => l_array_source_45(Idx)
71677 , p_source_46 => g_array_event(l_event_id).array_value_char('source_46')
71678 , p_source_47 => l_array_source_47(Idx)
71679 , p_source_48 => l_array_source_48(Idx)
71680 , p_source_49 => l_array_source_49(Idx)
71681 , p_source_50 => l_array_source_50(Idx)
71682 , p_source_51 => l_array_source_51(Idx)
71683 , p_source_52 => g_array_event(l_event_id).array_value_num('source_52')
71684 , p_source_53 => g_array_event(l_event_id).array_value_num('source_53')
71685 , p_source_54 => l_array_source_54(Idx)
71686 , p_source_55 => l_array_source_55(Idx)
71687 , p_source_56 => l_array_source_56(Idx)
71688 , p_source_69 => g_array_event(l_event_id).array_value_num('source_69')
71689 );
71690 If(l_balance_type_code = 'A') THEN
71691 l_actual_gain_loss_ref := l_gain_or_loss_ref;
71692 END IF;
71693
71694 --
71695
71696 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
71697 -- or secondary ledger that has different currency with primary
71698 -- or alc that is calculated by sla
71699 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
71700 (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'))
71701
71702 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
71703 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
71704 AND (l_actual_flag = 'A')) THEN
71705 XLA_AE_LINES_PKG.CreateGainOrLossLines(
71706 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
71707 ,p_application_id => p_application_id
71708 ,p_amb_context_code => 'DEFAULT'
71709 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
71710 ,p_event_class_code => C_EVENT_CLASS_CODE
71711 ,p_event_type_code => C_EVENT_TYPE_CODE
71712
71713 ,p_gain_ccid => -1
71714 ,p_loss_ccid => -1
71715
71716 ,p_actual_flag => l_actual_flag
71717 ,p_enc_flag => null
71718 ,p_actual_g_l_ref => l_actual_gain_loss_ref
71719 ,p_enc_g_l_ref => null
71720 );
71721 END IF;
71722 END IF;
71723 END IF;
71724
71725 ELSE
71726 --
71730 trace
71727 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
71728 --
71729 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
71731 (p_msg => 'Trancaction revesal option is Y'
71732 ,p_level => C_LEVEL_STATEMENT
71733 ,p_module => l_log_module);
71734 END IF;
71735 END IF;
71736
71737 END LOOP;
71738 l_result := XLA_AE_LINES_PKG.InsertLines ;
71739 end loop;
71740 close line_cur;
71741
71742
71743 --
71744 -- insert headers into xla_ae_headers_gt table
71745 --
71746 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
71747
71748 -- insert into errors table here.
71749
71750 END LOOP;
71751
71752 --
71753 -- 4865292
71754 --
71755 -- Compare g_hdr_extract_count with event count in
71756 -- CreateHeadersAndLines.
71757 --
71758 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
71759
71760 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
71761 trace (p_msg => '# rows extracted from header extract objects '
71762 || ' (running total): '
71763 || g_hdr_extract_count
71764 ,p_level => C_LEVEL_STATEMENT
71765 ,p_module => l_log_module);
71766 END IF;
71767
71768 CLOSE header_cur;
71769 --
71770
71771 --
71772 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
71773 trace
71774 (p_msg => 'END of EventClass_140'
71775 ,p_level => C_LEVEL_PROCEDURE
71776 ,p_module => l_log_module);
71777 END IF;
71778 --
71779 RETURN l_result;
71780 EXCEPTION
71781 WHEN xla_exceptions_pkg.application_exception THEN
71782
71783 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
71784
71785
71786 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
71787
71788 RAISE;
71789
71790 WHEN NO_DATA_FOUND THEN
71791
71792 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
71793 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
71794
71795 FOR header_record IN header_cur
71796 LOOP
71797 l_array_header_events(header_record.event_id) := header_record.event_id;
71798 END LOOP;
71799
71800 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
71801 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
71802
71803 fnd_file.put_line(fnd_file.LOG, ' ');
71804 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
71805 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
71806 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
71807
71808 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
71809 LOOP
71810 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
71811 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
71812 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
71813 END IF;
71814 END LOOP;
71815
71816 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
71817 fnd_file.put_line(fnd_file.LOG, ' ');
71818
71819
71820 xla_exceptions_pkg.raise_message
71821 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_140');
71822
71823
71824 WHEN OTHERS THEN
71825 xla_exceptions_pkg.raise_message
71826 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_140');
71827 END EventClass_140;
71828 --
71829
71830 ---------------------------------------
71831 --
71832 -- PRIVATE PROCEDURE
71833 -- insert_sources_141
71834 --
71835 ----------------------------------------
71836 --
71837 PROCEDURE insert_sources_141(
71838 p_target_ledger_id IN NUMBER
71839 , p_language IN VARCHAR2
71840 , p_sla_ledger_id IN NUMBER
71841 , p_pad_start_date IN DATE
71842 , p_pad_end_date IN DATE
71843 )
71844 IS
71845
71846 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DEBIT_MEMO_ALL';
71847 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DEBIT_MEMO';
71848 p_apps_owner VARCHAR2(30);
71849 l_log_module VARCHAR2(240);
71850 BEGIN
71851 IF g_log_enabled THEN
71852 l_log_module := C_DEFAULT_MODULE||'.insert_sources_141';
71853 END IF;
71854 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
71855
71856 trace
71857 (p_msg => 'BEGIN of insert_sources_141'
71858 ,p_level => C_LEVEL_PROCEDURE
71859 ,p_module => l_log_module);
71860
71861 END IF;
71862
71863 -- select APPS owner
71864 SELECT oracle_username
71865 INTO p_apps_owner
71866 FROM fnd_oracle_userid
71867 WHERE read_only_flag = 'U'
71868 ;
71869
71870 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
71871 trace
71872 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
71873 ' - p_language = '||p_language||
71874 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
71878 ,p_level => C_LEVEL_STATEMENT
71875 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
71876 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
71877 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
71879 ,p_module => l_log_module);
71880 END IF;
71881
71882
71883 --
71884 INSERT INTO xla_diag_sources --hdr2
71885 (
71886 event_id
71887 , ledger_id
71888 , sla_ledger_id
71889 , description_language
71890 , object_name
71891 , object_type_code
71892 , line_number
71893 , source_application_id
71894 , source_type_code
71895 , source_code
71896 , source_value
71897 , source_meaning
71898 , created_by
71899 , creation_date
71900 , last_update_date
71901 , last_updated_by
71902 , last_update_login
71903 , program_update_date
71904 , program_application_id
71905 , program_id
71906 , request_id
71907 )
71908 SELECT
71909 event_id
71910 , p_target_ledger_id
71911 , p_sla_ledger_id
71912 , p_language
71913 , object_name
71914 , object_type_code
71915 , line_number
71916 , source_application_id
71917 , source_type_code
71918 , source_code
71919 , SUBSTR(source_value ,1,1996)
71920 , SUBSTR(source_meaning ,1,200)
71921 , xla_environment_pkg.g_Usr_Id
71922 , TRUNC(SYSDATE)
71923 , TRUNC(SYSDATE)
71924 , xla_environment_pkg.g_Usr_Id
71925 , xla_environment_pkg.g_Login_Id
71926 , TRUNC(SYSDATE)
71927 , xla_environment_pkg.g_Prog_Appl_Id
71928 , xla_environment_pkg.g_Prog_Id
71929 , xla_environment_pkg.g_Req_Id
71930 FROM (
71931 SELECT xet.event_id event_id
71932 , 0 line_number
71933 , CASE r
71934 WHEN 1 THEN 'AR_TRANSACTIONS_S_V'
71935 WHEN 2 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
71936 WHEN 3 THEN 'AR_BILL_TO_SITE_USES_S_V'
71937 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
71938 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
71939 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
71940 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
71941 WHEN 8 THEN 'AR_TRANSACTIONS_S_V'
71942 WHEN 9 THEN 'AR_TRANSACTIONS_S_V'
71943
71944 ELSE null
71945 END object_name
71946 , CASE r
71947 WHEN 1 THEN 'HEADER'
71948 WHEN 2 THEN 'HEADER'
71949 WHEN 3 THEN 'HEADER'
71950 WHEN 4 THEN 'HEADER'
71951 WHEN 5 THEN 'HEADER'
71952 WHEN 6 THEN 'HEADER'
71953 WHEN 7 THEN 'HEADER'
71954 WHEN 8 THEN 'HEADER'
71955 WHEN 9 THEN 'HEADER'
71956
71957 ELSE null
71958 END object_type_code
71959 , CASE r
71960 WHEN 1 THEN '222'
71961 WHEN 2 THEN '222'
71962 WHEN 3 THEN '222'
71963 WHEN 4 THEN '222'
71964 WHEN 5 THEN '222'
71965 WHEN 6 THEN '222'
71966 WHEN 7 THEN '222'
71967 WHEN 8 THEN '222'
71968 WHEN 9 THEN '222'
71969
71970 ELSE null
71971 END source_application_id
71972 , 'S' source_type_code
71973 , CASE r
71974 WHEN 1 THEN 'TRX_RECEIVABLE_CCID'
71975 WHEN 2 THEN 'BILL_CUST_ACCOUNT_ID'
71976 WHEN 3 THEN 'BILL_USES_SITE_USE_ID'
71977 WHEN 4 THEN 'XLA_PARTY_TYPE'
71978 WHEN 5 THEN 'TRX_INVOICE_CURRENCY_CODE'
71979 WHEN 6 THEN 'TRX_INVOICING_RULE_ID'
71980 WHEN 7 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
71981 WHEN 8 THEN 'TRX_DOC_SEQUENCE_ID'
71982 WHEN 9 THEN 'TRX_DOC_SEQUENCE_VALUE'
71983
71984 ELSE null
71985 END source_code
71986 , CASE r
71987 WHEN 1 THEN TO_CHAR(h5.TRX_RECEIVABLE_CCID)
71988 WHEN 2 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
71989 WHEN 3 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
71990 WHEN 4 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
71991 WHEN 5 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
71992 WHEN 6 THEN TO_CHAR(h5.TRX_INVOICING_RULE_ID)
71993 WHEN 7 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
71994 WHEN 8 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
71995 WHEN 9 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
71996
71997 ELSE null
71998 END source_value
71999 , null source_meaning
72000 FROM xla_events_gt xet
72001 , AR_BILL_TO_CUSTOMERS_S_V h1
72002 , AR_BILL_TO_SITE_USES_S_V h2
72003 , AR_TRANSACTIONS_S_V h5
72004 ,(select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
72008 AND h2.event_id = h1.event_id
72005 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
72006 AND xet.event_class_code = C_EVENT_CLASS_CODE
72007 AND h1.event_id = xet.event_id
72009 AND h5.event_id = h1.event_id
72010
72011 )
72012 ;
72013 --
72014 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
72015
72016 trace
72017 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
72018 ,p_level => C_LEVEL_STATEMENT
72019 ,p_module => l_log_module);
72020
72021 END IF;
72022 --
72023
72024
72025
72026 --
72027 INSERT INTO xla_diag_sources --line2
72028 (
72029 event_id
72030 , ledger_id
72031 , sla_ledger_id
72032 , description_language
72033 , object_name
72034 , object_type_code
72035 , line_number
72036 , source_application_id
72037 , source_type_code
72038 , source_code
72039 , source_value
72040 , source_meaning
72041 , created_by
72042 , creation_date
72043 , last_update_date
72044 , last_updated_by
72045 , last_update_login
72046 , program_update_date
72047 , program_application_id
72048 , program_id
72049 , request_id
72050 )
72051 SELECT event_id
72052 , p_target_ledger_id
72053 , p_sla_ledger_id
72054 , p_language
72055 , object_name
72056 , object_type_code
72057 , line_number
72058 , source_application_id
72059 , source_type_code
72060 , source_code
72061 , SUBSTR(source_value,1,1996)
72062 , SUBSTR(source_meaning ,1,200)
72063 , xla_environment_pkg.g_Usr_Id
72064 , TRUNC(SYSDATE)
72065 , TRUNC(SYSDATE)
72066 , xla_environment_pkg.g_Usr_Id
72067 , xla_environment_pkg.g_Login_Id
72068 , TRUNC(SYSDATE)
72069 , xla_environment_pkg.g_Prog_Appl_Id
72070 , xla_environment_pkg.g_Prog_Id
72071 , xla_environment_pkg.g_Req_Id
72072 FROM (
72073 SELECT xet.event_id event_id
72074 , l4.line_number line_number
72075 , CASE r
72076 WHEN 1 THEN 'AR_CUST_TRX_LINES_L_V'
72077 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
72078 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
72079 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
72080 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
72081 WHEN 6 THEN 'AR_CUST_TRX_LINES_BASE_V'
72082 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
72083 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
72084 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
72085 WHEN 10 THEN 'AR_CUST_TRX_LINES_L_V'
72086
72087 ELSE null
72088 END object_name
72089 , CASE r
72090 WHEN 1 THEN 'LINE'
72091 WHEN 2 THEN 'LINE'
72092 WHEN 3 THEN 'LINE'
72093 WHEN 4 THEN 'LINE'
72094 WHEN 5 THEN 'LINE'
72095 WHEN 6 THEN 'LINE'
72096 WHEN 7 THEN 'LINE'
72097 WHEN 8 THEN 'LINE'
72098 WHEN 9 THEN 'LINE'
72099 WHEN 10 THEN 'LINE'
72100
72101 ELSE null
72102 END object_type_code
72103 , CASE r
72104 WHEN 1 THEN '222'
72105 WHEN 2 THEN '222'
72106 WHEN 3 THEN '222'
72107 WHEN 4 THEN '222'
72108 WHEN 5 THEN '222'
72109 WHEN 6 THEN '222'
72110 WHEN 7 THEN '222'
72111 WHEN 8 THEN '222'
72112 WHEN 9 THEN '222'
72113 WHEN 10 THEN '222'
72114
72115 ELSE null
72116 END source_application_id
72117 , 'S' source_type_code
72118 , CASE r
72119 WHEN 1 THEN 'TRX_LINE_DIST_CCID'
72120 WHEN 2 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
72121 WHEN 3 THEN 'TRX_LINE_DIST_ID'
72122 WHEN 4 THEN 'TRX_DISTRIBUTION_TYPE'
72123 WHEN 5 THEN 'TRX_LINE_DIST_AMT'
72124 WHEN 6 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
72125 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
72126 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
72127 WHEN 9 THEN 'TRX_LINE_ACCTD_AMT'
72128 WHEN 10 THEN 'TRX_TAX_LINE_ID'
72129
72130 ELSE null
72131 END source_code
72132 , CASE r
72133 WHEN 1 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
72134 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
72135 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
72136 WHEN 4 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
72137 WHEN 5 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
72138 WHEN 6 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
72139 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
72143
72140 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
72141 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
72142 WHEN 10 THEN TO_CHAR(l4.TRX_TAX_LINE_ID)
72144 ELSE null
72145 END source_value
72146 , null source_meaning
72147 FROM xla_events_gt xet
72148 , AR_CUST_TRX_LINES_BASE_V l3
72149 , AR_CUST_TRX_LINES_L_V l4
72150 , (select rownum r from all_objects where rownum <= 10 and owner = p_apps_owner)
72151 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
72152 AND xet.event_class_code = C_EVENT_CLASS_CODE
72153 AND l3.event_id = xet.event_id
72154 AND l4.event_id = l3.event_id
72155 AND l4.line_number = l3.line_number
72156
72157 )
72158 ;
72159 --
72160 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
72161
72162 trace
72163 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
72164 ,p_level => C_LEVEL_STATEMENT
72165 ,p_module => l_log_module);
72166
72167 END IF;
72168
72169
72170 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
72171 trace
72172 (p_msg => 'END of insert_sources_141'
72173 ,p_level => C_LEVEL_PROCEDURE
72174 ,p_module => l_log_module);
72175 END IF;
72176 EXCEPTION
72177 WHEN xla_exceptions_pkg.application_exception THEN
72178 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
72179 trace
72180 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
72181 ,p_level => C_LEVEL_EXCEPTION
72182 ,p_module => l_log_module);
72183 END IF;
72184 RAISE;
72185 WHEN OTHERS THEN
72186 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
72187 trace
72188 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
72189 ,p_level => C_LEVEL_EXCEPTION
72190 ,p_module => l_log_module);
72191 END IF;
72192 xla_exceptions_pkg.raise_message
72193 (p_location => 'XLA_00222_AAD_S_000009_PKG.insert_sources_141');
72194 END insert_sources_141;
72195 --
72196
72197 ---------------------------------------
72198 --
72199 -- PRIVATE FUNCTION
72200 -- EventClass_141
72201 --
72202 ----------------------------------------
72203 --
72204 FUNCTION EventClass_141
72205 (p_application_id IN NUMBER
72206 ,p_base_ledger_id IN NUMBER
72207 ,p_target_ledger_id IN NUMBER
72208 ,p_language IN VARCHAR2
72209 ,p_currency_code IN VARCHAR2
72210 ,p_sla_ledger_id IN NUMBER
72211 ,p_pad_start_date IN DATE
72212 ,p_pad_end_date IN DATE
72213 ,p_primary_ledger_id IN NUMBER)
72214 RETURN BOOLEAN IS
72215 --
72216 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DEBIT_MEMO_ALL';
72217 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DEBIT_MEMO';
72218
72219 l_calculate_acctd_flag VARCHAR2(1) :='N';
72220 l_calculate_g_l_flag VARCHAR2(1) :='N';
72221 --
72222 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72223 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72224 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
72225 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
72226 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72227 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
72228 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
72229 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72230 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
72231 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
72232 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72233 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72234 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72235 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72236 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
72237 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
72238 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
72239 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
72240 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
72241 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
72242 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
72243 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
72244 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
72245 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
72246 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
72247 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
72248
72249 l_event_id NUMBER;
72250 l_previous_event_id NUMBER;
72251 l_first_event_id NUMBER;
72255 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
72252 l_last_event_id NUMBER;
72253
72254 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
72256 --
72257 --
72258 l_result BOOLEAN := TRUE;
72259 l_rows NUMBER := 1000;
72260 l_event_type_name VARCHAR2(80) := 'All';
72261 l_event_class_name VARCHAR2(80) := 'Debit Memo';
72262 l_description VARCHAR2(4000);
72263 l_transaction_reversal NUMBER;
72264 l_ae_header_id NUMBER;
72265 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
72266 l_log_module VARCHAR2(240);
72267 --
72268 l_acct_reversal_source VARCHAR2(30);
72269 l_trx_reversal_source VARCHAR2(30);
72270
72271 l_continue_with_lines BOOLEAN := TRUE;
72272 --
72273 l_acc_rev_gl_date_source DATE; -- 4262811
72274 --
72275 type t_array_event_id is table of number index by binary_integer;
72276
72277 l_rec_array_event t_rec_array_event;
72278 l_null_rec_array_event t_rec_array_event;
72279 l_array_ae_header_id xla_number_array_type;
72280 l_actual_flag VARCHAR2(1) := NULL;
72281 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
72282 l_balance_type_code VARCHAR2(1) :=NULL;
72283 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
72284
72285 --
72286 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
72287 --
72288
72289 TYPE t_array_source_8 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_RECEIVABLE_CCID%TYPE INDEX BY BINARY_INTEGER;
72290 TYPE t_array_source_32 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
72291 TYPE t_array_source_33 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
72292 TYPE t_array_source_34 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
72293 TYPE t_array_source_39 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
72294 TYPE t_array_source_70 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICING_RULE_ID%TYPE INDEX BY BINARY_INTEGER;
72295 TYPE t_array_source_85 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
72296 TYPE t_array_source_86 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
72297 TYPE t_array_source_87 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
72298
72299 TYPE t_array_source_21 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
72300 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
72301 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
72302 TYPE t_array_source_37 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
72303 TYPE t_array_source_38 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
72304 TYPE t_array_source_40 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
72305 TYPE t_array_source_41 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
72306 TYPE t_array_source_42 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
72307 TYPE t_array_source_43 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
72308 TYPE t_array_source_57 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_TAX_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
72309
72310 l_array_source_8 t_array_source_8;
72311 l_array_source_32 t_array_source_32;
72312 l_array_source_33 t_array_source_33;
72313 l_array_source_34 t_array_source_34;
72314 l_array_source_39 t_array_source_39;
72315 l_array_source_70 t_array_source_70;
72316 l_array_source_85 t_array_source_85;
72317 l_array_source_86 t_array_source_86;
72318 l_array_source_87 t_array_source_87;
72319
72320 l_array_source_21 t_array_source_21;
72321 l_array_source_35 t_array_source_35;
72322 l_array_source_36 t_array_source_36;
72323 l_array_source_37 t_array_source_37;
72324 l_array_source_38 t_array_source_38;
72325 l_array_source_40 t_array_source_40;
72326 l_array_source_41 t_array_source_41;
72327 l_array_source_42 t_array_source_42;
72328 l_array_source_43 t_array_source_43;
72329 l_array_source_57 t_array_source_57;
72330
72331 --
72332 CURSOR header_cur
72333 IS
72334 SELECT /*+ leading(xet) cardinality(xet,1) */
72335 -- Event Class Code: DEBIT_MEMO
72336 xet.entity_id
72337 ,xet.legal_entity_id
72338 ,xet.entity_code
72339 ,xet.transaction_number
72340 ,xet.event_id
72341 ,xet.event_class_code
72342 ,xet.event_type_code
72343 ,xet.event_number
72344 ,xet.event_date
72345 ,xet.transaction_date
72346 ,xet.reference_num_1
72347 ,xet.reference_num_2
72348 ,xet.reference_num_3
72349 ,xet.reference_num_4
72350 ,xet.reference_char_1
72351 ,xet.reference_char_2
72352 ,xet.reference_char_3
72353 ,xet.reference_char_4
72354 ,xet.reference_date_1
72355 ,xet.reference_date_2
72356 ,xet.reference_date_3
72357 ,xet.reference_date_4
72361 , h1.BILL_CUST_ACCOUNT_ID source_32
72358 ,xet.event_created_by
72359 ,xet.budgetary_control_flag
72360 , h5.TRX_RECEIVABLE_CCID source_8
72362 , h2.BILL_USES_SITE_USE_ID source_33
72363 , h5.XLA_PARTY_TYPE source_34
72364 , h5.TRX_INVOICE_CURRENCY_CODE source_39
72365 , h5.TRX_INVOICING_RULE_ID source_70
72366 , h5.TRX_DOC_SEQUENCE_CATEGORY source_85
72367 , h5.TRX_DOC_SEQUENCE_ID source_86
72368 , h5.TRX_DOC_SEQUENCE_VALUE source_87
72369 FROM xla_events_gt xet
72370 , AR_BILL_TO_CUSTOMERS_S_V h1
72371 , AR_BILL_TO_SITE_USES_S_V h2
72372 , AR_TRANSACTIONS_S_V h5
72373 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
72374 and xet.event_class_code = C_EVENT_CLASS_CODE
72375 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
72376 AND h2.event_id = h1.event_id
72377 AND h5.event_id = h1.event_id
72378
72379 ORDER BY event_id
72380 ;
72381
72382
72383 --
72384 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
72385 IS
72386 SELECT /*+ leading(xet) cardinality(xet,1) */
72387 -- Event Class Code: DEBIT_MEMO
72388 xet.entity_id
72389 ,xet.legal_entity_id
72390 ,xet.entity_code
72391 ,xet.transaction_number
72392 ,xet.event_id
72393 ,xet.event_class_code
72394 ,xet.event_type_code
72395 ,xet.event_number
72396 ,xet.event_date
72397 ,xet.transaction_date
72398 ,xet.reference_num_1
72399 ,xet.reference_num_2
72400 ,xet.reference_num_3
72401 ,xet.reference_num_4
72402 ,xet.reference_char_1
72403 ,xet.reference_char_2
72404 ,xet.reference_char_3
72405 ,xet.reference_char_4
72406 ,xet.reference_date_1
72407 ,xet.reference_date_2
72408 ,xet.reference_date_3
72409 ,xet.reference_date_4
72410 ,xet.event_created_by
72411 ,xet.budgetary_control_flag
72412 , l3.LINE_NUMBER
72413 , l4.TRX_LINE_DIST_CCID source_21
72414 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_35
72415 , l4.TRX_LINE_DIST_ID source_36
72416 , l4.TRX_DISTRIBUTION_TYPE source_37
72417 , l4.TRX_LINE_DIST_AMT source_38
72418 , l3.TRX_LINE_CUR_CONVERSION_DATE source_40
72419 , l3.TRX_LINE_CUR_CONVERSION_RATE source_41
72420 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_42
72421 , l3.TRX_LINE_ACCTD_AMT source_43
72422 , l4.TRX_TAX_LINE_ID source_57
72423 FROM xla_events_gt xet
72424 , AR_CUST_TRX_LINES_BASE_V l3
72425 , AR_CUST_TRX_LINES_L_V l4
72426 WHERE xet.event_id between x_first_event_id and x_last_event_id
72427 and xet.event_date between p_pad_start_date and p_pad_end_date
72428 and xet.event_class_code = C_EVENT_CLASS_CODE
72429 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
72430 AND l4.event_id = l3.event_id
72431 AND l4.line_number = l3.line_number
72432 ;
72433
72434 --
72435 BEGIN
72436 IF g_log_enabled THEN
72437 l_log_module := C_DEFAULT_MODULE||'.EventClass_141';
72438 END IF;
72439 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
72440 trace
72441 (p_msg => 'BEGIN of EventClass_141'
72442 ,p_level => C_LEVEL_PROCEDURE
72443 ,p_module => l_log_module);
72444 END IF;
72445
72446 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
72447 trace
72448 (p_msg => 'p_application_id = '||p_application_id||
72449 ' - p_base_ledger_id = '||p_base_ledger_id||
72450 ' - p_target_ledger_id = '||p_target_ledger_id||
72451 ' - p_language = '||p_language||
72452 ' - p_currency_code = '||p_currency_code||
72453 ' - p_sla_ledger_id = '||p_sla_ledger_id
72454 ,p_level => C_LEVEL_STATEMENT
72455 ,p_module => l_log_module);
72456 END IF;
72457 --
72458 -- initialze arrays
72459 --
72460 g_array_event.DELETE;
72461 l_rec_array_event := l_null_rec_array_event;
72462 --
72463 --------------------------------------
72464 -- 4262811 Initialze MPA Line Number
72465 --------------------------------------
72466 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
72467
72468 --
72469
72470 --
72471 OPEN header_cur;
72472 --
72473 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
72474 trace
72475 (p_msg => 'SQL - FETCH header_cur'
72476 ,p_level => C_LEVEL_STATEMENT
72477 ,p_module => l_log_module);
72478 END IF;
72479 --
72480 LOOP
72481 FETCH header_cur BULK COLLECT INTO
72482 l_array_entity_id
72483 , l_array_legal_entity_id
72484 , l_array_entity_code
72485 , l_array_transaction_num
72486 , l_array_event_id
72487 , l_array_class_code
72488 , l_array_event_type
72489 , l_array_event_number
72490 , l_array_event_date
72491 , l_array_transaction_date
72492 , l_array_reference_num_1
72493 , l_array_reference_num_2
72494 , l_array_reference_num_3
72495 , l_array_reference_num_4
72496 , l_array_reference_char_1
72497 , l_array_reference_char_2
72498 , l_array_reference_char_3
72499 , l_array_reference_char_4
72500 , l_array_reference_date_1
72501 , l_array_reference_date_2
72502 , l_array_reference_date_3
72503 , l_array_reference_date_4
72504 , l_array_event_created_by
72508 , l_array_source_33
72505 , l_array_budgetary_control_flag
72506 , l_array_source_8
72507 , l_array_source_32
72509 , l_array_source_34
72510 , l_array_source_39
72511 , l_array_source_70
72512 , l_array_source_85
72513 , l_array_source_86
72514 , l_array_source_87
72515 LIMIT l_rows;
72516 --
72517 IF (C_LEVEL_EVENT >= g_log_level) THEN
72518 trace
72519 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
72520 ,p_level => C_LEVEL_EVENT
72521 ,p_module => l_log_module);
72522 END IF;
72523 --
72524 EXIT WHEN l_array_entity_id.COUNT = 0;
72525
72526 -- initialize arrays
72527 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
72528 XLA_AE_LINES_PKG.g_rec_lines := NULL;
72529
72530 --
72531 -- Bug 4458708
72532 --
72533 XLA_AE_LINES_PKG.g_LineNumber := 0;
72534
72535
72536 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
72537 g_last_hdr_idx := l_array_event_id.LAST;
72538 --
72539 -- loop for the headers. Each iteration is for each header extract row
72540 -- fetched in header cursor
72541 --
72542 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
72543
72544 --
72545 -- set event info as cache for other routines to refer event attributes
72546 --
72547 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
72548 (p_application_id => p_application_id
72549 ,p_primary_ledger_id => p_primary_ledger_id
72550 ,p_base_ledger_id => p_base_ledger_id
72551 ,p_target_ledger_id => p_target_ledger_id
72552 ,p_entity_id => l_array_entity_id(hdr_idx)
72553 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
72554 ,p_entity_code => l_array_entity_code(hdr_idx)
72555 ,p_transaction_num => l_array_transaction_num(hdr_idx)
72556 ,p_event_id => l_array_event_id(hdr_idx)
72557 ,p_event_class_code => l_array_class_code(hdr_idx)
72558 ,p_event_type_code => l_array_event_type(hdr_idx)
72559 ,p_event_number => l_array_event_number(hdr_idx)
72560 ,p_event_date => l_array_event_date(hdr_idx)
72561 ,p_transaction_date => l_array_transaction_date(hdr_idx)
72562 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
72563 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
72564 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
72565 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
72566 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
72567 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
72568 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
72569 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
72570 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
72571 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
72572 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
72573 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
72574 ,p_event_created_by => l_array_event_created_by(hdr_idx)
72575 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
72576
72577 --
72578 -- set the status of entry to C_VALID (0)
72579 --
72580 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
72581
72582 --
72583 -- initialize a row for ae header
72584 --
72585 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
72586
72587 l_event_id := l_array_event_id(hdr_idx);
72588
72589 --
72590 -- storing the hdr_idx for event. May be used by line cursor.
72591 --
72592 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
72593
72594 --
72595 -- store sources from header extract. This can be improved to
72596 -- store only those sources from header extract that may be used in lines
72597 --
72598
72599 g_array_event(l_event_id).array_value_num('source_8') := l_array_source_8(hdr_idx);
72600 g_array_event(l_event_id).array_value_num('source_32') := l_array_source_32(hdr_idx);
72601 g_array_event(l_event_id).array_value_num('source_33') := l_array_source_33(hdr_idx);
72602 g_array_event(l_event_id).array_value_char('source_34') := l_array_source_34(hdr_idx);
72603 g_array_event(l_event_id).array_value_char('source_39') := l_array_source_39(hdr_idx);
72604 g_array_event(l_event_id).array_value_num('source_70') := l_array_source_70(hdr_idx);
72605 g_array_event(l_event_id).array_value_char('source_85') := l_array_source_85(hdr_idx);
72606 g_array_event(l_event_id).array_value_num('source_86') := l_array_source_86(hdr_idx);
72607 g_array_event(l_event_id).array_value_num('source_87') := l_array_source_87(hdr_idx);
72608
72609 --
72610 -- initilaize the status of ae headers for diffrent balance types
72611 -- the status is initialised to C_NOT_CREATED (2)
72612 --
72613 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
72614 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
72615 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
72616
72617 --
72618 -- call api to validate and store accounting attributes for header
72619 --
72620
72624 l_acc_rev_gl_date_source := NULL;
72621 ------------------------------------------------------------
72622 -- Accrual Reversal : to get date for Standard Source (NONE)
72623 ------------------------------------------------------------
72625
72626 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
72627 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_85');
72628 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
72629 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_86');
72630 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
72631 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_87');
72632 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
72633 l_rec_acct_attrs.array_date_value(4) :=
72634 xla_ae_sources_pkg.GetSystemSourceDate(
72635 p_source_code => 'XLA_EVENT_DATE'
72636 , p_source_type_code => 'Y'
72637 , p_source_application_id => 602
72638 );
72639
72640
72641 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
72642
72643 XLA_AE_HEADER_PKG.SetJeCategoryName;
72644
72645 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
72646 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
72647 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
72648 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
72649 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
72650
72651
72652 -- No header level analytical criteria
72653
72654 --
72655 --accounting attribute enhancement, bug 3612931
72656 --
72657 l_trx_reversal_source := SUBSTR(NULL, 1,30);
72658
72659 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
72660 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
72661
72662 xla_accounting_err_pkg.build_message
72663 (p_appli_s_name => 'XLA'
72664 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
72665 ,p_token_1 => 'ACCT_ATTR_NAME'
72666 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
72667 ,p_token_2 => 'PRODUCT_NAME'
72668 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
72669 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
72670 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
72671 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
72672
72673 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
72674 --
72675 -- following sets the accounting attributes needed to reverse
72676 -- accounting for a distributeion
72677 --
72678 xla_ae_lines_pkg.SetTrxReversalAttrs
72679 (p_event_id => l_event_id
72680 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
72681 ,p_trx_reversal_source => l_trx_reversal_source);
72682
72683 END IF;
72684
72685
72686 ----------------------------------------------------------------
72687 -- 4262811 - update the header statuses to invalid in need be
72688 ----------------------------------------------------------------
72689 --
72690 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
72691
72692
72693 -----------------------------------------------
72694 -- No accrual reversal for the event class/type
72695 -----------------------------------------------
72696 ----------------------------------------------------------------
72697
72698 --
72699 -- this ends the header loop iteration for one bulk fetch
72700 --
72701 END LOOP;
72702
72703 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
72704 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
72705
72706 --
72707 -- insert dummy rows into lines gt table that were created due to
72708 -- transaction reversals
72709 --
72710 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
72711 l_result := XLA_AE_LINES_PKG.InsertLines;
72712 END IF;
72713
72714 --
72715 -- reset the temp_line_num for each set of events fetched from header
72716 -- cursor rather than doing it for each new event in line cursor
72717 -- Bug 3939231
72718 --
72719 xla_ae_lines_pkg.g_temp_line_num := 0;
72720
72721
72722
72723 --
72724 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
72725 --
72726 --
72727 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
72728
72729 trace
72730 (p_msg => 'SQL - FETCH line_cur'
72731 ,p_level => C_LEVEL_STATEMENT
72732 ,p_module => l_log_module);
72733
72734 END IF;
72735 --
72736 --
72737 LOOP
72738 --
72739 FETCH line_cur BULK COLLECT INTO
72740 l_array_entity_id
72741 , l_array_legal_entity_id
72742 , l_array_entity_code
72743 , l_array_transaction_num
72744 , l_array_event_id
72745 , l_array_class_code
72746 , l_array_event_type
72747 , l_array_event_number
72751 , l_array_reference_num_2
72748 , l_array_event_date
72749 , l_array_transaction_date
72750 , l_array_reference_num_1
72752 , l_array_reference_num_3
72753 , l_array_reference_num_4
72754 , l_array_reference_char_1
72755 , l_array_reference_char_2
72756 , l_array_reference_char_3
72757 , l_array_reference_char_4
72758 , l_array_reference_date_1
72759 , l_array_reference_date_2
72760 , l_array_reference_date_3
72761 , l_array_reference_date_4
72762 , l_array_event_created_by
72763 , l_array_budgetary_control_flag
72764 , l_array_extract_line_num
72765 , l_array_source_21
72766 , l_array_source_35
72767 , l_array_source_36
72768 , l_array_source_37
72769 , l_array_source_38
72770 , l_array_source_40
72771 , l_array_source_41
72772 , l_array_source_42
72773 , l_array_source_43
72774 , l_array_source_57
72775 LIMIT l_rows;
72776
72777 --
72778 IF (C_LEVEL_EVENT >= g_log_level) THEN
72779 trace
72780 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
72781 ,p_level => C_LEVEL_EVENT
72782 ,p_module => l_log_module);
72783 END IF;
72784 --
72785 EXIT WHEN l_array_entity_id.count = 0;
72786
72787 XLA_AE_LINES_PKG.g_rec_lines := null;
72788
72789 --
72790 -- Bug 4458708
72791 --
72792 XLA_AE_LINES_PKG.g_LineNumber := 0;
72793 --
72794 --
72795
72796 FOR Idx IN 1..l_array_event_id.count LOOP
72797 --
72798 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
72799 --
72800 l_event_id := l_array_event_id(idx); -- 5648433
72801
72802 --
72803 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
72804 --
72805
72806 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
72807 (g_array_event(l_event_id).array_value_num('header_index'))
72808 ,'N'
72809 ) <> 'Y'
72810 THEN
72811 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
72812 trace
72813 (p_msg => 'Trancaction revesal option is not Y '
72814 ,p_level => C_LEVEL_STATEMENT
72815 ,p_module => l_log_module);
72816 END IF;
72817
72818 --
72819 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
72820 --
72821 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
72822 --
72823 -- set event info as cache for other routines to refer event attributes
72824 --
72825
72826 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
72827 l_previous_event_id := l_event_id;
72828
72829 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
72830 (p_application_id => p_application_id
72831 ,p_primary_ledger_id => p_primary_ledger_id
72832 ,p_base_ledger_id => p_base_ledger_id
72833 ,p_target_ledger_id => p_target_ledger_id
72834 ,p_entity_id => l_array_entity_id(Idx)
72835 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
72836 ,p_entity_code => l_array_entity_code(Idx)
72837 ,p_transaction_num => l_array_transaction_num(Idx)
72838 ,p_event_id => l_array_event_id(Idx)
72839 ,p_event_class_code => l_array_class_code(Idx)
72840 ,p_event_type_code => l_array_event_type(Idx)
72841 ,p_event_number => l_array_event_number(Idx)
72842 ,p_event_date => l_array_event_date(Idx)
72843 ,p_transaction_date => l_array_transaction_date(Idx)
72844 ,p_reference_num_1 => l_array_reference_num_1(Idx)
72845 ,p_reference_num_2 => l_array_reference_num_2(Idx)
72846 ,p_reference_num_3 => l_array_reference_num_3(Idx)
72847 ,p_reference_num_4 => l_array_reference_num_4(Idx)
72848 ,p_reference_char_1 => l_array_reference_char_1(Idx)
72849 ,p_reference_char_2 => l_array_reference_char_2(Idx)
72850 ,p_reference_char_3 => l_array_reference_char_3(Idx)
72851 ,p_reference_char_4 => l_array_reference_char_4(Idx)
72852 ,p_reference_date_1 => l_array_reference_date_1(Idx)
72853 ,p_reference_date_2 => l_array_reference_date_2(Idx)
72854 ,p_reference_date_3 => l_array_reference_date_3(Idx)
72855 ,p_reference_date_4 => l_array_reference_date_4(Idx)
72856 ,p_event_created_by => l_array_event_created_by(Idx)
72857 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
72858 --
72859 END IF;
72860
72861
72862
72863 --
72864 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
72865
72866 l_acct_reversal_source := SUBSTR(NULL, 1,30);
72867
72868 IF l_continue_with_lines THEN
72869 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
72870 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
72871
72872 xla_accounting_err_pkg.build_message
72873 (p_appli_s_name => 'XLA'
72874 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
72875 ,p_token_1 => 'LINE_NUMBER'
72879 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
72876 ,p_value_1 => l_array_extract_line_num(Idx)
72877 ,p_token_2 => 'PRODUCT_NAME'
72878 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
72880 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
72881 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
72882
72883 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
72884 --
72885 -- following sets the accounting attributes needed to reverse
72886 -- accounting for a distributeion
72887 --
72888
72889 --
72890 -- 5217187
72891 --
72892 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
72893 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
72894 g_array_event(l_event_id).array_value_num('header_index'));
72895 --
72896 --
72897
72898 -- No reversal code generated
72899
72900 xla_ae_lines_pkg.SetAcctReversalAttrs
72901 (p_event_id => l_event_id
72902 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
72903 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72904 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
72905 END IF;
72906
72907 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
72908 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
72909
72910 --
72911 AcctLineType_53 (
72912 p_application_id => p_application_id
72913 ,p_event_id => l_event_id
72914 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72915 ,p_calculate_g_l_flag => l_calculate_g_l_flag
72916 ,p_actual_flag => l_actual_flag
72917 ,p_balance_type_code => l_balance_type_code
72918 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
72919
72920 , p_source_21 => l_array_source_21(Idx)
72921 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
72922 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
72923 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
72924 , p_source_35 => l_array_source_35(Idx)
72925 , p_source_36 => l_array_source_36(Idx)
72926 , p_source_37 => l_array_source_37(Idx)
72927 , p_source_38 => l_array_source_38(Idx)
72928 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
72929 , p_source_40 => l_array_source_40(Idx)
72930 , p_source_41 => l_array_source_41(Idx)
72931 , p_source_42 => l_array_source_42(Idx)
72932 , p_source_43 => l_array_source_43(Idx)
72933 , p_source_57 => l_array_source_57(Idx)
72934 );
72935 If(l_balance_type_code = 'A') THEN
72936 l_actual_gain_loss_ref := l_gain_or_loss_ref;
72937 END IF;
72938
72939 --
72940
72941
72942 --
72943 AcctLineType_54 (
72944 p_application_id => p_application_id
72945 ,p_event_id => l_event_id
72946 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72947 ,p_calculate_g_l_flag => l_calculate_g_l_flag
72948 ,p_actual_flag => l_actual_flag
72949 ,p_balance_type_code => l_balance_type_code
72950 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
72951
72952 , p_source_21 => l_array_source_21(Idx)
72953 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
72954 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
72955 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
72956 , p_source_35 => l_array_source_35(Idx)
72957 , p_source_36 => l_array_source_36(Idx)
72958 , p_source_37 => l_array_source_37(Idx)
72959 , p_source_38 => l_array_source_38(Idx)
72960 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
72961 , p_source_40 => l_array_source_40(Idx)
72962 , p_source_41 => l_array_source_41(Idx)
72963 , p_source_42 => l_array_source_42(Idx)
72964 , p_source_43 => l_array_source_43(Idx)
72965 , p_source_57 => l_array_source_57(Idx)
72966 );
72967 If(l_balance_type_code = 'A') THEN
72968 l_actual_gain_loss_ref := l_gain_or_loss_ref;
72969 END IF;
72970
72971 --
72972
72973
72974 --
72975 AcctLineType_55 (
72976 p_application_id => p_application_id
72977 ,p_event_id => l_event_id
72978 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72979 ,p_calculate_g_l_flag => l_calculate_g_l_flag
72980 ,p_actual_flag => l_actual_flag
72981 ,p_balance_type_code => l_balance_type_code
72982 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
72983
72984 , p_source_21 => l_array_source_21(Idx)
72985 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
72986 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
72987 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
72988 , p_source_35 => l_array_source_35(Idx)
72989 , p_source_36 => l_array_source_36(Idx)
72990 , p_source_37 => l_array_source_37(Idx)
72991 , p_source_38 => l_array_source_38(Idx)
72992 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
72993 , p_source_40 => l_array_source_40(Idx)
72994 , p_source_41 => l_array_source_41(Idx)
72995 , p_source_42 => l_array_source_42(Idx)
72996 , p_source_43 => l_array_source_43(Idx)
72997 , p_source_57 => l_array_source_57(Idx)
72998 );
72999 If(l_balance_type_code = 'A') THEN
73003 --
73000 l_actual_gain_loss_ref := l_gain_or_loss_ref;
73001 END IF;
73002
73004
73005
73006 --
73007 AcctLineType_56 (
73008 p_application_id => p_application_id
73009 ,p_event_id => l_event_id
73010 ,p_calculate_acctd_flag => l_calculate_acctd_flag
73011 ,p_calculate_g_l_flag => l_calculate_g_l_flag
73012 ,p_actual_flag => l_actual_flag
73013 ,p_balance_type_code => l_balance_type_code
73014 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
73015
73016 , p_source_21 => l_array_source_21(Idx)
73017 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
73018 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
73019 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
73020 , p_source_35 => l_array_source_35(Idx)
73021 , p_source_36 => l_array_source_36(Idx)
73022 , p_source_37 => l_array_source_37(Idx)
73023 , p_source_38 => l_array_source_38(Idx)
73024 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
73025 , p_source_40 => l_array_source_40(Idx)
73026 , p_source_41 => l_array_source_41(Idx)
73027 , p_source_42 => l_array_source_42(Idx)
73028 , p_source_43 => l_array_source_43(Idx)
73029 , p_source_57 => l_array_source_57(Idx)
73030 );
73031 If(l_balance_type_code = 'A') THEN
73032 l_actual_gain_loss_ref := l_gain_or_loss_ref;
73033 END IF;
73034
73035 --
73036
73037
73038 --
73039 AcctLineType_57 (
73040 p_application_id => p_application_id
73041 ,p_event_id => l_event_id
73042 ,p_calculate_acctd_flag => l_calculate_acctd_flag
73043 ,p_calculate_g_l_flag => l_calculate_g_l_flag
73044 ,p_actual_flag => l_actual_flag
73045 ,p_balance_type_code => l_balance_type_code
73046 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
73047
73048 , p_source_21 => l_array_source_21(Idx)
73049 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
73050 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
73051 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
73052 , p_source_35 => l_array_source_35(Idx)
73053 , p_source_36 => l_array_source_36(Idx)
73054 , p_source_37 => l_array_source_37(Idx)
73055 , p_source_38 => l_array_source_38(Idx)
73056 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
73057 , p_source_40 => l_array_source_40(Idx)
73058 , p_source_41 => l_array_source_41(Idx)
73059 , p_source_42 => l_array_source_42(Idx)
73060 , p_source_43 => l_array_source_43(Idx)
73061 , p_source_57 => l_array_source_57(Idx)
73062 );
73063 If(l_balance_type_code = 'A') THEN
73064 l_actual_gain_loss_ref := l_gain_or_loss_ref;
73065 END IF;
73066
73067 --
73068
73069
73070 --
73071 AcctLineType_58 (
73072 p_application_id => p_application_id
73073 ,p_event_id => l_event_id
73074 ,p_calculate_acctd_flag => l_calculate_acctd_flag
73075 ,p_calculate_g_l_flag => l_calculate_g_l_flag
73076 ,p_actual_flag => l_actual_flag
73077 ,p_balance_type_code => l_balance_type_code
73078 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
73079
73080 , p_source_21 => l_array_source_21(Idx)
73081 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
73082 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
73083 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
73084 , p_source_35 => l_array_source_35(Idx)
73085 , p_source_36 => l_array_source_36(Idx)
73086 , p_source_37 => l_array_source_37(Idx)
73087 , p_source_38 => l_array_source_38(Idx)
73088 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
73089 , p_source_40 => l_array_source_40(Idx)
73090 , p_source_41 => l_array_source_41(Idx)
73091 , p_source_42 => l_array_source_42(Idx)
73092 , p_source_43 => l_array_source_43(Idx)
73093 , p_source_57 => l_array_source_57(Idx)
73094 );
73095 If(l_balance_type_code = 'A') THEN
73096 l_actual_gain_loss_ref := l_gain_or_loss_ref;
73097 END IF;
73098
73099 --
73100
73101
73102 --
73103 AcctLineType_59 (
73104 p_application_id => p_application_id
73105 ,p_event_id => l_event_id
73106 ,p_calculate_acctd_flag => l_calculate_acctd_flag
73107 ,p_calculate_g_l_flag => l_calculate_g_l_flag
73108 ,p_actual_flag => l_actual_flag
73109 ,p_balance_type_code => l_balance_type_code
73110 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
73111
73112 , p_source_21 => l_array_source_21(Idx)
73113 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
73114 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
73115 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
73116 , p_source_35 => l_array_source_35(Idx)
73117 , p_source_36 => l_array_source_36(Idx)
73118 , p_source_37 => l_array_source_37(Idx)
73119 , p_source_38 => l_array_source_38(Idx)
73120 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
73121 , p_source_40 => l_array_source_40(Idx)
73122 , p_source_41 => l_array_source_41(Idx)
73123 , p_source_42 => l_array_source_42(Idx)
73124 , p_source_43 => l_array_source_43(Idx)
73125 , p_source_57 => l_array_source_57(Idx)
73126 );
73127 If(l_balance_type_code = 'A') THEN
73128 l_actual_gain_loss_ref := l_gain_or_loss_ref;
73129 END IF;
73130
73131 --
73132
73133
73134 --
73135 AcctLineType_89 (
73139 ,p_calculate_g_l_flag => l_calculate_g_l_flag
73136 p_application_id => p_application_id
73137 ,p_event_id => l_event_id
73138 ,p_calculate_acctd_flag => l_calculate_acctd_flag
73140 ,p_actual_flag => l_actual_flag
73141 ,p_balance_type_code => l_balance_type_code
73142 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
73143
73144 , p_source_8 => g_array_event(l_event_id).array_value_num('source_8')
73145 , p_source_21 => l_array_source_21(Idx)
73146 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
73147 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
73148 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
73149 , p_source_35 => l_array_source_35(Idx)
73150 , p_source_36 => l_array_source_36(Idx)
73151 , p_source_37 => l_array_source_37(Idx)
73152 , p_source_38 => l_array_source_38(Idx)
73153 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
73154 , p_source_40 => l_array_source_40(Idx)
73155 , p_source_41 => l_array_source_41(Idx)
73156 , p_source_42 => l_array_source_42(Idx)
73157 , p_source_43 => l_array_source_43(Idx)
73158 , p_source_57 => l_array_source_57(Idx)
73159 , p_source_70 => g_array_event(l_event_id).array_value_num('source_70')
73160 );
73161 If(l_balance_type_code = 'A') THEN
73162 l_actual_gain_loss_ref := l_gain_or_loss_ref;
73163 END IF;
73164
73165 --
73166
73167 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
73168 -- or secondary ledger that has different currency with primary
73169 -- or alc that is calculated by sla
73170 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
73171 (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'))
73172
73173 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
73174 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
73175 AND (l_actual_flag = 'A')) THEN
73176 XLA_AE_LINES_PKG.CreateGainOrLossLines(
73177 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
73178 ,p_application_id => p_application_id
73179 ,p_amb_context_code => 'DEFAULT'
73180 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
73181 ,p_event_class_code => C_EVENT_CLASS_CODE
73182 ,p_event_type_code => C_EVENT_TYPE_CODE
73183
73184 ,p_gain_ccid => -1
73185 ,p_loss_ccid => -1
73186
73187 ,p_actual_flag => l_actual_flag
73188 ,p_enc_flag => null
73189 ,p_actual_g_l_ref => l_actual_gain_loss_ref
73190 ,p_enc_g_l_ref => null
73191 );
73192 END IF;
73193 END IF;
73194 END IF;
73195
73196 ELSE
73197 --
73198 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
73199 --
73200 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73201 trace
73202 (p_msg => 'Trancaction revesal option is Y'
73203 ,p_level => C_LEVEL_STATEMENT
73204 ,p_module => l_log_module);
73205 END IF;
73206 END IF;
73207
73208 END LOOP;
73209 l_result := XLA_AE_LINES_PKG.InsertLines ;
73210 end loop;
73211 close line_cur;
73212
73213
73214 --
73215 -- insert headers into xla_ae_headers_gt table
73216 --
73217 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
73218
73219 -- insert into errors table here.
73220
73221 END LOOP;
73222
73223 --
73224 -- 4865292
73225 --
73226 -- Compare g_hdr_extract_count with event count in
73227 -- CreateHeadersAndLines.
73228 --
73229 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
73230
73231 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73232 trace (p_msg => '# rows extracted from header extract objects '
73233 || ' (running total): '
73234 || g_hdr_extract_count
73235 ,p_level => C_LEVEL_STATEMENT
73236 ,p_module => l_log_module);
73237 END IF;
73238
73239 CLOSE header_cur;
73240 --
73241
73242 --
73243 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
73244 trace
73245 (p_msg => 'END of EventClass_141'
73246 ,p_level => C_LEVEL_PROCEDURE
73247 ,p_module => l_log_module);
73248 END IF;
73249 --
73250 RETURN l_result;
73251 EXCEPTION
73252 WHEN xla_exceptions_pkg.application_exception THEN
73253
73254 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
73255
73256
73257 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
73258
73259 RAISE;
73260
73261 WHEN NO_DATA_FOUND THEN
73262
73263 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
73264 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
73265
73266 FOR header_record IN header_cur
73267 LOOP
73268 l_array_header_events(header_record.event_id) := header_record.event_id;
73269 END LOOP;
73270
73271 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
73272 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
73273
73277 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
73274 fnd_file.put_line(fnd_file.LOG, ' ');
73275 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
73276 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
73278
73279 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
73280 LOOP
73281 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
73282 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
73283 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
73284 END IF;
73285 END LOOP;
73286
73287 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
73288 fnd_file.put_line(fnd_file.LOG, ' ');
73289
73290
73291 xla_exceptions_pkg.raise_message
73292 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_141');
73293
73294
73295 WHEN OTHERS THEN
73296 xla_exceptions_pkg.raise_message
73297 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_141');
73298 END EventClass_141;
73299 --
73300
73301 ---------------------------------------
73302 --
73303 -- PRIVATE PROCEDURE
73304 -- insert_sources_142
73305 --
73306 ----------------------------------------
73307 --
73308 PROCEDURE insert_sources_142(
73309 p_target_ledger_id IN NUMBER
73310 , p_language IN VARCHAR2
73311 , p_sla_ledger_id IN NUMBER
73312 , p_pad_start_date IN DATE
73313 , p_pad_end_date IN DATE
73314 )
73315 IS
73316
73317 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DEPOSIT_ALL';
73318 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DEPOSIT';
73319 p_apps_owner VARCHAR2(30);
73320 l_log_module VARCHAR2(240);
73321 BEGIN
73322 IF g_log_enabled THEN
73323 l_log_module := C_DEFAULT_MODULE||'.insert_sources_142';
73324 END IF;
73325 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
73326
73327 trace
73328 (p_msg => 'BEGIN of insert_sources_142'
73329 ,p_level => C_LEVEL_PROCEDURE
73330 ,p_module => l_log_module);
73331
73332 END IF;
73333
73334 -- select APPS owner
73335 SELECT oracle_username
73336 INTO p_apps_owner
73337 FROM fnd_oracle_userid
73338 WHERE read_only_flag = 'U'
73339 ;
73340
73341 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73342 trace
73343 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
73344 ' - p_language = '||p_language||
73345 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
73346 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
73347 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
73348 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
73349 ,p_level => C_LEVEL_STATEMENT
73350 ,p_module => l_log_module);
73351 END IF;
73352
73353
73354 --
73355 INSERT INTO xla_diag_sources --hdr2
73356 (
73357 event_id
73358 , ledger_id
73359 , sla_ledger_id
73360 , description_language
73361 , object_name
73362 , object_type_code
73363 , line_number
73364 , source_application_id
73365 , source_type_code
73366 , source_code
73367 , source_value
73368 , source_meaning
73369 , created_by
73370 , creation_date
73371 , last_update_date
73372 , last_updated_by
73373 , last_update_login
73374 , program_update_date
73375 , program_application_id
73376 , program_id
73377 , request_id
73378 )
73379 SELECT
73380 event_id
73381 , p_target_ledger_id
73382 , p_sla_ledger_id
73383 , p_language
73384 , object_name
73385 , object_type_code
73386 , line_number
73387 , source_application_id
73388 , source_type_code
73389 , source_code
73390 , SUBSTR(source_value ,1,1996)
73391 , SUBSTR(source_meaning ,1,200)
73392 , xla_environment_pkg.g_Usr_Id
73393 , TRUNC(SYSDATE)
73394 , TRUNC(SYSDATE)
73395 , xla_environment_pkg.g_Usr_Id
73396 , xla_environment_pkg.g_Login_Id
73397 , TRUNC(SYSDATE)
73398 , xla_environment_pkg.g_Prog_Appl_Id
73399 , xla_environment_pkg.g_Prog_Id
73400 , xla_environment_pkg.g_Req_Id
73401 FROM (
73402 SELECT xet.event_id event_id
73403 , 0 line_number
73404 , CASE r
73405 WHEN 1 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
73406 WHEN 2 THEN 'AR_BILL_TO_SITE_USES_S_V'
73407 WHEN 3 THEN 'AR_TRANSACTIONS_S_V'
73408 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
73409 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
73410 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
73411 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
73412
73416 WHEN 1 THEN 'HEADER'
73413 ELSE null
73414 END object_name
73415 , CASE r
73417 WHEN 2 THEN 'HEADER'
73418 WHEN 3 THEN 'HEADER'
73419 WHEN 4 THEN 'HEADER'
73420 WHEN 5 THEN 'HEADER'
73421 WHEN 6 THEN 'HEADER'
73422 WHEN 7 THEN 'HEADER'
73423
73424 ELSE null
73425 END object_type_code
73426 , CASE r
73427 WHEN 1 THEN '222'
73428 WHEN 2 THEN '222'
73429 WHEN 3 THEN '222'
73430 WHEN 4 THEN '222'
73431 WHEN 5 THEN '222'
73432 WHEN 6 THEN '222'
73433 WHEN 7 THEN '222'
73434
73435 ELSE null
73436 END source_application_id
73437 , 'S' source_type_code
73438 , CASE r
73439 WHEN 1 THEN 'BILL_CUST_ACCOUNT_ID'
73440 WHEN 2 THEN 'BILL_USES_SITE_USE_ID'
73441 WHEN 3 THEN 'XLA_PARTY_TYPE'
73442 WHEN 4 THEN 'TRX_INVOICE_CURRENCY_CODE'
73443 WHEN 5 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
73444 WHEN 6 THEN 'TRX_DOC_SEQUENCE_ID'
73445 WHEN 7 THEN 'TRX_DOC_SEQUENCE_VALUE'
73446
73447 ELSE null
73448 END source_code
73449 , CASE r
73450 WHEN 1 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
73451 WHEN 2 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
73452 WHEN 3 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
73453 WHEN 4 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
73454 WHEN 5 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
73455 WHEN 6 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
73456 WHEN 7 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
73457
73458 ELSE null
73459 END source_value
73460 , null source_meaning
73461 FROM xla_events_gt xet
73462 , AR_BILL_TO_CUSTOMERS_S_V h1
73463 , AR_BILL_TO_SITE_USES_S_V h2
73464 , AR_TRANSACTIONS_S_V h5
73465 ,(select rownum r from all_objects where rownum <= 7 and owner = p_apps_owner)
73466 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
73467 AND xet.event_class_code = C_EVENT_CLASS_CODE
73468 AND h1.event_id = xet.event_id
73469 AND h2.event_id = h1.event_id
73470 AND h5.event_id = h1.event_id
73471
73472 )
73473 ;
73474 --
73475 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73476
73477 trace
73478 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
73479 ,p_level => C_LEVEL_STATEMENT
73480 ,p_module => l_log_module);
73481
73482 END IF;
73483 --
73484
73485
73486
73487 --
73488 INSERT INTO xla_diag_sources --line2
73489 (
73490 event_id
73491 , ledger_id
73492 , sla_ledger_id
73493 , description_language
73494 , object_name
73495 , object_type_code
73496 , line_number
73497 , source_application_id
73498 , source_type_code
73499 , source_code
73500 , source_value
73501 , source_meaning
73502 , created_by
73503 , creation_date
73504 , last_update_date
73505 , last_updated_by
73506 , last_update_login
73507 , program_update_date
73508 , program_application_id
73509 , program_id
73510 , request_id
73511 )
73512 SELECT event_id
73513 , p_target_ledger_id
73514 , p_sla_ledger_id
73515 , p_language
73516 , object_name
73517 , object_type_code
73518 , line_number
73519 , source_application_id
73520 , source_type_code
73521 , source_code
73522 , SUBSTR(source_value,1,1996)
73523 , SUBSTR(source_meaning ,1,200)
73524 , xla_environment_pkg.g_Usr_Id
73525 , TRUNC(SYSDATE)
73526 , TRUNC(SYSDATE)
73527 , xla_environment_pkg.g_Usr_Id
73528 , xla_environment_pkg.g_Login_Id
73529 , TRUNC(SYSDATE)
73530 , xla_environment_pkg.g_Prog_Appl_Id
73531 , xla_environment_pkg.g_Prog_Id
73532 , xla_environment_pkg.g_Req_Id
73533 FROM (
73534 SELECT xet.event_id event_id
73535 , l4.line_number line_number
73536 , CASE r
73537 WHEN 1 THEN 'AR_CUST_TRX_LINES_L_V'
73538 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
73539 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
73540 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
73541 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
73542 WHEN 6 THEN 'AR_CUST_TRX_LINES_BASE_V'
73543 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
73544 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
73545 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
73546
73547 ELSE null
73548 END object_name
73549 , CASE r
73553 WHEN 4 THEN 'LINE'
73550 WHEN 1 THEN 'LINE'
73551 WHEN 2 THEN 'LINE'
73552 WHEN 3 THEN 'LINE'
73554 WHEN 5 THEN 'LINE'
73555 WHEN 6 THEN 'LINE'
73556 WHEN 7 THEN 'LINE'
73557 WHEN 8 THEN 'LINE'
73558 WHEN 9 THEN 'LINE'
73559
73560 ELSE null
73561 END object_type_code
73562 , CASE r
73563 WHEN 1 THEN '222'
73564 WHEN 2 THEN '222'
73565 WHEN 3 THEN '222'
73566 WHEN 4 THEN '222'
73567 WHEN 5 THEN '222'
73568 WHEN 6 THEN '222'
73569 WHEN 7 THEN '222'
73570 WHEN 8 THEN '222'
73571 WHEN 9 THEN '222'
73572
73573 ELSE null
73574 END source_application_id
73575 , 'S' source_type_code
73576 , CASE r
73577 WHEN 1 THEN 'TRX_LINE_DIST_CCID'
73578 WHEN 2 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
73579 WHEN 3 THEN 'TRX_LINE_DIST_ID'
73580 WHEN 4 THEN 'TRX_DISTRIBUTION_TYPE'
73581 WHEN 5 THEN 'TRX_LINE_DIST_AMT'
73582 WHEN 6 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
73583 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
73584 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
73585 WHEN 9 THEN 'TRX_LINE_ACCTD_AMT'
73586
73587 ELSE null
73588 END source_code
73589 , CASE r
73590 WHEN 1 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
73591 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
73592 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
73593 WHEN 4 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
73594 WHEN 5 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
73595 WHEN 6 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
73596 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
73597 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
73598 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
73599
73600 ELSE null
73601 END source_value
73602 , null source_meaning
73603 FROM xla_events_gt xet
73604 , AR_CUST_TRX_LINES_BASE_V l3
73605 , AR_CUST_TRX_LINES_L_V l4
73606 , (select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
73607 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
73608 AND xet.event_class_code = C_EVENT_CLASS_CODE
73609 AND l3.event_id = xet.event_id
73610 AND l4.event_id = l3.event_id
73611 AND l4.line_number = l3.line_number
73612
73613 )
73614 ;
73615 --
73616 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73617
73618 trace
73619 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
73620 ,p_level => C_LEVEL_STATEMENT
73621 ,p_module => l_log_module);
73622
73623 END IF;
73624
73625
73626 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
73627 trace
73628 (p_msg => 'END of insert_sources_142'
73629 ,p_level => C_LEVEL_PROCEDURE
73630 ,p_module => l_log_module);
73631 END IF;
73632 EXCEPTION
73633 WHEN xla_exceptions_pkg.application_exception THEN
73634 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
73635 trace
73636 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
73637 ,p_level => C_LEVEL_EXCEPTION
73638 ,p_module => l_log_module);
73639 END IF;
73640 RAISE;
73641 WHEN OTHERS THEN
73642 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
73643 trace
73644 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
73645 ,p_level => C_LEVEL_EXCEPTION
73646 ,p_module => l_log_module);
73647 END IF;
73648 xla_exceptions_pkg.raise_message
73649 (p_location => 'XLA_00222_AAD_S_000009_PKG.insert_sources_142');
73650 END insert_sources_142;
73651 --
73652
73653 ---------------------------------------
73654 --
73655 -- PRIVATE FUNCTION
73656 -- EventClass_142
73657 --
73658 ----------------------------------------
73659 --
73660 FUNCTION EventClass_142
73661 (p_application_id IN NUMBER
73662 ,p_base_ledger_id IN NUMBER
73663 ,p_target_ledger_id IN NUMBER
73664 ,p_language IN VARCHAR2
73665 ,p_currency_code IN VARCHAR2
73666 ,p_sla_ledger_id IN NUMBER
73667 ,p_pad_start_date IN DATE
73668 ,p_pad_end_date IN DATE
73669 ,p_primary_ledger_id IN NUMBER)
73670 RETURN BOOLEAN IS
73671 --
73672 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DEPOSIT_ALL';
73673 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DEPOSIT';
73674
73675 l_calculate_acctd_flag VARCHAR2(1) :='N';
73676 l_calculate_g_l_flag VARCHAR2(1) :='N';
73677 --
73681 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
73678 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
73679 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
73680 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
73682 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
73683 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
73684 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
73685 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
73686 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
73687 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
73688 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
73689 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
73690 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
73691 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
73692 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
73693 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
73694 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
73695 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
73696 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
73697 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
73698 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
73699 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
73700 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
73701 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
73702 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
73703 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
73704
73705 l_event_id NUMBER;
73706 l_previous_event_id NUMBER;
73707 l_first_event_id NUMBER;
73708 l_last_event_id NUMBER;
73709
73710 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
73711 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
73712 --
73713 --
73714 l_result BOOLEAN := TRUE;
73715 l_rows NUMBER := 1000;
73716 l_event_type_name VARCHAR2(80) := 'All';
73717 l_event_class_name VARCHAR2(80) := 'Deposit';
73718 l_description VARCHAR2(4000);
73719 l_transaction_reversal NUMBER;
73720 l_ae_header_id NUMBER;
73721 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
73722 l_log_module VARCHAR2(240);
73723 --
73724 l_acct_reversal_source VARCHAR2(30);
73725 l_trx_reversal_source VARCHAR2(30);
73726
73727 l_continue_with_lines BOOLEAN := TRUE;
73728 --
73729 l_acc_rev_gl_date_source DATE; -- 4262811
73730 --
73731 type t_array_event_id is table of number index by binary_integer;
73732
73733 l_rec_array_event t_rec_array_event;
73734 l_null_rec_array_event t_rec_array_event;
73735 l_array_ae_header_id xla_number_array_type;
73736 l_actual_flag VARCHAR2(1) := NULL;
73737 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
73738 l_balance_type_code VARCHAR2(1) :=NULL;
73739 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
73740
73741 --
73742 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
73743 --
73744
73745 TYPE t_array_source_32 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
73746 TYPE t_array_source_33 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
73747 TYPE t_array_source_34 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
73748 TYPE t_array_source_39 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
73749 TYPE t_array_source_85 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
73750 TYPE t_array_source_86 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
73751 TYPE t_array_source_87 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
73752
73753 TYPE t_array_source_21 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
73754 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
73755 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
73756 TYPE t_array_source_37 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
73757 TYPE t_array_source_38 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
73758 TYPE t_array_source_40 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
73759 TYPE t_array_source_41 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
73760 TYPE t_array_source_42 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
73764 l_array_source_33 t_array_source_33;
73761 TYPE t_array_source_43 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
73762
73763 l_array_source_32 t_array_source_32;
73765 l_array_source_34 t_array_source_34;
73766 l_array_source_39 t_array_source_39;
73767 l_array_source_85 t_array_source_85;
73768 l_array_source_86 t_array_source_86;
73769 l_array_source_87 t_array_source_87;
73770
73771 l_array_source_21 t_array_source_21;
73772 l_array_source_35 t_array_source_35;
73773 l_array_source_36 t_array_source_36;
73774 l_array_source_37 t_array_source_37;
73775 l_array_source_38 t_array_source_38;
73776 l_array_source_40 t_array_source_40;
73777 l_array_source_41 t_array_source_41;
73778 l_array_source_42 t_array_source_42;
73779 l_array_source_43 t_array_source_43;
73780
73781 --
73782 CURSOR header_cur
73783 IS
73784 SELECT /*+ leading(xet) cardinality(xet,1) */
73785 -- Event Class Code: DEPOSIT
73786 xet.entity_id
73787 ,xet.legal_entity_id
73788 ,xet.entity_code
73789 ,xet.transaction_number
73790 ,xet.event_id
73791 ,xet.event_class_code
73792 ,xet.event_type_code
73793 ,xet.event_number
73794 ,xet.event_date
73795 ,xet.transaction_date
73796 ,xet.reference_num_1
73797 ,xet.reference_num_2
73798 ,xet.reference_num_3
73799 ,xet.reference_num_4
73800 ,xet.reference_char_1
73801 ,xet.reference_char_2
73802 ,xet.reference_char_3
73803 ,xet.reference_char_4
73804 ,xet.reference_date_1
73805 ,xet.reference_date_2
73806 ,xet.reference_date_3
73807 ,xet.reference_date_4
73808 ,xet.event_created_by
73809 ,xet.budgetary_control_flag
73810 , h1.BILL_CUST_ACCOUNT_ID source_32
73811 , h2.BILL_USES_SITE_USE_ID source_33
73812 , h5.XLA_PARTY_TYPE source_34
73813 , h5.TRX_INVOICE_CURRENCY_CODE source_39
73814 , h5.TRX_DOC_SEQUENCE_CATEGORY source_85
73815 , h5.TRX_DOC_SEQUENCE_ID source_86
73816 , h5.TRX_DOC_SEQUENCE_VALUE source_87
73817 FROM xla_events_gt xet
73818 , AR_BILL_TO_CUSTOMERS_S_V h1
73819 , AR_BILL_TO_SITE_USES_S_V h2
73820 , AR_TRANSACTIONS_S_V h5
73821 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
73822 and xet.event_class_code = C_EVENT_CLASS_CODE
73823 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
73824 AND h2.event_id = h1.event_id
73825 AND h5.event_id = h1.event_id
73826
73827 ORDER BY event_id
73828 ;
73829
73830
73831 --
73832 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
73833 IS
73834 SELECT /*+ leading(xet) cardinality(xet,1) */
73835 -- Event Class Code: DEPOSIT
73836 xet.entity_id
73837 ,xet.legal_entity_id
73838 ,xet.entity_code
73839 ,xet.transaction_number
73840 ,xet.event_id
73841 ,xet.event_class_code
73842 ,xet.event_type_code
73843 ,xet.event_number
73844 ,xet.event_date
73845 ,xet.transaction_date
73846 ,xet.reference_num_1
73847 ,xet.reference_num_2
73848 ,xet.reference_num_3
73849 ,xet.reference_num_4
73850 ,xet.reference_char_1
73851 ,xet.reference_char_2
73852 ,xet.reference_char_3
73853 ,xet.reference_char_4
73854 ,xet.reference_date_1
73855 ,xet.reference_date_2
73856 ,xet.reference_date_3
73857 ,xet.reference_date_4
73858 ,xet.event_created_by
73859 ,xet.budgetary_control_flag
73860 , l3.LINE_NUMBER
73861 , l4.TRX_LINE_DIST_CCID source_21
73862 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_35
73863 , l4.TRX_LINE_DIST_ID source_36
73864 , l4.TRX_DISTRIBUTION_TYPE source_37
73865 , l4.TRX_LINE_DIST_AMT source_38
73866 , l3.TRX_LINE_CUR_CONVERSION_DATE source_40
73867 , l3.TRX_LINE_CUR_CONVERSION_RATE source_41
73868 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_42
73869 , l3.TRX_LINE_ACCTD_AMT source_43
73870 FROM xla_events_gt xet
73871 , AR_CUST_TRX_LINES_BASE_V l3
73872 , AR_CUST_TRX_LINES_L_V l4
73873 WHERE xet.event_id between x_first_event_id and x_last_event_id
73874 and xet.event_date between p_pad_start_date and p_pad_end_date
73875 and xet.event_class_code = C_EVENT_CLASS_CODE
73876 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
73877 AND l4.event_id = l3.event_id
73878 AND l4.line_number = l3.line_number
73879 ;
73880
73881 --
73882 BEGIN
73883 IF g_log_enabled THEN
73884 l_log_module := C_DEFAULT_MODULE||'.EventClass_142';
73885 END IF;
73886 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
73887 trace
73888 (p_msg => 'BEGIN of EventClass_142'
73889 ,p_level => C_LEVEL_PROCEDURE
73890 ,p_module => l_log_module);
73891 END IF;
73892
73893 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73894 trace
73895 (p_msg => 'p_application_id = '||p_application_id||
73896 ' - p_base_ledger_id = '||p_base_ledger_id||
73897 ' - p_target_ledger_id = '||p_target_ledger_id||
73898 ' - p_language = '||p_language||
73899 ' - p_currency_code = '||p_currency_code||
73900 ' - p_sla_ledger_id = '||p_sla_ledger_id
73901 ,p_level => C_LEVEL_STATEMENT
73905 -- initialze arrays
73902 ,p_module => l_log_module);
73903 END IF;
73904 --
73906 --
73907 g_array_event.DELETE;
73908 l_rec_array_event := l_null_rec_array_event;
73909 --
73910 --------------------------------------
73911 -- 4262811 Initialze MPA Line Number
73912 --------------------------------------
73913 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
73914
73915 --
73916
73917 --
73918 OPEN header_cur;
73919 --
73920 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73921 trace
73922 (p_msg => 'SQL - FETCH header_cur'
73923 ,p_level => C_LEVEL_STATEMENT
73924 ,p_module => l_log_module);
73925 END IF;
73926 --
73927 LOOP
73928 FETCH header_cur BULK COLLECT INTO
73929 l_array_entity_id
73930 , l_array_legal_entity_id
73931 , l_array_entity_code
73932 , l_array_transaction_num
73933 , l_array_event_id
73934 , l_array_class_code
73935 , l_array_event_type
73936 , l_array_event_number
73937 , l_array_event_date
73938 , l_array_transaction_date
73939 , l_array_reference_num_1
73940 , l_array_reference_num_2
73941 , l_array_reference_num_3
73942 , l_array_reference_num_4
73943 , l_array_reference_char_1
73944 , l_array_reference_char_2
73945 , l_array_reference_char_3
73946 , l_array_reference_char_4
73947 , l_array_reference_date_1
73948 , l_array_reference_date_2
73949 , l_array_reference_date_3
73950 , l_array_reference_date_4
73951 , l_array_event_created_by
73952 , l_array_budgetary_control_flag
73953 , l_array_source_32
73954 , l_array_source_33
73955 , l_array_source_34
73956 , l_array_source_39
73957 , l_array_source_85
73958 , l_array_source_86
73959 , l_array_source_87
73960 LIMIT l_rows;
73961 --
73962 IF (C_LEVEL_EVENT >= g_log_level) THEN
73963 trace
73964 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
73965 ,p_level => C_LEVEL_EVENT
73966 ,p_module => l_log_module);
73967 END IF;
73968 --
73969 EXIT WHEN l_array_entity_id.COUNT = 0;
73970
73971 -- initialize arrays
73972 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
73973 XLA_AE_LINES_PKG.g_rec_lines := NULL;
73974
73975 --
73976 -- Bug 4458708
73977 --
73978 XLA_AE_LINES_PKG.g_LineNumber := 0;
73979
73980
73981 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
73982 g_last_hdr_idx := l_array_event_id.LAST;
73983 --
73984 -- loop for the headers. Each iteration is for each header extract row
73985 -- fetched in header cursor
73986 --
73987 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
73988
73989 --
73990 -- set event info as cache for other routines to refer event attributes
73991 --
73992 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
73993 (p_application_id => p_application_id
73994 ,p_primary_ledger_id => p_primary_ledger_id
73995 ,p_base_ledger_id => p_base_ledger_id
73996 ,p_target_ledger_id => p_target_ledger_id
73997 ,p_entity_id => l_array_entity_id(hdr_idx)
73998 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
73999 ,p_entity_code => l_array_entity_code(hdr_idx)
74000 ,p_transaction_num => l_array_transaction_num(hdr_idx)
74001 ,p_event_id => l_array_event_id(hdr_idx)
74002 ,p_event_class_code => l_array_class_code(hdr_idx)
74003 ,p_event_type_code => l_array_event_type(hdr_idx)
74004 ,p_event_number => l_array_event_number(hdr_idx)
74005 ,p_event_date => l_array_event_date(hdr_idx)
74006 ,p_transaction_date => l_array_transaction_date(hdr_idx)
74007 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
74008 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
74009 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
74010 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
74011 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
74012 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
74013 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
74014 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
74015 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
74016 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
74017 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
74018 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
74019 ,p_event_created_by => l_array_event_created_by(hdr_idx)
74020 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
74021
74022 --
74023 -- set the status of entry to C_VALID (0)
74024 --
74025 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
74026
74027 --
74028 -- initialize a row for ae header
74029 --
74030 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
74031
74032 l_event_id := l_array_event_id(hdr_idx);
74033
74034 --
74035 -- storing the hdr_idx for event. May be used by line cursor.
74036 --
74040 -- store sources from header extract. This can be improved to
74037 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
74038
74039 --
74041 -- store only those sources from header extract that may be used in lines
74042 --
74043
74044 g_array_event(l_event_id).array_value_num('source_32') := l_array_source_32(hdr_idx);
74045 g_array_event(l_event_id).array_value_num('source_33') := l_array_source_33(hdr_idx);
74046 g_array_event(l_event_id).array_value_char('source_34') := l_array_source_34(hdr_idx);
74047 g_array_event(l_event_id).array_value_char('source_39') := l_array_source_39(hdr_idx);
74048 g_array_event(l_event_id).array_value_char('source_85') := l_array_source_85(hdr_idx);
74049 g_array_event(l_event_id).array_value_num('source_86') := l_array_source_86(hdr_idx);
74050 g_array_event(l_event_id).array_value_num('source_87') := l_array_source_87(hdr_idx);
74051
74052 --
74053 -- initilaize the status of ae headers for diffrent balance types
74054 -- the status is initialised to C_NOT_CREATED (2)
74055 --
74056 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
74057 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
74058 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
74059
74060 --
74061 -- call api to validate and store accounting attributes for header
74062 --
74063
74064 ------------------------------------------------------------
74065 -- Accrual Reversal : to get date for Standard Source (NONE)
74066 ------------------------------------------------------------
74067 l_acc_rev_gl_date_source := NULL;
74068
74069 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
74070 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_85');
74071 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
74072 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_86');
74073 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
74074 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_87');
74075 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
74076 l_rec_acct_attrs.array_date_value(4) :=
74077 xla_ae_sources_pkg.GetSystemSourceDate(
74078 p_source_code => 'XLA_EVENT_DATE'
74079 , p_source_type_code => 'Y'
74080 , p_source_application_id => 602
74081 );
74082
74083
74084 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
74085
74086 XLA_AE_HEADER_PKG.SetJeCategoryName;
74087
74088 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
74089 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
74090 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
74091 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
74092 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
74093
74094
74095 -- No header level analytical criteria
74096
74097 --
74098 --accounting attribute enhancement, bug 3612931
74099 --
74100 l_trx_reversal_source := SUBSTR(NULL, 1,30);
74101
74102 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
74103 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
74104
74105 xla_accounting_err_pkg.build_message
74106 (p_appli_s_name => 'XLA'
74107 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
74108 ,p_token_1 => 'ACCT_ATTR_NAME'
74109 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
74110 ,p_token_2 => 'PRODUCT_NAME'
74111 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
74112 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
74113 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
74114 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
74115
74116 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
74117 --
74118 -- following sets the accounting attributes needed to reverse
74119 -- accounting for a distributeion
74120 --
74121 xla_ae_lines_pkg.SetTrxReversalAttrs
74122 (p_event_id => l_event_id
74123 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
74124 ,p_trx_reversal_source => l_trx_reversal_source);
74125
74126 END IF;
74127
74128
74129 ----------------------------------------------------------------
74130 -- 4262811 - update the header statuses to invalid in need be
74131 ----------------------------------------------------------------
74132 --
74133 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
74134
74135
74136 -----------------------------------------------
74137 -- No accrual reversal for the event class/type
74138 -----------------------------------------------
74139 ----------------------------------------------------------------
74140
74141 --
74142 -- this ends the header loop iteration for one bulk fetch
74143 --
74144 END LOOP;
74145
74146 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
74150 -- insert dummy rows into lines gt table that were created due to
74147 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
74148
74149 --
74151 -- transaction reversals
74152 --
74153 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
74154 l_result := XLA_AE_LINES_PKG.InsertLines;
74155 END IF;
74156
74157 --
74158 -- reset the temp_line_num for each set of events fetched from header
74159 -- cursor rather than doing it for each new event in line cursor
74160 -- Bug 3939231
74161 --
74162 xla_ae_lines_pkg.g_temp_line_num := 0;
74163
74164
74165
74166 --
74167 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
74168 --
74169 --
74170 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74171
74172 trace
74173 (p_msg => 'SQL - FETCH line_cur'
74174 ,p_level => C_LEVEL_STATEMENT
74175 ,p_module => l_log_module);
74176
74177 END IF;
74178 --
74179 --
74180 LOOP
74181 --
74182 FETCH line_cur BULK COLLECT INTO
74183 l_array_entity_id
74184 , l_array_legal_entity_id
74185 , l_array_entity_code
74186 , l_array_transaction_num
74187 , l_array_event_id
74188 , l_array_class_code
74189 , l_array_event_type
74190 , l_array_event_number
74191 , l_array_event_date
74192 , l_array_transaction_date
74193 , l_array_reference_num_1
74194 , l_array_reference_num_2
74195 , l_array_reference_num_3
74196 , l_array_reference_num_4
74197 , l_array_reference_char_1
74198 , l_array_reference_char_2
74199 , l_array_reference_char_3
74200 , l_array_reference_char_4
74201 , l_array_reference_date_1
74202 , l_array_reference_date_2
74203 , l_array_reference_date_3
74204 , l_array_reference_date_4
74205 , l_array_event_created_by
74206 , l_array_budgetary_control_flag
74207 , l_array_extract_line_num
74208 , l_array_source_21
74209 , l_array_source_35
74210 , l_array_source_36
74211 , l_array_source_37
74212 , l_array_source_38
74213 , l_array_source_40
74214 , l_array_source_41
74215 , l_array_source_42
74216 , l_array_source_43
74217 LIMIT l_rows;
74218
74219 --
74220 IF (C_LEVEL_EVENT >= g_log_level) THEN
74221 trace
74222 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
74223 ,p_level => C_LEVEL_EVENT
74224 ,p_module => l_log_module);
74225 END IF;
74226 --
74227 EXIT WHEN l_array_entity_id.count = 0;
74228
74229 XLA_AE_LINES_PKG.g_rec_lines := null;
74230
74231 --
74232 -- Bug 4458708
74233 --
74234 XLA_AE_LINES_PKG.g_LineNumber := 0;
74235 --
74236 --
74237
74238 FOR Idx IN 1..l_array_event_id.count LOOP
74239 --
74240 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
74241 --
74242 l_event_id := l_array_event_id(idx); -- 5648433
74243
74244 --
74245 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
74246 --
74247
74248 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
74249 (g_array_event(l_event_id).array_value_num('header_index'))
74250 ,'N'
74251 ) <> 'Y'
74252 THEN
74253 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74254 trace
74255 (p_msg => 'Trancaction revesal option is not Y '
74256 ,p_level => C_LEVEL_STATEMENT
74257 ,p_module => l_log_module);
74258 END IF;
74259
74260 --
74261 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
74262 --
74263 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
74264 --
74265 -- set event info as cache for other routines to refer event attributes
74266 --
74267
74268 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
74269 l_previous_event_id := l_event_id;
74270
74271 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
74272 (p_application_id => p_application_id
74273 ,p_primary_ledger_id => p_primary_ledger_id
74274 ,p_base_ledger_id => p_base_ledger_id
74275 ,p_target_ledger_id => p_target_ledger_id
74276 ,p_entity_id => l_array_entity_id(Idx)
74277 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
74278 ,p_entity_code => l_array_entity_code(Idx)
74279 ,p_transaction_num => l_array_transaction_num(Idx)
74280 ,p_event_id => l_array_event_id(Idx)
74281 ,p_event_class_code => l_array_class_code(Idx)
74282 ,p_event_type_code => l_array_event_type(Idx)
74283 ,p_event_number => l_array_event_number(Idx)
74284 ,p_event_date => l_array_event_date(Idx)
74285 ,p_transaction_date => l_array_transaction_date(Idx)
74286 ,p_reference_num_1 => l_array_reference_num_1(Idx)
74287 ,p_reference_num_2 => l_array_reference_num_2(Idx)
74288 ,p_reference_num_3 => l_array_reference_num_3(Idx)
74289 ,p_reference_num_4 => l_array_reference_num_4(Idx)
74290 ,p_reference_char_1 => l_array_reference_char_1(Idx)
74291 ,p_reference_char_2 => l_array_reference_char_2(Idx)
74292 ,p_reference_char_3 => l_array_reference_char_3(Idx)
74293 ,p_reference_char_4 => l_array_reference_char_4(Idx)
74294 ,p_reference_date_1 => l_array_reference_date_1(Idx)
74295 ,p_reference_date_2 => l_array_reference_date_2(Idx)
74296 ,p_reference_date_3 => l_array_reference_date_3(Idx)
74297 ,p_reference_date_4 => l_array_reference_date_4(Idx)
74298 ,p_event_created_by => l_array_event_created_by(Idx)
74299 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
74300 --
74301 END IF;
74302
74303
74304
74305 --
74306 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
74307
74308 l_acct_reversal_source := SUBSTR(NULL, 1,30);
74309
74310 IF l_continue_with_lines THEN
74311 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
74312 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
74313
74314 xla_accounting_err_pkg.build_message
74315 (p_appli_s_name => 'XLA'
74316 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
74317 ,p_token_1 => 'LINE_NUMBER'
74318 ,p_value_1 => l_array_extract_line_num(Idx)
74319 ,p_token_2 => 'PRODUCT_NAME'
74320 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
74321 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
74322 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
74323 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
74324
74325 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
74326 --
74327 -- following sets the accounting attributes needed to reverse
74328 -- accounting for a distributeion
74329 --
74330
74331 --
74332 -- 5217187
74333 --
74337 --
74334 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
74335 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
74336 g_array_event(l_event_id).array_value_num('header_index'));
74338 --
74339
74340 -- No reversal code generated
74341
74342 xla_ae_lines_pkg.SetAcctReversalAttrs
74343 (p_event_id => l_event_id
74344 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
74345 ,p_calculate_acctd_flag => l_calculate_acctd_flag
74346 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
74347 END IF;
74348
74349 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
74350 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
74351
74352 --
74353 AcctLineType_51 (
74354 p_application_id => p_application_id
74355 ,p_event_id => l_event_id
74356 ,p_calculate_acctd_flag => l_calculate_acctd_flag
74357 ,p_calculate_g_l_flag => l_calculate_g_l_flag
74358 ,p_actual_flag => l_actual_flag
74359 ,p_balance_type_code => l_balance_type_code
74360 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
74361
74362 , p_source_21 => l_array_source_21(Idx)
74363 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
74364 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
74365 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
74366 , p_source_35 => l_array_source_35(Idx)
74367 , p_source_36 => l_array_source_36(Idx)
74368 , p_source_37 => l_array_source_37(Idx)
74369 , p_source_38 => l_array_source_38(Idx)
74370 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
74371 , p_source_40 => l_array_source_40(Idx)
74372 , p_source_41 => l_array_source_41(Idx)
74373 , p_source_42 => l_array_source_42(Idx)
74374 , p_source_43 => l_array_source_43(Idx)
74375 );
74376 If(l_balance_type_code = 'A') THEN
74377 l_actual_gain_loss_ref := l_gain_or_loss_ref;
74378 END IF;
74379
74380 --
74381
74382
74383 --
74384 AcctLineType_52 (
74385 p_application_id => p_application_id
74386 ,p_event_id => l_event_id
74387 ,p_calculate_acctd_flag => l_calculate_acctd_flag
74388 ,p_calculate_g_l_flag => l_calculate_g_l_flag
74389 ,p_actual_flag => l_actual_flag
74390 ,p_balance_type_code => l_balance_type_code
74391 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
74392
74393 , p_source_21 => l_array_source_21(Idx)
74394 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
74395 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
74396 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
74397 , p_source_35 => l_array_source_35(Idx)
74398 , p_source_36 => l_array_source_36(Idx)
74399 , p_source_37 => l_array_source_37(Idx)
74400 , p_source_38 => l_array_source_38(Idx)
74401 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
74402 , p_source_40 => l_array_source_40(Idx)
74403 , p_source_41 => l_array_source_41(Idx)
74404 , p_source_42 => l_array_source_42(Idx)
74405 , p_source_43 => l_array_source_43(Idx)
74406 );
74407 If(l_balance_type_code = 'A') THEN
74408 l_actual_gain_loss_ref := l_gain_or_loss_ref;
74409 END IF;
74410
74411 --
74412
74413 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
74414 -- or secondary ledger that has different currency with primary
74415 -- or alc that is calculated by sla
74416 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
74417 (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'))
74418
74419 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
74420 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
74421 AND (l_actual_flag = 'A')) THEN
74422 XLA_AE_LINES_PKG.CreateGainOrLossLines(
74423 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
74424 ,p_application_id => p_application_id
74425 ,p_amb_context_code => 'DEFAULT'
74426 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
74427 ,p_event_class_code => C_EVENT_CLASS_CODE
74428 ,p_event_type_code => C_EVENT_TYPE_CODE
74429
74430 ,p_gain_ccid => -1
74431 ,p_loss_ccid => -1
74432
74433 ,p_actual_flag => l_actual_flag
74434 ,p_enc_flag => null
74435 ,p_actual_g_l_ref => l_actual_gain_loss_ref
74436 ,p_enc_g_l_ref => null
74437 );
74438 END IF;
74439 END IF;
74440 END IF;
74441
74442 ELSE
74443 --
74444 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
74445 --
74446 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74447 trace
74448 (p_msg => 'Trancaction revesal option is Y'
74449 ,p_level => C_LEVEL_STATEMENT
74450 ,p_module => l_log_module);
74451 END IF;
74452 END IF;
74453
74454 END LOOP;
74455 l_result := XLA_AE_LINES_PKG.InsertLines ;
74456 end loop;
74457 close line_cur;
74458
74459
74460 --
74461 -- insert headers into xla_ae_headers_gt table
74462 --
74463 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
74464
74465 -- insert into errors table here.
74466
74467 END LOOP;
74468
74469 --
74470 -- 4865292
74471 --
74472 -- Compare g_hdr_extract_count with event count in
74473 -- CreateHeadersAndLines.
74474 --
74478 trace (p_msg => '# rows extracted from header extract objects '
74475 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
74476
74477 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74479 || ' (running total): '
74480 || g_hdr_extract_count
74481 ,p_level => C_LEVEL_STATEMENT
74482 ,p_module => l_log_module);
74483 END IF;
74484
74485 CLOSE header_cur;
74486 --
74487
74488 --
74489 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
74490 trace
74491 (p_msg => 'END of EventClass_142'
74492 ,p_level => C_LEVEL_PROCEDURE
74493 ,p_module => l_log_module);
74494 END IF;
74495 --
74496 RETURN l_result;
74497 EXCEPTION
74498 WHEN xla_exceptions_pkg.application_exception THEN
74499
74500 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
74501
74502
74503 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
74504
74505 RAISE;
74506
74507 WHEN NO_DATA_FOUND THEN
74508
74509 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
74510 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
74511
74512 FOR header_record IN header_cur
74513 LOOP
74514 l_array_header_events(header_record.event_id) := header_record.event_id;
74515 END LOOP;
74516
74517 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
74518 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
74519
74520 fnd_file.put_line(fnd_file.LOG, ' ');
74521 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
74522 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
74523 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
74524
74525 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
74526 LOOP
74527 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
74528 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
74529 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
74530 END IF;
74531 END LOOP;
74532
74533 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
74534 fnd_file.put_line(fnd_file.LOG, ' ');
74535
74536
74537 xla_exceptions_pkg.raise_message
74538 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_142');
74539
74540
74541 WHEN OTHERS THEN
74542 xla_exceptions_pkg.raise_message
74543 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_142');
74544 END EventClass_142;
74545 --
74546
74547 ---------------------------------------
74548 --
74549 -- PRIVATE PROCEDURE
74550 -- insert_sources_143
74551 --
74552 ----------------------------------------
74553 --
74554 PROCEDURE insert_sources_143(
74555 p_target_ledger_id IN NUMBER
74556 , p_language IN VARCHAR2
74557 , p_sla_ledger_id IN NUMBER
74558 , p_pad_start_date IN DATE
74559 , p_pad_end_date IN DATE
74560 )
74561 IS
74562
74563 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'GUARANTEE_ALL';
74564 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'GUARANTEE';
74565 p_apps_owner VARCHAR2(30);
74566 l_log_module VARCHAR2(240);
74567 BEGIN
74568 IF g_log_enabled THEN
74569 l_log_module := C_DEFAULT_MODULE||'.insert_sources_143';
74570 END IF;
74571 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
74572
74573 trace
74574 (p_msg => 'BEGIN of insert_sources_143'
74575 ,p_level => C_LEVEL_PROCEDURE
74576 ,p_module => l_log_module);
74577
74578 END IF;
74579
74580 -- select APPS owner
74581 SELECT oracle_username
74582 INTO p_apps_owner
74583 FROM fnd_oracle_userid
74584 WHERE read_only_flag = 'U'
74585 ;
74586
74587 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74588 trace
74589 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
74590 ' - p_language = '||p_language||
74591 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
74592 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
74593 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
74594 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
74595 ,p_level => C_LEVEL_STATEMENT
74596 ,p_module => l_log_module);
74597 END IF;
74598
74599
74600 --
74601 INSERT INTO xla_diag_sources --hdr2
74602 (
74603 event_id
74604 , ledger_id
74605 , sla_ledger_id
74606 , description_language
74607 , object_name
74608 , object_type_code
74609 , line_number
74610 , source_application_id
74611 , source_type_code
74612 , source_code
74613 , source_value
74614 , source_meaning
74615 , created_by
74616 , creation_date
74617 , last_update_date
74618 , last_updated_by
74619 , last_update_login
74620 , program_update_date
74621 , program_application_id
74622 , program_id
74623 , request_id
74624 )
74625 SELECT
74626 event_id
74627 , p_target_ledger_id
74628 , p_sla_ledger_id
74629 , p_language
74630 , object_name
74631 , object_type_code
74632 , line_number
74636 , SUBSTR(source_value ,1,1996)
74633 , source_application_id
74634 , source_type_code
74635 , source_code
74637 , SUBSTR(source_meaning ,1,200)
74638 , xla_environment_pkg.g_Usr_Id
74639 , TRUNC(SYSDATE)
74640 , TRUNC(SYSDATE)
74641 , xla_environment_pkg.g_Usr_Id
74642 , xla_environment_pkg.g_Login_Id
74643 , TRUNC(SYSDATE)
74644 , xla_environment_pkg.g_Prog_Appl_Id
74645 , xla_environment_pkg.g_Prog_Id
74646 , xla_environment_pkg.g_Req_Id
74647 FROM (
74648 SELECT xet.event_id event_id
74649 , 0 line_number
74650 , CASE r
74651 WHEN 1 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
74652 WHEN 2 THEN 'AR_BILL_TO_SITE_USES_S_V'
74653 WHEN 3 THEN 'AR_TRANSACTIONS_S_V'
74654 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
74655 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
74656 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
74657 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
74658
74659 ELSE null
74660 END object_name
74661 , CASE r
74662 WHEN 1 THEN 'HEADER'
74663 WHEN 2 THEN 'HEADER'
74664 WHEN 3 THEN 'HEADER'
74665 WHEN 4 THEN 'HEADER'
74666 WHEN 5 THEN 'HEADER'
74667 WHEN 6 THEN 'HEADER'
74668 WHEN 7 THEN 'HEADER'
74669
74670 ELSE null
74671 END object_type_code
74672 , CASE r
74673 WHEN 1 THEN '222'
74674 WHEN 2 THEN '222'
74675 WHEN 3 THEN '222'
74676 WHEN 4 THEN '222'
74677 WHEN 5 THEN '222'
74678 WHEN 6 THEN '222'
74679 WHEN 7 THEN '222'
74680
74681 ELSE null
74682 END source_application_id
74683 , 'S' source_type_code
74684 , CASE r
74685 WHEN 1 THEN 'BILL_CUST_ACCOUNT_ID'
74686 WHEN 2 THEN 'BILL_USES_SITE_USE_ID'
74687 WHEN 3 THEN 'XLA_PARTY_TYPE'
74688 WHEN 4 THEN 'TRX_INVOICE_CURRENCY_CODE'
74689 WHEN 5 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
74690 WHEN 6 THEN 'TRX_DOC_SEQUENCE_ID'
74691 WHEN 7 THEN 'TRX_DOC_SEQUENCE_VALUE'
74692
74693 ELSE null
74694 END source_code
74695 , CASE r
74696 WHEN 1 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
74697 WHEN 2 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
74698 WHEN 3 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
74699 WHEN 4 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
74700 WHEN 5 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
74701 WHEN 6 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
74702 WHEN 7 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
74703
74704 ELSE null
74705 END source_value
74706 , null source_meaning
74707 FROM xla_events_gt xet
74708 , AR_BILL_TO_CUSTOMERS_S_V h1
74709 , AR_BILL_TO_SITE_USES_S_V h2
74710 , AR_TRANSACTIONS_S_V h5
74711 ,(select rownum r from all_objects where rownum <= 7 and owner = p_apps_owner)
74712 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
74713 AND xet.event_class_code = C_EVENT_CLASS_CODE
74714 AND h1.event_id = xet.event_id
74715 AND h2.event_id = h1.event_id
74716 AND h5.event_id = h1.event_id
74717
74718 )
74719 ;
74720 --
74721 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74722
74723 trace
74724 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
74725 ,p_level => C_LEVEL_STATEMENT
74726 ,p_module => l_log_module);
74727
74728 END IF;
74729 --
74730
74731
74732
74733 --
74734 INSERT INTO xla_diag_sources --line2
74735 (
74736 event_id
74737 , ledger_id
74738 , sla_ledger_id
74739 , description_language
74740 , object_name
74741 , object_type_code
74742 , line_number
74743 , source_application_id
74744 , source_type_code
74745 , source_code
74746 , source_value
74747 , source_meaning
74748 , created_by
74749 , creation_date
74750 , last_update_date
74751 , last_updated_by
74752 , last_update_login
74753 , program_update_date
74754 , program_application_id
74755 , program_id
74756 , request_id
74757 )
74758 SELECT event_id
74759 , p_target_ledger_id
74760 , p_sla_ledger_id
74761 , p_language
74762 , object_name
74763 , object_type_code
74764 , line_number
74765 , source_application_id
74766 , source_type_code
74767 , source_code
74768 , SUBSTR(source_value,1,1996)
74769 , SUBSTR(source_meaning ,1,200)
74770 , xla_environment_pkg.g_Usr_Id
74771 , TRUNC(SYSDATE)
74772 , TRUNC(SYSDATE)
74773 , xla_environment_pkg.g_Usr_Id
74774 , xla_environment_pkg.g_Login_Id
74775 , TRUNC(SYSDATE)
74776 , xla_environment_pkg.g_Prog_Appl_Id
74777 , xla_environment_pkg.g_Prog_Id
74778 , xla_environment_pkg.g_Req_Id
74779 FROM (
74780 SELECT xet.event_id event_id
74784 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
74781 , l4.line_number line_number
74782 , CASE r
74783 WHEN 1 THEN 'AR_CUST_TRX_LINES_L_V'
74785 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
74786 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
74787 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
74788 WHEN 6 THEN 'AR_CUST_TRX_LINES_BASE_V'
74789 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
74790 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
74791 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
74792
74793 ELSE null
74794 END object_name
74795 , CASE r
74796 WHEN 1 THEN 'LINE'
74797 WHEN 2 THEN 'LINE'
74798 WHEN 3 THEN 'LINE'
74799 WHEN 4 THEN 'LINE'
74800 WHEN 5 THEN 'LINE'
74801 WHEN 6 THEN 'LINE'
74802 WHEN 7 THEN 'LINE'
74803 WHEN 8 THEN 'LINE'
74804 WHEN 9 THEN 'LINE'
74805
74806 ELSE null
74807 END object_type_code
74808 , CASE r
74809 WHEN 1 THEN '222'
74810 WHEN 2 THEN '222'
74811 WHEN 3 THEN '222'
74812 WHEN 4 THEN '222'
74813 WHEN 5 THEN '222'
74814 WHEN 6 THEN '222'
74815 WHEN 7 THEN '222'
74816 WHEN 8 THEN '222'
74817 WHEN 9 THEN '222'
74818
74819 ELSE null
74820 END source_application_id
74821 , 'S' source_type_code
74822 , CASE r
74823 WHEN 1 THEN 'TRX_LINE_DIST_CCID'
74824 WHEN 2 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
74825 WHEN 3 THEN 'TRX_LINE_DIST_ID'
74826 WHEN 4 THEN 'TRX_DISTRIBUTION_TYPE'
74827 WHEN 5 THEN 'TRX_LINE_DIST_AMT'
74828 WHEN 6 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
74829 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
74830 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
74831 WHEN 9 THEN 'TRX_LINE_ACCTD_AMT'
74832
74833 ELSE null
74834 END source_code
74835 , CASE r
74836 WHEN 1 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
74837 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
74838 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
74839 WHEN 4 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
74840 WHEN 5 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
74841 WHEN 6 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
74842 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
74843 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
74844 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
74845
74846 ELSE null
74847 END source_value
74848 , null source_meaning
74849 FROM xla_events_gt xet
74850 , AR_CUST_TRX_LINES_BASE_V l3
74851 , AR_CUST_TRX_LINES_L_V l4
74852 , (select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
74853 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
74854 AND xet.event_class_code = C_EVENT_CLASS_CODE
74855 AND l3.event_id = xet.event_id
74856 AND l4.event_id = l3.event_id
74857 AND l4.line_number = l3.line_number
74858
74859 )
74860 ;
74861 --
74862 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74863
74864 trace
74865 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
74866 ,p_level => C_LEVEL_STATEMENT
74867 ,p_module => l_log_module);
74868
74869 END IF;
74870
74871
74872 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
74873 trace
74874 (p_msg => 'END of insert_sources_143'
74875 ,p_level => C_LEVEL_PROCEDURE
74876 ,p_module => l_log_module);
74877 END IF;
74878 EXCEPTION
74879 WHEN xla_exceptions_pkg.application_exception THEN
74880 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
74881 trace
74882 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
74883 ,p_level => C_LEVEL_EXCEPTION
74884 ,p_module => l_log_module);
74885 END IF;
74886 RAISE;
74887 WHEN OTHERS THEN
74888 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
74889 trace
74890 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
74891 ,p_level => C_LEVEL_EXCEPTION
74892 ,p_module => l_log_module);
74893 END IF;
74894 xla_exceptions_pkg.raise_message
74895 (p_location => 'XLA_00222_AAD_S_000009_PKG.insert_sources_143');
74896 END insert_sources_143;
74897 --
74898
74899 ---------------------------------------
74900 --
74901 -- PRIVATE FUNCTION
74902 -- EventClass_143
74903 --
74904 ----------------------------------------
74905 --
74906 FUNCTION EventClass_143
74907 (p_application_id IN NUMBER
74908 ,p_base_ledger_id IN NUMBER
74909 ,p_target_ledger_id IN NUMBER
74910 ,p_language IN VARCHAR2
74911 ,p_currency_code IN VARCHAR2
74912 ,p_sla_ledger_id IN NUMBER
74913 ,p_pad_start_date IN DATE
74914 ,p_pad_end_date IN DATE
74915 ,p_primary_ledger_id IN NUMBER)
74919 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'GUARANTEE';
74916 RETURN BOOLEAN IS
74917 --
74918 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'GUARANTEE_ALL';
74920
74921 l_calculate_acctd_flag VARCHAR2(1) :='N';
74922 l_calculate_g_l_flag VARCHAR2(1) :='N';
74923 --
74924 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74925 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74926 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
74927 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
74928 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74929 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
74930 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
74931 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74932 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
74933 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
74934 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74935 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74936 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74937 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74938 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
74939 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
74940 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
74941 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
74942 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
74943 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
74944 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
74945 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
74946 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
74947 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
74948 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
74949 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
74950
74951 l_event_id NUMBER;
74952 l_previous_event_id NUMBER;
74953 l_first_event_id NUMBER;
74954 l_last_event_id NUMBER;
74955
74956 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
74957 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
74958 --
74959 --
74960 l_result BOOLEAN := TRUE;
74961 l_rows NUMBER := 1000;
74962 l_event_type_name VARCHAR2(80) := 'All';
74963 l_event_class_name VARCHAR2(80) := 'Guarantee';
74964 l_description VARCHAR2(4000);
74965 l_transaction_reversal NUMBER;
74966 l_ae_header_id NUMBER;
74967 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
74968 l_log_module VARCHAR2(240);
74969 --
74970 l_acct_reversal_source VARCHAR2(30);
74971 l_trx_reversal_source VARCHAR2(30);
74972
74973 l_continue_with_lines BOOLEAN := TRUE;
74974 --
74975 l_acc_rev_gl_date_source DATE; -- 4262811
74976 --
74977 type t_array_event_id is table of number index by binary_integer;
74978
74979 l_rec_array_event t_rec_array_event;
74980 l_null_rec_array_event t_rec_array_event;
74981 l_array_ae_header_id xla_number_array_type;
74982 l_actual_flag VARCHAR2(1) := NULL;
74983 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
74984 l_balance_type_code VARCHAR2(1) :=NULL;
74985 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
74986
74987 --
74988 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
74989 --
74990
74991 TYPE t_array_source_32 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
74992 TYPE t_array_source_33 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
74993 TYPE t_array_source_34 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
74994 TYPE t_array_source_39 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
74995 TYPE t_array_source_85 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
74996 TYPE t_array_source_86 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
74997 TYPE t_array_source_87 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
74998
74999 TYPE t_array_source_21 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
75000 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
75001 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
75002 TYPE t_array_source_37 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
75003 TYPE t_array_source_38 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
75004 TYPE t_array_source_40 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
75005 TYPE t_array_source_41 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
75006 TYPE t_array_source_42 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
75007 TYPE t_array_source_43 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
75008
75009 l_array_source_32 t_array_source_32;
75010 l_array_source_33 t_array_source_33;
75011 l_array_source_34 t_array_source_34;
75015 l_array_source_87 t_array_source_87;
75012 l_array_source_39 t_array_source_39;
75013 l_array_source_85 t_array_source_85;
75014 l_array_source_86 t_array_source_86;
75016
75017 l_array_source_21 t_array_source_21;
75018 l_array_source_35 t_array_source_35;
75019 l_array_source_36 t_array_source_36;
75020 l_array_source_37 t_array_source_37;
75021 l_array_source_38 t_array_source_38;
75022 l_array_source_40 t_array_source_40;
75023 l_array_source_41 t_array_source_41;
75024 l_array_source_42 t_array_source_42;
75025 l_array_source_43 t_array_source_43;
75026
75027 --
75028 CURSOR header_cur
75029 IS
75030 SELECT /*+ leading(xet) cardinality(xet,1) */
75031 -- Event Class Code: GUARANTEE
75032 xet.entity_id
75033 ,xet.legal_entity_id
75034 ,xet.entity_code
75035 ,xet.transaction_number
75036 ,xet.event_id
75037 ,xet.event_class_code
75038 ,xet.event_type_code
75039 ,xet.event_number
75040 ,xet.event_date
75041 ,xet.transaction_date
75042 ,xet.reference_num_1
75043 ,xet.reference_num_2
75044 ,xet.reference_num_3
75045 ,xet.reference_num_4
75046 ,xet.reference_char_1
75047 ,xet.reference_char_2
75048 ,xet.reference_char_3
75049 ,xet.reference_char_4
75050 ,xet.reference_date_1
75051 ,xet.reference_date_2
75052 ,xet.reference_date_3
75053 ,xet.reference_date_4
75054 ,xet.event_created_by
75055 ,xet.budgetary_control_flag
75056 , h1.BILL_CUST_ACCOUNT_ID source_32
75057 , h2.BILL_USES_SITE_USE_ID source_33
75058 , h5.XLA_PARTY_TYPE source_34
75059 , h5.TRX_INVOICE_CURRENCY_CODE source_39
75060 , h5.TRX_DOC_SEQUENCE_CATEGORY source_85
75061 , h5.TRX_DOC_SEQUENCE_ID source_86
75062 , h5.TRX_DOC_SEQUENCE_VALUE source_87
75063 FROM xla_events_gt xet
75064 , AR_BILL_TO_CUSTOMERS_S_V h1
75065 , AR_BILL_TO_SITE_USES_S_V h2
75066 , AR_TRANSACTIONS_S_V h5
75067 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
75068 and xet.event_class_code = C_EVENT_CLASS_CODE
75069 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
75070 AND h2.event_id = h1.event_id
75071 AND h5.event_id = h1.event_id
75072
75073 ORDER BY event_id
75074 ;
75075
75076
75077 --
75078 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
75079 IS
75080 SELECT /*+ leading(xet) cardinality(xet,1) */
75081 -- Event Class Code: GUARANTEE
75082 xet.entity_id
75083 ,xet.legal_entity_id
75084 ,xet.entity_code
75085 ,xet.transaction_number
75086 ,xet.event_id
75087 ,xet.event_class_code
75088 ,xet.event_type_code
75089 ,xet.event_number
75090 ,xet.event_date
75091 ,xet.transaction_date
75092 ,xet.reference_num_1
75093 ,xet.reference_num_2
75094 ,xet.reference_num_3
75095 ,xet.reference_num_4
75096 ,xet.reference_char_1
75097 ,xet.reference_char_2
75098 ,xet.reference_char_3
75099 ,xet.reference_char_4
75100 ,xet.reference_date_1
75101 ,xet.reference_date_2
75102 ,xet.reference_date_3
75103 ,xet.reference_date_4
75104 ,xet.event_created_by
75105 ,xet.budgetary_control_flag
75106 , l3.LINE_NUMBER
75107 , l4.TRX_LINE_DIST_CCID source_21
75108 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_35
75109 , l4.TRX_LINE_DIST_ID source_36
75110 , l4.TRX_DISTRIBUTION_TYPE source_37
75111 , l4.TRX_LINE_DIST_AMT source_38
75112 , l3.TRX_LINE_CUR_CONVERSION_DATE source_40
75113 , l3.TRX_LINE_CUR_CONVERSION_RATE source_41
75114 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_42
75115 , l3.TRX_LINE_ACCTD_AMT source_43
75116 FROM xla_events_gt xet
75117 , AR_CUST_TRX_LINES_BASE_V l3
75118 , AR_CUST_TRX_LINES_L_V l4
75119 WHERE xet.event_id between x_first_event_id and x_last_event_id
75120 and xet.event_date between p_pad_start_date and p_pad_end_date
75121 and xet.event_class_code = C_EVENT_CLASS_CODE
75122 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
75123 AND l4.event_id = l3.event_id
75124 AND l4.line_number = l3.line_number
75125 ;
75126
75127 --
75128 BEGIN
75129 IF g_log_enabled THEN
75130 l_log_module := C_DEFAULT_MODULE||'.EventClass_143';
75131 END IF;
75132 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
75133 trace
75134 (p_msg => 'BEGIN of EventClass_143'
75135 ,p_level => C_LEVEL_PROCEDURE
75136 ,p_module => l_log_module);
75137 END IF;
75138
75139 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75140 trace
75141 (p_msg => 'p_application_id = '||p_application_id||
75142 ' - p_base_ledger_id = '||p_base_ledger_id||
75143 ' - p_target_ledger_id = '||p_target_ledger_id||
75144 ' - p_language = '||p_language||
75145 ' - p_currency_code = '||p_currency_code||
75146 ' - p_sla_ledger_id = '||p_sla_ledger_id
75147 ,p_level => C_LEVEL_STATEMENT
75148 ,p_module => l_log_module);
75149 END IF;
75150 --
75151 -- initialze arrays
75152 --
75153 g_array_event.DELETE;
75154 l_rec_array_event := l_null_rec_array_event;
75155 --
75156 --------------------------------------
75157 -- 4262811 Initialze MPA Line Number
75158 --------------------------------------
75159 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
75160
75161 --
75162
75163 --
75164 OPEN header_cur;
75165 --
75166 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75167 trace
75168 (p_msg => 'SQL - FETCH header_cur'
75169 ,p_level => C_LEVEL_STATEMENT
75170 ,p_module => l_log_module);
75174 FETCH header_cur BULK COLLECT INTO
75171 END IF;
75172 --
75173 LOOP
75175 l_array_entity_id
75176 , l_array_legal_entity_id
75177 , l_array_entity_code
75178 , l_array_transaction_num
75179 , l_array_event_id
75180 , l_array_class_code
75181 , l_array_event_type
75182 , l_array_event_number
75183 , l_array_event_date
75184 , l_array_transaction_date
75185 , l_array_reference_num_1
75186 , l_array_reference_num_2
75187 , l_array_reference_num_3
75188 , l_array_reference_num_4
75189 , l_array_reference_char_1
75190 , l_array_reference_char_2
75191 , l_array_reference_char_3
75192 , l_array_reference_char_4
75193 , l_array_reference_date_1
75194 , l_array_reference_date_2
75195 , l_array_reference_date_3
75196 , l_array_reference_date_4
75197 , l_array_event_created_by
75198 , l_array_budgetary_control_flag
75199 , l_array_source_32
75200 , l_array_source_33
75201 , l_array_source_34
75202 , l_array_source_39
75203 , l_array_source_85
75204 , l_array_source_86
75205 , l_array_source_87
75206 LIMIT l_rows;
75207 --
75208 IF (C_LEVEL_EVENT >= g_log_level) THEN
75209 trace
75210 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
75211 ,p_level => C_LEVEL_EVENT
75212 ,p_module => l_log_module);
75213 END IF;
75214 --
75215 EXIT WHEN l_array_entity_id.COUNT = 0;
75216
75217 -- initialize arrays
75218 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
75219 XLA_AE_LINES_PKG.g_rec_lines := NULL;
75220
75221 --
75222 -- Bug 4458708
75223 --
75224 XLA_AE_LINES_PKG.g_LineNumber := 0;
75225
75226
75227 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
75228 g_last_hdr_idx := l_array_event_id.LAST;
75229 --
75230 -- loop for the headers. Each iteration is for each header extract row
75231 -- fetched in header cursor
75232 --
75233 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
75234
75235 --
75236 -- set event info as cache for other routines to refer event attributes
75237 --
75238 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
75239 (p_application_id => p_application_id
75240 ,p_primary_ledger_id => p_primary_ledger_id
75241 ,p_base_ledger_id => p_base_ledger_id
75242 ,p_target_ledger_id => p_target_ledger_id
75243 ,p_entity_id => l_array_entity_id(hdr_idx)
75244 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
75245 ,p_entity_code => l_array_entity_code(hdr_idx)
75246 ,p_transaction_num => l_array_transaction_num(hdr_idx)
75247 ,p_event_id => l_array_event_id(hdr_idx)
75248 ,p_event_class_code => l_array_class_code(hdr_idx)
75249 ,p_event_type_code => l_array_event_type(hdr_idx)
75250 ,p_event_number => l_array_event_number(hdr_idx)
75251 ,p_event_date => l_array_event_date(hdr_idx)
75252 ,p_transaction_date => l_array_transaction_date(hdr_idx)
75253 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
75254 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
75255 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
75256 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
75257 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
75258 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
75259 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
75260 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
75261 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
75262 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
75263 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
75264 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
75265 ,p_event_created_by => l_array_event_created_by(hdr_idx)
75266 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
75267
75268 --
75269 -- set the status of entry to C_VALID (0)
75270 --
75271 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
75272
75273 --
75274 -- initialize a row for ae header
75275 --
75276 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
75277
75278 l_event_id := l_array_event_id(hdr_idx);
75279
75280 --
75281 -- storing the hdr_idx for event. May be used by line cursor.
75282 --
75283 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
75284
75285 --
75286 -- store sources from header extract. This can be improved to
75287 -- store only those sources from header extract that may be used in lines
75288 --
75289
75290 g_array_event(l_event_id).array_value_num('source_32') := l_array_source_32(hdr_idx);
75291 g_array_event(l_event_id).array_value_num('source_33') := l_array_source_33(hdr_idx);
75292 g_array_event(l_event_id).array_value_char('source_34') := l_array_source_34(hdr_idx);
75293 g_array_event(l_event_id).array_value_char('source_39') := l_array_source_39(hdr_idx);
75294 g_array_event(l_event_id).array_value_char('source_85') := l_array_source_85(hdr_idx);
75295 g_array_event(l_event_id).array_value_num('source_86') := l_array_source_86(hdr_idx);
75296 g_array_event(l_event_id).array_value_num('source_87') := l_array_source_87(hdr_idx);
75297
75298 --
75299 -- initilaize the status of ae headers for diffrent balance types
75300 -- the status is initialised to C_NOT_CREATED (2)
75301 --
75302 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
75303 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
75307 -- call api to validate and store accounting attributes for header
75304 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
75305
75306 --
75308 --
75309
75310 ------------------------------------------------------------
75311 -- Accrual Reversal : to get date for Standard Source (NONE)
75312 ------------------------------------------------------------
75313 l_acc_rev_gl_date_source := NULL;
75314
75315 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
75316 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_85');
75317 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
75318 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_86');
75319 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
75320 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_87');
75321 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
75322 l_rec_acct_attrs.array_date_value(4) :=
75323 xla_ae_sources_pkg.GetSystemSourceDate(
75324 p_source_code => 'XLA_EVENT_DATE'
75325 , p_source_type_code => 'Y'
75326 , p_source_application_id => 602
75327 );
75328
75329
75330 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
75331
75332 XLA_AE_HEADER_PKG.SetJeCategoryName;
75333
75334 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
75335 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
75336 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
75337 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
75338 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
75339
75340
75341 -- No header level analytical criteria
75342
75343 --
75344 --accounting attribute enhancement, bug 3612931
75345 --
75346 l_trx_reversal_source := SUBSTR(NULL, 1,30);
75347
75348 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
75349 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
75350
75351 xla_accounting_err_pkg.build_message
75352 (p_appli_s_name => 'XLA'
75353 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
75354 ,p_token_1 => 'ACCT_ATTR_NAME'
75355 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
75356 ,p_token_2 => 'PRODUCT_NAME'
75357 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
75358 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
75359 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
75360 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
75361
75362 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
75363 --
75364 -- following sets the accounting attributes needed to reverse
75365 -- accounting for a distributeion
75366 --
75367 xla_ae_lines_pkg.SetTrxReversalAttrs
75368 (p_event_id => l_event_id
75369 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
75370 ,p_trx_reversal_source => l_trx_reversal_source);
75371
75372 END IF;
75373
75374
75375 ----------------------------------------------------------------
75376 -- 4262811 - update the header statuses to invalid in need be
75377 ----------------------------------------------------------------
75378 --
75379 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
75380
75381
75382 -----------------------------------------------
75383 -- No accrual reversal for the event class/type
75384 -----------------------------------------------
75385 ----------------------------------------------------------------
75386
75387 --
75388 -- this ends the header loop iteration for one bulk fetch
75389 --
75390 END LOOP;
75391
75392 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
75393 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
75394
75395 --
75396 -- insert dummy rows into lines gt table that were created due to
75397 -- transaction reversals
75398 --
75399 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
75400 l_result := XLA_AE_LINES_PKG.InsertLines;
75401 END IF;
75402
75403 --
75404 -- reset the temp_line_num for each set of events fetched from header
75405 -- cursor rather than doing it for each new event in line cursor
75406 -- Bug 3939231
75407 --
75408 xla_ae_lines_pkg.g_temp_line_num := 0;
75409
75410
75411
75412 --
75413 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
75414 --
75415 --
75416 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75417
75418 trace
75419 (p_msg => 'SQL - FETCH line_cur'
75420 ,p_level => C_LEVEL_STATEMENT
75421 ,p_module => l_log_module);
75422
75423 END IF;
75424 --
75425 --
75426 LOOP
75427 --
75428 FETCH line_cur BULK COLLECT INTO
75429 l_array_entity_id
75430 , l_array_legal_entity_id
75431 , l_array_entity_code
75432 , l_array_transaction_num
75433 , l_array_event_id
75434 , l_array_class_code
75435 , l_array_event_type
75436 , l_array_event_number
75437 , l_array_event_date
75438 , l_array_transaction_date
75439 , l_array_reference_num_1
75440 , l_array_reference_num_2
75441 , l_array_reference_num_3
75442 , l_array_reference_num_4
75446 , l_array_reference_char_4
75443 , l_array_reference_char_1
75444 , l_array_reference_char_2
75445 , l_array_reference_char_3
75447 , l_array_reference_date_1
75448 , l_array_reference_date_2
75449 , l_array_reference_date_3
75450 , l_array_reference_date_4
75451 , l_array_event_created_by
75452 , l_array_budgetary_control_flag
75453 , l_array_extract_line_num
75454 , l_array_source_21
75455 , l_array_source_35
75456 , l_array_source_36
75457 , l_array_source_37
75458 , l_array_source_38
75459 , l_array_source_40
75460 , l_array_source_41
75461 , l_array_source_42
75462 , l_array_source_43
75463 LIMIT l_rows;
75464
75465 --
75466 IF (C_LEVEL_EVENT >= g_log_level) THEN
75467 trace
75468 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
75469 ,p_level => C_LEVEL_EVENT
75470 ,p_module => l_log_module);
75471 END IF;
75472 --
75473 EXIT WHEN l_array_entity_id.count = 0;
75474
75475 XLA_AE_LINES_PKG.g_rec_lines := null;
75476
75477 --
75478 -- Bug 4458708
75479 --
75480 XLA_AE_LINES_PKG.g_LineNumber := 0;
75481 --
75482 --
75483
75484 FOR Idx IN 1..l_array_event_id.count LOOP
75485 --
75486 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
75487 --
75488 l_event_id := l_array_event_id(idx); -- 5648433
75489
75490 --
75491 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
75492 --
75493
75494 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
75495 (g_array_event(l_event_id).array_value_num('header_index'))
75496 ,'N'
75497 ) <> 'Y'
75498 THEN
75499 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75500 trace
75501 (p_msg => 'Trancaction revesal option is not Y '
75502 ,p_level => C_LEVEL_STATEMENT
75503 ,p_module => l_log_module);
75504 END IF;
75505
75506 --
75507 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
75508 --
75509 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
75510 --
75511 -- set event info as cache for other routines to refer event attributes
75512 --
75513
75514 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
75515 l_previous_event_id := l_event_id;
75516
75517 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
75518 (p_application_id => p_application_id
75519 ,p_primary_ledger_id => p_primary_ledger_id
75520 ,p_base_ledger_id => p_base_ledger_id
75521 ,p_target_ledger_id => p_target_ledger_id
75522 ,p_entity_id => l_array_entity_id(Idx)
75523 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
75524 ,p_entity_code => l_array_entity_code(Idx)
75525 ,p_transaction_num => l_array_transaction_num(Idx)
75526 ,p_event_id => l_array_event_id(Idx)
75527 ,p_event_class_code => l_array_class_code(Idx)
75528 ,p_event_type_code => l_array_event_type(Idx)
75529 ,p_event_number => l_array_event_number(Idx)
75530 ,p_event_date => l_array_event_date(Idx)
75531 ,p_transaction_date => l_array_transaction_date(Idx)
75532 ,p_reference_num_1 => l_array_reference_num_1(Idx)
75533 ,p_reference_num_2 => l_array_reference_num_2(Idx)
75534 ,p_reference_num_3 => l_array_reference_num_3(Idx)
75535 ,p_reference_num_4 => l_array_reference_num_4(Idx)
75536 ,p_reference_char_1 => l_array_reference_char_1(Idx)
75537 ,p_reference_char_2 => l_array_reference_char_2(Idx)
75538 ,p_reference_char_3 => l_array_reference_char_3(Idx)
75539 ,p_reference_char_4 => l_array_reference_char_4(Idx)
75540 ,p_reference_date_1 => l_array_reference_date_1(Idx)
75541 ,p_reference_date_2 => l_array_reference_date_2(Idx)
75542 ,p_reference_date_3 => l_array_reference_date_3(Idx)
75543 ,p_reference_date_4 => l_array_reference_date_4(Idx)
75544 ,p_event_created_by => l_array_event_created_by(Idx)
75545 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
75546 --
75547 END IF;
75548
75549
75550
75551 --
75552 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
75553
75554 l_acct_reversal_source := SUBSTR(NULL, 1,30);
75555
75556 IF l_continue_with_lines THEN
75557 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
75558 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
75559
75560 xla_accounting_err_pkg.build_message
75561 (p_appli_s_name => 'XLA'
75562 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
75563 ,p_token_1 => 'LINE_NUMBER'
75564 ,p_value_1 => l_array_extract_line_num(Idx)
75565 ,p_token_2 => 'PRODUCT_NAME'
75566 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
75567 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
75568 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
75569 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
75570
75571 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
75572 --
75573 -- following sets the accounting attributes needed to reverse
75574 -- accounting for a distributeion
75575 --
75576
75580 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
75577 --
75578 -- 5217187
75579 --
75581 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
75582 g_array_event(l_event_id).array_value_num('header_index'));
75583 --
75584 --
75585
75586 -- No reversal code generated
75587
75588 xla_ae_lines_pkg.SetAcctReversalAttrs
75589 (p_event_id => l_event_id
75590 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
75591 ,p_calculate_acctd_flag => l_calculate_acctd_flag
75592 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
75593 END IF;
75594
75595 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
75596 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
75597
75598 --
75599 AcctLineType_78 (
75600 p_application_id => p_application_id
75601 ,p_event_id => l_event_id
75602 ,p_calculate_acctd_flag => l_calculate_acctd_flag
75603 ,p_calculate_g_l_flag => l_calculate_g_l_flag
75604 ,p_actual_flag => l_actual_flag
75605 ,p_balance_type_code => l_balance_type_code
75606 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
75607
75608 , p_source_21 => l_array_source_21(Idx)
75609 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
75610 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
75611 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
75612 , p_source_35 => l_array_source_35(Idx)
75613 , p_source_36 => l_array_source_36(Idx)
75614 , p_source_37 => l_array_source_37(Idx)
75615 , p_source_38 => l_array_source_38(Idx)
75616 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
75617 , p_source_40 => l_array_source_40(Idx)
75618 , p_source_41 => l_array_source_41(Idx)
75619 , p_source_42 => l_array_source_42(Idx)
75620 , p_source_43 => l_array_source_43(Idx)
75621 );
75622 If(l_balance_type_code = 'A') THEN
75623 l_actual_gain_loss_ref := l_gain_or_loss_ref;
75624 END IF;
75625
75626 --
75627
75628
75629 --
75630 AcctLineType_79 (
75631 p_application_id => p_application_id
75632 ,p_event_id => l_event_id
75633 ,p_calculate_acctd_flag => l_calculate_acctd_flag
75634 ,p_calculate_g_l_flag => l_calculate_g_l_flag
75635 ,p_actual_flag => l_actual_flag
75636 ,p_balance_type_code => l_balance_type_code
75637 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
75638
75639 , p_source_21 => l_array_source_21(Idx)
75640 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
75641 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
75642 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
75643 , p_source_35 => l_array_source_35(Idx)
75644 , p_source_36 => l_array_source_36(Idx)
75645 , p_source_37 => l_array_source_37(Idx)
75646 , p_source_38 => l_array_source_38(Idx)
75647 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
75648 , p_source_40 => l_array_source_40(Idx)
75649 , p_source_41 => l_array_source_41(Idx)
75650 , p_source_42 => l_array_source_42(Idx)
75651 , p_source_43 => l_array_source_43(Idx)
75652 );
75653 If(l_balance_type_code = 'A') THEN
75654 l_actual_gain_loss_ref := l_gain_or_loss_ref;
75655 END IF;
75656
75657 --
75658
75659 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
75660 -- or secondary ledger that has different currency with primary
75661 -- or alc that is calculated by sla
75662 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
75663 (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'))
75664
75665 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
75666 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
75667 AND (l_actual_flag = 'A')) THEN
75668 XLA_AE_LINES_PKG.CreateGainOrLossLines(
75669 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
75670 ,p_application_id => p_application_id
75671 ,p_amb_context_code => 'DEFAULT'
75672 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
75673 ,p_event_class_code => C_EVENT_CLASS_CODE
75674 ,p_event_type_code => C_EVENT_TYPE_CODE
75675
75676 ,p_gain_ccid => -1
75677 ,p_loss_ccid => -1
75678
75679 ,p_actual_flag => l_actual_flag
75680 ,p_enc_flag => null
75681 ,p_actual_g_l_ref => l_actual_gain_loss_ref
75682 ,p_enc_g_l_ref => null
75683 );
75684 END IF;
75685 END IF;
75686 END IF;
75687
75688 ELSE
75689 --
75690 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
75691 --
75692 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75693 trace
75694 (p_msg => 'Trancaction revesal option is Y'
75695 ,p_level => C_LEVEL_STATEMENT
75696 ,p_module => l_log_module);
75697 END IF;
75698 END IF;
75699
75700 END LOOP;
75701 l_result := XLA_AE_LINES_PKG.InsertLines ;
75702 end loop;
75703 close line_cur;
75704
75705
75706 --
75707 -- insert headers into xla_ae_headers_gt table
75708 --
75709 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
75710
75711 -- insert into errors table here.
75712
75713 END LOOP;
75714
75715 --
75716 -- 4865292
75717 --
75718 -- Compare g_hdr_extract_count with event count in
75719 -- CreateHeadersAndLines.
75723 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75720 --
75721 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
75722
75724 trace (p_msg => '# rows extracted from header extract objects '
75725 || ' (running total): '
75726 || g_hdr_extract_count
75727 ,p_level => C_LEVEL_STATEMENT
75728 ,p_module => l_log_module);
75729 END IF;
75730
75731 CLOSE header_cur;
75732 --
75733
75734 --
75735 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
75736 trace
75737 (p_msg => 'END of EventClass_143'
75738 ,p_level => C_LEVEL_PROCEDURE
75739 ,p_module => l_log_module);
75740 END IF;
75741 --
75742 RETURN l_result;
75743 EXCEPTION
75744 WHEN xla_exceptions_pkg.application_exception THEN
75745
75746 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
75747
75748
75749 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
75750
75751 RAISE;
75752
75753 WHEN NO_DATA_FOUND THEN
75754
75755 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
75756 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
75757
75758 FOR header_record IN header_cur
75759 LOOP
75760 l_array_header_events(header_record.event_id) := header_record.event_id;
75761 END LOOP;
75762
75763 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
75764 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
75765
75766 fnd_file.put_line(fnd_file.LOG, ' ');
75767 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
75768 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
75769 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
75770
75771 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
75772 LOOP
75773 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
75774 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
75775 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
75776 END IF;
75777 END LOOP;
75778
75779 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
75780 fnd_file.put_line(fnd_file.LOG, ' ');
75781
75782
75783 xla_exceptions_pkg.raise_message
75784 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_143');
75785
75786
75787 WHEN OTHERS THEN
75788 xla_exceptions_pkg.raise_message
75789 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_143');
75790 END EventClass_143;
75791 --
75792
75793 ---------------------------------------
75794 --
75795 -- PRIVATE PROCEDURE
75796 -- insert_sources_144
75797 --
75798 ----------------------------------------
75799 --
75800 PROCEDURE insert_sources_144(
75801 p_target_ledger_id IN NUMBER
75802 , p_language IN VARCHAR2
75803 , p_sla_ledger_id IN NUMBER
75804 , p_pad_start_date IN DATE
75805 , p_pad_end_date IN DATE
75806 )
75807 IS
75808
75809 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'INVOICE_ALL';
75810 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'INVOICE';
75811 p_apps_owner VARCHAR2(30);
75812 l_log_module VARCHAR2(240);
75813 BEGIN
75814 IF g_log_enabled THEN
75815 l_log_module := C_DEFAULT_MODULE||'.insert_sources_144';
75816 END IF;
75817 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
75818
75819 trace
75820 (p_msg => 'BEGIN of insert_sources_144'
75821 ,p_level => C_LEVEL_PROCEDURE
75822 ,p_module => l_log_module);
75823
75824 END IF;
75825
75826 -- select APPS owner
75827 SELECT oracle_username
75828 INTO p_apps_owner
75829 FROM fnd_oracle_userid
75830 WHERE read_only_flag = 'U'
75831 ;
75832
75833 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75834 trace
75835 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
75836 ' - p_language = '||p_language||
75837 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
75838 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
75839 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
75840 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
75841 ,p_level => C_LEVEL_STATEMENT
75842 ,p_module => l_log_module);
75843 END IF;
75844
75845
75846 --
75847 INSERT INTO xla_diag_sources --hdr2
75848 (
75849 event_id
75850 , ledger_id
75851 , sla_ledger_id
75852 , description_language
75853 , object_name
75854 , object_type_code
75855 , line_number
75856 , source_application_id
75857 , source_type_code
75858 , source_code
75859 , source_value
75860 , source_meaning
75861 , created_by
75862 , creation_date
75863 , last_update_date
75864 , last_updated_by
75865 , last_update_login
75866 , program_update_date
75867 , program_application_id
75868 , program_id
75869 , request_id
75870 )
75871 SELECT
75872 event_id
75873 , p_target_ledger_id
75874 , p_sla_ledger_id
75875 , p_language
75876 , object_name
75877 , object_type_code
75878 , line_number
75882 , SUBSTR(source_value ,1,1996)
75879 , source_application_id
75880 , source_type_code
75881 , source_code
75883 , SUBSTR(source_meaning ,1,200)
75884 , xla_environment_pkg.g_Usr_Id
75885 , TRUNC(SYSDATE)
75886 , TRUNC(SYSDATE)
75887 , xla_environment_pkg.g_Usr_Id
75888 , xla_environment_pkg.g_Login_Id
75889 , TRUNC(SYSDATE)
75890 , xla_environment_pkg.g_Prog_Appl_Id
75891 , xla_environment_pkg.g_Prog_Id
75892 , xla_environment_pkg.g_Req_Id
75893 FROM (
75894 SELECT xet.event_id event_id
75895 , 0 line_number
75896 , CASE r
75897 WHEN 1 THEN 'AR_TRANSACTIONS_S_V'
75898 WHEN 2 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
75899 WHEN 3 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
75900 WHEN 4 THEN 'AR_BILL_TO_SITE_USES_S_V'
75901 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
75902 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
75903 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
75904 WHEN 8 THEN 'AR_TRANSACTIONS_S_V'
75905 WHEN 9 THEN 'AR_TRANSACTIONS_S_V'
75906 WHEN 10 THEN 'AR_TRANSACTIONS_S_V'
75907
75908 ELSE null
75909 END object_name
75910 , CASE r
75911 WHEN 1 THEN 'HEADER'
75912 WHEN 2 THEN 'HEADER'
75913 WHEN 3 THEN 'HEADER'
75914 WHEN 4 THEN 'HEADER'
75915 WHEN 5 THEN 'HEADER'
75916 WHEN 6 THEN 'HEADER'
75917 WHEN 7 THEN 'HEADER'
75918 WHEN 8 THEN 'HEADER'
75919 WHEN 9 THEN 'HEADER'
75920 WHEN 10 THEN 'HEADER'
75921
75922 ELSE null
75923 END object_type_code
75924 , CASE r
75925 WHEN 1 THEN '222'
75926 WHEN 2 THEN '222'
75927 WHEN 3 THEN '222'
75928 WHEN 4 THEN '222'
75929 WHEN 5 THEN '222'
75930 WHEN 6 THEN '222'
75931 WHEN 7 THEN '222'
75932 WHEN 8 THEN '222'
75933 WHEN 9 THEN '222'
75934 WHEN 10 THEN '222'
75935
75936 ELSE null
75937 END source_application_id
75938 , 'S' source_type_code
75939 , CASE r
75940 WHEN 1 THEN 'TRX_RECEIVABLE_CCID'
75941 WHEN 2 THEN 'BILL_CUSTOMER_CLASS_CODE'
75942 WHEN 3 THEN 'BILL_CUST_ACCOUNT_ID'
75943 WHEN 4 THEN 'BILL_USES_SITE_USE_ID'
75944 WHEN 5 THEN 'XLA_PARTY_TYPE'
75945 WHEN 6 THEN 'TRX_INVOICE_CURRENCY_CODE'
75946 WHEN 7 THEN 'TRX_INVOICING_RULE_ID'
75947 WHEN 8 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
75948 WHEN 9 THEN 'TRX_DOC_SEQUENCE_ID'
75949 WHEN 10 THEN 'TRX_DOC_SEQUENCE_VALUE'
75950
75951 ELSE null
75952 END source_code
75953 , CASE r
75954 WHEN 1 THEN TO_CHAR(h5.TRX_RECEIVABLE_CCID)
75955 WHEN 2 THEN TO_CHAR(h1.BILL_CUSTOMER_CLASS_CODE)
75956 WHEN 3 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
75957 WHEN 4 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
75958 WHEN 5 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
75959 WHEN 6 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
75960 WHEN 7 THEN TO_CHAR(h5.TRX_INVOICING_RULE_ID)
75961 WHEN 8 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
75962 WHEN 9 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
75963 WHEN 10 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
75964
75965 ELSE null
75966 END source_value
75967 , null source_meaning
75968 FROM xla_events_gt xet
75969 , AR_BILL_TO_CUSTOMERS_S_V h1
75970 , AR_BILL_TO_SITE_USES_S_V h2
75971 , AR_TRANSACTIONS_S_V h5
75972 ,(select rownum r from all_objects where rownum <= 10 and owner = p_apps_owner)
75973 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
75974 AND xet.event_class_code = C_EVENT_CLASS_CODE
75975 AND h1.event_id = xet.event_id
75976 AND h2.event_id = h1.event_id
75977 AND h5.event_id = h1.event_id
75978
75979 )
75980 ;
75981 --
75982 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75983
75984 trace
75985 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
75986 ,p_level => C_LEVEL_STATEMENT
75987 ,p_module => l_log_module);
75988
75989 END IF;
75990 --
75991
75992
75993
75994 --
75995 INSERT INTO xla_diag_sources --line2
75996 (
75997 event_id
75998 , ledger_id
75999 , sla_ledger_id
76000 , description_language
76001 , object_name
76002 , object_type_code
76003 , line_number
76004 , source_application_id
76005 , source_type_code
76006 , source_code
76007 , source_value
76008 , source_meaning
76009 , created_by
76010 , creation_date
76011 , last_update_date
76012 , last_updated_by
76013 , last_update_login
76014 , program_update_date
76015 , program_application_id
76016 , program_id
76017 , request_id
76018 )
76019 SELECT event_id
76020 , p_target_ledger_id
76021 , p_sla_ledger_id
76025 , line_number
76022 , p_language
76023 , object_name
76024 , object_type_code
76026 , source_application_id
76027 , source_type_code
76028 , source_code
76029 , SUBSTR(source_value,1,1996)
76030 , SUBSTR(source_meaning ,1,200)
76031 , xla_environment_pkg.g_Usr_Id
76032 , TRUNC(SYSDATE)
76033 , TRUNC(SYSDATE)
76034 , xla_environment_pkg.g_Usr_Id
76035 , xla_environment_pkg.g_Login_Id
76036 , TRUNC(SYSDATE)
76037 , xla_environment_pkg.g_Prog_Appl_Id
76038 , xla_environment_pkg.g_Prog_Id
76039 , xla_environment_pkg.g_Req_Id
76040 FROM (
76041 SELECT xet.event_id event_id
76042 , l4.line_number line_number
76043 , CASE r
76044 WHEN 1 THEN 'FV_XLA_AR_REF_V'
76045 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
76046 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
76047 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
76048 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
76049 WHEN 6 THEN 'AR_CUST_TRX_LINES_L_V'
76050 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
76051 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
76052 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
76053 WHEN 10 THEN 'AR_CUST_TRX_LINES_BASE_V'
76054 WHEN 11 THEN 'AR_CUST_TRX_LINES_L_V'
76055 WHEN 12 THEN 'FV_XLA_AR_REF_V'
76056 WHEN 13 THEN 'AR_CUST_TRX_LINES_BASE_V'
76057
76058 ELSE null
76059 END object_name
76060 , CASE r
76061 WHEN 1 THEN 'LINE'
76062 WHEN 2 THEN 'LINE'
76063 WHEN 3 THEN 'LINE'
76064 WHEN 4 THEN 'LINE'
76065 WHEN 5 THEN 'LINE'
76066 WHEN 6 THEN 'LINE'
76067 WHEN 7 THEN 'LINE'
76068 WHEN 8 THEN 'LINE'
76069 WHEN 9 THEN 'LINE'
76070 WHEN 10 THEN 'LINE'
76071 WHEN 11 THEN 'LINE'
76072 WHEN 12 THEN 'LINE'
76073 WHEN 13 THEN 'LINE'
76074
76075 ELSE null
76076 END object_type_code
76077 , CASE r
76078 WHEN 1 THEN '8901'
76079 WHEN 2 THEN '222'
76080 WHEN 3 THEN '222'
76081 WHEN 4 THEN '222'
76082 WHEN 5 THEN '222'
76083 WHEN 6 THEN '222'
76084 WHEN 7 THEN '222'
76085 WHEN 8 THEN '222'
76086 WHEN 9 THEN '222'
76087 WHEN 10 THEN '222'
76088 WHEN 11 THEN '222'
76089 WHEN 12 THEN '8901'
76090 WHEN 13 THEN '222'
76091
76092 ELSE null
76093 END source_application_id
76094 , 'S' source_type_code
76095 , CASE r
76096 WHEN 1 THEN 'FEDERAL_FUND_CATEGORY'
76097 WHEN 2 THEN 'TRX_LINE_DIST_CCID'
76098 WHEN 3 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
76099 WHEN 4 THEN 'TRX_LINE_DIST_ID'
76100 WHEN 5 THEN 'TRX_DISTRIBUTION_TYPE'
76101 WHEN 6 THEN 'TRX_LINE_DIST_AMT'
76102 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
76103 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
76104 WHEN 9 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
76105 WHEN 10 THEN 'TRX_LINE_ACCTD_AMT'
76106 WHEN 11 THEN 'TRX_TAX_LINE_ID'
76107 WHEN 12 THEN 'FEDERAL_ACCOUNT_VALID_FLAG'
76108 WHEN 13 THEN 'ROUNDING_CORRECTION_FLAG'
76109
76110 ELSE null
76111 END source_code
76112 , CASE r
76113 WHEN 1 THEN TO_CHAR(l6.FEDERAL_FUND_CATEGORY)
76114 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
76115 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
76116 WHEN 4 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
76117 WHEN 5 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
76118 WHEN 6 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
76119 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
76120 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
76121 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
76122 WHEN 10 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
76123 WHEN 11 THEN TO_CHAR(l4.TRX_TAX_LINE_ID)
76124 WHEN 12 THEN TO_CHAR(l6.FEDERAL_ACCOUNT_VALID_FLAG)
76125 WHEN 13 THEN TO_CHAR(l3.ROUNDING_CORRECTION_FLAG)
76126
76127 ELSE null
76128 END source_value
76129 , null source_meaning
76130 FROM xla_events_gt xet
76131 , AR_CUST_TRX_LINES_BASE_V l3
76132 , AR_CUST_TRX_LINES_L_V l4
76133 , FV_XLA_AR_REF_V l6
76134 , (select rownum r from all_objects where rownum <= 13 and owner = p_apps_owner)
76135 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
76136 AND xet.event_class_code = C_EVENT_CLASS_CODE
76137 AND l3.event_id = xet.event_id
76138 AND l4.event_id = l3.event_id
76139 AND l4.line_number = l3.line_number
76140 AND l6.federal_event_id (+) = l4.event_id and l6.federal_line_number (+) = l4.line_number
76141 )
76142 ;
76143 --
76144 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
76145
76146 trace
76147 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
76151 END IF;
76148 ,p_level => C_LEVEL_STATEMENT
76149 ,p_module => l_log_module);
76150
76152
76153
76154 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
76155 trace
76156 (p_msg => 'END of insert_sources_144'
76157 ,p_level => C_LEVEL_PROCEDURE
76158 ,p_module => l_log_module);
76159 END IF;
76160 EXCEPTION
76161 WHEN xla_exceptions_pkg.application_exception THEN
76162 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
76163 trace
76164 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
76165 ,p_level => C_LEVEL_EXCEPTION
76166 ,p_module => l_log_module);
76167 END IF;
76168 RAISE;
76169 WHEN OTHERS THEN
76170 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
76171 trace
76172 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
76173 ,p_level => C_LEVEL_EXCEPTION
76174 ,p_module => l_log_module);
76175 END IF;
76176 xla_exceptions_pkg.raise_message
76177 (p_location => 'XLA_00222_AAD_S_000009_PKG.insert_sources_144');
76178 END insert_sources_144;
76179 --
76180
76181 ---------------------------------------
76182 --
76183 -- PRIVATE FUNCTION
76184 -- EventClass_144
76185 --
76186 ----------------------------------------
76187 --
76188 FUNCTION EventClass_144
76189 (p_application_id IN NUMBER
76190 ,p_base_ledger_id IN NUMBER
76191 ,p_target_ledger_id IN NUMBER
76192 ,p_language IN VARCHAR2
76193 ,p_currency_code IN VARCHAR2
76194 ,p_sla_ledger_id IN NUMBER
76195 ,p_pad_start_date IN DATE
76196 ,p_pad_end_date IN DATE
76197 ,p_primary_ledger_id IN NUMBER)
76198 RETURN BOOLEAN IS
76199 --
76200 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'INVOICE_ALL';
76201 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'INVOICE';
76202
76203 l_calculate_acctd_flag VARCHAR2(1) :='N';
76204 l_calculate_g_l_flag VARCHAR2(1) :='N';
76205 --
76206 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
76207 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
76208 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
76209 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
76210 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
76211 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
76212 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
76213 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
76214 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
76215 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
76216 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
76217 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
76218 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
76219 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
76220 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
76221 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
76222 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
76223 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
76224 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
76225 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
76226 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
76227 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
76228 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
76229 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
76230 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
76231 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
76232
76233 l_event_id NUMBER;
76234 l_previous_event_id NUMBER;
76235 l_first_event_id NUMBER;
76236 l_last_event_id NUMBER;
76237
76238 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
76239 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
76240 --
76241 --
76242 l_result BOOLEAN := TRUE;
76243 l_rows NUMBER := 1000;
76244 l_event_type_name VARCHAR2(80) := 'All';
76245 l_event_class_name VARCHAR2(80) := 'Invoice';
76246 l_description VARCHAR2(4000);
76247 l_transaction_reversal NUMBER;
76248 l_ae_header_id NUMBER;
76249 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
76250 l_log_module VARCHAR2(240);
76251 --
76252 l_acct_reversal_source VARCHAR2(30);
76253 l_trx_reversal_source VARCHAR2(30);
76254
76255 l_continue_with_lines BOOLEAN := TRUE;
76256 --
76257 l_acc_rev_gl_date_source DATE; -- 4262811
76258 --
76259 type t_array_event_id is table of number index by binary_integer;
76260
76261 l_rec_array_event t_rec_array_event;
76262 l_null_rec_array_event t_rec_array_event;
76263 l_array_ae_header_id xla_number_array_type;
76264 l_actual_flag VARCHAR2(1) := NULL;
76265 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
76266 l_balance_type_code VARCHAR2(1) :=NULL;
76267 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
76268
76269 --
76273 TYPE t_array_source_8 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_RECEIVABLE_CCID%TYPE INDEX BY BINARY_INTEGER;
76270 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
76271 --
76272
76274 TYPE t_array_source_12 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUSTOMER_CLASS_CODE%TYPE INDEX BY BINARY_INTEGER;
76275 TYPE t_array_source_32 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
76276 TYPE t_array_source_33 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
76277 TYPE t_array_source_34 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
76278 TYPE t_array_source_39 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
76279 TYPE t_array_source_70 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICING_RULE_ID%TYPE INDEX BY BINARY_INTEGER;
76280 TYPE t_array_source_85 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
76281 TYPE t_array_source_86 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
76282 TYPE t_array_source_87 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
76283
76284 TYPE t_array_source_11 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_FUND_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
76285 TYPE t_array_source_21 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
76286 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
76287 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
76288 TYPE t_array_source_37 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
76289 TYPE t_array_source_38 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
76290 TYPE t_array_source_40 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
76291 TYPE t_array_source_41 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
76292 TYPE t_array_source_42 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
76293 TYPE t_array_source_43 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
76294 TYPE t_array_source_57 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_TAX_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
76295 TYPE t_array_source_58 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_ACCOUNT_VALID_FLAG%TYPE INDEX BY BINARY_INTEGER;
76296 TYPE t_array_source_68 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.ROUNDING_CORRECTION_FLAG%TYPE INDEX BY BINARY_INTEGER;
76297
76298 l_array_source_8 t_array_source_8;
76299 l_array_source_12 t_array_source_12;
76300 l_array_source_32 t_array_source_32;
76301 l_array_source_33 t_array_source_33;
76302 l_array_source_34 t_array_source_34;
76303 l_array_source_39 t_array_source_39;
76304 l_array_source_70 t_array_source_70;
76305 l_array_source_85 t_array_source_85;
76306 l_array_source_86 t_array_source_86;
76307 l_array_source_87 t_array_source_87;
76308
76309 l_array_source_11 t_array_source_11;
76310 l_array_source_21 t_array_source_21;
76311 l_array_source_35 t_array_source_35;
76312 l_array_source_36 t_array_source_36;
76313 l_array_source_37 t_array_source_37;
76314 l_array_source_38 t_array_source_38;
76315 l_array_source_40 t_array_source_40;
76316 l_array_source_41 t_array_source_41;
76317 l_array_source_42 t_array_source_42;
76318 l_array_source_43 t_array_source_43;
76319 l_array_source_57 t_array_source_57;
76320 l_array_source_58 t_array_source_58;
76321 l_array_source_68 t_array_source_68;
76322
76323 --
76324 CURSOR header_cur
76325 IS
76326 SELECT /*+ leading(xet) cardinality(xet,1) */
76327 -- Event Class Code: INVOICE
76328 xet.entity_id
76329 ,xet.legal_entity_id
76330 ,xet.entity_code
76331 ,xet.transaction_number
76332 ,xet.event_id
76333 ,xet.event_class_code
76334 ,xet.event_type_code
76335 ,xet.event_number
76336 ,xet.event_date
76337 ,xet.transaction_date
76338 ,xet.reference_num_1
76339 ,xet.reference_num_2
76340 ,xet.reference_num_3
76341 ,xet.reference_num_4
76342 ,xet.reference_char_1
76343 ,xet.reference_char_2
76344 ,xet.reference_char_3
76345 ,xet.reference_char_4
76346 ,xet.reference_date_1
76347 ,xet.reference_date_2
76348 ,xet.reference_date_3
76349 ,xet.reference_date_4
76350 ,xet.event_created_by
76351 ,xet.budgetary_control_flag
76352 , h5.TRX_RECEIVABLE_CCID source_8
76353 , h1.BILL_CUSTOMER_CLASS_CODE source_12
76354 , h1.BILL_CUST_ACCOUNT_ID source_32
76355 , h2.BILL_USES_SITE_USE_ID source_33
76356 , h5.XLA_PARTY_TYPE source_34
76357 , h5.TRX_INVOICE_CURRENCY_CODE source_39
76358 , h5.TRX_INVOICING_RULE_ID source_70
76359 , h5.TRX_DOC_SEQUENCE_CATEGORY source_85
76360 , h5.TRX_DOC_SEQUENCE_ID source_86
76361 , h5.TRX_DOC_SEQUENCE_VALUE source_87
76362 FROM xla_events_gt xet
76363 , AR_BILL_TO_CUSTOMERS_S_V h1
76364 , AR_BILL_TO_SITE_USES_S_V h2
76365 , AR_TRANSACTIONS_S_V h5
76366 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
76367 and xet.event_class_code = C_EVENT_CLASS_CODE
76368 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
76369 AND h2.event_id = h1.event_id
76370 AND h5.event_id = h1.event_id
76371
76372 ORDER BY event_id
76373 ;
76374
76375
76376 --
76377 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
76378 IS
76379 SELECT /*+ leading(xet) cardinality(xet,1) */
76380 -- Event Class Code: INVOICE
76381 xet.entity_id
76382 ,xet.legal_entity_id
76383 ,xet.entity_code
76384 ,xet.transaction_number
76385 ,xet.event_id
76389 ,xet.event_date
76386 ,xet.event_class_code
76387 ,xet.event_type_code
76388 ,xet.event_number
76390 ,xet.transaction_date
76391 ,xet.reference_num_1
76392 ,xet.reference_num_2
76393 ,xet.reference_num_3
76394 ,xet.reference_num_4
76395 ,xet.reference_char_1
76396 ,xet.reference_char_2
76397 ,xet.reference_char_3
76398 ,xet.reference_char_4
76399 ,xet.reference_date_1
76400 ,xet.reference_date_2
76401 ,xet.reference_date_3
76402 ,xet.reference_date_4
76403 ,xet.event_created_by
76404 ,xet.budgetary_control_flag
76405 , l3.LINE_NUMBER
76406 , l6.FEDERAL_FUND_CATEGORY source_11
76407 , l4.TRX_LINE_DIST_CCID source_21
76408 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_35
76409 , l4.TRX_LINE_DIST_ID source_36
76410 , l4.TRX_DISTRIBUTION_TYPE source_37
76411 , l4.TRX_LINE_DIST_AMT source_38
76412 , l3.TRX_LINE_CUR_CONVERSION_DATE source_40
76413 , l3.TRX_LINE_CUR_CONVERSION_RATE source_41
76414 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_42
76415 , l3.TRX_LINE_ACCTD_AMT source_43
76416 , l4.TRX_TAX_LINE_ID source_57
76417 , l6.FEDERAL_ACCOUNT_VALID_FLAG source_58
76418 , l3.ROUNDING_CORRECTION_FLAG source_68
76419 FROM xla_events_gt xet
76420 , AR_CUST_TRX_LINES_BASE_V l3
76421 , AR_CUST_TRX_LINES_L_V l4
76422 , FV_XLA_AR_REF_V l6
76423 WHERE xet.event_id between x_first_event_id and x_last_event_id
76424 and xet.event_date between p_pad_start_date and p_pad_end_date
76425 and xet.event_class_code = C_EVENT_CLASS_CODE
76426 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
76427 AND l4.event_id = l3.event_id
76428 AND l4.line_number = l3.line_number
76429 AND l6.federal_event_id (+) = l4.event_id AND l6.federal_line_number (+) = l4.line_number;
76430
76431 --
76432 BEGIN
76433 IF g_log_enabled THEN
76434 l_log_module := C_DEFAULT_MODULE||'.EventClass_144';
76435 END IF;
76436 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
76437 trace
76438 (p_msg => 'BEGIN of EventClass_144'
76439 ,p_level => C_LEVEL_PROCEDURE
76440 ,p_module => l_log_module);
76441 END IF;
76442
76443 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
76444 trace
76445 (p_msg => 'p_application_id = '||p_application_id||
76446 ' - p_base_ledger_id = '||p_base_ledger_id||
76447 ' - p_target_ledger_id = '||p_target_ledger_id||
76448 ' - p_language = '||p_language||
76449 ' - p_currency_code = '||p_currency_code||
76450 ' - p_sla_ledger_id = '||p_sla_ledger_id
76451 ,p_level => C_LEVEL_STATEMENT
76452 ,p_module => l_log_module);
76453 END IF;
76454 --
76455 -- initialze arrays
76456 --
76457 g_array_event.DELETE;
76458 l_rec_array_event := l_null_rec_array_event;
76459 --
76460 --------------------------------------
76461 -- 4262811 Initialze MPA Line Number
76462 --------------------------------------
76463 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
76464
76465 --
76466
76467 --
76468 OPEN header_cur;
76469 --
76470 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
76471 trace
76472 (p_msg => 'SQL - FETCH header_cur'
76473 ,p_level => C_LEVEL_STATEMENT
76474 ,p_module => l_log_module);
76475 END IF;
76476 --
76477 LOOP
76478 FETCH header_cur BULK COLLECT INTO
76479 l_array_entity_id
76480 , l_array_legal_entity_id
76481 , l_array_entity_code
76482 , l_array_transaction_num
76483 , l_array_event_id
76484 , l_array_class_code
76485 , l_array_event_type
76486 , l_array_event_number
76487 , l_array_event_date
76488 , l_array_transaction_date
76489 , l_array_reference_num_1
76490 , l_array_reference_num_2
76491 , l_array_reference_num_3
76492 , l_array_reference_num_4
76493 , l_array_reference_char_1
76494 , l_array_reference_char_2
76495 , l_array_reference_char_3
76496 , l_array_reference_char_4
76497 , l_array_reference_date_1
76498 , l_array_reference_date_2
76499 , l_array_reference_date_3
76500 , l_array_reference_date_4
76501 , l_array_event_created_by
76502 , l_array_budgetary_control_flag
76503 , l_array_source_8
76504 , l_array_source_12
76505 , l_array_source_32
76506 , l_array_source_33
76507 , l_array_source_34
76508 , l_array_source_39
76509 , l_array_source_70
76510 , l_array_source_85
76511 , l_array_source_86
76512 , l_array_source_87
76513 LIMIT l_rows;
76514 --
76515 IF (C_LEVEL_EVENT >= g_log_level) THEN
76516 trace
76517 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
76518 ,p_level => C_LEVEL_EVENT
76519 ,p_module => l_log_module);
76520 END IF;
76521 --
76522 EXIT WHEN l_array_entity_id.COUNT = 0;
76523
76524 -- initialize arrays
76525 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
76526 XLA_AE_LINES_PKG.g_rec_lines := NULL;
76527
76528 --
76529 -- Bug 4458708
76530 --
76531 XLA_AE_LINES_PKG.g_LineNumber := 0;
76532
76533
76534 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
76535 g_last_hdr_idx := l_array_event_id.LAST;
76536 --
76537 -- loop for the headers. Each iteration is for each header extract row
76538 -- fetched in header cursor
76539 --
76540 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
76541
76542 --
76543 -- set event info as cache for other routines to refer event attributes
76544 --
76548 ,p_base_ledger_id => p_base_ledger_id
76545 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
76546 (p_application_id => p_application_id
76547 ,p_primary_ledger_id => p_primary_ledger_id
76549 ,p_target_ledger_id => p_target_ledger_id
76550 ,p_entity_id => l_array_entity_id(hdr_idx)
76551 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
76552 ,p_entity_code => l_array_entity_code(hdr_idx)
76553 ,p_transaction_num => l_array_transaction_num(hdr_idx)
76554 ,p_event_id => l_array_event_id(hdr_idx)
76555 ,p_event_class_code => l_array_class_code(hdr_idx)
76556 ,p_event_type_code => l_array_event_type(hdr_idx)
76557 ,p_event_number => l_array_event_number(hdr_idx)
76558 ,p_event_date => l_array_event_date(hdr_idx)
76559 ,p_transaction_date => l_array_transaction_date(hdr_idx)
76560 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
76561 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
76562 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
76563 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
76564 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
76565 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
76566 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
76567 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
76568 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
76569 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
76570 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
76571 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
76572 ,p_event_created_by => l_array_event_created_by(hdr_idx)
76573 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
76574
76575 --
76576 -- set the status of entry to C_VALID (0)
76577 --
76578 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
76579
76580 --
76581 -- initialize a row for ae header
76582 --
76583 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
76584
76585 l_event_id := l_array_event_id(hdr_idx);
76586
76587 --
76588 -- storing the hdr_idx for event. May be used by line cursor.
76589 --
76590 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
76591
76592 --
76593 -- store sources from header extract. This can be improved to
76594 -- store only those sources from header extract that may be used in lines
76595 --
76596
76597 g_array_event(l_event_id).array_value_num('source_8') := l_array_source_8(hdr_idx);
76598 g_array_event(l_event_id).array_value_char('source_12') := l_array_source_12(hdr_idx);
76599 g_array_event(l_event_id).array_value_num('source_32') := l_array_source_32(hdr_idx);
76600 g_array_event(l_event_id).array_value_num('source_33') := l_array_source_33(hdr_idx);
76601 g_array_event(l_event_id).array_value_char('source_34') := l_array_source_34(hdr_idx);
76602 g_array_event(l_event_id).array_value_char('source_39') := l_array_source_39(hdr_idx);
76603 g_array_event(l_event_id).array_value_num('source_70') := l_array_source_70(hdr_idx);
76604 g_array_event(l_event_id).array_value_char('source_85') := l_array_source_85(hdr_idx);
76605 g_array_event(l_event_id).array_value_num('source_86') := l_array_source_86(hdr_idx);
76606 g_array_event(l_event_id).array_value_num('source_87') := l_array_source_87(hdr_idx);
76607
76608 --
76609 -- initilaize the status of ae headers for diffrent balance types
76610 -- the status is initialised to C_NOT_CREATED (2)
76611 --
76612 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
76613 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
76614 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
76615
76616 --
76617 -- call api to validate and store accounting attributes for header
76618 --
76619
76620 ------------------------------------------------------------
76621 -- Accrual Reversal : to get date for Standard Source (NONE)
76622 ------------------------------------------------------------
76623 l_acc_rev_gl_date_source := NULL;
76624
76625 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
76626 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_85');
76627 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
76628 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_86');
76629 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
76630 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_87');
76631 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
76632 l_rec_acct_attrs.array_date_value(4) :=
76633 xla_ae_sources_pkg.GetSystemSourceDate(
76634 p_source_code => 'XLA_EVENT_DATE'
76635 , p_source_type_code => 'Y'
76636 , p_source_application_id => 602
76637 );
76638
76639
76640 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
76641
76642 XLA_AE_HEADER_PKG.SetJeCategoryName;
76643
76644 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
76645 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
76646 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
76647 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
76648 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
76649
76650
76651 -- No header level analytical criteria
76652
76653 --
76654 --accounting attribute enhancement, bug 3612931
76655 --
76656 l_trx_reversal_source := SUBSTR(NULL, 1,30);
76660
76657
76658 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
76659 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
76661 xla_accounting_err_pkg.build_message
76662 (p_appli_s_name => 'XLA'
76663 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
76664 ,p_token_1 => 'ACCT_ATTR_NAME'
76665 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
76666 ,p_token_2 => 'PRODUCT_NAME'
76667 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
76668 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
76669 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
76670 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
76671
76672 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
76673 --
76674 -- following sets the accounting attributes needed to reverse
76675 -- accounting for a distributeion
76676 --
76677 xla_ae_lines_pkg.SetTrxReversalAttrs
76678 (p_event_id => l_event_id
76679 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
76680 ,p_trx_reversal_source => l_trx_reversal_source);
76681
76682 END IF;
76683
76684
76685 ----------------------------------------------------------------
76686 -- 4262811 - update the header statuses to invalid in need be
76687 ----------------------------------------------------------------
76688 --
76689 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
76690
76691
76692 -----------------------------------------------
76693 -- No accrual reversal for the event class/type
76694 -----------------------------------------------
76695 ----------------------------------------------------------------
76696
76697 --
76698 -- this ends the header loop iteration for one bulk fetch
76699 --
76700 END LOOP;
76701
76702 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
76703 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
76704
76705 --
76706 -- insert dummy rows into lines gt table that were created due to
76707 -- transaction reversals
76708 --
76709 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
76710 l_result := XLA_AE_LINES_PKG.InsertLines;
76711 END IF;
76712
76713 --
76714 -- reset the temp_line_num for each set of events fetched from header
76715 -- cursor rather than doing it for each new event in line cursor
76716 -- Bug 3939231
76717 --
76718 xla_ae_lines_pkg.g_temp_line_num := 0;
76719
76720
76721
76722 --
76723 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
76724 --
76725 --
76726 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
76727
76728 trace
76729 (p_msg => 'SQL - FETCH line_cur'
76730 ,p_level => C_LEVEL_STATEMENT
76731 ,p_module => l_log_module);
76732
76733 END IF;
76734 --
76735 --
76736 LOOP
76737 --
76738 FETCH line_cur BULK COLLECT INTO
76739 l_array_entity_id
76740 , l_array_legal_entity_id
76741 , l_array_entity_code
76742 , l_array_transaction_num
76743 , l_array_event_id
76744 , l_array_class_code
76745 , l_array_event_type
76746 , l_array_event_number
76747 , l_array_event_date
76748 , l_array_transaction_date
76749 , l_array_reference_num_1
76750 , l_array_reference_num_2
76751 , l_array_reference_num_3
76752 , l_array_reference_num_4
76753 , l_array_reference_char_1
76754 , l_array_reference_char_2
76755 , l_array_reference_char_3
76756 , l_array_reference_char_4
76757 , l_array_reference_date_1
76758 , l_array_reference_date_2
76759 , l_array_reference_date_3
76760 , l_array_reference_date_4
76761 , l_array_event_created_by
76762 , l_array_budgetary_control_flag
76763 , l_array_extract_line_num
76764 , l_array_source_11
76765 , l_array_source_21
76766 , l_array_source_35
76767 , l_array_source_36
76768 , l_array_source_37
76769 , l_array_source_38
76770 , l_array_source_40
76771 , l_array_source_41
76772 , l_array_source_42
76773 , l_array_source_43
76774 , l_array_source_57
76775 , l_array_source_58
76776 , l_array_source_68
76777 LIMIT l_rows;
76778
76779 --
76780 IF (C_LEVEL_EVENT >= g_log_level) THEN
76781 trace
76782 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
76783 ,p_level => C_LEVEL_EVENT
76784 ,p_module => l_log_module);
76785 END IF;
76786 --
76787 EXIT WHEN l_array_entity_id.count = 0;
76788
76789 XLA_AE_LINES_PKG.g_rec_lines := null;
76790
76791 --
76792 -- Bug 4458708
76793 --
76794 XLA_AE_LINES_PKG.g_LineNumber := 0;
76795 --
76796 --
76797
76798 FOR Idx IN 1..l_array_event_id.count LOOP
76799 --
76800 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
76801 --
76802 l_event_id := l_array_event_id(idx); -- 5648433
76803
76804 --
76805 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
76806 --
76807
76808 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
76809 (g_array_event(l_event_id).array_value_num('header_index'))
76810 ,'N'
76811 ) <> 'Y'
76812 THEN
76816 ,p_level => C_LEVEL_STATEMENT
76813 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
76814 trace
76815 (p_msg => 'Trancaction revesal option is not Y '
76817 ,p_module => l_log_module);
76818 END IF;
76819
76820 --
76821 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
76822 --
76823 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
76824 --
76825 -- set event info as cache for other routines to refer event attributes
76826 --
76827
76828 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
76829 l_previous_event_id := l_event_id;
76830
76831 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
76832 (p_application_id => p_application_id
76833 ,p_primary_ledger_id => p_primary_ledger_id
76834 ,p_base_ledger_id => p_base_ledger_id
76835 ,p_target_ledger_id => p_target_ledger_id
76836 ,p_entity_id => l_array_entity_id(Idx)
76837 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
76838 ,p_entity_code => l_array_entity_code(Idx)
76839 ,p_transaction_num => l_array_transaction_num(Idx)
76840 ,p_event_id => l_array_event_id(Idx)
76841 ,p_event_class_code => l_array_class_code(Idx)
76842 ,p_event_type_code => l_array_event_type(Idx)
76843 ,p_event_number => l_array_event_number(Idx)
76844 ,p_event_date => l_array_event_date(Idx)
76845 ,p_transaction_date => l_array_transaction_date(Idx)
76846 ,p_reference_num_1 => l_array_reference_num_1(Idx)
76847 ,p_reference_num_2 => l_array_reference_num_2(Idx)
76848 ,p_reference_num_3 => l_array_reference_num_3(Idx)
76849 ,p_reference_num_4 => l_array_reference_num_4(Idx)
76850 ,p_reference_char_1 => l_array_reference_char_1(Idx)
76851 ,p_reference_char_2 => l_array_reference_char_2(Idx)
76852 ,p_reference_char_3 => l_array_reference_char_3(Idx)
76853 ,p_reference_char_4 => l_array_reference_char_4(Idx)
76854 ,p_reference_date_1 => l_array_reference_date_1(Idx)
76855 ,p_reference_date_2 => l_array_reference_date_2(Idx)
76856 ,p_reference_date_3 => l_array_reference_date_3(Idx)
76857 ,p_reference_date_4 => l_array_reference_date_4(Idx)
76858 ,p_event_created_by => l_array_event_created_by(Idx)
76859 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
76860 --
76861 END IF;
76862
76863
76864
76865 --
76866 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
76867
76868 l_acct_reversal_source := SUBSTR(NULL, 1,30);
76869
76870 IF l_continue_with_lines THEN
76871 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
76872 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
76873
76874 xla_accounting_err_pkg.build_message
76875 (p_appli_s_name => 'XLA'
76876 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
76877 ,p_token_1 => 'LINE_NUMBER'
76878 ,p_value_1 => l_array_extract_line_num(Idx)
76879 ,p_token_2 => 'PRODUCT_NAME'
76880 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
76881 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
76882 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
76883 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
76884
76885 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
76886 --
76887 -- following sets the accounting attributes needed to reverse
76888 -- accounting for a distributeion
76889 --
76890
76891 --
76892 -- 5217187
76893 --
76894 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
76895 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
76896 g_array_event(l_event_id).array_value_num('header_index'));
76897 --
76898 --
76899
76900 -- No reversal code generated
76901
76902 xla_ae_lines_pkg.SetAcctReversalAttrs
76903 (p_event_id => l_event_id
76904 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
76905 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76906 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
76907 END IF;
76908
76909 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
76910 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
76911
76912 --
76913 AcctLineType_60 (
76914 p_application_id => p_application_id
76915 ,p_event_id => l_event_id
76916 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76917 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76918 ,p_actual_flag => l_actual_flag
76919 ,p_balance_type_code => l_balance_type_code
76920 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76921
76922 , p_source_11 => l_array_source_11(Idx)
76923 , p_source_12 => g_array_event(l_event_id).array_value_char('source_12')
76924 , p_source_21 => l_array_source_21(Idx)
76925 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
76926 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
76927 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
76928 , p_source_35 => l_array_source_35(Idx)
76929 , p_source_36 => l_array_source_36(Idx)
76930 , p_source_37 => l_array_source_37(Idx)
76931 , p_source_38 => l_array_source_38(Idx)
76932 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
76933 , p_source_40 => l_array_source_40(Idx)
76937 , p_source_57 => l_array_source_57(Idx)
76934 , p_source_41 => l_array_source_41(Idx)
76935 , p_source_42 => l_array_source_42(Idx)
76936 , p_source_43 => l_array_source_43(Idx)
76938 , p_source_58 => l_array_source_58(Idx)
76939 );
76940 If(l_balance_type_code = 'A') THEN
76941 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76942 END IF;
76943
76944 --
76945
76946
76947 --
76948 AcctLineType_61 (
76949 p_application_id => p_application_id
76950 ,p_event_id => l_event_id
76951 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76952 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76953 ,p_actual_flag => l_actual_flag
76954 ,p_balance_type_code => l_balance_type_code
76955 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76956
76957 , p_source_11 => l_array_source_11(Idx)
76958 , p_source_12 => g_array_event(l_event_id).array_value_char('source_12')
76959 , p_source_21 => l_array_source_21(Idx)
76960 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
76961 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
76962 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
76963 , p_source_35 => l_array_source_35(Idx)
76964 , p_source_36 => l_array_source_36(Idx)
76965 , p_source_37 => l_array_source_37(Idx)
76966 , p_source_38 => l_array_source_38(Idx)
76967 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
76968 , p_source_40 => l_array_source_40(Idx)
76969 , p_source_41 => l_array_source_41(Idx)
76970 , p_source_42 => l_array_source_42(Idx)
76971 , p_source_43 => l_array_source_43(Idx)
76972 , p_source_57 => l_array_source_57(Idx)
76973 , p_source_58 => l_array_source_58(Idx)
76974 );
76975 If(l_balance_type_code = 'A') THEN
76976 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76977 END IF;
76978
76979 --
76980
76981
76982 --
76983 AcctLineType_80 (
76984 p_application_id => p_application_id
76985 ,p_event_id => l_event_id
76986 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76987 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76988 ,p_actual_flag => l_actual_flag
76989 ,p_balance_type_code => l_balance_type_code
76990 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76991
76992 , p_source_21 => l_array_source_21(Idx)
76993 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
76994 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
76995 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
76996 , p_source_35 => l_array_source_35(Idx)
76997 , p_source_36 => l_array_source_36(Idx)
76998 , p_source_37 => l_array_source_37(Idx)
76999 , p_source_38 => l_array_source_38(Idx)
77000 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
77001 , p_source_40 => l_array_source_40(Idx)
77002 , p_source_41 => l_array_source_41(Idx)
77003 , p_source_42 => l_array_source_42(Idx)
77004 , p_source_43 => l_array_source_43(Idx)
77005 , p_source_57 => l_array_source_57(Idx)
77006 );
77007 If(l_balance_type_code = 'A') THEN
77008 l_actual_gain_loss_ref := l_gain_or_loss_ref;
77009 END IF;
77010
77011 --
77012
77013
77014 --
77015 AcctLineType_81 (
77016 p_application_id => p_application_id
77017 ,p_event_id => l_event_id
77018 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77019 ,p_calculate_g_l_flag => l_calculate_g_l_flag
77020 ,p_actual_flag => l_actual_flag
77021 ,p_balance_type_code => l_balance_type_code
77022 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
77023
77024 , p_source_21 => l_array_source_21(Idx)
77025 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
77026 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
77027 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
77028 , p_source_35 => l_array_source_35(Idx)
77029 , p_source_36 => l_array_source_36(Idx)
77030 , p_source_37 => l_array_source_37(Idx)
77031 , p_source_38 => l_array_source_38(Idx)
77032 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
77033 , p_source_40 => l_array_source_40(Idx)
77034 , p_source_41 => l_array_source_41(Idx)
77035 , p_source_42 => l_array_source_42(Idx)
77036 , p_source_43 => l_array_source_43(Idx)
77037 , p_source_57 => l_array_source_57(Idx)
77038 );
77039 If(l_balance_type_code = 'A') THEN
77040 l_actual_gain_loss_ref := l_gain_or_loss_ref;
77041 END IF;
77042
77043 --
77044
77045
77046 --
77047 AcctLineType_82 (
77048 p_application_id => p_application_id
77049 ,p_event_id => l_event_id
77050 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77051 ,p_calculate_g_l_flag => l_calculate_g_l_flag
77052 ,p_actual_flag => l_actual_flag
77053 ,p_balance_type_code => l_balance_type_code
77054 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
77055
77056 , p_source_21 => l_array_source_21(Idx)
77057 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
77058 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
77059 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
77060 , p_source_35 => l_array_source_35(Idx)
77061 , p_source_36 => l_array_source_36(Idx)
77062 , p_source_37 => l_array_source_37(Idx)
77063 , p_source_38 => l_array_source_38(Idx)
77064 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
77065 , p_source_40 => l_array_source_40(Idx)
77066 , p_source_41 => l_array_source_41(Idx)
77067 , p_source_42 => l_array_source_42(Idx)
77068 , p_source_43 => l_array_source_43(Idx)
77069 , p_source_57 => l_array_source_57(Idx)
77070 , p_source_68 => l_array_source_68(Idx)
77071 );
77072 If(l_balance_type_code = 'A') THEN
77073 l_actual_gain_loss_ref := l_gain_or_loss_ref;
77074 END IF;
77075
77076 --
77077
77078
77082 ,p_event_id => l_event_id
77079 --
77080 AcctLineType_83 (
77081 p_application_id => p_application_id
77083 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77084 ,p_calculate_g_l_flag => l_calculate_g_l_flag
77085 ,p_actual_flag => l_actual_flag
77086 ,p_balance_type_code => l_balance_type_code
77087 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
77088
77089 , p_source_21 => l_array_source_21(Idx)
77090 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
77091 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
77092 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
77093 , p_source_35 => l_array_source_35(Idx)
77094 , p_source_36 => l_array_source_36(Idx)
77095 , p_source_37 => l_array_source_37(Idx)
77096 , p_source_38 => l_array_source_38(Idx)
77097 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
77098 , p_source_40 => l_array_source_40(Idx)
77099 , p_source_41 => l_array_source_41(Idx)
77100 , p_source_42 => l_array_source_42(Idx)
77101 , p_source_43 => l_array_source_43(Idx)
77102 , p_source_57 => l_array_source_57(Idx)
77103 );
77104 If(l_balance_type_code = 'A') THEN
77105 l_actual_gain_loss_ref := l_gain_or_loss_ref;
77106 END IF;
77107
77108 --
77109
77110
77111 --
77112 AcctLineType_84 (
77113 p_application_id => p_application_id
77114 ,p_event_id => l_event_id
77115 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77116 ,p_calculate_g_l_flag => l_calculate_g_l_flag
77117 ,p_actual_flag => l_actual_flag
77118 ,p_balance_type_code => l_balance_type_code
77119 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
77120
77121 , p_source_21 => l_array_source_21(Idx)
77122 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
77123 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
77124 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
77125 , p_source_35 => l_array_source_35(Idx)
77126 , p_source_36 => l_array_source_36(Idx)
77127 , p_source_37 => l_array_source_37(Idx)
77128 , p_source_38 => l_array_source_38(Idx)
77129 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
77130 , p_source_40 => l_array_source_40(Idx)
77131 , p_source_41 => l_array_source_41(Idx)
77132 , p_source_42 => l_array_source_42(Idx)
77133 , p_source_43 => l_array_source_43(Idx)
77134 , p_source_57 => l_array_source_57(Idx)
77135 );
77136 If(l_balance_type_code = 'A') THEN
77137 l_actual_gain_loss_ref := l_gain_or_loss_ref;
77138 END IF;
77139
77140 --
77141
77142
77143 --
77144 AcctLineType_85 (
77145 p_application_id => p_application_id
77146 ,p_event_id => l_event_id
77147 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77148 ,p_calculate_g_l_flag => l_calculate_g_l_flag
77149 ,p_actual_flag => l_actual_flag
77150 ,p_balance_type_code => l_balance_type_code
77151 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
77152
77153 , p_source_21 => l_array_source_21(Idx)
77154 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
77155 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
77156 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
77157 , p_source_35 => l_array_source_35(Idx)
77158 , p_source_36 => l_array_source_36(Idx)
77159 , p_source_37 => l_array_source_37(Idx)
77160 , p_source_38 => l_array_source_38(Idx)
77161 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
77162 , p_source_40 => l_array_source_40(Idx)
77163 , p_source_41 => l_array_source_41(Idx)
77164 , p_source_42 => l_array_source_42(Idx)
77165 , p_source_43 => l_array_source_43(Idx)
77166 , p_source_57 => l_array_source_57(Idx)
77167 , p_source_68 => l_array_source_68(Idx)
77168 );
77169 If(l_balance_type_code = 'A') THEN
77170 l_actual_gain_loss_ref := l_gain_or_loss_ref;
77171 END IF;
77172
77173 --
77174
77175
77176 --
77177 AcctLineType_86 (
77178 p_application_id => p_application_id
77179 ,p_event_id => l_event_id
77180 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77181 ,p_calculate_g_l_flag => l_calculate_g_l_flag
77182 ,p_actual_flag => l_actual_flag
77183 ,p_balance_type_code => l_balance_type_code
77184 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
77185
77186 , p_source_21 => l_array_source_21(Idx)
77187 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
77188 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
77189 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
77190 , p_source_35 => l_array_source_35(Idx)
77191 , p_source_36 => l_array_source_36(Idx)
77192 , p_source_37 => l_array_source_37(Idx)
77193 , p_source_38 => l_array_source_38(Idx)
77194 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
77195 , p_source_40 => l_array_source_40(Idx)
77196 , p_source_41 => l_array_source_41(Idx)
77197 , p_source_42 => l_array_source_42(Idx)
77198 , p_source_43 => l_array_source_43(Idx)
77199 , p_source_57 => l_array_source_57(Idx)
77200 , p_source_68 => l_array_source_68(Idx)
77201 );
77202 If(l_balance_type_code = 'A') THEN
77203 l_actual_gain_loss_ref := l_gain_or_loss_ref;
77204 END IF;
77205
77206 --
77207
77208
77209 --
77210 AcctLineType_90 (
77211 p_application_id => p_application_id
77212 ,p_event_id => l_event_id
77213 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77214 ,p_calculate_g_l_flag => l_calculate_g_l_flag
77215 ,p_actual_flag => l_actual_flag
77216 ,p_balance_type_code => l_balance_type_code
77217 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
77218
77219 , p_source_8 => g_array_event(l_event_id).array_value_num('source_8')
77220 , p_source_21 => l_array_source_21(Idx)
77224 , p_source_35 => l_array_source_35(Idx)
77221 , p_source_32 => g_array_event(l_event_id).array_value_num('source_32')
77222 , p_source_33 => g_array_event(l_event_id).array_value_num('source_33')
77223 , p_source_34 => g_array_event(l_event_id).array_value_char('source_34')
77225 , p_source_36 => l_array_source_36(Idx)
77226 , p_source_37 => l_array_source_37(Idx)
77227 , p_source_38 => l_array_source_38(Idx)
77228 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
77229 , p_source_40 => l_array_source_40(Idx)
77230 , p_source_41 => l_array_source_41(Idx)
77231 , p_source_42 => l_array_source_42(Idx)
77232 , p_source_43 => l_array_source_43(Idx)
77233 , p_source_57 => l_array_source_57(Idx)
77234 , p_source_70 => g_array_event(l_event_id).array_value_num('source_70')
77235 );
77236 If(l_balance_type_code = 'A') THEN
77237 l_actual_gain_loss_ref := l_gain_or_loss_ref;
77238 END IF;
77239
77240 --
77241
77242 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
77243 -- or secondary ledger that has different currency with primary
77244 -- or alc that is calculated by sla
77245 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
77246 (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'))
77247
77248 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
77249 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
77250 AND (l_actual_flag = 'A')) THEN
77251 XLA_AE_LINES_PKG.CreateGainOrLossLines(
77252 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
77253 ,p_application_id => p_application_id
77254 ,p_amb_context_code => 'DEFAULT'
77255 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
77256 ,p_event_class_code => C_EVENT_CLASS_CODE
77257 ,p_event_type_code => C_EVENT_TYPE_CODE
77258
77259 ,p_gain_ccid => -1
77260 ,p_loss_ccid => -1
77261
77262 ,p_actual_flag => l_actual_flag
77263 ,p_enc_flag => null
77264 ,p_actual_g_l_ref => l_actual_gain_loss_ref
77265 ,p_enc_g_l_ref => null
77266 );
77267 END IF;
77268 END IF;
77269 END IF;
77270
77271 ELSE
77272 --
77273 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
77274 --
77275 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
77276 trace
77277 (p_msg => 'Trancaction revesal option is Y'
77278 ,p_level => C_LEVEL_STATEMENT
77279 ,p_module => l_log_module);
77280 END IF;
77281 END IF;
77282
77283 END LOOP;
77284 l_result := XLA_AE_LINES_PKG.InsertLines ;
77285 end loop;
77286 close line_cur;
77287
77288
77289 --
77290 -- insert headers into xla_ae_headers_gt table
77291 --
77292 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
77293
77294 -- insert into errors table here.
77295
77296 END LOOP;
77297
77298 --
77299 -- 4865292
77300 --
77301 -- Compare g_hdr_extract_count with event count in
77302 -- CreateHeadersAndLines.
77303 --
77304 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
77305
77306 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
77307 trace (p_msg => '# rows extracted from header extract objects '
77308 || ' (running total): '
77309 || g_hdr_extract_count
77310 ,p_level => C_LEVEL_STATEMENT
77311 ,p_module => l_log_module);
77312 END IF;
77313
77314 CLOSE header_cur;
77315 --
77316
77317 --
77318 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
77319 trace
77320 (p_msg => 'END of EventClass_144'
77321 ,p_level => C_LEVEL_PROCEDURE
77322 ,p_module => l_log_module);
77323 END IF;
77324 --
77325 RETURN l_result;
77326 EXCEPTION
77327 WHEN xla_exceptions_pkg.application_exception THEN
77328
77329 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
77330
77331
77332 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
77333
77334 RAISE;
77335
77336 WHEN NO_DATA_FOUND THEN
77337
77338 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
77339 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
77340
77341 FOR header_record IN header_cur
77342 LOOP
77343 l_array_header_events(header_record.event_id) := header_record.event_id;
77344 END LOOP;
77345
77346 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
77347 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
77348
77349 fnd_file.put_line(fnd_file.LOG, ' ');
77350 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
77351 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
77352 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
77353
77354 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
77355 LOOP
77356 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
77357 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
77358 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
77359 END IF;
77360 END LOOP;
77361
77362 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
77366 xla_exceptions_pkg.raise_message
77363 fnd_file.put_line(fnd_file.LOG, ' ');
77364
77365
77367 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_144');
77368
77369
77370 WHEN OTHERS THEN
77371 xla_exceptions_pkg.raise_message
77372 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_144');
77373 END EventClass_144;
77374 --
77375
77376 ---------------------------------------
77377 --
77378 -- PRIVATE PROCEDURE
77379 -- insert_sources_145
77380 --
77381 ----------------------------------------
77382 --
77383 PROCEDURE insert_sources_145(
77384 p_target_ledger_id IN NUMBER
77385 , p_language IN VARCHAR2
77386 , p_sla_ledger_id IN NUMBER
77387 , p_pad_start_date IN DATE
77388 , p_pad_end_date IN DATE
77389 )
77390 IS
77391
77392 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'MISC_RECEIPT_ALL';
77393 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'MISC_RECEIPT';
77394 p_apps_owner VARCHAR2(30);
77395 l_log_module VARCHAR2(240);
77396 BEGIN
77397 IF g_log_enabled THEN
77398 l_log_module := C_DEFAULT_MODULE||'.insert_sources_145';
77399 END IF;
77400 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
77401
77402 trace
77403 (p_msg => 'BEGIN of insert_sources_145'
77404 ,p_level => C_LEVEL_PROCEDURE
77405 ,p_module => l_log_module);
77406
77407 END IF;
77408
77409 -- select APPS owner
77410 SELECT oracle_username
77411 INTO p_apps_owner
77412 FROM fnd_oracle_userid
77413 WHERE read_only_flag = 'U'
77414 ;
77415
77416 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
77417 trace
77418 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
77419 ' - p_language = '||p_language||
77420 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
77421 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
77422 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
77423 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
77424 ,p_level => C_LEVEL_STATEMENT
77425 ,p_module => l_log_module);
77426 END IF;
77427
77428
77429 --
77430 INSERT INTO xla_diag_sources --hdr2
77431 (
77432 event_id
77433 , ledger_id
77434 , sla_ledger_id
77435 , description_language
77436 , object_name
77437 , object_type_code
77438 , line_number
77439 , source_application_id
77440 , source_type_code
77441 , source_code
77442 , source_value
77443 , source_meaning
77444 , created_by
77445 , creation_date
77446 , last_update_date
77447 , last_updated_by
77448 , last_update_login
77449 , program_update_date
77450 , program_application_id
77451 , program_id
77452 , request_id
77453 )
77454 SELECT
77455 event_id
77456 , p_target_ledger_id
77457 , p_sla_ledger_id
77458 , p_language
77459 , object_name
77460 , object_type_code
77461 , line_number
77462 , source_application_id
77463 , source_type_code
77464 , source_code
77465 , SUBSTR(source_value ,1,1996)
77466 , SUBSTR(source_meaning ,1,200)
77467 , xla_environment_pkg.g_Usr_Id
77468 , TRUNC(SYSDATE)
77469 , TRUNC(SYSDATE)
77470 , xla_environment_pkg.g_Usr_Id
77471 , xla_environment_pkg.g_Login_Id
77472 , TRUNC(SYSDATE)
77473 , xla_environment_pkg.g_Prog_Appl_Id
77474 , xla_environment_pkg.g_Prog_Id
77475 , xla_environment_pkg.g_Req_Id
77476 FROM (
77477 SELECT xet.event_id event_id
77478 , 0 line_number
77479 , CASE r
77480 WHEN 1 THEN 'AR_REMIT_BANK_ACCT_H_V'
77481 WHEN 2 THEN 'AR_REMIT_BANK_ACCT_H_V'
77482 WHEN 3 THEN 'AR_REMIT_BANK_ACCT_H_V'
77483 WHEN 4 THEN 'AR_REMIT_BANK_ACCT_H_V'
77484 WHEN 5 THEN 'AR_RCT_METHOD_H_V'
77485 WHEN 6 THEN 'AR_RCT_METHOD_H_V'
77486 WHEN 7 THEN 'AR_CASH_RECEIPTS_H_V'
77487 WHEN 8 THEN 'AR_CASH_RECEIPTS_H_V'
77488 WHEN 9 THEN 'AR_CASH_RECEIPTS_H_V'
77489 WHEN 10 THEN 'AR_CASH_RECEIPTS_H_V'
77490
77491 ELSE null
77492 END object_name
77493 , CASE r
77494 WHEN 1 THEN 'HEADER'
77495 WHEN 2 THEN 'HEADER'
77496 WHEN 3 THEN 'HEADER'
77497 WHEN 4 THEN 'HEADER'
77498 WHEN 5 THEN 'HEADER'
77499 WHEN 6 THEN 'HEADER'
77500 WHEN 7 THEN 'HEADER'
77501 WHEN 8 THEN 'HEADER'
77502 WHEN 9 THEN 'HEADER'
77503 WHEN 10 THEN 'HEADER'
77504
77505 ELSE null
77506 END object_type_code
77507 , CASE r
77508 WHEN 1 THEN '222'
77509 WHEN 2 THEN '222'
77510 WHEN 3 THEN '222'
77511 WHEN 4 THEN '222'
77512 WHEN 5 THEN '222'
77513 WHEN 6 THEN '222'
77514 WHEN 7 THEN '222'
77515 WHEN 8 THEN '222'
77516 WHEN 9 THEN '222'
77517 WHEN 10 THEN '222'
77521 , 'S' source_type_code
77518
77519 ELSE null
77520 END source_application_id
77522 , CASE r
77523 WHEN 1 THEN 'RMT_BNK_BANK_CHARGES_CCID'
77524 WHEN 2 THEN 'RMT_BNK_CONFIRMATION_CCID'
77525 WHEN 3 THEN 'RMT_BNK_CASH_CCID'
77526 WHEN 4 THEN 'RMT_BNK_REMITTANCE_CCID'
77527 WHEN 5 THEN 'RCT_CLASS_REMIT_FLAG'
77528 WHEN 6 THEN 'RCT_CLASS_CONFIRM_FLAG'
77529 WHEN 7 THEN 'RCT_DOC_SEQUENCE_CATEGORY'
77530 WHEN 8 THEN 'RCT_DOC_SEQUENCE_ID'
77531 WHEN 9 THEN 'RCT_DOC_SEQUENCE_VALUE'
77532 WHEN 10 THEN 'RCT_TRX_ACCT_REVERSAL'
77533
77534 ELSE null
77535 END source_code
77536 , CASE r
77537 WHEN 1 THEN TO_CHAR(h5.RMT_BNK_BANK_CHARGES_CCID)
77538 WHEN 2 THEN TO_CHAR(h5.RMT_BNK_CONFIRMATION_CCID)
77539 WHEN 3 THEN TO_CHAR(h5.RMT_BNK_CASH_CCID)
77540 WHEN 4 THEN TO_CHAR(h5.RMT_BNK_REMITTANCE_CCID)
77541 WHEN 5 THEN TO_CHAR(h4.RCT_CLASS_REMIT_FLAG)
77542 WHEN 6 THEN TO_CHAR(h4.RCT_CLASS_CONFIRM_FLAG)
77543 WHEN 7 THEN TO_CHAR(h1.RCT_DOC_SEQUENCE_CATEGORY)
77544 WHEN 8 THEN TO_CHAR(h1.RCT_DOC_SEQUENCE_ID)
77545 WHEN 9 THEN TO_CHAR(h1.RCT_DOC_SEQUENCE_VALUE)
77546 WHEN 10 THEN TO_CHAR(h1.RCT_TRX_ACCT_REVERSAL)
77547
77548 ELSE null
77549 END source_value
77550 , null source_meaning
77551 FROM xla_events_gt xet
77552 , AR_CASH_RECEIPTS_H_V h1
77553 , AR_RCT_METHOD_H_V h4
77554 , AR_REMIT_BANK_ACCT_H_V h5
77555 ,(select rownum r from all_objects where rownum <= 10 and owner = p_apps_owner)
77556 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
77557 AND xet.event_class_code = C_EVENT_CLASS_CODE
77558
77559 )
77560 ;
77561 --
77562 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
77563
77564 trace
77565 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
77566 ,p_level => C_LEVEL_STATEMENT
77567 ,p_module => l_log_module);
77568
77569 END IF;
77570 --
77571
77572
77573
77574 --
77575 INSERT INTO xla_diag_sources --line2
77576 (
77577 event_id
77578 , ledger_id
77579 , sla_ledger_id
77580 , description_language
77581 , object_name
77582 , object_type_code
77583 , line_number
77584 , source_application_id
77585 , source_type_code
77586 , source_code
77587 , source_value
77588 , source_meaning
77589 , created_by
77590 , creation_date
77591 , last_update_date
77592 , last_updated_by
77593 , last_update_login
77594 , program_update_date
77595 , program_application_id
77596 , program_id
77597 , request_id
77598 )
77599 SELECT event_id
77600 , p_target_ledger_id
77601 , p_sla_ledger_id
77602 , p_language
77603 , object_name
77604 , object_type_code
77605 , line_number
77606 , source_application_id
77607 , source_type_code
77608 , source_code
77609 , SUBSTR(source_value,1,1996)
77610 , SUBSTR(source_meaning ,1,200)
77611 , xla_environment_pkg.g_Usr_Id
77612 , TRUNC(SYSDATE)
77613 , TRUNC(SYSDATE)
77614 , xla_environment_pkg.g_Usr_Id
77615 , xla_environment_pkg.g_Login_Id
77616 , TRUNC(SYSDATE)
77617 , xla_environment_pkg.g_Prog_Appl_Id
77618 , xla_environment_pkg.g_Prog_Id
77619 , xla_environment_pkg.g_Req_Id
77620 FROM (
77621 SELECT xet.event_id event_id
77622 , l3.line_number line_number
77623 , CASE r
77624 WHEN 1 THEN 'AR_DISTRIBUTIONS_L_V'
77625 WHEN 2 THEN 'FV_XLA_AR_REF_V'
77626 WHEN 3 THEN 'FV_XLA_AR_REF_V'
77627 WHEN 4 THEN 'FV_XLA_AR_REF_V'
77628 WHEN 5 THEN 'FV_XLA_AR_REF_V'
77629 WHEN 6 THEN 'FV_XLA_AR_REF_V'
77630 WHEN 7 THEN 'AR_DISTRIBUTIONS_L_V'
77631 WHEN 8 THEN 'AR_DISTRIBUTIONS_L_V'
77632 WHEN 9 THEN 'AR_DISTRIBUTIONS_L_V'
77633 WHEN 10 THEN 'AR_DISTRIBUTIONS_L_V'
77634 WHEN 11 THEN 'AR_DISTRIBUTIONS_L_V'
77635 WHEN 12 THEN 'AR_DISTRIBUTIONS_BASE_V'
77636 WHEN 13 THEN 'AR_DISTRIBUTIONS_BASE_V'
77637 WHEN 14 THEN 'AR_DISTRIBUTIONS_BASE_V'
77638 WHEN 15 THEN 'FV_XLA_AR_REF_V'
77639 WHEN 16 THEN 'AR_DISTRIBUTIONS_BASE_V'
77640 WHEN 17 THEN 'AR_DISTRIBUTIONS_L_V'
77641
77642 ELSE null
77643 END object_name
77644 , CASE r
77645 WHEN 1 THEN 'LINE'
77646 WHEN 2 THEN 'LINE'
77647 WHEN 3 THEN 'LINE'
77648 WHEN 4 THEN 'LINE'
77649 WHEN 5 THEN 'LINE'
77650 WHEN 6 THEN 'LINE'
77651 WHEN 7 THEN 'LINE'
77652 WHEN 8 THEN 'LINE'
77653 WHEN 9 THEN 'LINE'
77654 WHEN 10 THEN 'LINE'
77655 WHEN 11 THEN 'LINE'
77656 WHEN 12 THEN 'LINE'
77657 WHEN 13 THEN 'LINE'
77658 WHEN 14 THEN 'LINE'
77662
77659 WHEN 15 THEN 'LINE'
77660 WHEN 16 THEN 'LINE'
77661 WHEN 17 THEN 'LINE'
77663 ELSE null
77664 END object_type_code
77665 , CASE r
77666 WHEN 1 THEN '222'
77667 WHEN 2 THEN '8901'
77668 WHEN 3 THEN '8901'
77669 WHEN 4 THEN '8901'
77670 WHEN 5 THEN '8901'
77671 WHEN 6 THEN '8901'
77672 WHEN 7 THEN '222'
77673 WHEN 8 THEN '222'
77674 WHEN 9 THEN '222'
77675 WHEN 10 THEN '222'
77676 WHEN 11 THEN '222'
77677 WHEN 12 THEN '222'
77678 WHEN 13 THEN '222'
77679 WHEN 14 THEN '222'
77680 WHEN 15 THEN '8901'
77681 WHEN 16 THEN '222'
77682 WHEN 17 THEN '222'
77683
77684 ELSE null
77685 END source_application_id
77686 , 'S' source_type_code
77687 , CASE r
77688 WHEN 1 THEN 'DIST_CODE_COMBINATION_ID'
77689 WHEN 2 THEN 'FEDERAL_FUND_CATEGORY'
77690 WHEN 3 THEN 'FEDERAL_FUND_EXPIRED_STATUS'
77691 WHEN 4 THEN 'FEDERAL_PRIOR_YEAR_FLAG'
77692 WHEN 5 THEN 'FEDERAL_FUND_TIME_FRAME'
77693 WHEN 6 THEN 'FEDERAL_APPORTIONMENT_CATEGORY'
77694 WHEN 7 THEN 'DIST_SOURCE_TYPE'
77695 WHEN 8 THEN 'DIST_LINE_ID'
77696 WHEN 9 THEN 'DISTRIBUTION_TYPE'
77697 WHEN 10 THEN 'DIST_ENT_AMT'
77698 WHEN 11 THEN 'DIST_CURRENCY_CODE'
77699 WHEN 12 THEN 'DIST_CUR_CONVERSION_RATE'
77700 WHEN 13 THEN 'DIST_CUR_CONVERSION_TYPE'
77701 WHEN 14 THEN 'DIST_TO_ACCTD_AMT'
77702 WHEN 15 THEN 'FEDERAL_ACCOUNT_VALID_FLAG'
77703 WHEN 16 THEN 'DIST_TO_CUR_CONVERSION_DATE'
77704 WHEN 17 THEN 'DIST_MFAR_ADDITIONAL_ENTRY'
77705
77706 ELSE null
77707 END source_code
77708 , CASE r
77709 WHEN 1 THEN TO_CHAR(l3.DIST_CODE_COMBINATION_ID)
77710 WHEN 2 THEN TO_CHAR(l6.FEDERAL_FUND_CATEGORY)
77711 WHEN 3 THEN TO_CHAR(l6.FEDERAL_FUND_EXPIRED_STATUS)
77712 WHEN 4 THEN TO_CHAR(l6.FEDERAL_PRIOR_YEAR_FLAG)
77713 WHEN 5 THEN TO_CHAR(l6.FEDERAL_FUND_TIME_FRAME)
77714 WHEN 6 THEN TO_CHAR(l6.FEDERAL_APPORTIONMENT_CATEGORY)
77715 WHEN 7 THEN TO_CHAR(l3.DIST_SOURCE_TYPE)
77716 WHEN 8 THEN TO_CHAR(l3.DIST_LINE_ID)
77717 WHEN 9 THEN TO_CHAR(l3.DISTRIBUTION_TYPE)
77718 WHEN 10 THEN TO_CHAR(l3.DIST_ENT_AMT)
77719 WHEN 11 THEN TO_CHAR(l3.DIST_CURRENCY_CODE)
77720 WHEN 12 THEN TO_CHAR(l2.DIST_CUR_CONVERSION_RATE)
77721 WHEN 13 THEN TO_CHAR(l2.DIST_CUR_CONVERSION_TYPE)
77722 WHEN 14 THEN TO_CHAR(l2.DIST_TO_ACCTD_AMT)
77723 WHEN 15 THEN TO_CHAR(l6.FEDERAL_ACCOUNT_VALID_FLAG)
77724 WHEN 16 THEN TO_CHAR(l2.DIST_TO_CUR_CONVERSION_DATE)
77725 WHEN 17 THEN TO_CHAR(l3.DIST_MFAR_ADDITIONAL_ENTRY)
77726
77727 ELSE null
77728 END source_value
77729 , null source_meaning
77730 FROM xla_events_gt xet
77731 , AR_DISTRIBUTIONS_BASE_V l2
77732 , AR_DISTRIBUTIONS_L_V l3
77733 , FV_XLA_AR_REF_V l6
77734 , (select rownum r from all_objects where rownum <= 17 and owner = p_apps_owner)
77735 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
77736 AND xet.event_class_code = C_EVENT_CLASS_CODE
77737 AND l2.event_id = xet.event_id
77738 AND l3.event_id = l2.event_id
77739 AND l3.line_number = l2.line_number
77740 AND l6.federal_event_id (+) = l3.event_id and l6.federal_line_number (+) = l3.line_number
77741 )
77742 ;
77743 --
77744 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
77745
77746 trace
77747 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
77748 ,p_level => C_LEVEL_STATEMENT
77749 ,p_module => l_log_module);
77750
77751 END IF;
77752
77753
77754 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
77755 trace
77756 (p_msg => 'END of insert_sources_145'
77757 ,p_level => C_LEVEL_PROCEDURE
77758 ,p_module => l_log_module);
77759 END IF;
77760 EXCEPTION
77761 WHEN xla_exceptions_pkg.application_exception THEN
77762 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
77763 trace
77764 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
77765 ,p_level => C_LEVEL_EXCEPTION
77766 ,p_module => l_log_module);
77767 END IF;
77768 RAISE;
77769 WHEN OTHERS THEN
77770 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
77771 trace
77772 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
77773 ,p_level => C_LEVEL_EXCEPTION
77774 ,p_module => l_log_module);
77775 END IF;
77776 xla_exceptions_pkg.raise_message
77777 (p_location => 'XLA_00222_AAD_S_000009_PKG.insert_sources_145');
77778 END insert_sources_145;
77779 --
77780
77781 ---------------------------------------
77782 --
77783 -- PRIVATE FUNCTION
77784 -- EventClass_145
77785 --
77786 ----------------------------------------
77787 --
77788 FUNCTION EventClass_145
77792 ,p_language IN VARCHAR2
77789 (p_application_id IN NUMBER
77790 ,p_base_ledger_id IN NUMBER
77791 ,p_target_ledger_id IN NUMBER
77793 ,p_currency_code IN VARCHAR2
77794 ,p_sla_ledger_id IN NUMBER
77795 ,p_pad_start_date IN DATE
77796 ,p_pad_end_date IN DATE
77797 ,p_primary_ledger_id IN NUMBER)
77798 RETURN BOOLEAN IS
77799 --
77800 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'MISC_RECEIPT_ALL';
77801 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'MISC_RECEIPT';
77802
77803 l_calculate_acctd_flag VARCHAR2(1) :='N';
77804 l_calculate_g_l_flag VARCHAR2(1) :='N';
77805 --
77806 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77807 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77808 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
77809 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
77810 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77811 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
77812 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
77813 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77814 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
77815 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
77816 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77817 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77818 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77819 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77820 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
77821 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
77822 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
77823 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
77824 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
77825 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
77826 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
77827 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
77828 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
77829 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
77830 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
77831 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
77832
77833 l_event_id NUMBER;
77834 l_previous_event_id NUMBER;
77835 l_first_event_id NUMBER;
77836 l_last_event_id NUMBER;
77837
77838 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
77839 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
77840 --
77841 --
77842 l_result BOOLEAN := TRUE;
77843 l_rows NUMBER := 1000;
77844 l_event_type_name VARCHAR2(80) := 'All';
77845 l_event_class_name VARCHAR2(80) := 'Miscellaneous Receipt';
77846 l_description VARCHAR2(4000);
77847 l_transaction_reversal NUMBER;
77848 l_ae_header_id NUMBER;
77849 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
77850 l_log_module VARCHAR2(240);
77851 --
77852 l_acct_reversal_source VARCHAR2(30);
77853 l_trx_reversal_source VARCHAR2(30);
77854
77855 l_continue_with_lines BOOLEAN := TRUE;
77856 --
77857 l_acc_rev_gl_date_source DATE; -- 4262811
77858 --
77859 type t_array_event_id is table of number index by binary_integer;
77860
77861 l_rec_array_event t_rec_array_event;
77862 l_null_rec_array_event t_rec_array_event;
77863 l_array_ae_header_id xla_number_array_type;
77864 l_actual_flag VARCHAR2(1) := NULL;
77865 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
77866 l_balance_type_code VARCHAR2(1) :=NULL;
77867 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
77868
77869 --
77870 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
77871 --
77872
77873 TYPE t_array_source_1 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_BANK_CHARGES_CCID%TYPE INDEX BY BINARY_INTEGER;
77874 TYPE t_array_source_3 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_CONFIRMATION_CCID%TYPE INDEX BY BINARY_INTEGER;
77875 TYPE t_array_source_5 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_CASH_CCID%TYPE INDEX BY BINARY_INTEGER;
77876 TYPE t_array_source_6 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_REMITTANCE_CCID%TYPE INDEX BY BINARY_INTEGER;
77877 TYPE t_array_source_72 IS TABLE OF AR_RCT_METHOD_H_V.RCT_CLASS_REMIT_FLAG%TYPE INDEX BY BINARY_INTEGER;
77878 TYPE t_array_source_73 IS TABLE OF AR_RCT_METHOD_H_V.RCT_CLASS_CONFIRM_FLAG%TYPE INDEX BY BINARY_INTEGER;
77879 TYPE t_array_source_88 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
77880 TYPE t_array_source_89 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
77881 TYPE t_array_source_90 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
77882 TYPE t_array_source_91 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_TRX_ACCT_REVERSAL%TYPE INDEX BY BINARY_INTEGER;
77883
77884 TYPE t_array_source_10 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
77885 TYPE t_array_source_11 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_FUND_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
77886 TYPE t_array_source_14 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_FUND_EXPIRED_STATUS%TYPE INDEX BY BINARY_INTEGER;
77890 TYPE t_array_source_22 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
77887 TYPE t_array_source_15 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_PRIOR_YEAR_FLAG%TYPE INDEX BY BINARY_INTEGER;
77888 TYPE t_array_source_16 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_FUND_TIME_FRAME%TYPE INDEX BY BINARY_INTEGER;
77889 TYPE t_array_source_17 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_APPORTIONMENT_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
77891 TYPE t_array_source_24 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
77892 TYPE t_array_source_25 IS TABLE OF AR_DISTRIBUTIONS_L_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
77893 TYPE t_array_source_26 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT%TYPE INDEX BY BINARY_INTEGER;
77894 TYPE t_array_source_27 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
77895 TYPE t_array_source_29 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
77896 TYPE t_array_source_30 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
77897 TYPE t_array_source_31 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
77898 TYPE t_array_source_58 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_ACCOUNT_VALID_FLAG%TYPE INDEX BY BINARY_INTEGER;
77899 TYPE t_array_source_59 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
77900 TYPE t_array_source_71 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_MFAR_ADDITIONAL_ENTRY%TYPE INDEX BY BINARY_INTEGER;
77901
77902 l_array_source_1 t_array_source_1;
77903 l_array_source_3 t_array_source_3;
77904 l_array_source_5 t_array_source_5;
77905 l_array_source_6 t_array_source_6;
77906 l_array_source_72 t_array_source_72;
77907 l_array_source_73 t_array_source_73;
77908 l_array_source_88 t_array_source_88;
77909 l_array_source_89 t_array_source_89;
77910 l_array_source_90 t_array_source_90;
77911 l_array_source_91 t_array_source_91;
77912
77913 l_array_source_10 t_array_source_10;
77914 l_array_source_11 t_array_source_11;
77915 l_array_source_14 t_array_source_14;
77916 l_array_source_15 t_array_source_15;
77917 l_array_source_16 t_array_source_16;
77918 l_array_source_17 t_array_source_17;
77919 l_array_source_22 t_array_source_22;
77920 l_array_source_24 t_array_source_24;
77921 l_array_source_25 t_array_source_25;
77922 l_array_source_26 t_array_source_26;
77923 l_array_source_27 t_array_source_27;
77924 l_array_source_29 t_array_source_29;
77925 l_array_source_30 t_array_source_30;
77926 l_array_source_31 t_array_source_31;
77927 l_array_source_58 t_array_source_58;
77928 l_array_source_59 t_array_source_59;
77929 l_array_source_71 t_array_source_71;
77930
77931 --
77932 CURSOR header_cur
77933 IS
77934 SELECT /*+ leading(xet) cardinality(xet,1) */
77935 -- Event Class Code: MISC_RECEIPT
77936 xet.entity_id
77937 ,xet.legal_entity_id
77938 ,xet.entity_code
77939 ,xet.transaction_number
77940 ,xet.event_id
77941 ,xet.event_class_code
77942 ,xet.event_type_code
77943 ,xet.event_number
77944 ,xet.event_date
77945 ,xet.transaction_date
77946 ,xet.reference_num_1
77947 ,xet.reference_num_2
77948 ,xet.reference_num_3
77949 ,xet.reference_num_4
77950 ,xet.reference_char_1
77951 ,xet.reference_char_2
77952 ,xet.reference_char_3
77953 ,xet.reference_char_4
77954 ,xet.reference_date_1
77955 ,xet.reference_date_2
77956 ,xet.reference_date_3
77957 ,xet.reference_date_4
77958 ,xet.event_created_by
77959 ,xet.budgetary_control_flag
77960 , h5.RMT_BNK_BANK_CHARGES_CCID source_1
77961 , h5.RMT_BNK_CONFIRMATION_CCID source_3
77962 , h5.RMT_BNK_CASH_CCID source_5
77963 , h5.RMT_BNK_REMITTANCE_CCID source_6
77964 , h4.RCT_CLASS_REMIT_FLAG source_72
77965 , h4.RCT_CLASS_CONFIRM_FLAG source_73
77966 , h1.RCT_DOC_SEQUENCE_CATEGORY source_88
77967 , h1.RCT_DOC_SEQUENCE_ID source_89
77968 , h1.RCT_DOC_SEQUENCE_VALUE source_90
77969 , h1.RCT_TRX_ACCT_REVERSAL source_91
77970 FROM xla_events_gt xet
77971 , AR_CASH_RECEIPTS_H_V h1
77972 , AR_RCT_METHOD_H_V h4
77973 , AR_REMIT_BANK_ACCT_H_V h5
77974 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
77975 and xet.event_class_code = C_EVENT_CLASS_CODE
77976 and xet.event_status_code <> 'N' AND h1.event_id (+) = xet.event_id
77977 AND h4.event_id (+) = xet.event_id
77978 AND h5.event_id (+) = xet.event_id
77979
77980 ORDER BY event_id
77981 ;
77982
77983
77984 --
77985 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
77986 IS
77987 SELECT /*+ leading(xet) cardinality(xet,1) */
77988 -- Event Class Code: MISC_RECEIPT
77989 xet.entity_id
77990 ,xet.legal_entity_id
77991 ,xet.entity_code
77992 ,xet.transaction_number
77993 ,xet.event_id
77994 ,xet.event_class_code
77995 ,xet.event_type_code
77996 ,xet.event_number
77997 ,xet.event_date
77998 ,xet.transaction_date
77999 ,xet.reference_num_1
78000 ,xet.reference_num_2
78001 ,xet.reference_num_3
78002 ,xet.reference_num_4
78003 ,xet.reference_char_1
78004 ,xet.reference_char_2
78005 ,xet.reference_char_3
78006 ,xet.reference_char_4
78007 ,xet.reference_date_1
78008 ,xet.reference_date_2
78009 ,xet.reference_date_3
78010 ,xet.reference_date_4
78011 ,xet.event_created_by
78012 ,xet.budgetary_control_flag
78013 , l2.LINE_NUMBER
78014 , l3.DIST_CODE_COMBINATION_ID source_10
78015 , l6.FEDERAL_FUND_CATEGORY source_11
78016 , l6.FEDERAL_FUND_EXPIRED_STATUS source_14
78017 , l6.FEDERAL_PRIOR_YEAR_FLAG source_15
78021 , l3.DIST_LINE_ID source_24
78018 , l6.FEDERAL_FUND_TIME_FRAME source_16
78019 , l6.FEDERAL_APPORTIONMENT_CATEGORY source_17
78020 , l3.DIST_SOURCE_TYPE source_22
78022 , l3.DISTRIBUTION_TYPE source_25
78023 , l3.DIST_ENT_AMT source_26
78024 , l3.DIST_CURRENCY_CODE source_27
78025 , l2.DIST_CUR_CONVERSION_RATE source_29
78026 , l2.DIST_CUR_CONVERSION_TYPE source_30
78027 , l2.DIST_TO_ACCTD_AMT source_31
78028 , l6.FEDERAL_ACCOUNT_VALID_FLAG source_58
78029 , l2.DIST_TO_CUR_CONVERSION_DATE source_59
78030 , l3.DIST_MFAR_ADDITIONAL_ENTRY source_71
78031 FROM xla_events_gt xet
78032 , AR_DISTRIBUTIONS_BASE_V l2
78033 , AR_DISTRIBUTIONS_L_V l3
78034 , FV_XLA_AR_REF_V l6
78035 WHERE xet.event_id between x_first_event_id and x_last_event_id
78036 and xet.event_date between p_pad_start_date and p_pad_end_date
78037 and xet.event_class_code = C_EVENT_CLASS_CODE
78038 and xet.event_status_code <> 'N' AND l2.event_id = xet.event_id
78039 AND l3.event_id = l2.event_id
78040 AND l3.line_number = l2.line_number
78041 AND l6.federal_event_id (+) = l3.event_id AND l6.federal_line_number (+) = l3.line_number;
78042
78043 --
78044 BEGIN
78045 IF g_log_enabled THEN
78046 l_log_module := C_DEFAULT_MODULE||'.EventClass_145';
78047 END IF;
78048 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
78049 trace
78050 (p_msg => 'BEGIN of EventClass_145'
78051 ,p_level => C_LEVEL_PROCEDURE
78052 ,p_module => l_log_module);
78053 END IF;
78054
78055 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
78056 trace
78057 (p_msg => 'p_application_id = '||p_application_id||
78058 ' - p_base_ledger_id = '||p_base_ledger_id||
78059 ' - p_target_ledger_id = '||p_target_ledger_id||
78060 ' - p_language = '||p_language||
78061 ' - p_currency_code = '||p_currency_code||
78062 ' - p_sla_ledger_id = '||p_sla_ledger_id
78063 ,p_level => C_LEVEL_STATEMENT
78064 ,p_module => l_log_module);
78065 END IF;
78066 --
78067 -- initialze arrays
78068 --
78069 g_array_event.DELETE;
78070 l_rec_array_event := l_null_rec_array_event;
78071 --
78072 --------------------------------------
78073 -- 4262811 Initialze MPA Line Number
78074 --------------------------------------
78075 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
78076
78077 --
78078
78079 --
78080 OPEN header_cur;
78081 --
78082 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
78083 trace
78084 (p_msg => 'SQL - FETCH header_cur'
78085 ,p_level => C_LEVEL_STATEMENT
78086 ,p_module => l_log_module);
78087 END IF;
78088 --
78089 LOOP
78090 FETCH header_cur BULK COLLECT INTO
78091 l_array_entity_id
78092 , l_array_legal_entity_id
78093 , l_array_entity_code
78094 , l_array_transaction_num
78095 , l_array_event_id
78096 , l_array_class_code
78097 , l_array_event_type
78098 , l_array_event_number
78099 , l_array_event_date
78100 , l_array_transaction_date
78101 , l_array_reference_num_1
78102 , l_array_reference_num_2
78103 , l_array_reference_num_3
78104 , l_array_reference_num_4
78105 , l_array_reference_char_1
78106 , l_array_reference_char_2
78107 , l_array_reference_char_3
78108 , l_array_reference_char_4
78109 , l_array_reference_date_1
78110 , l_array_reference_date_2
78111 , l_array_reference_date_3
78112 , l_array_reference_date_4
78113 , l_array_event_created_by
78114 , l_array_budgetary_control_flag
78115 , l_array_source_1
78116 , l_array_source_3
78117 , l_array_source_5
78118 , l_array_source_6
78119 , l_array_source_72
78120 , l_array_source_73
78121 , l_array_source_88
78122 , l_array_source_89
78123 , l_array_source_90
78124 , l_array_source_91
78125 LIMIT l_rows;
78126 --
78127 IF (C_LEVEL_EVENT >= g_log_level) THEN
78128 trace
78129 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
78130 ,p_level => C_LEVEL_EVENT
78131 ,p_module => l_log_module);
78132 END IF;
78133 --
78134 EXIT WHEN l_array_entity_id.COUNT = 0;
78135
78136 -- initialize arrays
78137 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
78138 XLA_AE_LINES_PKG.g_rec_lines := NULL;
78139
78140 --
78141 -- Bug 4458708
78142 --
78143 XLA_AE_LINES_PKG.g_LineNumber := 0;
78144
78145
78146 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
78147 g_last_hdr_idx := l_array_event_id.LAST;
78148 --
78149 -- loop for the headers. Each iteration is for each header extract row
78150 -- fetched in header cursor
78151 --
78152 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
78153
78154 --
78155 -- set event info as cache for other routines to refer event attributes
78156 --
78157 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
78158 (p_application_id => p_application_id
78159 ,p_primary_ledger_id => p_primary_ledger_id
78160 ,p_base_ledger_id => p_base_ledger_id
78161 ,p_target_ledger_id => p_target_ledger_id
78162 ,p_entity_id => l_array_entity_id(hdr_idx)
78163 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
78164 ,p_entity_code => l_array_entity_code(hdr_idx)
78165 ,p_transaction_num => l_array_transaction_num(hdr_idx)
78166 ,p_event_id => l_array_event_id(hdr_idx)
78167 ,p_event_class_code => l_array_class_code(hdr_idx)
78171 ,p_transaction_date => l_array_transaction_date(hdr_idx)
78168 ,p_event_type_code => l_array_event_type(hdr_idx)
78169 ,p_event_number => l_array_event_number(hdr_idx)
78170 ,p_event_date => l_array_event_date(hdr_idx)
78172 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
78173 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
78174 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
78175 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
78176 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
78177 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
78178 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
78179 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
78180 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
78181 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
78182 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
78183 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
78184 ,p_event_created_by => l_array_event_created_by(hdr_idx)
78185 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
78186
78187 --
78188 -- set the status of entry to C_VALID (0)
78189 --
78190 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
78191
78192 --
78193 -- initialize a row for ae header
78194 --
78195 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
78196
78197 l_event_id := l_array_event_id(hdr_idx);
78198
78199 --
78200 -- storing the hdr_idx for event. May be used by line cursor.
78201 --
78202 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
78203
78204 --
78205 -- store sources from header extract. This can be improved to
78206 -- store only those sources from header extract that may be used in lines
78207 --
78208
78209 g_array_event(l_event_id).array_value_num('source_1') := l_array_source_1(hdr_idx);
78210 g_array_event(l_event_id).array_value_num('source_3') := l_array_source_3(hdr_idx);
78211 g_array_event(l_event_id).array_value_num('source_5') := l_array_source_5(hdr_idx);
78212 g_array_event(l_event_id).array_value_num('source_6') := l_array_source_6(hdr_idx);
78213 g_array_event(l_event_id).array_value_char('source_72') := l_array_source_72(hdr_idx);
78214 g_array_event(l_event_id).array_value_char('source_73') := l_array_source_73(hdr_idx);
78215 g_array_event(l_event_id).array_value_char('source_88') := l_array_source_88(hdr_idx);
78216 g_array_event(l_event_id).array_value_num('source_89') := l_array_source_89(hdr_idx);
78217 g_array_event(l_event_id).array_value_num('source_90') := l_array_source_90(hdr_idx);
78218 g_array_event(l_event_id).array_value_char('source_91') := l_array_source_91(hdr_idx);
78219
78220 --
78221 -- initilaize the status of ae headers for diffrent balance types
78222 -- the status is initialised to C_NOT_CREATED (2)
78223 --
78224 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
78225 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
78226 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
78227
78228 --
78229 -- call api to validate and store accounting attributes for header
78230 --
78231
78232 ------------------------------------------------------------
78233 -- Accrual Reversal : to get date for Standard Source (NONE)
78234 ------------------------------------------------------------
78235 l_acc_rev_gl_date_source := NULL;
78236
78237 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
78238 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_88');
78239 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
78240 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_89');
78241 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
78242 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_90');
78243 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
78244 l_rec_acct_attrs.array_date_value(4) :=
78245 xla_ae_sources_pkg.GetSystemSourceDate(
78246 p_source_code => 'XLA_EVENT_DATE'
78247 , p_source_type_code => 'Y'
78248 , p_source_application_id => 602
78249 );
78250 l_rec_acct_attrs.array_acct_attr_code(5) := 'TRX_ACCT_REVERSAL_OPTION';
78251 l_rec_acct_attrs.array_char_value(5) := g_array_event(l_event_id).array_value_char('source_91');
78252
78253
78254 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
78255
78256 XLA_AE_HEADER_PKG.SetJeCategoryName;
78257
78258 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
78259 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
78260 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
78261 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
78262 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
78263
78264
78265 -- No header level analytical criteria
78266
78267 --
78268 --accounting attribute enhancement, bug 3612931
78269 --
78270 l_trx_reversal_source := SUBSTR(g_array_event(l_event_id).array_value_char('source_91'), 1,30);
78271
78272 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
78273 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
78274
78275 xla_accounting_err_pkg.build_message
78276 (p_appli_s_name => 'XLA'
78277 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
78278 ,p_token_1 => 'ACCT_ATTR_NAME'
78282 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
78279 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
78280 ,p_token_2 => 'PRODUCT_NAME'
78281 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
78283 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
78284 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
78285
78286 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
78287 --
78288 -- following sets the accounting attributes needed to reverse
78289 -- accounting for a distributeion
78290 --
78291 xla_ae_lines_pkg.SetTrxReversalAttrs
78292 (p_event_id => l_event_id
78293 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
78294 ,p_trx_reversal_source => l_trx_reversal_source);
78295
78296 END IF;
78297
78298
78299 ----------------------------------------------------------------
78300 -- 4262811 - update the header statuses to invalid in need be
78301 ----------------------------------------------------------------
78302 --
78303 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
78304
78305
78306 -----------------------------------------------
78307 -- No accrual reversal for the event class/type
78308 -----------------------------------------------
78309 ----------------------------------------------------------------
78310
78311 --
78312 -- this ends the header loop iteration for one bulk fetch
78313 --
78314 END LOOP;
78315
78316 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
78317 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
78318
78319 --
78320 -- insert dummy rows into lines gt table that were created due to
78321 -- transaction reversals
78322 --
78323 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
78324 l_result := XLA_AE_LINES_PKG.InsertLines;
78325 END IF;
78326
78327 --
78328 -- reset the temp_line_num for each set of events fetched from header
78329 -- cursor rather than doing it for each new event in line cursor
78330 -- Bug 3939231
78331 --
78332 xla_ae_lines_pkg.g_temp_line_num := 0;
78333
78334
78335
78336 --
78337 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
78338 --
78339 --
78340 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
78341
78342 trace
78343 (p_msg => 'SQL - FETCH line_cur'
78344 ,p_level => C_LEVEL_STATEMENT
78345 ,p_module => l_log_module);
78346
78347 END IF;
78348 --
78349 --
78350 LOOP
78351 --
78352 FETCH line_cur BULK COLLECT INTO
78353 l_array_entity_id
78354 , l_array_legal_entity_id
78355 , l_array_entity_code
78356 , l_array_transaction_num
78357 , l_array_event_id
78358 , l_array_class_code
78359 , l_array_event_type
78360 , l_array_event_number
78361 , l_array_event_date
78362 , l_array_transaction_date
78363 , l_array_reference_num_1
78364 , l_array_reference_num_2
78365 , l_array_reference_num_3
78366 , l_array_reference_num_4
78367 , l_array_reference_char_1
78368 , l_array_reference_char_2
78369 , l_array_reference_char_3
78370 , l_array_reference_char_4
78371 , l_array_reference_date_1
78372 , l_array_reference_date_2
78373 , l_array_reference_date_3
78374 , l_array_reference_date_4
78375 , l_array_event_created_by
78376 , l_array_budgetary_control_flag
78377 , l_array_extract_line_num
78378 , l_array_source_10
78379 , l_array_source_11
78380 , l_array_source_14
78381 , l_array_source_15
78382 , l_array_source_16
78383 , l_array_source_17
78384 , l_array_source_22
78385 , l_array_source_24
78386 , l_array_source_25
78387 , l_array_source_26
78388 , l_array_source_27
78389 , l_array_source_29
78390 , l_array_source_30
78391 , l_array_source_31
78392 , l_array_source_58
78393 , l_array_source_59
78394 , l_array_source_71
78395 LIMIT l_rows;
78396
78397 --
78398 IF (C_LEVEL_EVENT >= g_log_level) THEN
78399 trace
78400 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
78401 ,p_level => C_LEVEL_EVENT
78402 ,p_module => l_log_module);
78403 END IF;
78404 --
78405 EXIT WHEN l_array_entity_id.count = 0;
78406
78407 XLA_AE_LINES_PKG.g_rec_lines := null;
78408
78409 --
78410 -- Bug 4458708
78411 --
78412 XLA_AE_LINES_PKG.g_LineNumber := 0;
78413 --
78414 --
78415
78416 FOR Idx IN 1..l_array_event_id.count LOOP
78417 --
78418 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
78419 --
78420 l_event_id := l_array_event_id(idx); -- 5648433
78421
78422 --
78423 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
78424 --
78425
78426 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
78427 (g_array_event(l_event_id).array_value_num('header_index'))
78428 ,'N'
78429 ) <> 'Y'
78430 THEN
78431 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
78432 trace
78433 (p_msg => 'Trancaction revesal option is not Y '
78434 ,p_level => C_LEVEL_STATEMENT
78435 ,p_module => l_log_module);
78436 END IF;
78440 --
78437
78438 --
78439 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
78441 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
78442 --
78443 -- set event info as cache for other routines to refer event attributes
78444 --
78445
78446 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
78447 l_previous_event_id := l_event_id;
78448
78449 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
78450 (p_application_id => p_application_id
78451 ,p_primary_ledger_id => p_primary_ledger_id
78452 ,p_base_ledger_id => p_base_ledger_id
78453 ,p_target_ledger_id => p_target_ledger_id
78454 ,p_entity_id => l_array_entity_id(Idx)
78455 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
78456 ,p_entity_code => l_array_entity_code(Idx)
78457 ,p_transaction_num => l_array_transaction_num(Idx)
78458 ,p_event_id => l_array_event_id(Idx)
78459 ,p_event_class_code => l_array_class_code(Idx)
78460 ,p_event_type_code => l_array_event_type(Idx)
78461 ,p_event_number => l_array_event_number(Idx)
78462 ,p_event_date => l_array_event_date(Idx)
78463 ,p_transaction_date => l_array_transaction_date(Idx)
78464 ,p_reference_num_1 => l_array_reference_num_1(Idx)
78465 ,p_reference_num_2 => l_array_reference_num_2(Idx)
78466 ,p_reference_num_3 => l_array_reference_num_3(Idx)
78467 ,p_reference_num_4 => l_array_reference_num_4(Idx)
78468 ,p_reference_char_1 => l_array_reference_char_1(Idx)
78469 ,p_reference_char_2 => l_array_reference_char_2(Idx)
78470 ,p_reference_char_3 => l_array_reference_char_3(Idx)
78471 ,p_reference_char_4 => l_array_reference_char_4(Idx)
78472 ,p_reference_date_1 => l_array_reference_date_1(Idx)
78473 ,p_reference_date_2 => l_array_reference_date_2(Idx)
78474 ,p_reference_date_3 => l_array_reference_date_3(Idx)
78475 ,p_reference_date_4 => l_array_reference_date_4(Idx)
78476 ,p_event_created_by => l_array_event_created_by(Idx)
78477 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
78478 --
78479 END IF;
78480
78481
78482
78483 --
78484 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
78485
78486 l_acct_reversal_source := SUBSTR(NULL, 1,30);
78487
78488 IF l_continue_with_lines THEN
78489 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
78490 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
78491
78492 xla_accounting_err_pkg.build_message
78493 (p_appli_s_name => 'XLA'
78494 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
78495 ,p_token_1 => 'LINE_NUMBER'
78496 ,p_value_1 => l_array_extract_line_num(Idx)
78497 ,p_token_2 => 'PRODUCT_NAME'
78498 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
78499 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
78500 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
78501 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
78502
78503 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
78504 --
78505 -- following sets the accounting attributes needed to reverse
78506 -- accounting for a distributeion
78507 --
78508
78509 --
78510 -- 5217187
78511 --
78512 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
78513 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
78514 g_array_event(l_event_id).array_value_num('header_index'));
78515 --
78516 --
78517
78518 -- No reversal code generated
78519
78520 xla_ae_lines_pkg.SetAcctReversalAttrs
78521 (p_event_id => l_event_id
78522 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
78523 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78524 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
78525 END IF;
78526
78527 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
78528 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
78529
78530 --
78531 AcctLineType_62 (
78532 p_application_id => p_application_id
78533 ,p_event_id => l_event_id
78534 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78535 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78536 ,p_actual_flag => l_actual_flag
78537 ,p_balance_type_code => l_balance_type_code
78538 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78539
78540 , p_source_10 => l_array_source_10(Idx)
78541 , p_source_14 => l_array_source_14(Idx)
78542 , p_source_15 => l_array_source_15(Idx)
78543 , p_source_16 => l_array_source_16(Idx)
78544 , p_source_22 => l_array_source_22(Idx)
78545 , p_source_24 => l_array_source_24(Idx)
78546 , p_source_25 => l_array_source_25(Idx)
78547 , p_source_26 => l_array_source_26(Idx)
78548 , p_source_27 => l_array_source_27(Idx)
78549 , p_source_29 => l_array_source_29(Idx)
78550 , p_source_30 => l_array_source_30(Idx)
78551 , p_source_31 => l_array_source_31(Idx)
78552 , p_source_58 => l_array_source_58(Idx)
78553 , p_source_59 => l_array_source_59(Idx)
78554 );
78555 If(l_balance_type_code = 'A') THEN
78556 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78557 END IF;
78558
78559 --
78560
78561
78562 --
78563 AcctLineType_63 (
78564 p_application_id => p_application_id
78565 ,p_event_id => l_event_id
78569 ,p_balance_type_code => l_balance_type_code
78566 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78567 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78568 ,p_actual_flag => l_actual_flag
78570 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78571
78572 , p_source_10 => l_array_source_10(Idx)
78573 , p_source_14 => l_array_source_14(Idx)
78574 , p_source_15 => l_array_source_15(Idx)
78575 , p_source_16 => l_array_source_16(Idx)
78576 , p_source_22 => l_array_source_22(Idx)
78577 , p_source_24 => l_array_source_24(Idx)
78578 , p_source_25 => l_array_source_25(Idx)
78579 , p_source_26 => l_array_source_26(Idx)
78580 , p_source_27 => l_array_source_27(Idx)
78581 , p_source_29 => l_array_source_29(Idx)
78582 , p_source_30 => l_array_source_30(Idx)
78583 , p_source_31 => l_array_source_31(Idx)
78584 , p_source_58 => l_array_source_58(Idx)
78585 , p_source_59 => l_array_source_59(Idx)
78586 );
78587 If(l_balance_type_code = 'A') THEN
78588 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78589 END IF;
78590
78591 --
78592
78593
78594 --
78595 AcctLineType_64 (
78596 p_application_id => p_application_id
78597 ,p_event_id => l_event_id
78598 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78599 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78600 ,p_actual_flag => l_actual_flag
78601 ,p_balance_type_code => l_balance_type_code
78602 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78603
78604 , p_source_10 => l_array_source_10(Idx)
78605 , p_source_14 => l_array_source_14(Idx)
78606 , p_source_15 => l_array_source_15(Idx)
78607 , p_source_16 => l_array_source_16(Idx)
78608 , p_source_17 => l_array_source_17(Idx)
78609 , p_source_22 => l_array_source_22(Idx)
78610 , p_source_24 => l_array_source_24(Idx)
78611 , p_source_25 => l_array_source_25(Idx)
78612 , p_source_26 => l_array_source_26(Idx)
78613 , p_source_27 => l_array_source_27(Idx)
78614 , p_source_29 => l_array_source_29(Idx)
78615 , p_source_30 => l_array_source_30(Idx)
78616 , p_source_31 => l_array_source_31(Idx)
78617 , p_source_58 => l_array_source_58(Idx)
78618 , p_source_59 => l_array_source_59(Idx)
78619 );
78620 If(l_balance_type_code = 'A') THEN
78621 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78622 END IF;
78623
78624 --
78625
78626
78627 --
78628 AcctLineType_65 (
78629 p_application_id => p_application_id
78630 ,p_event_id => l_event_id
78631 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78632 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78633 ,p_actual_flag => l_actual_flag
78634 ,p_balance_type_code => l_balance_type_code
78635 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78636
78637 , p_source_10 => l_array_source_10(Idx)
78638 , p_source_14 => l_array_source_14(Idx)
78639 , p_source_15 => l_array_source_15(Idx)
78640 , p_source_16 => l_array_source_16(Idx)
78641 , p_source_17 => l_array_source_17(Idx)
78642 , p_source_22 => l_array_source_22(Idx)
78643 , p_source_24 => l_array_source_24(Idx)
78644 , p_source_25 => l_array_source_25(Idx)
78645 , p_source_26 => l_array_source_26(Idx)
78646 , p_source_27 => l_array_source_27(Idx)
78647 , p_source_29 => l_array_source_29(Idx)
78648 , p_source_30 => l_array_source_30(Idx)
78649 , p_source_31 => l_array_source_31(Idx)
78650 , p_source_58 => l_array_source_58(Idx)
78651 , p_source_59 => l_array_source_59(Idx)
78652 );
78653 If(l_balance_type_code = 'A') THEN
78654 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78655 END IF;
78656
78657 --
78658
78659
78660 --
78661 AcctLineType_66 (
78662 p_application_id => p_application_id
78663 ,p_event_id => l_event_id
78664 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78665 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78666 ,p_actual_flag => l_actual_flag
78667 ,p_balance_type_code => l_balance_type_code
78668 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78669
78670 , p_source_10 => l_array_source_10(Idx)
78671 , p_source_14 => l_array_source_14(Idx)
78672 , p_source_15 => l_array_source_15(Idx)
78673 , p_source_16 => l_array_source_16(Idx)
78674 , p_source_22 => l_array_source_22(Idx)
78675 , p_source_24 => l_array_source_24(Idx)
78676 , p_source_25 => l_array_source_25(Idx)
78677 , p_source_26 => l_array_source_26(Idx)
78678 , p_source_27 => l_array_source_27(Idx)
78679 , p_source_29 => l_array_source_29(Idx)
78680 , p_source_30 => l_array_source_30(Idx)
78681 , p_source_31 => l_array_source_31(Idx)
78682 , p_source_58 => l_array_source_58(Idx)
78683 , p_source_59 => l_array_source_59(Idx)
78684 );
78685 If(l_balance_type_code = 'A') THEN
78686 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78687 END IF;
78688
78689 --
78690
78691
78692 --
78693 AcctLineType_67 (
78694 p_application_id => p_application_id
78695 ,p_event_id => l_event_id
78696 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78697 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78698 ,p_actual_flag => l_actual_flag
78699 ,p_balance_type_code => l_balance_type_code
78700 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78701
78702 , p_source_10 => l_array_source_10(Idx)
78703 , p_source_14 => l_array_source_14(Idx)
78704 , p_source_15 => l_array_source_15(Idx)
78705 , p_source_16 => l_array_source_16(Idx)
78706 , p_source_22 => l_array_source_22(Idx)
78707 , p_source_24 => l_array_source_24(Idx)
78708 , p_source_25 => l_array_source_25(Idx)
78709 , p_source_26 => l_array_source_26(Idx)
78710 , p_source_27 => l_array_source_27(Idx)
78711 , p_source_29 => l_array_source_29(Idx)
78712 , p_source_30 => l_array_source_30(Idx)
78713 , p_source_31 => l_array_source_31(Idx)
78714 , p_source_58 => l_array_source_58(Idx)
78715 , p_source_59 => l_array_source_59(Idx)
78716 );
78717 If(l_balance_type_code = 'A') THEN
78721 --
78718 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78719 END IF;
78720
78722
78723
78724 --
78725 AcctLineType_68 (
78726 p_application_id => p_application_id
78727 ,p_event_id => l_event_id
78728 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78729 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78730 ,p_actual_flag => l_actual_flag
78731 ,p_balance_type_code => l_balance_type_code
78732 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78733
78734 , p_source_10 => l_array_source_10(Idx)
78735 , p_source_11 => l_array_source_11(Idx)
78736 , p_source_22 => l_array_source_22(Idx)
78737 , p_source_24 => l_array_source_24(Idx)
78738 , p_source_25 => l_array_source_25(Idx)
78739 , p_source_26 => l_array_source_26(Idx)
78740 , p_source_27 => l_array_source_27(Idx)
78741 , p_source_29 => l_array_source_29(Idx)
78742 , p_source_30 => l_array_source_30(Idx)
78743 , p_source_31 => l_array_source_31(Idx)
78744 , p_source_58 => l_array_source_58(Idx)
78745 , p_source_59 => l_array_source_59(Idx)
78746 );
78747 If(l_balance_type_code = 'A') THEN
78748 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78749 END IF;
78750
78751 --
78752
78753
78754 --
78755 AcctLineType_69 (
78756 p_application_id => p_application_id
78757 ,p_event_id => l_event_id
78758 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78759 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78760 ,p_actual_flag => l_actual_flag
78761 ,p_balance_type_code => l_balance_type_code
78762 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78763
78764 , p_source_10 => l_array_source_10(Idx)
78765 , p_source_11 => l_array_source_11(Idx)
78766 , p_source_22 => l_array_source_22(Idx)
78767 , p_source_24 => l_array_source_24(Idx)
78768 , p_source_25 => l_array_source_25(Idx)
78769 , p_source_26 => l_array_source_26(Idx)
78770 , p_source_27 => l_array_source_27(Idx)
78771 , p_source_29 => l_array_source_29(Idx)
78772 , p_source_30 => l_array_source_30(Idx)
78773 , p_source_31 => l_array_source_31(Idx)
78774 , p_source_58 => l_array_source_58(Idx)
78775 , p_source_59 => l_array_source_59(Idx)
78776 );
78777 If(l_balance_type_code = 'A') THEN
78778 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78779 END IF;
78780
78781 --
78782
78783
78784 --
78785 AcctLineType_91 (
78786 p_application_id => p_application_id
78787 ,p_event_id => l_event_id
78788 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78789 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78790 ,p_actual_flag => l_actual_flag
78791 ,p_balance_type_code => l_balance_type_code
78792 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78793
78794 , p_source_1 => g_array_event(l_event_id).array_value_num('source_1')
78795 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
78796 , p_source_22 => l_array_source_22(Idx)
78797 , p_source_24 => l_array_source_24(Idx)
78798 , p_source_25 => l_array_source_25(Idx)
78799 , p_source_26 => l_array_source_26(Idx)
78800 , p_source_27 => l_array_source_27(Idx)
78801 , p_source_29 => l_array_source_29(Idx)
78802 , p_source_30 => l_array_source_30(Idx)
78803 , p_source_31 => l_array_source_31(Idx)
78804 , p_source_59 => l_array_source_59(Idx)
78805 , p_source_71 => l_array_source_71(Idx)
78806 );
78807 If(l_balance_type_code = 'A') THEN
78808 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78809 END IF;
78810
78811 --
78812
78813
78814 --
78815 AcctLineType_92 (
78816 p_application_id => p_application_id
78817 ,p_event_id => l_event_id
78818 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78819 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78820 ,p_actual_flag => l_actual_flag
78821 ,p_balance_type_code => l_balance_type_code
78822 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78823
78824 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
78825 , p_source_10 => l_array_source_10(Idx)
78826 , p_source_22 => l_array_source_22(Idx)
78827 , p_source_24 => l_array_source_24(Idx)
78828 , p_source_25 => l_array_source_25(Idx)
78829 , p_source_26 => l_array_source_26(Idx)
78830 , p_source_27 => l_array_source_27(Idx)
78831 , p_source_29 => l_array_source_29(Idx)
78832 , p_source_30 => l_array_source_30(Idx)
78833 , p_source_31 => l_array_source_31(Idx)
78834 , p_source_59 => l_array_source_59(Idx)
78835 , p_source_71 => l_array_source_71(Idx)
78836 , p_source_72 => g_array_event(l_event_id).array_value_char('source_72')
78837 , p_source_73 => g_array_event(l_event_id).array_value_char('source_73')
78838 );
78839 If(l_balance_type_code = 'A') THEN
78840 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78841 END IF;
78842
78843 --
78844
78845
78846 --
78847 AcctLineType_93 (
78848 p_application_id => p_application_id
78849 ,p_event_id => l_event_id
78850 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78851 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78852 ,p_actual_flag => l_actual_flag
78853 ,p_balance_type_code => l_balance_type_code
78854 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78855
78856 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
78857 , p_source_10 => l_array_source_10(Idx)
78858 , p_source_22 => l_array_source_22(Idx)
78859 , p_source_24 => l_array_source_24(Idx)
78860 , p_source_25 => l_array_source_25(Idx)
78861 , p_source_26 => l_array_source_26(Idx)
78862 , p_source_27 => l_array_source_27(Idx)
78863 , p_source_29 => l_array_source_29(Idx)
78864 , p_source_30 => l_array_source_30(Idx)
78865 , p_source_31 => l_array_source_31(Idx)
78866 , p_source_59 => l_array_source_59(Idx)
78867 , p_source_71 => l_array_source_71(Idx)
78868 , p_source_72 => g_array_event(l_event_id).array_value_char('source_72')
78869 );
78873
78870 If(l_balance_type_code = 'A') THEN
78871 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78872 END IF;
78874 --
78875
78876
78877 --
78878 AcctLineType_94 (
78879 p_application_id => p_application_id
78880 ,p_event_id => l_event_id
78881 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78882 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78883 ,p_actual_flag => l_actual_flag
78884 ,p_balance_type_code => l_balance_type_code
78885 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78886
78887 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
78888 , p_source_10 => l_array_source_10(Idx)
78889 , p_source_22 => l_array_source_22(Idx)
78890 , p_source_24 => l_array_source_24(Idx)
78891 , p_source_25 => l_array_source_25(Idx)
78892 , p_source_26 => l_array_source_26(Idx)
78893 , p_source_27 => l_array_source_27(Idx)
78894 , p_source_29 => l_array_source_29(Idx)
78895 , p_source_30 => l_array_source_30(Idx)
78896 , p_source_31 => l_array_source_31(Idx)
78897 , p_source_59 => l_array_source_59(Idx)
78898 , p_source_71 => l_array_source_71(Idx)
78899 );
78900 If(l_balance_type_code = 'A') THEN
78901 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78902 END IF;
78903
78904 --
78905
78906
78907 --
78908 AcctLineType_95 (
78909 p_application_id => p_application_id
78910 ,p_event_id => l_event_id
78911 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78912 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78913 ,p_actual_flag => l_actual_flag
78914 ,p_balance_type_code => l_balance_type_code
78915 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78916
78917 , p_source_6 => g_array_event(l_event_id).array_value_num('source_6')
78918 , p_source_10 => l_array_source_10(Idx)
78919 , p_source_22 => l_array_source_22(Idx)
78920 , p_source_24 => l_array_source_24(Idx)
78921 , p_source_25 => l_array_source_25(Idx)
78922 , p_source_26 => l_array_source_26(Idx)
78923 , p_source_27 => l_array_source_27(Idx)
78924 , p_source_29 => l_array_source_29(Idx)
78925 , p_source_30 => l_array_source_30(Idx)
78926 , p_source_31 => l_array_source_31(Idx)
78927 , p_source_59 => l_array_source_59(Idx)
78928 , p_source_71 => l_array_source_71(Idx)
78929 );
78930 If(l_balance_type_code = 'A') THEN
78931 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78932 END IF;
78933
78934 --
78935
78936
78937 --
78938 AcctLineType_103 (
78939 p_application_id => p_application_id
78940 ,p_event_id => l_event_id
78941 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78942 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78943 ,p_actual_flag => l_actual_flag
78944 ,p_balance_type_code => l_balance_type_code
78945 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78946
78947 , p_source_10 => l_array_source_10(Idx)
78948 , p_source_22 => l_array_source_22(Idx)
78949 , p_source_24 => l_array_source_24(Idx)
78950 , p_source_25 => l_array_source_25(Idx)
78951 , p_source_26 => l_array_source_26(Idx)
78952 , p_source_27 => l_array_source_27(Idx)
78953 , p_source_29 => l_array_source_29(Idx)
78954 , p_source_30 => l_array_source_30(Idx)
78955 , p_source_31 => l_array_source_31(Idx)
78956 , p_source_59 => l_array_source_59(Idx)
78957 , p_source_71 => l_array_source_71(Idx)
78958 );
78959 If(l_balance_type_code = 'A') THEN
78960 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78961 END IF;
78962
78963 --
78964
78965
78966 --
78967 AcctLineType_104 (
78968 p_application_id => p_application_id
78969 ,p_event_id => l_event_id
78970 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78971 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78972 ,p_actual_flag => l_actual_flag
78973 ,p_balance_type_code => l_balance_type_code
78974 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78975
78976 , p_source_10 => l_array_source_10(Idx)
78977 , p_source_22 => l_array_source_22(Idx)
78978 , p_source_24 => l_array_source_24(Idx)
78979 , p_source_25 => l_array_source_25(Idx)
78980 , p_source_26 => l_array_source_26(Idx)
78981 , p_source_27 => l_array_source_27(Idx)
78982 , p_source_29 => l_array_source_29(Idx)
78983 , p_source_30 => l_array_source_30(Idx)
78984 , p_source_31 => l_array_source_31(Idx)
78985 , p_source_59 => l_array_source_59(Idx)
78986 , p_source_71 => l_array_source_71(Idx)
78987 );
78988 If(l_balance_type_code = 'A') THEN
78989 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78990 END IF;
78991
78992 --
78993
78994
78995 --
78996 AcctLineType_105 (
78997 p_application_id => p_application_id
78998 ,p_event_id => l_event_id
78999 ,p_calculate_acctd_flag => l_calculate_acctd_flag
79000 ,p_calculate_g_l_flag => l_calculate_g_l_flag
79001 ,p_actual_flag => l_actual_flag
79002 ,p_balance_type_code => l_balance_type_code
79003 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
79004
79005 , p_source_10 => l_array_source_10(Idx)
79006 , p_source_22 => l_array_source_22(Idx)
79007 , p_source_24 => l_array_source_24(Idx)
79008 , p_source_25 => l_array_source_25(Idx)
79009 , p_source_26 => l_array_source_26(Idx)
79010 , p_source_27 => l_array_source_27(Idx)
79011 , p_source_29 => l_array_source_29(Idx)
79012 , p_source_30 => l_array_source_30(Idx)
79013 , p_source_31 => l_array_source_31(Idx)
79014 , p_source_59 => l_array_source_59(Idx)
79015 , p_source_71 => l_array_source_71(Idx)
79016 );
79017 If(l_balance_type_code = 'A') THEN
79018 l_actual_gain_loss_ref := l_gain_or_loss_ref;
79019 END IF;
79020
79021 --
79022
79023
79024 --
79025 AcctLineType_106 (
79026 p_application_id => p_application_id
79027 ,p_event_id => l_event_id
79028 ,p_calculate_acctd_flag => l_calculate_acctd_flag
79032 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
79029 ,p_calculate_g_l_flag => l_calculate_g_l_flag
79030 ,p_actual_flag => l_actual_flag
79031 ,p_balance_type_code => l_balance_type_code
79033
79034 , p_source_10 => l_array_source_10(Idx)
79035 , p_source_22 => l_array_source_22(Idx)
79036 , p_source_24 => l_array_source_24(Idx)
79037 , p_source_25 => l_array_source_25(Idx)
79038 , p_source_26 => l_array_source_26(Idx)
79039 , p_source_27 => l_array_source_27(Idx)
79040 , p_source_29 => l_array_source_29(Idx)
79041 , p_source_30 => l_array_source_30(Idx)
79042 , p_source_31 => l_array_source_31(Idx)
79043 , p_source_59 => l_array_source_59(Idx)
79044 , p_source_71 => l_array_source_71(Idx)
79045 );
79046 If(l_balance_type_code = 'A') THEN
79047 l_actual_gain_loss_ref := l_gain_or_loss_ref;
79048 END IF;
79049
79050 --
79051
79052
79053 --
79054 AcctLineType_107 (
79055 p_application_id => p_application_id
79056 ,p_event_id => l_event_id
79057 ,p_calculate_acctd_flag => l_calculate_acctd_flag
79058 ,p_calculate_g_l_flag => l_calculate_g_l_flag
79059 ,p_actual_flag => l_actual_flag
79060 ,p_balance_type_code => l_balance_type_code
79061 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
79062
79063 , p_source_10 => l_array_source_10(Idx)
79064 , p_source_22 => l_array_source_22(Idx)
79065 , p_source_24 => l_array_source_24(Idx)
79066 , p_source_25 => l_array_source_25(Idx)
79067 , p_source_26 => l_array_source_26(Idx)
79068 , p_source_27 => l_array_source_27(Idx)
79069 , p_source_29 => l_array_source_29(Idx)
79070 , p_source_30 => l_array_source_30(Idx)
79071 , p_source_31 => l_array_source_31(Idx)
79072 , p_source_59 => l_array_source_59(Idx)
79073 , p_source_71 => l_array_source_71(Idx)
79074 );
79075 If(l_balance_type_code = 'A') THEN
79076 l_actual_gain_loss_ref := l_gain_or_loss_ref;
79077 END IF;
79078
79079 --
79080
79081 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
79082 -- or secondary ledger that has different currency with primary
79083 -- or alc that is calculated by sla
79084 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
79085 (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'))
79086
79087 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
79088 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
79089 AND (l_actual_flag = 'A')) THEN
79090 XLA_AE_LINES_PKG.CreateGainOrLossLines(
79091 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
79092 ,p_application_id => p_application_id
79093 ,p_amb_context_code => 'DEFAULT'
79094 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
79095 ,p_event_class_code => C_EVENT_CLASS_CODE
79096 ,p_event_type_code => C_EVENT_TYPE_CODE
79097
79098 ,p_gain_ccid => -1
79099 ,p_loss_ccid => -1
79100
79101 ,p_actual_flag => l_actual_flag
79102 ,p_enc_flag => null
79103 ,p_actual_g_l_ref => l_actual_gain_loss_ref
79104 ,p_enc_g_l_ref => null
79105 );
79106 END IF;
79107 END IF;
79108 END IF;
79109
79110 ELSE
79111 --
79112 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
79113 --
79114 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
79115 trace
79116 (p_msg => 'Trancaction revesal option is Y'
79117 ,p_level => C_LEVEL_STATEMENT
79118 ,p_module => l_log_module);
79119 END IF;
79120 END IF;
79121
79122 END LOOP;
79123 l_result := XLA_AE_LINES_PKG.InsertLines ;
79124 end loop;
79125 close line_cur;
79126
79127
79128 --
79129 -- insert headers into xla_ae_headers_gt table
79130 --
79131 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
79132
79133 -- insert into errors table here.
79134
79135 END LOOP;
79136
79137 --
79138 -- 4865292
79139 --
79140 -- Compare g_hdr_extract_count with event count in
79141 -- CreateHeadersAndLines.
79142 --
79143 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
79144
79145 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
79146 trace (p_msg => '# rows extracted from header extract objects '
79147 || ' (running total): '
79148 || g_hdr_extract_count
79149 ,p_level => C_LEVEL_STATEMENT
79150 ,p_module => l_log_module);
79151 END IF;
79152
79153 CLOSE header_cur;
79154 --
79155
79156 --
79157 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
79158 trace
79159 (p_msg => 'END of EventClass_145'
79160 ,p_level => C_LEVEL_PROCEDURE
79161 ,p_module => l_log_module);
79162 END IF;
79163 --
79164 RETURN l_result;
79165 EXCEPTION
79166 WHEN xla_exceptions_pkg.application_exception THEN
79167
79168 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
79169
79170
79171 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
79172
79173 RAISE;
79174
79175 WHEN NO_DATA_FOUND THEN
79176
79177 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
79178 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
79179
79180 FOR header_record IN header_cur
79181 LOOP
79182 l_array_header_events(header_record.event_id) := header_record.event_id;
79183 END LOOP;
79184
79185 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
79189 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
79186 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
79187
79188 fnd_file.put_line(fnd_file.LOG, ' ');
79190 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
79191 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
79192
79193 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
79194 LOOP
79195 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
79196 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
79197 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
79198 END IF;
79199 END LOOP;
79200
79201 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
79202 fnd_file.put_line(fnd_file.LOG, ' ');
79203
79204
79205 xla_exceptions_pkg.raise_message
79206 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_145');
79207
79208
79209 WHEN OTHERS THEN
79210 xla_exceptions_pkg.raise_message
79211 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_145');
79212 END EventClass_145;
79213 --
79214
79215 ---------------------------------------
79216 --
79217 -- PRIVATE PROCEDURE
79218 -- insert_sources_146
79219 --
79220 ----------------------------------------
79221 --
79222 PROCEDURE insert_sources_146(
79223 p_target_ledger_id IN NUMBER
79224 , p_language IN VARCHAR2
79225 , p_sla_ledger_id IN NUMBER
79226 , p_pad_start_date IN DATE
79227 , p_pad_end_date IN DATE
79228 )
79229 IS
79230
79231 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'RECEIPT_ALL';
79232 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'RECEIPT';
79233 p_apps_owner VARCHAR2(30);
79234 l_log_module VARCHAR2(240);
79235 BEGIN
79236 IF g_log_enabled THEN
79237 l_log_module := C_DEFAULT_MODULE||'.insert_sources_146';
79238 END IF;
79239 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
79240
79241 trace
79242 (p_msg => 'BEGIN of insert_sources_146'
79243 ,p_level => C_LEVEL_PROCEDURE
79244 ,p_module => l_log_module);
79245
79246 END IF;
79247
79248 -- select APPS owner
79249 SELECT oracle_username
79250 INTO p_apps_owner
79251 FROM fnd_oracle_userid
79252 WHERE read_only_flag = 'U'
79253 ;
79254
79255 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
79256 trace
79257 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
79258 ' - p_language = '||p_language||
79259 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
79260 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
79261 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
79262 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
79263 ,p_level => C_LEVEL_STATEMENT
79264 ,p_module => l_log_module);
79265 END IF;
79266
79267
79268 --
79269 INSERT INTO xla_diag_sources --hdr2
79270 (
79271 event_id
79272 , ledger_id
79273 , sla_ledger_id
79274 , description_language
79275 , object_name
79276 , object_type_code
79277 , line_number
79278 , source_application_id
79279 , source_type_code
79280 , source_code
79281 , source_value
79282 , source_meaning
79283 , created_by
79284 , creation_date
79285 , last_update_date
79286 , last_updated_by
79287 , last_update_login
79288 , program_update_date
79289 , program_application_id
79290 , program_id
79291 , request_id
79292 )
79293 SELECT
79294 event_id
79295 , p_target_ledger_id
79296 , p_sla_ledger_id
79297 , p_language
79298 , object_name
79299 , object_type_code
79300 , line_number
79301 , source_application_id
79302 , source_type_code
79303 , source_code
79304 , SUBSTR(source_value ,1,1996)
79305 , SUBSTR(source_meaning ,1,200)
79306 , xla_environment_pkg.g_Usr_Id
79307 , TRUNC(SYSDATE)
79308 , TRUNC(SYSDATE)
79309 , xla_environment_pkg.g_Usr_Id
79310 , xla_environment_pkg.g_Login_Id
79311 , TRUNC(SYSDATE)
79312 , xla_environment_pkg.g_Prog_Appl_Id
79313 , xla_environment_pkg.g_Prog_Id
79314 , xla_environment_pkg.g_Req_Id
79315 FROM (
79316 SELECT xet.event_id event_id
79317 , 0 line_number
79318 , CASE r
79319 WHEN 1 THEN 'AR_REMIT_BANK_ACCT_H_V'
79320 WHEN 2 THEN 'AR_REMIT_BANK_ACCT_H_V'
79321 WHEN 3 THEN 'AR_REMIT_BANK_ACCT_H_V'
79322 WHEN 4 THEN 'AR_REMIT_BANK_ACCT_H_V'
79323 WHEN 5 THEN 'AR_REMIT_BANK_ACCT_H_V'
79324 WHEN 6 THEN 'AR_REMIT_BANK_ACCT_H_V'
79325 WHEN 7 THEN 'AR_REMIT_BANK_ACCT_H_V'
79326 WHEN 8 THEN 'AR_SYSTEM_PARAM_H_V'
79327 WHEN 9 THEN 'AR_SYSTEM_PARAM_H_V'
79328 WHEN 10 THEN 'AR_CASH_RECEIPTS_H_V'
79329 WHEN 11 THEN 'AR_RCT_METHOD_H_V'
79330 WHEN 12 THEN 'AR_RCT_METHOD_H_V'
79331 WHEN 13 THEN 'AR_CASH_RECEIPTS_H_V'
79335 WHEN 17 THEN 'AR_CASH_RECEIPTS_H_V'
79332 WHEN 14 THEN 'AR_RCT_SITE_USES_H_V'
79333 WHEN 15 THEN 'AR_CASH_RECEIPTS_H_V'
79334 WHEN 16 THEN 'AR_CASH_RECEIPTS_H_V'
79336 WHEN 18 THEN 'AR_CASH_RECEIPTS_H_V'
79337 WHEN 19 THEN 'AR_CASH_RECEIPTS_H_V'
79338
79339 ELSE null
79340 END object_name
79341 , CASE r
79342 WHEN 1 THEN 'HEADER'
79343 WHEN 2 THEN 'HEADER'
79344 WHEN 3 THEN 'HEADER'
79345 WHEN 4 THEN 'HEADER'
79346 WHEN 5 THEN 'HEADER'
79347 WHEN 6 THEN 'HEADER'
79348 WHEN 7 THEN 'HEADER'
79349 WHEN 8 THEN 'HEADER'
79350 WHEN 9 THEN 'HEADER'
79351 WHEN 10 THEN 'HEADER'
79352 WHEN 11 THEN 'HEADER'
79353 WHEN 12 THEN 'HEADER'
79354 WHEN 13 THEN 'HEADER'
79355 WHEN 14 THEN 'HEADER'
79356 WHEN 15 THEN 'HEADER'
79357 WHEN 16 THEN 'HEADER'
79358 WHEN 17 THEN 'HEADER'
79359 WHEN 18 THEN 'HEADER'
79360 WHEN 19 THEN 'HEADER'
79361
79362 ELSE null
79363 END object_type_code
79364 , CASE r
79365 WHEN 1 THEN '222'
79366 WHEN 2 THEN '222'
79367 WHEN 3 THEN '222'
79368 WHEN 4 THEN '222'
79369 WHEN 5 THEN '222'
79370 WHEN 6 THEN '222'
79371 WHEN 7 THEN '222'
79372 WHEN 8 THEN '222'
79373 WHEN 9 THEN '222'
79374 WHEN 10 THEN '222'
79375 WHEN 11 THEN '222'
79376 WHEN 12 THEN '222'
79377 WHEN 13 THEN '222'
79378 WHEN 14 THEN '222'
79379 WHEN 15 THEN '222'
79380 WHEN 16 THEN '222'
79381 WHEN 17 THEN '222'
79382 WHEN 18 THEN '222'
79383 WHEN 19 THEN '222'
79384
79385 ELSE null
79386 END source_application_id
79387 , 'S' source_type_code
79388 , CASE r
79389 WHEN 1 THEN 'RMT_BNK_BANK_CHARGES_CCID'
79390 WHEN 2 THEN 'RMT_BNK_CONFIRMATION_CCID'
79391 WHEN 3 THEN 'RMT_BNK_EARNED_CCID'
79392 WHEN 4 THEN 'RMT_BNK_CASH_CCID'
79393 WHEN 5 THEN 'RMT_BNK_REMITTANCE_CCID'
79394 WHEN 6 THEN 'RMT_BNK_UNEARNED_CCID'
79395 WHEN 7 THEN 'RMT_BNK_UNAPPLIED_CCID'
79396 WHEN 8 THEN 'CODE_COMBINATION_ID_GAIN'
79397 WHEN 9 THEN 'CODE_COMBINATION_ID_LOSS'
79398 WHEN 10 THEN 'RCT_XLA_APPLIED_TO_APP_ID'
79399 WHEN 11 THEN 'RCT_CLASS_REMIT_FLAG'
79400 WHEN 12 THEN 'RCT_CLASS_CONFIRM_FLAG'
79401 WHEN 13 THEN 'RCT_PAY_FROM_CUSTOMER'
79402 WHEN 14 THEN 'RCT_SITE_SITE_USE_ID'
79403 WHEN 15 THEN 'RCT_APP_STATUS'
79404 WHEN 16 THEN 'RCT_DOC_SEQUENCE_CATEGORY'
79405 WHEN 17 THEN 'RCT_DOC_SEQUENCE_ID'
79406 WHEN 18 THEN 'RCT_DOC_SEQUENCE_VALUE'
79407 WHEN 19 THEN 'RCT_TRX_ACCT_REVERSAL'
79408
79409 ELSE null
79410 END source_code
79411 , CASE r
79412 WHEN 1 THEN TO_CHAR(h9.RMT_BNK_BANK_CHARGES_CCID)
79413 WHEN 2 THEN TO_CHAR(h9.RMT_BNK_CONFIRMATION_CCID)
79414 WHEN 3 THEN TO_CHAR(h9.RMT_BNK_EARNED_CCID)
79415 WHEN 4 THEN TO_CHAR(h9.RMT_BNK_CASH_CCID)
79416 WHEN 5 THEN TO_CHAR(h9.RMT_BNK_REMITTANCE_CCID)
79417 WHEN 6 THEN TO_CHAR(h9.RMT_BNK_UNEARNED_CCID)
79418 WHEN 7 THEN TO_CHAR(h9.RMT_BNK_UNAPPLIED_CCID)
79419 WHEN 8 THEN TO_CHAR(h10.CODE_COMBINATION_ID_GAIN)
79420 WHEN 9 THEN TO_CHAR(h10.CODE_COMBINATION_ID_LOSS)
79421 WHEN 10 THEN TO_CHAR(h2.RCT_XLA_APPLIED_TO_APP_ID)
79422 WHEN 11 THEN TO_CHAR(h6.RCT_CLASS_REMIT_FLAG)
79423 WHEN 12 THEN TO_CHAR(h6.RCT_CLASS_CONFIRM_FLAG)
79424 WHEN 13 THEN TO_CHAR(h2.RCT_PAY_FROM_CUSTOMER)
79425 WHEN 14 THEN TO_CHAR(h7.RCT_SITE_SITE_USE_ID)
79426 WHEN 15 THEN TO_CHAR(h2.RCT_APP_STATUS)
79427 WHEN 16 THEN TO_CHAR(h2.RCT_DOC_SEQUENCE_CATEGORY)
79428 WHEN 17 THEN TO_CHAR(h2.RCT_DOC_SEQUENCE_ID)
79429 WHEN 18 THEN TO_CHAR(h2.RCT_DOC_SEQUENCE_VALUE)
79430 WHEN 19 THEN TO_CHAR(h2.RCT_TRX_ACCT_REVERSAL)
79431
79432 ELSE null
79433 END source_value
79434 , null source_meaning
79435 FROM xla_events_gt xet
79436 , AR_CASH_RECEIPTS_H_V h2
79437 , AR_RCT_METHOD_H_V h6
79438 , AR_RCT_SITE_USES_H_V h7
79439 , AR_REMIT_BANK_ACCT_H_V h9
79440 , AR_SYSTEM_PARAM_H_V h10
79441 ,(select rownum r from all_objects where rownum <= 19 and owner = p_apps_owner)
79442 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
79443 AND xet.event_class_code = C_EVENT_CLASS_CODE
79444 AND h2.event_id = xet.event_id
79445 AND h6.event_id (+) = h2.event_id
79446 AND h7.event_id (+) = h2.event_id
79447 AND h9.event_id (+) = h2.event_id
79448 AND h10.event_id (+) = h2.event_id
79449
79450 )
79451 ;
79452 --
79453 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
79454
79458 ,p_module => l_log_module);
79455 trace
79456 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
79457 ,p_level => C_LEVEL_STATEMENT
79459
79460 END IF;
79461 --
79462
79463
79464
79465 --
79466 INSERT INTO xla_diag_sources --line2
79467 (
79468 event_id
79469 , ledger_id
79470 , sla_ledger_id
79471 , description_language
79472 , object_name
79473 , object_type_code
79474 , line_number
79475 , source_application_id
79476 , source_type_code
79477 , source_code
79478 , source_value
79479 , source_meaning
79480 , created_by
79481 , creation_date
79482 , last_update_date
79483 , last_updated_by
79484 , last_update_login
79485 , program_update_date
79486 , program_application_id
79487 , program_id
79488 , request_id
79489 )
79490 SELECT event_id
79491 , p_target_ledger_id
79492 , p_sla_ledger_id
79493 , p_language
79494 , object_name
79495 , object_type_code
79496 , line_number
79497 , source_application_id
79498 , source_type_code
79499 , source_code
79500 , SUBSTR(source_value,1,1996)
79501 , SUBSTR(source_meaning ,1,200)
79502 , xla_environment_pkg.g_Usr_Id
79503 , TRUNC(SYSDATE)
79504 , TRUNC(SYSDATE)
79505 , xla_environment_pkg.g_Usr_Id
79506 , xla_environment_pkg.g_Login_Id
79507 , TRUNC(SYSDATE)
79508 , xla_environment_pkg.g_Prog_Appl_Id
79509 , xla_environment_pkg.g_Prog_Id
79510 , xla_environment_pkg.g_Req_Id
79511 FROM (
79512 SELECT xet.event_id event_id
79513 , l5.line_number line_number
79514 , CASE r
79515 WHEN 1 THEN 'AR_DISTRIBUTIONS_L_V'
79516 WHEN 2 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
79517 WHEN 3 THEN 'FV_XLA_AR_REF_V'
79518 WHEN 4 THEN 'FV_XLA_AR_REF_V'
79519 WHEN 5 THEN 'FV_XLA_AR_REF_V'
79520 WHEN 6 THEN 'FV_XLA_AR_REF_V'
79521 WHEN 7 THEN 'FV_XLA_AR_REF_V'
79522 WHEN 8 THEN 'AR_CUST_TRX_LINES_L_V'
79523 WHEN 9 THEN 'AR_DISTRIBUTIONS_L_V'
79524 WHEN 10 THEN 'AR_RECEIVABLES_TRX_ACT_S_V'
79525 WHEN 11 THEN 'AR_DISTRIBUTIONS_L_V'
79526 WHEN 12 THEN 'AR_DISTRIBUTIONS_L_V'
79527 WHEN 13 THEN 'AR_DISTRIBUTIONS_L_V'
79528 WHEN 14 THEN 'AR_DISTRIBUTIONS_L_V'
79529 WHEN 15 THEN 'AR_DISTRIBUTIONS_BASE_V'
79530 WHEN 16 THEN 'AR_DISTRIBUTIONS_BASE_V'
79531 WHEN 17 THEN 'AR_DISTRIBUTIONS_BASE_V'
79532 WHEN 18 THEN 'AR_DISTRIBUTIONS_BASE_V'
79533 WHEN 19 THEN 'AR_CUST_TRX_LINES_L_V'
79534 WHEN 20 THEN 'AR_CUST_TRX_LINES_L_V'
79535 WHEN 21 THEN 'AR_CUST_TRX_LINES_L_V'
79536 WHEN 22 THEN 'FV_XLA_AR_REF_V'
79537 WHEN 23 THEN 'AR_DISTRIBUTIONS_BASE_V'
79538 WHEN 24 THEN 'AR_TRANSACTIONS_S_V'
79539 WHEN 25 THEN 'AR_TRANSACTIONS_S_V'
79540 WHEN 26 THEN 'AR_DISTRIBUTIONS_L_V'
79541 WHEN 27 THEN 'AR_DISTRIBUTIONS_BASE_V'
79542 WHEN 28 THEN 'AR_DISTRIBUTIONS_L_V'
79543 WHEN 29 THEN 'AR_DISTRIBUTIONS_L_V'
79544 WHEN 30 THEN 'AR_DISTRIBUTIONS_L_V'
79545 WHEN 31 THEN 'AR_DISTRIBUTIONS_L_V'
79546 WHEN 32 THEN 'AR_DISTRIBUTIONS_L_V'
79547 WHEN 33 THEN 'AR_DISTRIBUTIONS_BASE_V'
79548 WHEN 34 THEN 'AR_DISTRIBUTIONS_BASE_V'
79549 WHEN 35 THEN 'AR_DISTRIBUTIONS_L_V'
79550
79551 ELSE null
79552 END object_name
79553 , CASE r
79554 WHEN 1 THEN 'LINE'
79555 WHEN 2 THEN 'LINE'
79556 WHEN 3 THEN 'LINE'
79557 WHEN 4 THEN 'LINE'
79558 WHEN 5 THEN 'LINE'
79559 WHEN 6 THEN 'LINE'
79560 WHEN 7 THEN 'LINE'
79561 WHEN 8 THEN 'LINE'
79562 WHEN 9 THEN 'LINE'
79563 WHEN 10 THEN 'LINE'
79564 WHEN 11 THEN 'LINE'
79565 WHEN 12 THEN 'LINE'
79566 WHEN 13 THEN 'LINE'
79567 WHEN 14 THEN 'LINE'
79568 WHEN 15 THEN 'LINE'
79569 WHEN 16 THEN 'LINE'
79570 WHEN 17 THEN 'LINE'
79571 WHEN 18 THEN 'LINE'
79572 WHEN 19 THEN 'LINE'
79573 WHEN 20 THEN 'LINE'
79574 WHEN 21 THEN 'LINE'
79575 WHEN 22 THEN 'LINE'
79576 WHEN 23 THEN 'LINE'
79577 WHEN 24 THEN 'LINE'
79578 WHEN 25 THEN 'LINE'
79579 WHEN 26 THEN 'LINE'
79580 WHEN 27 THEN 'LINE'
79581 WHEN 28 THEN 'LINE'
79582 WHEN 29 THEN 'LINE'
79583 WHEN 30 THEN 'LINE'
79584 WHEN 31 THEN 'LINE'
79585 WHEN 32 THEN 'LINE'
79586 WHEN 33 THEN 'LINE'
79587 WHEN 34 THEN 'LINE'
79588 WHEN 35 THEN 'LINE'
79589
79590 ELSE null
79591 END object_type_code
79592 , CASE r
79593 WHEN 1 THEN '222'
79594 WHEN 2 THEN '222'
79595 WHEN 3 THEN '8901'
79596 WHEN 4 THEN '8901'
79600 WHEN 8 THEN '222'
79597 WHEN 5 THEN '8901'
79598 WHEN 6 THEN '8901'
79599 WHEN 7 THEN '8901'
79601 WHEN 9 THEN '222'
79602 WHEN 10 THEN '222'
79603 WHEN 11 THEN '222'
79604 WHEN 12 THEN '222'
79605 WHEN 13 THEN '222'
79606 WHEN 14 THEN '222'
79607 WHEN 15 THEN '222'
79608 WHEN 16 THEN '222'
79609 WHEN 17 THEN '222'
79610 WHEN 18 THEN '222'
79611 WHEN 19 THEN '222'
79612 WHEN 20 THEN '222'
79613 WHEN 21 THEN '222'
79614 WHEN 22 THEN '8901'
79615 WHEN 23 THEN '222'
79616 WHEN 24 THEN '222'
79617 WHEN 25 THEN '222'
79618 WHEN 26 THEN '222'
79619 WHEN 27 THEN '222'
79620 WHEN 28 THEN '222'
79621 WHEN 29 THEN '222'
79622 WHEN 30 THEN '222'
79623 WHEN 31 THEN '222'
79624 WHEN 32 THEN '222'
79625 WHEN 33 THEN '222'
79626 WHEN 34 THEN '222'
79627 WHEN 35 THEN '222'
79628
79629 ELSE null
79630 END source_application_id
79631 , 'S' source_type_code
79632 , CASE r
79633 WHEN 1 THEN 'DIST_CODE_COMBINATION_ID'
79634 WHEN 2 THEN 'BILL_CUSTOMER_CLASS_CODE'
79635 WHEN 3 THEN 'FEDERAL_ACCOUNT_RULE'
79636 WHEN 4 THEN 'FEDERAL_FUND_EXPIRED_STATUS'
79637 WHEN 5 THEN 'FEDERAL_PRIOR_YEAR_FLAG'
79638 WHEN 6 THEN 'FEDERAL_FUND_TIME_FRAME'
79639 WHEN 7 THEN 'FEDERAL_APPORTIONMENT_CATEGORY'
79640 WHEN 8 THEN 'TRX_LINE_DIST_CCID'
79641 WHEN 9 THEN 'DIST_SOURCE_TYPE'
79642 WHEN 10 THEN 'REC_ACT_TYPE'
79643 WHEN 11 THEN 'DIST_LINE_ID'
79644 WHEN 12 THEN 'DISTRIBUTION_TYPE'
79645 WHEN 13 THEN 'DIST_ENT_AMT'
79646 WHEN 14 THEN 'DIST_CURRENCY_CODE'
79647 WHEN 15 THEN 'DIST_CUR_CONVERSION_DATE'
79648 WHEN 16 THEN 'DIST_CUR_CONVERSION_RATE'
79649 WHEN 17 THEN 'DIST_CUR_CONVERSION_TYPE'
79650 WHEN 18 THEN 'DIST_TO_ACCTD_AMT'
79651 WHEN 19 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
79652 WHEN 20 THEN 'TRX_LINE_DIST_ID'
79653 WHEN 21 THEN 'TRX_DISTRIBUTION_TYPE'
79654 WHEN 22 THEN 'FEDERAL_ACCOUNT_VALID_FLAG'
79655 WHEN 23 THEN 'DIST_TO_CUR_CONVERSION_DATE'
79656 WHEN 24 THEN 'TRX_ENTITY_CODE'
79657 WHEN 25 THEN 'TRX_CUSTOMER_TRX_ID'
79658 WHEN 26 THEN 'DIST_CURRENCY_CODE_FROM'
79659 WHEN 27 THEN 'DIST_TO_CUR_CONVERSION_RATE'
79660 WHEN 28 THEN 'DIST_PARTY_ID'
79661 WHEN 29 THEN 'DIST_PARTY_SITE_ID'
79662 WHEN 30 THEN 'DIST_PARTY_TYPE'
79663 WHEN 31 THEN 'DIST_MFAR_ADDITIONAL_ENTRY'
79664 WHEN 32 THEN 'DIST_ENT_AMT_FROM'
79665 WHEN 33 THEN 'DIST_ACCTD_AMT'
79666 WHEN 34 THEN 'DIST_TO_CUR_CONVERSION_TYPE'
79667 WHEN 35 THEN 'DIST_SOURCE_TABLE'
79668
79669 ELSE null
79670 END source_code
79671 , CASE r
79672 WHEN 1 THEN TO_CHAR(l5.DIST_CODE_COMBINATION_ID)
79673 WHEN 2 THEN TO_CHAR(l1.BILL_CUSTOMER_CLASS_CODE)
79674 WHEN 3 THEN TO_CHAR(l12.FEDERAL_ACCOUNT_RULE)
79675 WHEN 4 THEN TO_CHAR(l12.FEDERAL_FUND_EXPIRED_STATUS)
79676 WHEN 5 THEN TO_CHAR(l12.FEDERAL_PRIOR_YEAR_FLAG)
79677 WHEN 6 THEN TO_CHAR(l12.FEDERAL_FUND_TIME_FRAME)
79678 WHEN 7 THEN TO_CHAR(l12.FEDERAL_APPORTIONMENT_CATEGORY)
79679 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_DIST_CCID)
79680 WHEN 9 THEN TO_CHAR(l5.DIST_SOURCE_TYPE)
79681 WHEN 10 THEN TO_CHAR(l8.REC_ACT_TYPE)
79682 WHEN 11 THEN TO_CHAR(l5.DIST_LINE_ID)
79683 WHEN 12 THEN TO_CHAR(l5.DISTRIBUTION_TYPE)
79684 WHEN 13 THEN TO_CHAR(l5.DIST_ENT_AMT)
79685 WHEN 14 THEN TO_CHAR(l5.DIST_CURRENCY_CODE)
79686 WHEN 15 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_DATE)
79687 WHEN 16 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_RATE)
79688 WHEN 17 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_TYPE)
79689 WHEN 18 THEN TO_CHAR(l4.DIST_TO_ACCTD_AMT)
79690 WHEN 19 THEN TO_CHAR(l3.TRX_LINE_DIST_ACCOUNT_CLASS)
79691 WHEN 20 THEN TO_CHAR(l3.TRX_LINE_DIST_ID)
79692 WHEN 21 THEN TO_CHAR(l3.TRX_DISTRIBUTION_TYPE)
79693 WHEN 22 THEN TO_CHAR(l12.FEDERAL_ACCOUNT_VALID_FLAG)
79694 WHEN 23 THEN TO_CHAR(l4.DIST_TO_CUR_CONVERSION_DATE)
79695 WHEN 24 THEN TO_CHAR(l11.TRX_ENTITY_CODE)
79696 WHEN 25 THEN TO_CHAR(l11.TRX_CUSTOMER_TRX_ID)
79697 WHEN 26 THEN TO_CHAR(l5.DIST_CURRENCY_CODE_FROM)
79698 WHEN 27 THEN TO_CHAR(l4.DIST_TO_CUR_CONVERSION_RATE)
79699 WHEN 28 THEN TO_CHAR(l5.DIST_PARTY_ID)
79700 WHEN 29 THEN TO_CHAR(l5.DIST_PARTY_SITE_ID)
79701 WHEN 30 THEN TO_CHAR(l5.DIST_PARTY_TYPE)
79702 WHEN 31 THEN TO_CHAR(l5.DIST_MFAR_ADDITIONAL_ENTRY)
79703 WHEN 32 THEN TO_CHAR(l5.DIST_ENT_AMT_FROM)
79704 WHEN 33 THEN TO_CHAR(l4.DIST_ACCTD_AMT)
79705 WHEN 34 THEN TO_CHAR(l4.DIST_TO_CUR_CONVERSION_TYPE)
79706 WHEN 35 THEN TO_CHAR(l5.DIST_SOURCE_TABLE)
79707
79708 ELSE null
79712 , AR_BILL_TO_CUSTOMERS_S_V l1
79709 END source_value
79710 , null source_meaning
79711 FROM xla_events_gt xet
79713 , AR_CUST_TRX_LINES_L_V l3
79714 , AR_DISTRIBUTIONS_BASE_V l4
79715 , AR_DISTRIBUTIONS_L_V l5
79716 , AR_RECEIVABLES_TRX_ACT_S_V l8
79717 , AR_TRANSACTIONS_S_V l11
79718 , FV_XLA_AR_REF_V l12
79719 , (select rownum r from all_objects where rownum <= 35 and owner = p_apps_owner)
79720 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
79721 AND xet.event_class_code = C_EVENT_CLASS_CODE
79722 AND l4.event_id = xet.event_id
79723 AND l1.event_id (+) = l4.event_id
79724 AND l1.line_number (+) = l4.line_number
79725 AND l3.event_id (+) = l4.event_id
79726 AND l3.line_number (+) = l4.line_number
79727 AND l5.event_id = l4.event_id
79728 AND l5.line_number = l4.line_number
79729 AND l8.event_id (+) = l4.event_id
79730 AND l8.line_number (+) = l4.line_number
79731 AND l11.event_id (+) = l4.event_id
79732 AND l11.line_number (+) = l4.line_number
79733 AND l12.federal_event_id (+) = l5.event_id and l12.federal_line_number (+) = l5.line_number
79734 )
79735 ;
79736 --
79737 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
79738
79739 trace
79740 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
79741 ,p_level => C_LEVEL_STATEMENT
79742 ,p_module => l_log_module);
79743
79744 END IF;
79745
79746
79747 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
79748 trace
79749 (p_msg => 'END of insert_sources_146'
79750 ,p_level => C_LEVEL_PROCEDURE
79751 ,p_module => l_log_module);
79752 END IF;
79753 EXCEPTION
79754 WHEN xla_exceptions_pkg.application_exception THEN
79755 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
79756 trace
79757 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
79758 ,p_level => C_LEVEL_EXCEPTION
79759 ,p_module => l_log_module);
79760 END IF;
79761 RAISE;
79762 WHEN OTHERS THEN
79763 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
79764 trace
79765 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
79766 ,p_level => C_LEVEL_EXCEPTION
79767 ,p_module => l_log_module);
79768 END IF;
79769 xla_exceptions_pkg.raise_message
79770 (p_location => 'XLA_00222_AAD_S_000009_PKG.insert_sources_146');
79771 END insert_sources_146;
79772 --
79773
79774 ---------------------------------------
79775 --
79776 -- PRIVATE FUNCTION
79777 -- EventClass_146
79778 --
79779 ----------------------------------------
79780 --
79781 FUNCTION EventClass_146
79782 (p_application_id IN NUMBER
79783 ,p_base_ledger_id IN NUMBER
79784 ,p_target_ledger_id IN NUMBER
79785 ,p_language IN VARCHAR2
79786 ,p_currency_code IN VARCHAR2
79787 ,p_sla_ledger_id IN NUMBER
79788 ,p_pad_start_date IN DATE
79789 ,p_pad_end_date IN DATE
79790 ,p_primary_ledger_id IN NUMBER)
79791 RETURN BOOLEAN IS
79792 --
79793 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'RECEIPT_ALL';
79794 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'RECEIPT';
79795
79796 l_calculate_acctd_flag VARCHAR2(1) :='N';
79797 l_calculate_g_l_flag VARCHAR2(1) :='Y';
79798 --
79799 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79800 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79801 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
79802 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
79803 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79804 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
79805 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
79806 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79807 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
79808 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
79809 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79810 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79811 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79812 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79813 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
79814 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
79815 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
79816 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
79817 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
79818 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
79819 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
79820 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
79821 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
79822 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
79823 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
79824 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
79825
79826 l_event_id NUMBER;
79827 l_previous_event_id NUMBER;
79828 l_first_event_id NUMBER;
79829 l_last_event_id NUMBER;
79833 --
79830
79831 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
79832 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
79834 --
79835 l_result BOOLEAN := TRUE;
79836 l_rows NUMBER := 1000;
79837 l_event_type_name VARCHAR2(80) := 'All';
79838 l_event_class_name VARCHAR2(80) := 'Receipt';
79839 l_description VARCHAR2(4000);
79840 l_transaction_reversal NUMBER;
79841 l_ae_header_id NUMBER;
79842 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
79843 l_log_module VARCHAR2(240);
79844 --
79845 l_acct_reversal_source VARCHAR2(30);
79846 l_trx_reversal_source VARCHAR2(30);
79847
79848 l_continue_with_lines BOOLEAN := TRUE;
79849 --
79850 l_acc_rev_gl_date_source DATE; -- 4262811
79851 --
79852 type t_array_event_id is table of number index by binary_integer;
79853
79854 l_rec_array_event t_rec_array_event;
79855 l_null_rec_array_event t_rec_array_event;
79856 l_array_ae_header_id xla_number_array_type;
79857 l_actual_flag VARCHAR2(1) := NULL;
79858 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
79859 l_balance_type_code VARCHAR2(1) :=NULL;
79860 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
79861
79862 --
79863 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
79864 --
79865
79866 TYPE t_array_source_1 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_BANK_CHARGES_CCID%TYPE INDEX BY BINARY_INTEGER;
79867 TYPE t_array_source_3 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_CONFIRMATION_CCID%TYPE INDEX BY BINARY_INTEGER;
79868 TYPE t_array_source_4 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_EARNED_CCID%TYPE INDEX BY BINARY_INTEGER;
79869 TYPE t_array_source_5 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_CASH_CCID%TYPE INDEX BY BINARY_INTEGER;
79870 TYPE t_array_source_6 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_REMITTANCE_CCID%TYPE INDEX BY BINARY_INTEGER;
79871 TYPE t_array_source_7 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_UNEARNED_CCID%TYPE INDEX BY BINARY_INTEGER;
79872 TYPE t_array_source_18 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_UNAPPLIED_CCID%TYPE INDEX BY BINARY_INTEGER;
79873 TYPE t_array_source_19 IS TABLE OF AR_SYSTEM_PARAM_H_V.CODE_COMBINATION_ID_GAIN%TYPE INDEX BY BINARY_INTEGER;
79874 TYPE t_array_source_20 IS TABLE OF AR_SYSTEM_PARAM_H_V.CODE_COMBINATION_ID_LOSS%TYPE INDEX BY BINARY_INTEGER;
79875 TYPE t_array_source_60 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_XLA_APPLIED_TO_APP_ID%TYPE INDEX BY BINARY_INTEGER;
79876 TYPE t_array_source_72 IS TABLE OF AR_RCT_METHOD_H_V.RCT_CLASS_REMIT_FLAG%TYPE INDEX BY BINARY_INTEGER;
79877 TYPE t_array_source_73 IS TABLE OF AR_RCT_METHOD_H_V.RCT_CLASS_CONFIRM_FLAG%TYPE INDEX BY BINARY_INTEGER;
79878 TYPE t_array_source_78 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_PAY_FROM_CUSTOMER%TYPE INDEX BY BINARY_INTEGER;
79879 TYPE t_array_source_79 IS TABLE OF AR_RCT_SITE_USES_H_V.RCT_SITE_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
79880 TYPE t_array_source_80 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_APP_STATUS%TYPE INDEX BY BINARY_INTEGER;
79881 TYPE t_array_source_88 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
79882 TYPE t_array_source_89 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
79883 TYPE t_array_source_90 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
79884 TYPE t_array_source_91 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_TRX_ACCT_REVERSAL%TYPE INDEX BY BINARY_INTEGER;
79885
79886 TYPE t_array_source_10 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
79887 TYPE t_array_source_12 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUSTOMER_CLASS_CODE%TYPE INDEX BY BINARY_INTEGER;
79888 TYPE t_array_source_13 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_ACCOUNT_RULE%TYPE INDEX BY BINARY_INTEGER;
79889 TYPE t_array_source_14 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_FUND_EXPIRED_STATUS%TYPE INDEX BY BINARY_INTEGER;
79890 TYPE t_array_source_15 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_PRIOR_YEAR_FLAG%TYPE INDEX BY BINARY_INTEGER;
79891 TYPE t_array_source_16 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_FUND_TIME_FRAME%TYPE INDEX BY BINARY_INTEGER;
79892 TYPE t_array_source_17 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_APPORTIONMENT_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
79893 TYPE t_array_source_21 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
79894 TYPE t_array_source_22 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
79895 TYPE t_array_source_23 IS TABLE OF AR_RECEIVABLES_TRX_ACT_S_V.REC_ACT_TYPE%TYPE INDEX BY BINARY_INTEGER;
79896 TYPE t_array_source_24 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
79897 TYPE t_array_source_25 IS TABLE OF AR_DISTRIBUTIONS_L_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
79898 TYPE t_array_source_26 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT%TYPE INDEX BY BINARY_INTEGER;
79899 TYPE t_array_source_27 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
79900 TYPE t_array_source_28 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
79901 TYPE t_array_source_29 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
79902 TYPE t_array_source_30 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
79903 TYPE t_array_source_31 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
79904 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
79905 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
79906 TYPE t_array_source_37 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
79907 TYPE t_array_source_58 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_ACCOUNT_VALID_FLAG%TYPE INDEX BY BINARY_INTEGER;
79908 TYPE t_array_source_59 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
79909 TYPE t_array_source_61 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_ENTITY_CODE%TYPE INDEX BY BINARY_INTEGER;
79913 TYPE t_array_source_65 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_PARTY_ID%TYPE INDEX BY BINARY_INTEGER;
79910 TYPE t_array_source_62 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_CUSTOMER_TRX_ID%TYPE INDEX BY BINARY_INTEGER;
79911 TYPE t_array_source_63 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CURRENCY_CODE_FROM%TYPE INDEX BY BINARY_INTEGER;
79912 TYPE t_array_source_64 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
79914 TYPE t_array_source_66 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_PARTY_SITE_ID%TYPE INDEX BY BINARY_INTEGER;
79915 TYPE t_array_source_67 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
79916 TYPE t_array_source_71 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_MFAR_ADDITIONAL_ENTRY%TYPE INDEX BY BINARY_INTEGER;
79917 TYPE t_array_source_74 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT_FROM%TYPE INDEX BY BINARY_INTEGER;
79918 TYPE t_array_source_75 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
79919 TYPE t_array_source_76 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
79920 TYPE t_array_source_77 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TABLE%TYPE INDEX BY BINARY_INTEGER;
79921
79922 l_array_source_1 t_array_source_1;
79923 l_array_source_3 t_array_source_3;
79924 l_array_source_4 t_array_source_4;
79925 l_array_source_5 t_array_source_5;
79926 l_array_source_6 t_array_source_6;
79927 l_array_source_7 t_array_source_7;
79928 l_array_source_18 t_array_source_18;
79929 l_array_source_19 t_array_source_19;
79930 l_array_source_20 t_array_source_20;
79931 l_array_source_60 t_array_source_60;
79932 l_array_source_72 t_array_source_72;
79933 l_array_source_73 t_array_source_73;
79934 l_array_source_78 t_array_source_78;
79935 l_array_source_79 t_array_source_79;
79936 l_array_source_80 t_array_source_80;
79937 l_array_source_88 t_array_source_88;
79938 l_array_source_89 t_array_source_89;
79939 l_array_source_90 t_array_source_90;
79940 l_array_source_91 t_array_source_91;
79941
79942 l_array_source_10 t_array_source_10;
79943 l_array_source_12 t_array_source_12;
79944 l_array_source_13 t_array_source_13;
79945 l_array_source_14 t_array_source_14;
79946 l_array_source_15 t_array_source_15;
79947 l_array_source_16 t_array_source_16;
79948 l_array_source_17 t_array_source_17;
79949 l_array_source_21 t_array_source_21;
79950 l_array_source_22 t_array_source_22;
79951 l_array_source_23 t_array_source_23;
79952 l_array_source_24 t_array_source_24;
79953 l_array_source_25 t_array_source_25;
79954 l_array_source_26 t_array_source_26;
79955 l_array_source_27 t_array_source_27;
79956 l_array_source_28 t_array_source_28;
79957 l_array_source_29 t_array_source_29;
79958 l_array_source_30 t_array_source_30;
79959 l_array_source_31 t_array_source_31;
79960 l_array_source_35 t_array_source_35;
79961 l_array_source_36 t_array_source_36;
79962 l_array_source_37 t_array_source_37;
79963 l_array_source_58 t_array_source_58;
79964 l_array_source_59 t_array_source_59;
79965 l_array_source_61 t_array_source_61;
79966 l_array_source_62 t_array_source_62;
79967 l_array_source_63 t_array_source_63;
79968 l_array_source_64 t_array_source_64;
79969 l_array_source_65 t_array_source_65;
79970 l_array_source_66 t_array_source_66;
79971 l_array_source_67 t_array_source_67;
79972 l_array_source_71 t_array_source_71;
79973 l_array_source_74 t_array_source_74;
79974 l_array_source_75 t_array_source_75;
79975 l_array_source_76 t_array_source_76;
79976 l_array_source_77 t_array_source_77;
79977
79978 --
79979 CURSOR header_cur
79980 IS
79981 SELECT /*+ leading(xet) cardinality(xet,1) */
79982 -- Event Class Code: RECEIPT
79983 xet.entity_id
79984 ,xet.legal_entity_id
79985 ,xet.entity_code
79986 ,xet.transaction_number
79987 ,xet.event_id
79988 ,xet.event_class_code
79989 ,xet.event_type_code
79990 ,xet.event_number
79991 ,xet.event_date
79992 ,xet.transaction_date
79993 ,xet.reference_num_1
79994 ,xet.reference_num_2
79995 ,xet.reference_num_3
79996 ,xet.reference_num_4
79997 ,xet.reference_char_1
79998 ,xet.reference_char_2
79999 ,xet.reference_char_3
80000 ,xet.reference_char_4
80001 ,xet.reference_date_1
80002 ,xet.reference_date_2
80003 ,xet.reference_date_3
80004 ,xet.reference_date_4
80005 ,xet.event_created_by
80006 ,xet.budgetary_control_flag
80007 , h9.RMT_BNK_BANK_CHARGES_CCID source_1
80008 , h9.RMT_BNK_CONFIRMATION_CCID source_3
80009 , h9.RMT_BNK_EARNED_CCID source_4
80010 , h9.RMT_BNK_CASH_CCID source_5
80011 , h9.RMT_BNK_REMITTANCE_CCID source_6
80012 , h9.RMT_BNK_UNEARNED_CCID source_7
80013 , h9.RMT_BNK_UNAPPLIED_CCID source_18
80014 , h10.CODE_COMBINATION_ID_GAIN source_19
80015 , h10.CODE_COMBINATION_ID_LOSS source_20
80016 , h2.RCT_XLA_APPLIED_TO_APP_ID source_60
80017 , h6.RCT_CLASS_REMIT_FLAG source_72
80018 , h6.RCT_CLASS_CONFIRM_FLAG source_73
80019 , h2.RCT_PAY_FROM_CUSTOMER source_78
80020 , h7.RCT_SITE_SITE_USE_ID source_79
80021 , h2.RCT_APP_STATUS source_80
80022 , h2.RCT_DOC_SEQUENCE_CATEGORY source_88
80023 , h2.RCT_DOC_SEQUENCE_ID source_89
80024 , h2.RCT_DOC_SEQUENCE_VALUE source_90
80025 , h2.RCT_TRX_ACCT_REVERSAL source_91
80026 FROM xla_events_gt xet
80027 , AR_CASH_RECEIPTS_H_V h2
80028 , AR_RCT_METHOD_H_V h6
80029 , AR_RCT_SITE_USES_H_V h7
80030 , AR_REMIT_BANK_ACCT_H_V h9
80031 , AR_SYSTEM_PARAM_H_V h10
80032 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
80036 AND h7.event_id (+) = h2.event_id
80033 and xet.event_class_code = C_EVENT_CLASS_CODE
80034 and xet.event_status_code <> 'N' AND h2.event_id = xet.event_id
80035 AND h6.event_id (+) = h2.event_id
80037 AND h9.event_id (+) = h2.event_id
80038 AND h10.event_id (+) = h2.event_id
80039
80040 ORDER BY event_id
80041 ;
80042
80043
80044 --
80045 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
80046 IS
80047 SELECT /*+ leading(xet) cardinality(xet,1) */
80048 -- Event Class Code: RECEIPT
80049 xet.entity_id
80050 ,xet.legal_entity_id
80051 ,xet.entity_code
80052 ,xet.transaction_number
80053 ,xet.event_id
80054 ,xet.event_class_code
80055 ,xet.event_type_code
80056 ,xet.event_number
80057 ,xet.event_date
80058 ,xet.transaction_date
80059 ,xet.reference_num_1
80060 ,xet.reference_num_2
80061 ,xet.reference_num_3
80062 ,xet.reference_num_4
80063 ,xet.reference_char_1
80064 ,xet.reference_char_2
80065 ,xet.reference_char_3
80066 ,xet.reference_char_4
80067 ,xet.reference_date_1
80068 ,xet.reference_date_2
80069 ,xet.reference_date_3
80070 ,xet.reference_date_4
80071 ,xet.event_created_by
80072 ,xet.budgetary_control_flag
80073 , l4.LINE_NUMBER
80074 , l5.DIST_CODE_COMBINATION_ID source_10
80075 , l1.BILL_CUSTOMER_CLASS_CODE source_12
80076 , l12.FEDERAL_ACCOUNT_RULE source_13
80077 , l12.FEDERAL_FUND_EXPIRED_STATUS source_14
80078 , l12.FEDERAL_PRIOR_YEAR_FLAG source_15
80079 , l12.FEDERAL_FUND_TIME_FRAME source_16
80080 , l12.FEDERAL_APPORTIONMENT_CATEGORY source_17
80081 , l3.TRX_LINE_DIST_CCID source_21
80082 , l5.DIST_SOURCE_TYPE source_22
80083 , l8.REC_ACT_TYPE source_23
80084 , l5.DIST_LINE_ID source_24
80085 , l5.DISTRIBUTION_TYPE source_25
80086 , l5.DIST_ENT_AMT source_26
80087 , l5.DIST_CURRENCY_CODE source_27
80088 , l4.DIST_CUR_CONVERSION_DATE source_28
80089 , l4.DIST_CUR_CONVERSION_RATE source_29
80090 , l4.DIST_CUR_CONVERSION_TYPE source_30
80091 , l4.DIST_TO_ACCTD_AMT source_31
80092 , l3.TRX_LINE_DIST_ACCOUNT_CLASS source_35
80093 , l3.TRX_LINE_DIST_ID source_36
80094 , l3.TRX_DISTRIBUTION_TYPE source_37
80095 , l12.FEDERAL_ACCOUNT_VALID_FLAG source_58
80096 , l4.DIST_TO_CUR_CONVERSION_DATE source_59
80097 , l11.TRX_ENTITY_CODE source_61
80098 , l11.TRX_CUSTOMER_TRX_ID source_62
80099 , l5.DIST_CURRENCY_CODE_FROM source_63
80100 , l4.DIST_TO_CUR_CONVERSION_RATE source_64
80101 , l5.DIST_PARTY_ID source_65
80102 , l5.DIST_PARTY_SITE_ID source_66
80103 , l5.DIST_PARTY_TYPE source_67
80104 , l5.DIST_MFAR_ADDITIONAL_ENTRY source_71
80105 , l5.DIST_ENT_AMT_FROM source_74
80106 , l4.DIST_ACCTD_AMT source_75
80107 , l4.DIST_TO_CUR_CONVERSION_TYPE source_76
80108 , l5.DIST_SOURCE_TABLE source_77
80109 FROM xla_events_gt xet
80110 , AR_BILL_TO_CUSTOMERS_S_V l1
80111 , AR_CUST_TRX_LINES_L_V l3
80112 , AR_DISTRIBUTIONS_BASE_V l4
80113 , AR_DISTRIBUTIONS_L_V l5
80114 , AR_RECEIVABLES_TRX_ACT_S_V l8
80115 , AR_TRANSACTIONS_S_V l11
80116 , FV_XLA_AR_REF_V l12
80117 WHERE xet.event_id between x_first_event_id and x_last_event_id
80118 and xet.event_date between p_pad_start_date and p_pad_end_date
80119 and xet.event_class_code = C_EVENT_CLASS_CODE
80120 and xet.event_status_code <> 'N' AND l4.event_id = xet.event_id
80121 AND l1.event_id (+) = l4.event_id
80122 AND l1.line_number (+) = l4.line_number
80123 AND l3.event_id (+) = l4.event_id
80124 AND l3.line_number (+) = l4.line_number
80125 AND l5.event_id = l4.event_id
80126 AND l5.line_number = l4.line_number
80127 AND l8.event_id (+) = l4.event_id
80128 AND l8.line_number (+) = l4.line_number
80129 AND l11.event_id (+) = l4.event_id
80130 AND l11.line_number (+) = l4.line_number
80131 AND l12.federal_event_id (+) = l5.event_id AND l12.federal_line_number (+) = l5.line_number;
80132
80133 --
80134 BEGIN
80135 IF g_log_enabled THEN
80136 l_log_module := C_DEFAULT_MODULE||'.EventClass_146';
80137 END IF;
80138 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
80139 trace
80140 (p_msg => 'BEGIN of EventClass_146'
80141 ,p_level => C_LEVEL_PROCEDURE
80142 ,p_module => l_log_module);
80143 END IF;
80144
80145 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
80146 trace
80147 (p_msg => 'p_application_id = '||p_application_id||
80148 ' - p_base_ledger_id = '||p_base_ledger_id||
80149 ' - p_target_ledger_id = '||p_target_ledger_id||
80150 ' - p_language = '||p_language||
80151 ' - p_currency_code = '||p_currency_code||
80152 ' - p_sla_ledger_id = '||p_sla_ledger_id
80153 ,p_level => C_LEVEL_STATEMENT
80154 ,p_module => l_log_module);
80155 END IF;
80156 --
80157 -- initialze arrays
80158 --
80159 g_array_event.DELETE;
80160 l_rec_array_event := l_null_rec_array_event;
80161 --
80162 --------------------------------------
80163 -- 4262811 Initialze MPA Line Number
80164 --------------------------------------
80165 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
80166
80167 --
80168
80169 --
80170 OPEN header_cur;
80171 --
80172 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
80173 trace
80174 (p_msg => 'SQL - FETCH header_cur'
80175 ,p_level => C_LEVEL_STATEMENT
80176 ,p_module => l_log_module);
80177 END IF;
80178 --
80179 LOOP
80180 FETCH header_cur BULK COLLECT INTO
80181 l_array_entity_id
80182 , l_array_legal_entity_id
80183 , l_array_entity_code
80187 , l_array_event_type
80184 , l_array_transaction_num
80185 , l_array_event_id
80186 , l_array_class_code
80188 , l_array_event_number
80189 , l_array_event_date
80190 , l_array_transaction_date
80191 , l_array_reference_num_1
80192 , l_array_reference_num_2
80193 , l_array_reference_num_3
80194 , l_array_reference_num_4
80195 , l_array_reference_char_1
80196 , l_array_reference_char_2
80197 , l_array_reference_char_3
80198 , l_array_reference_char_4
80199 , l_array_reference_date_1
80200 , l_array_reference_date_2
80201 , l_array_reference_date_3
80202 , l_array_reference_date_4
80203 , l_array_event_created_by
80204 , l_array_budgetary_control_flag
80205 , l_array_source_1
80206 , l_array_source_3
80207 , l_array_source_4
80208 , l_array_source_5
80209 , l_array_source_6
80210 , l_array_source_7
80211 , l_array_source_18
80212 , l_array_source_19
80213 , l_array_source_20
80214 , l_array_source_60
80215 , l_array_source_72
80216 , l_array_source_73
80217 , l_array_source_78
80218 , l_array_source_79
80219 , l_array_source_80
80220 , l_array_source_88
80221 , l_array_source_89
80222 , l_array_source_90
80223 , l_array_source_91
80224 LIMIT l_rows;
80225 --
80226 IF (C_LEVEL_EVENT >= g_log_level) THEN
80227 trace
80228 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
80229 ,p_level => C_LEVEL_EVENT
80230 ,p_module => l_log_module);
80231 END IF;
80232 --
80233 EXIT WHEN l_array_entity_id.COUNT = 0;
80234
80235 -- initialize arrays
80236 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
80237 XLA_AE_LINES_PKG.g_rec_lines := NULL;
80238
80239 --
80240 -- Bug 4458708
80241 --
80242 XLA_AE_LINES_PKG.g_LineNumber := 0;
80243
80244
80245 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
80246 g_last_hdr_idx := l_array_event_id.LAST;
80247 --
80248 -- loop for the headers. Each iteration is for each header extract row
80249 -- fetched in header cursor
80250 --
80251 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
80252
80253 --
80254 -- set event info as cache for other routines to refer event attributes
80255 --
80256 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
80257 (p_application_id => p_application_id
80258 ,p_primary_ledger_id => p_primary_ledger_id
80259 ,p_base_ledger_id => p_base_ledger_id
80260 ,p_target_ledger_id => p_target_ledger_id
80261 ,p_entity_id => l_array_entity_id(hdr_idx)
80262 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
80263 ,p_entity_code => l_array_entity_code(hdr_idx)
80264 ,p_transaction_num => l_array_transaction_num(hdr_idx)
80265 ,p_event_id => l_array_event_id(hdr_idx)
80266 ,p_event_class_code => l_array_class_code(hdr_idx)
80267 ,p_event_type_code => l_array_event_type(hdr_idx)
80268 ,p_event_number => l_array_event_number(hdr_idx)
80269 ,p_event_date => l_array_event_date(hdr_idx)
80270 ,p_transaction_date => l_array_transaction_date(hdr_idx)
80271 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
80272 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
80273 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
80274 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
80275 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
80276 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
80277 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
80278 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
80279 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
80280 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
80281 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
80282 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
80283 ,p_event_created_by => l_array_event_created_by(hdr_idx)
80284 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
80285
80286 --
80287 -- set the status of entry to C_VALID (0)
80288 --
80289 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
80290
80291 --
80292 -- initialize a row for ae header
80293 --
80294 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
80295
80296 l_event_id := l_array_event_id(hdr_idx);
80297
80298 --
80299 -- storing the hdr_idx for event. May be used by line cursor.
80300 --
80301 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
80302
80303 --
80304 -- store sources from header extract. This can be improved to
80305 -- store only those sources from header extract that may be used in lines
80306 --
80307
80308 g_array_event(l_event_id).array_value_num('source_1') := l_array_source_1(hdr_idx);
80309 g_array_event(l_event_id).array_value_num('source_3') := l_array_source_3(hdr_idx);
80310 g_array_event(l_event_id).array_value_num('source_4') := l_array_source_4(hdr_idx);
80311 g_array_event(l_event_id).array_value_num('source_5') := l_array_source_5(hdr_idx);
80312 g_array_event(l_event_id).array_value_num('source_6') := l_array_source_6(hdr_idx);
80313 g_array_event(l_event_id).array_value_num('source_7') := l_array_source_7(hdr_idx);
80314 g_array_event(l_event_id).array_value_num('source_18') := l_array_source_18(hdr_idx);
80315 g_array_event(l_event_id).array_value_num('source_19') := l_array_source_19(hdr_idx);
80316 g_array_event(l_event_id).array_value_num('source_20') := l_array_source_20(hdr_idx);
80320 g_array_event(l_event_id).array_value_num('source_78') := l_array_source_78(hdr_idx);
80317 g_array_event(l_event_id).array_value_num('source_60') := l_array_source_60(hdr_idx);
80318 g_array_event(l_event_id).array_value_char('source_72') := l_array_source_72(hdr_idx);
80319 g_array_event(l_event_id).array_value_char('source_73') := l_array_source_73(hdr_idx);
80321 g_array_event(l_event_id).array_value_num('source_79') := l_array_source_79(hdr_idx);
80322 g_array_event(l_event_id).array_value_char('source_80') := l_array_source_80(hdr_idx);
80323 g_array_event(l_event_id).array_value_char('source_88') := l_array_source_88(hdr_idx);
80324 g_array_event(l_event_id).array_value_num('source_89') := l_array_source_89(hdr_idx);
80325 g_array_event(l_event_id).array_value_num('source_90') := l_array_source_90(hdr_idx);
80326 g_array_event(l_event_id).array_value_char('source_91') := l_array_source_91(hdr_idx);
80327
80328 --
80329 -- initilaize the status of ae headers for diffrent balance types
80330 -- the status is initialised to C_NOT_CREATED (2)
80331 --
80332 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
80333 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
80334 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
80335
80336 --
80337 -- call api to validate and store accounting attributes for header
80338 --
80339
80340 ------------------------------------------------------------
80341 -- Accrual Reversal : to get date for Standard Source (NONE)
80342 ------------------------------------------------------------
80343 l_acc_rev_gl_date_source := NULL;
80344
80345 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
80346 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_88');
80347 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
80348 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_89');
80349 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
80350 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_90');
80351 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
80352 l_rec_acct_attrs.array_date_value(4) :=
80353 xla_ae_sources_pkg.GetSystemSourceDate(
80354 p_source_code => 'XLA_EVENT_DATE'
80355 , p_source_type_code => 'Y'
80356 , p_source_application_id => 602
80357 );
80358 l_rec_acct_attrs.array_acct_attr_code(5) := 'TRX_ACCT_REVERSAL_OPTION';
80359 l_rec_acct_attrs.array_char_value(5) := g_array_event(l_event_id).array_value_char('source_91');
80360
80361
80362 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
80363
80364 XLA_AE_HEADER_PKG.SetJeCategoryName;
80365
80366 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
80367 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
80368 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
80369 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
80370 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
80371
80372
80373 -- No header level analytical criteria
80374
80375 --
80376 --accounting attribute enhancement, bug 3612931
80377 --
80378 l_trx_reversal_source := SUBSTR(g_array_event(l_event_id).array_value_char('source_91'), 1,30);
80379
80380 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
80381 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
80382
80383 xla_accounting_err_pkg.build_message
80384 (p_appli_s_name => 'XLA'
80385 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
80386 ,p_token_1 => 'ACCT_ATTR_NAME'
80387 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
80388 ,p_token_2 => 'PRODUCT_NAME'
80389 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
80390 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
80391 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
80392 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
80393
80394 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
80395 --
80396 -- following sets the accounting attributes needed to reverse
80397 -- accounting for a distributeion
80398 --
80399 xla_ae_lines_pkg.SetTrxReversalAttrs
80400 (p_event_id => l_event_id
80401 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
80402 ,p_trx_reversal_source => l_trx_reversal_source);
80403
80404 END IF;
80405
80406
80407 ----------------------------------------------------------------
80408 -- 4262811 - update the header statuses to invalid in need be
80409 ----------------------------------------------------------------
80410 --
80411 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
80412
80413
80414 -----------------------------------------------
80415 -- No accrual reversal for the event class/type
80416 -----------------------------------------------
80417 ----------------------------------------------------------------
80418
80419 --
80420 -- this ends the header loop iteration for one bulk fetch
80421 --
80422 END LOOP;
80423
80424 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
80425 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
80426
80427 --
80428 -- insert dummy rows into lines gt table that were created due to
80429 -- transaction reversals
80430 --
80434
80431 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
80432 l_result := XLA_AE_LINES_PKG.InsertLines;
80433 END IF;
80435 --
80436 -- reset the temp_line_num for each set of events fetched from header
80437 -- cursor rather than doing it for each new event in line cursor
80438 -- Bug 3939231
80439 --
80440 xla_ae_lines_pkg.g_temp_line_num := 0;
80441
80442
80443
80444 --
80445 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
80446 --
80447 --
80448 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
80449
80450 trace
80451 (p_msg => 'SQL - FETCH line_cur'
80452 ,p_level => C_LEVEL_STATEMENT
80453 ,p_module => l_log_module);
80454
80455 END IF;
80456 --
80457 --
80458 LOOP
80459 --
80460 FETCH line_cur BULK COLLECT INTO
80461 l_array_entity_id
80462 , l_array_legal_entity_id
80463 , l_array_entity_code
80464 , l_array_transaction_num
80465 , l_array_event_id
80466 , l_array_class_code
80467 , l_array_event_type
80468 , l_array_event_number
80469 , l_array_event_date
80470 , l_array_transaction_date
80471 , l_array_reference_num_1
80472 , l_array_reference_num_2
80473 , l_array_reference_num_3
80474 , l_array_reference_num_4
80475 , l_array_reference_char_1
80476 , l_array_reference_char_2
80477 , l_array_reference_char_3
80478 , l_array_reference_char_4
80479 , l_array_reference_date_1
80480 , l_array_reference_date_2
80481 , l_array_reference_date_3
80482 , l_array_reference_date_4
80483 , l_array_event_created_by
80484 , l_array_budgetary_control_flag
80485 , l_array_extract_line_num
80486 , l_array_source_10
80487 , l_array_source_12
80488 , l_array_source_13
80489 , l_array_source_14
80490 , l_array_source_15
80491 , l_array_source_16
80492 , l_array_source_17
80493 , l_array_source_21
80494 , l_array_source_22
80495 , l_array_source_23
80496 , l_array_source_24
80497 , l_array_source_25
80498 , l_array_source_26
80499 , l_array_source_27
80500 , l_array_source_28
80501 , l_array_source_29
80502 , l_array_source_30
80503 , l_array_source_31
80504 , l_array_source_35
80505 , l_array_source_36
80506 , l_array_source_37
80507 , l_array_source_58
80508 , l_array_source_59
80509 , l_array_source_61
80510 , l_array_source_62
80511 , l_array_source_63
80512 , l_array_source_64
80513 , l_array_source_65
80514 , l_array_source_66
80515 , l_array_source_67
80516 , l_array_source_71
80517 , l_array_source_74
80518 , l_array_source_75
80519 , l_array_source_76
80520 , l_array_source_77
80521 LIMIT l_rows;
80522
80523 --
80524 IF (C_LEVEL_EVENT >= g_log_level) THEN
80525 trace
80526 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
80527 ,p_level => C_LEVEL_EVENT
80528 ,p_module => l_log_module);
80529 END IF;
80530 --
80531 EXIT WHEN l_array_entity_id.count = 0;
80532
80533 XLA_AE_LINES_PKG.g_rec_lines := null;
80534
80535 --
80536 -- Bug 4458708
80537 --
80538 XLA_AE_LINES_PKG.g_LineNumber := 0;
80539 --
80540 --
80541
80542 FOR Idx IN 1..l_array_event_id.count LOOP
80543 --
80544 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
80545 --
80546 l_event_id := l_array_event_id(idx); -- 5648433
80547
80548 --
80549 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
80550 --
80551
80552 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
80553 (g_array_event(l_event_id).array_value_num('header_index'))
80554 ,'N'
80555 ) <> 'Y'
80556 THEN
80557 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
80558 trace
80559 (p_msg => 'Trancaction revesal option is not Y '
80560 ,p_level => C_LEVEL_STATEMENT
80561 ,p_module => l_log_module);
80562 END IF;
80563
80564 --
80565 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
80566 --
80567 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
80568 --
80569 -- set event info as cache for other routines to refer event attributes
80570 --
80571
80572 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
80573 l_previous_event_id := l_event_id;
80574
80575 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
80576 (p_application_id => p_application_id
80577 ,p_primary_ledger_id => p_primary_ledger_id
80578 ,p_base_ledger_id => p_base_ledger_id
80579 ,p_target_ledger_id => p_target_ledger_id
80580 ,p_entity_id => l_array_entity_id(Idx)
80581 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
80582 ,p_entity_code => l_array_entity_code(Idx)
80583 ,p_transaction_num => l_array_transaction_num(Idx)
80584 ,p_event_id => l_array_event_id(Idx)
80585 ,p_event_class_code => l_array_class_code(Idx)
80586 ,p_event_type_code => l_array_event_type(Idx)
80587 ,p_event_number => l_array_event_number(Idx)
80588 ,p_event_date => l_array_event_date(Idx)
80589 ,p_transaction_date => l_array_transaction_date(Idx)
80593 ,p_reference_num_4 => l_array_reference_num_4(Idx)
80590 ,p_reference_num_1 => l_array_reference_num_1(Idx)
80591 ,p_reference_num_2 => l_array_reference_num_2(Idx)
80592 ,p_reference_num_3 => l_array_reference_num_3(Idx)
80594 ,p_reference_char_1 => l_array_reference_char_1(Idx)
80595 ,p_reference_char_2 => l_array_reference_char_2(Idx)
80596 ,p_reference_char_3 => l_array_reference_char_3(Idx)
80597 ,p_reference_char_4 => l_array_reference_char_4(Idx)
80598 ,p_reference_date_1 => l_array_reference_date_1(Idx)
80599 ,p_reference_date_2 => l_array_reference_date_2(Idx)
80600 ,p_reference_date_3 => l_array_reference_date_3(Idx)
80601 ,p_reference_date_4 => l_array_reference_date_4(Idx)
80602 ,p_event_created_by => l_array_event_created_by(Idx)
80603 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
80604 --
80605 END IF;
80606
80607
80608
80609 --
80610 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
80611
80612 l_acct_reversal_source := SUBSTR(NULL, 1,30);
80613
80614 IF l_continue_with_lines THEN
80615 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
80616 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
80617
80618 xla_accounting_err_pkg.build_message
80619 (p_appli_s_name => 'XLA'
80620 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
80621 ,p_token_1 => 'LINE_NUMBER'
80622 ,p_value_1 => l_array_extract_line_num(Idx)
80623 ,p_token_2 => 'PRODUCT_NAME'
80624 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
80625 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
80626 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
80627 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
80628
80629 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
80630 --
80631 -- following sets the accounting attributes needed to reverse
80632 -- accounting for a distributeion
80633 --
80634
80635 --
80636 -- 5217187
80637 --
80638 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
80639 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
80640 g_array_event(l_event_id).array_value_num('header_index'));
80641 --
80642 --
80643
80644 -- No reversal code generated
80645
80646 xla_ae_lines_pkg.SetAcctReversalAttrs
80647 (p_event_id => l_event_id
80648 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
80649 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80650 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
80651 END IF;
80652
80653 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
80654 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
80655
80656 --
80657 AcctLineType_70 (
80658 p_application_id => p_application_id
80659 ,p_event_id => l_event_id
80660 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80661 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80662 ,p_actual_flag => l_actual_flag
80663 ,p_balance_type_code => l_balance_type_code
80664 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80665
80666 , p_source_13 => l_array_source_13(Idx)
80667 , p_source_14 => l_array_source_14(Idx)
80668 , p_source_15 => l_array_source_15(Idx)
80669 , p_source_16 => l_array_source_16(Idx)
80670 , p_source_21 => l_array_source_21(Idx)
80671 , p_source_22 => l_array_source_22(Idx)
80672 , p_source_24 => l_array_source_24(Idx)
80673 , p_source_25 => l_array_source_25(Idx)
80674 , p_source_26 => l_array_source_26(Idx)
80675 , p_source_30 => l_array_source_30(Idx)
80676 , p_source_31 => l_array_source_31(Idx)
80677 , p_source_35 => l_array_source_35(Idx)
80678 , p_source_36 => l_array_source_36(Idx)
80679 , p_source_37 => l_array_source_37(Idx)
80680 , p_source_58 => l_array_source_58(Idx)
80681 , p_source_59 => l_array_source_59(Idx)
80682 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
80683 , p_source_61 => l_array_source_61(Idx)
80684 , p_source_62 => l_array_source_62(Idx)
80685 , p_source_63 => l_array_source_63(Idx)
80686 , p_source_64 => l_array_source_64(Idx)
80687 , p_source_65 => l_array_source_65(Idx)
80688 , p_source_66 => l_array_source_66(Idx)
80689 , p_source_67 => l_array_source_67(Idx)
80690 );
80691 If(l_balance_type_code = 'A') THEN
80692 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80693 END IF;
80694
80695 --
80696
80697
80698 --
80699 AcctLineType_71 (
80700 p_application_id => p_application_id
80701 ,p_event_id => l_event_id
80702 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80703 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80704 ,p_actual_flag => l_actual_flag
80705 ,p_balance_type_code => l_balance_type_code
80706 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80707
80708 , p_source_13 => l_array_source_13(Idx)
80709 , p_source_14 => l_array_source_14(Idx)
80710 , p_source_15 => l_array_source_15(Idx)
80711 , p_source_16 => l_array_source_16(Idx)
80712 , p_source_21 => l_array_source_21(Idx)
80713 , p_source_22 => l_array_source_22(Idx)
80714 , p_source_24 => l_array_source_24(Idx)
80715 , p_source_25 => l_array_source_25(Idx)
80716 , p_source_26 => l_array_source_26(Idx)
80717 , p_source_30 => l_array_source_30(Idx)
80718 , p_source_31 => l_array_source_31(Idx)
80719 , p_source_35 => l_array_source_35(Idx)
80723 , p_source_59 => l_array_source_59(Idx)
80720 , p_source_36 => l_array_source_36(Idx)
80721 , p_source_37 => l_array_source_37(Idx)
80722 , p_source_58 => l_array_source_58(Idx)
80724 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
80725 , p_source_61 => l_array_source_61(Idx)
80726 , p_source_62 => l_array_source_62(Idx)
80727 , p_source_63 => l_array_source_63(Idx)
80728 , p_source_64 => l_array_source_64(Idx)
80729 , p_source_65 => l_array_source_65(Idx)
80730 , p_source_66 => l_array_source_66(Idx)
80731 , p_source_67 => l_array_source_67(Idx)
80732 );
80733 If(l_balance_type_code = 'A') THEN
80734 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80735 END IF;
80736
80737 --
80738
80739
80740 --
80741 AcctLineType_72 (
80742 p_application_id => p_application_id
80743 ,p_event_id => l_event_id
80744 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80745 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80746 ,p_actual_flag => l_actual_flag
80747 ,p_balance_type_code => l_balance_type_code
80748 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80749
80750 , p_source_13 => l_array_source_13(Idx)
80751 , p_source_14 => l_array_source_14(Idx)
80752 , p_source_15 => l_array_source_15(Idx)
80753 , p_source_16 => l_array_source_16(Idx)
80754 , p_source_17 => l_array_source_17(Idx)
80755 , p_source_21 => l_array_source_21(Idx)
80756 , p_source_22 => l_array_source_22(Idx)
80757 , p_source_24 => l_array_source_24(Idx)
80758 , p_source_25 => l_array_source_25(Idx)
80759 , p_source_26 => l_array_source_26(Idx)
80760 , p_source_30 => l_array_source_30(Idx)
80761 , p_source_31 => l_array_source_31(Idx)
80762 , p_source_35 => l_array_source_35(Idx)
80763 , p_source_36 => l_array_source_36(Idx)
80764 , p_source_37 => l_array_source_37(Idx)
80765 , p_source_58 => l_array_source_58(Idx)
80766 , p_source_59 => l_array_source_59(Idx)
80767 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
80768 , p_source_61 => l_array_source_61(Idx)
80769 , p_source_62 => l_array_source_62(Idx)
80770 , p_source_63 => l_array_source_63(Idx)
80771 , p_source_64 => l_array_source_64(Idx)
80772 , p_source_65 => l_array_source_65(Idx)
80773 , p_source_66 => l_array_source_66(Idx)
80774 , p_source_67 => l_array_source_67(Idx)
80775 );
80776 If(l_balance_type_code = 'A') THEN
80777 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80778 END IF;
80779
80780 --
80781
80782
80783 --
80784 AcctLineType_73 (
80785 p_application_id => p_application_id
80786 ,p_event_id => l_event_id
80787 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80788 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80789 ,p_actual_flag => l_actual_flag
80790 ,p_balance_type_code => l_balance_type_code
80791 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80792
80793 , p_source_13 => l_array_source_13(Idx)
80794 , p_source_14 => l_array_source_14(Idx)
80795 , p_source_15 => l_array_source_15(Idx)
80796 , p_source_16 => l_array_source_16(Idx)
80797 , p_source_17 => l_array_source_17(Idx)
80798 , p_source_21 => l_array_source_21(Idx)
80799 , p_source_22 => l_array_source_22(Idx)
80800 , p_source_24 => l_array_source_24(Idx)
80801 , p_source_25 => l_array_source_25(Idx)
80802 , p_source_26 => l_array_source_26(Idx)
80803 , p_source_30 => l_array_source_30(Idx)
80804 , p_source_31 => l_array_source_31(Idx)
80805 , p_source_35 => l_array_source_35(Idx)
80806 , p_source_36 => l_array_source_36(Idx)
80807 , p_source_37 => l_array_source_37(Idx)
80808 , p_source_58 => l_array_source_58(Idx)
80809 , p_source_59 => l_array_source_59(Idx)
80810 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
80811 , p_source_61 => l_array_source_61(Idx)
80812 , p_source_62 => l_array_source_62(Idx)
80813 , p_source_63 => l_array_source_63(Idx)
80814 , p_source_64 => l_array_source_64(Idx)
80815 , p_source_65 => l_array_source_65(Idx)
80816 , p_source_66 => l_array_source_66(Idx)
80817 , p_source_67 => l_array_source_67(Idx)
80818 );
80819 If(l_balance_type_code = 'A') THEN
80820 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80821 END IF;
80822
80823 --
80824
80825
80826 --
80827 AcctLineType_74 (
80828 p_application_id => p_application_id
80829 ,p_event_id => l_event_id
80830 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80831 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80832 ,p_actual_flag => l_actual_flag
80833 ,p_balance_type_code => l_balance_type_code
80834 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80835
80836 , p_source_13 => l_array_source_13(Idx)
80837 , p_source_14 => l_array_source_14(Idx)
80838 , p_source_15 => l_array_source_15(Idx)
80839 , p_source_16 => l_array_source_16(Idx)
80840 , p_source_21 => l_array_source_21(Idx)
80841 , p_source_22 => l_array_source_22(Idx)
80842 , p_source_24 => l_array_source_24(Idx)
80843 , p_source_25 => l_array_source_25(Idx)
80844 , p_source_26 => l_array_source_26(Idx)
80845 , p_source_30 => l_array_source_30(Idx)
80846 , p_source_31 => l_array_source_31(Idx)
80847 , p_source_35 => l_array_source_35(Idx)
80848 , p_source_36 => l_array_source_36(Idx)
80849 , p_source_37 => l_array_source_37(Idx)
80850 , p_source_58 => l_array_source_58(Idx)
80851 , p_source_59 => l_array_source_59(Idx)
80852 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
80853 , p_source_61 => l_array_source_61(Idx)
80854 , p_source_62 => l_array_source_62(Idx)
80855 , p_source_63 => l_array_source_63(Idx)
80856 , p_source_64 => l_array_source_64(Idx)
80857 , p_source_65 => l_array_source_65(Idx)
80858 , p_source_66 => l_array_source_66(Idx)
80859 , p_source_67 => l_array_source_67(Idx)
80860 );
80861 If(l_balance_type_code = 'A') THEN
80862 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80863 END IF;
80867
80864
80865 --
80866
80868 --
80869 AcctLineType_75 (
80870 p_application_id => p_application_id
80871 ,p_event_id => l_event_id
80872 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80873 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80874 ,p_actual_flag => l_actual_flag
80875 ,p_balance_type_code => l_balance_type_code
80876 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80877
80878 , p_source_13 => l_array_source_13(Idx)
80879 , p_source_14 => l_array_source_14(Idx)
80880 , p_source_15 => l_array_source_15(Idx)
80881 , p_source_16 => l_array_source_16(Idx)
80882 , p_source_21 => l_array_source_21(Idx)
80883 , p_source_22 => l_array_source_22(Idx)
80884 , p_source_24 => l_array_source_24(Idx)
80885 , p_source_25 => l_array_source_25(Idx)
80886 , p_source_26 => l_array_source_26(Idx)
80887 , p_source_30 => l_array_source_30(Idx)
80888 , p_source_31 => l_array_source_31(Idx)
80889 , p_source_35 => l_array_source_35(Idx)
80890 , p_source_36 => l_array_source_36(Idx)
80891 , p_source_37 => l_array_source_37(Idx)
80892 , p_source_58 => l_array_source_58(Idx)
80893 , p_source_59 => l_array_source_59(Idx)
80894 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
80895 , p_source_61 => l_array_source_61(Idx)
80896 , p_source_62 => l_array_source_62(Idx)
80897 , p_source_63 => l_array_source_63(Idx)
80898 , p_source_64 => l_array_source_64(Idx)
80899 , p_source_65 => l_array_source_65(Idx)
80900 , p_source_66 => l_array_source_66(Idx)
80901 , p_source_67 => l_array_source_67(Idx)
80902 );
80903 If(l_balance_type_code = 'A') THEN
80904 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80905 END IF;
80906
80907 --
80908
80909
80910 --
80911 AcctLineType_76 (
80912 p_application_id => p_application_id
80913 ,p_event_id => l_event_id
80914 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80915 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80916 ,p_actual_flag => l_actual_flag
80917 ,p_balance_type_code => l_balance_type_code
80918 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80919
80920 , p_source_12 => l_array_source_12(Idx)
80921 , p_source_13 => l_array_source_13(Idx)
80922 , p_source_21 => l_array_source_21(Idx)
80923 , p_source_22 => l_array_source_22(Idx)
80924 , p_source_24 => l_array_source_24(Idx)
80925 , p_source_25 => l_array_source_25(Idx)
80926 , p_source_26 => l_array_source_26(Idx)
80927 , p_source_28 => l_array_source_28(Idx)
80928 , p_source_29 => l_array_source_29(Idx)
80929 , p_source_30 => l_array_source_30(Idx)
80930 , p_source_31 => l_array_source_31(Idx)
80931 , p_source_35 => l_array_source_35(Idx)
80932 , p_source_36 => l_array_source_36(Idx)
80933 , p_source_37 => l_array_source_37(Idx)
80934 , p_source_58 => l_array_source_58(Idx)
80935 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
80936 , p_source_61 => l_array_source_61(Idx)
80937 , p_source_62 => l_array_source_62(Idx)
80938 , p_source_63 => l_array_source_63(Idx)
80939 , p_source_65 => l_array_source_65(Idx)
80940 , p_source_66 => l_array_source_66(Idx)
80941 , p_source_67 => l_array_source_67(Idx)
80942 );
80943 If(l_balance_type_code = 'A') THEN
80944 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80945 END IF;
80946
80947 --
80948
80949
80950 --
80951 AcctLineType_77 (
80952 p_application_id => p_application_id
80953 ,p_event_id => l_event_id
80954 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80955 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80956 ,p_actual_flag => l_actual_flag
80957 ,p_balance_type_code => l_balance_type_code
80958 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80959
80960 , p_source_12 => l_array_source_12(Idx)
80961 , p_source_13 => l_array_source_13(Idx)
80962 , p_source_21 => l_array_source_21(Idx)
80963 , p_source_22 => l_array_source_22(Idx)
80964 , p_source_24 => l_array_source_24(Idx)
80965 , p_source_25 => l_array_source_25(Idx)
80966 , p_source_26 => l_array_source_26(Idx)
80967 , p_source_30 => l_array_source_30(Idx)
80968 , p_source_31 => l_array_source_31(Idx)
80969 , p_source_35 => l_array_source_35(Idx)
80970 , p_source_36 => l_array_source_36(Idx)
80971 , p_source_37 => l_array_source_37(Idx)
80972 , p_source_58 => l_array_source_58(Idx)
80973 , p_source_59 => l_array_source_59(Idx)
80974 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
80975 , p_source_61 => l_array_source_61(Idx)
80976 , p_source_62 => l_array_source_62(Idx)
80977 , p_source_63 => l_array_source_63(Idx)
80978 , p_source_64 => l_array_source_64(Idx)
80979 , p_source_65 => l_array_source_65(Idx)
80980 , p_source_66 => l_array_source_66(Idx)
80981 , p_source_67 => l_array_source_67(Idx)
80982 );
80983 If(l_balance_type_code = 'A') THEN
80984 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80985 END IF;
80986
80987 --
80988
80989
80990 --
80991 AcctLineType_96 (
80992 p_application_id => p_application_id
80993 ,p_event_id => l_event_id
80994 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80995 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80996 ,p_actual_flag => l_actual_flag
80997 ,p_balance_type_code => l_balance_type_code
80998 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80999
81000 , p_source_1 => g_array_event(l_event_id).array_value_num('source_1')
81001 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
81002 , p_source_22 => l_array_source_22(Idx)
81003 , p_source_24 => l_array_source_24(Idx)
81004 , p_source_25 => l_array_source_25(Idx)
81005 , p_source_28 => l_array_source_28(Idx)
81006 , p_source_29 => l_array_source_29(Idx)
81007 , p_source_30 => l_array_source_30(Idx)
81008 , p_source_36 => l_array_source_36(Idx)
81009 , p_source_37 => l_array_source_37(Idx)
81013 , p_source_63 => l_array_source_63(Idx)
81010 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81011 , p_source_61 => l_array_source_61(Idx)
81012 , p_source_62 => l_array_source_62(Idx)
81014 , p_source_65 => l_array_source_65(Idx)
81015 , p_source_66 => l_array_source_66(Idx)
81016 , p_source_67 => l_array_source_67(Idx)
81017 , p_source_71 => l_array_source_71(Idx)
81018 , p_source_74 => l_array_source_74(Idx)
81019 , p_source_75 => l_array_source_75(Idx)
81020 );
81021 If(l_balance_type_code = 'A') THEN
81022 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81023 END IF;
81024
81025 --
81026
81027
81028 --
81029 AcctLineType_97 (
81030 p_application_id => p_application_id
81031 ,p_event_id => l_event_id
81032 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81033 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81034 ,p_actual_flag => l_actual_flag
81035 ,p_balance_type_code => l_balance_type_code
81036 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81037
81038 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
81039 , p_source_22 => l_array_source_22(Idx)
81040 , p_source_24 => l_array_source_24(Idx)
81041 , p_source_25 => l_array_source_25(Idx)
81042 , p_source_28 => l_array_source_28(Idx)
81043 , p_source_29 => l_array_source_29(Idx)
81044 , p_source_30 => l_array_source_30(Idx)
81045 , p_source_35 => l_array_source_35(Idx)
81046 , p_source_36 => l_array_source_36(Idx)
81047 , p_source_37 => l_array_source_37(Idx)
81048 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81049 , p_source_61 => l_array_source_61(Idx)
81050 , p_source_62 => l_array_source_62(Idx)
81051 , p_source_63 => l_array_source_63(Idx)
81052 , p_source_65 => l_array_source_65(Idx)
81053 , p_source_66 => l_array_source_66(Idx)
81054 , p_source_67 => l_array_source_67(Idx)
81055 , p_source_71 => l_array_source_71(Idx)
81056 , p_source_72 => g_array_event(l_event_id).array_value_char('source_72')
81057 , p_source_73 => g_array_event(l_event_id).array_value_char('source_73')
81058 , p_source_74 => l_array_source_74(Idx)
81059 , p_source_75 => l_array_source_75(Idx)
81060 );
81061 If(l_balance_type_code = 'A') THEN
81062 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81063 END IF;
81064
81065 --
81066
81067
81068 --
81069 AcctLineType_98 (
81070 p_application_id => p_application_id
81071 ,p_event_id => l_event_id
81072 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81073 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81074 ,p_actual_flag => l_actual_flag
81075 ,p_balance_type_code => l_balance_type_code
81076 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81077
81078 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
81079 , p_source_22 => l_array_source_22(Idx)
81080 , p_source_24 => l_array_source_24(Idx)
81081 , p_source_25 => l_array_source_25(Idx)
81082 , p_source_28 => l_array_source_28(Idx)
81083 , p_source_29 => l_array_source_29(Idx)
81084 , p_source_30 => l_array_source_30(Idx)
81085 , p_source_36 => l_array_source_36(Idx)
81086 , p_source_37 => l_array_source_37(Idx)
81087 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81088 , p_source_61 => l_array_source_61(Idx)
81089 , p_source_62 => l_array_source_62(Idx)
81090 , p_source_63 => l_array_source_63(Idx)
81091 , p_source_65 => l_array_source_65(Idx)
81092 , p_source_66 => l_array_source_66(Idx)
81093 , p_source_67 => l_array_source_67(Idx)
81094 , p_source_71 => l_array_source_71(Idx)
81095 , p_source_72 => g_array_event(l_event_id).array_value_char('source_72')
81096 , p_source_74 => l_array_source_74(Idx)
81097 , p_source_75 => l_array_source_75(Idx)
81098 );
81099 If(l_balance_type_code = 'A') THEN
81100 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81101 END IF;
81102
81103 --
81104
81105
81106 --
81107 AcctLineType_99 (
81108 p_application_id => p_application_id
81109 ,p_event_id => l_event_id
81110 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81111 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81112 ,p_actual_flag => l_actual_flag
81113 ,p_balance_type_code => l_balance_type_code
81114 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81115
81116 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
81117 , p_source_22 => l_array_source_22(Idx)
81118 , p_source_24 => l_array_source_24(Idx)
81119 , p_source_25 => l_array_source_25(Idx)
81120 , p_source_28 => l_array_source_28(Idx)
81121 , p_source_29 => l_array_source_29(Idx)
81122 , p_source_30 => l_array_source_30(Idx)
81123 , p_source_36 => l_array_source_36(Idx)
81124 , p_source_37 => l_array_source_37(Idx)
81125 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81126 , p_source_61 => l_array_source_61(Idx)
81127 , p_source_62 => l_array_source_62(Idx)
81128 , p_source_63 => l_array_source_63(Idx)
81129 , p_source_65 => l_array_source_65(Idx)
81130 , p_source_66 => l_array_source_66(Idx)
81131 , p_source_67 => l_array_source_67(Idx)
81132 , p_source_71 => l_array_source_71(Idx)
81133 , p_source_74 => l_array_source_74(Idx)
81134 , p_source_75 => l_array_source_75(Idx)
81135 );
81136 If(l_balance_type_code = 'A') THEN
81137 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81138 END IF;
81139
81140 --
81141
81142
81143 --
81144 AcctLineType_100 (
81145 p_application_id => p_application_id
81146 ,p_event_id => l_event_id
81147 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81148 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81149 ,p_actual_flag => l_actual_flag
81150 ,p_balance_type_code => l_balance_type_code
81151 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81152
81153 , p_source_22 => l_array_source_22(Idx)
81154 , p_source_24 => l_array_source_24(Idx)
81158 , p_source_31 => l_array_source_31(Idx)
81155 , p_source_25 => l_array_source_25(Idx)
81156 , p_source_26 => l_array_source_26(Idx)
81157 , p_source_27 => l_array_source_27(Idx)
81159 , p_source_36 => l_array_source_36(Idx)
81160 , p_source_37 => l_array_source_37(Idx)
81161 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81162 , p_source_61 => l_array_source_61(Idx)
81163 , p_source_62 => l_array_source_62(Idx)
81164 , p_source_67 => l_array_source_67(Idx)
81165 , p_source_71 => l_array_source_71(Idx)
81166 );
81167 If(l_balance_type_code = 'A') THEN
81168 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81169 END IF;
81170
81171 --
81172
81173
81174 --
81175 AcctLineType_101 (
81176 p_application_id => p_application_id
81177 ,p_event_id => l_event_id
81178 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81179 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81180 ,p_actual_flag => l_actual_flag
81181 ,p_balance_type_code => l_balance_type_code
81182 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81183
81184 , p_source_6 => g_array_event(l_event_id).array_value_num('source_6')
81185 , p_source_22 => l_array_source_22(Idx)
81186 , p_source_24 => l_array_source_24(Idx)
81187 , p_source_25 => l_array_source_25(Idx)
81188 , p_source_28 => l_array_source_28(Idx)
81189 , p_source_29 => l_array_source_29(Idx)
81190 , p_source_30 => l_array_source_30(Idx)
81191 , p_source_36 => l_array_source_36(Idx)
81192 , p_source_37 => l_array_source_37(Idx)
81193 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81194 , p_source_61 => l_array_source_61(Idx)
81195 , p_source_62 => l_array_source_62(Idx)
81196 , p_source_63 => l_array_source_63(Idx)
81197 , p_source_65 => l_array_source_65(Idx)
81198 , p_source_66 => l_array_source_66(Idx)
81199 , p_source_67 => l_array_source_67(Idx)
81200 , p_source_71 => l_array_source_71(Idx)
81201 , p_source_74 => l_array_source_74(Idx)
81202 , p_source_75 => l_array_source_75(Idx)
81203 );
81204 If(l_balance_type_code = 'A') THEN
81205 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81206 END IF;
81207
81208 --
81209
81210
81211 --
81212 AcctLineType_102 (
81213 p_application_id => p_application_id
81214 ,p_event_id => l_event_id
81215 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81216 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81217 ,p_actual_flag => l_actual_flag
81218 ,p_balance_type_code => l_balance_type_code
81219 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81220
81221 , p_source_22 => l_array_source_22(Idx)
81222 , p_source_24 => l_array_source_24(Idx)
81223 , p_source_25 => l_array_source_25(Idx)
81224 , p_source_26 => l_array_source_26(Idx)
81225 , p_source_27 => l_array_source_27(Idx)
81226 , p_source_31 => l_array_source_31(Idx)
81227 , p_source_36 => l_array_source_36(Idx)
81228 , p_source_37 => l_array_source_37(Idx)
81229 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81230 , p_source_61 => l_array_source_61(Idx)
81231 , p_source_62 => l_array_source_62(Idx)
81232 , p_source_67 => l_array_source_67(Idx)
81233 , p_source_71 => l_array_source_71(Idx)
81234 );
81235 If(l_balance_type_code = 'A') THEN
81236 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81237 END IF;
81238
81239 --
81240
81241
81242 --
81243 AcctLineType_108 (
81244 p_application_id => p_application_id
81245 ,p_event_id => l_event_id
81246 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81247 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81248 ,p_actual_flag => l_actual_flag
81249 ,p_balance_type_code => l_balance_type_code
81250 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81251
81252 , p_source_10 => l_array_source_10(Idx)
81253 , p_source_22 => l_array_source_22(Idx)
81254 , p_source_24 => l_array_source_24(Idx)
81255 , p_source_25 => l_array_source_25(Idx)
81256 , p_source_28 => l_array_source_28(Idx)
81257 , p_source_29 => l_array_source_29(Idx)
81258 , p_source_30 => l_array_source_30(Idx)
81259 , p_source_36 => l_array_source_36(Idx)
81260 , p_source_37 => l_array_source_37(Idx)
81261 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81262 , p_source_61 => l_array_source_61(Idx)
81263 , p_source_62 => l_array_source_62(Idx)
81264 , p_source_63 => l_array_source_63(Idx)
81265 , p_source_65 => l_array_source_65(Idx)
81266 , p_source_66 => l_array_source_66(Idx)
81267 , p_source_67 => l_array_source_67(Idx)
81268 , p_source_71 => l_array_source_71(Idx)
81269 , p_source_74 => l_array_source_74(Idx)
81270 , p_source_75 => l_array_source_75(Idx)
81271 );
81272 If(l_balance_type_code = 'A') THEN
81273 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81274 END IF;
81275
81276 --
81277
81278
81279 --
81280 AcctLineType_109 (
81281 p_application_id => p_application_id
81282 ,p_event_id => l_event_id
81283 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81284 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81285 ,p_actual_flag => l_actual_flag
81286 ,p_balance_type_code => l_balance_type_code
81287 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81288
81289 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
81290 , p_source_21 => l_array_source_21(Idx)
81291 , p_source_22 => l_array_source_22(Idx)
81292 , p_source_24 => l_array_source_24(Idx)
81293 , p_source_25 => l_array_source_25(Idx)
81294 , p_source_28 => l_array_source_28(Idx)
81295 , p_source_29 => l_array_source_29(Idx)
81296 , p_source_30 => l_array_source_30(Idx)
81297 , p_source_35 => l_array_source_35(Idx)
81298 , p_source_36 => l_array_source_36(Idx)
81299 , p_source_37 => l_array_source_37(Idx)
81300 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81304 , p_source_65 => l_array_source_65(Idx)
81301 , p_source_61 => l_array_source_61(Idx)
81302 , p_source_62 => l_array_source_62(Idx)
81303 , p_source_63 => l_array_source_63(Idx)
81305 , p_source_66 => l_array_source_66(Idx)
81306 , p_source_67 => l_array_source_67(Idx)
81307 , p_source_71 => l_array_source_71(Idx)
81308 , p_source_72 => g_array_event(l_event_id).array_value_char('source_72')
81309 , p_source_73 => g_array_event(l_event_id).array_value_char('source_73')
81310 , p_source_74 => l_array_source_74(Idx)
81311 , p_source_75 => l_array_source_75(Idx)
81312 );
81313 If(l_balance_type_code = 'A') THEN
81314 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81315 END IF;
81316
81317 --
81318
81319
81320 --
81321 AcctLineType_110 (
81322 p_application_id => p_application_id
81323 ,p_event_id => l_event_id
81324 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81325 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81326 ,p_actual_flag => l_actual_flag
81327 ,p_balance_type_code => l_balance_type_code
81328 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81329
81330 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
81331 , p_source_21 => l_array_source_21(Idx)
81332 , p_source_22 => l_array_source_22(Idx)
81333 , p_source_24 => l_array_source_24(Idx)
81334 , p_source_25 => l_array_source_25(Idx)
81335 , p_source_28 => l_array_source_28(Idx)
81336 , p_source_29 => l_array_source_29(Idx)
81337 , p_source_30 => l_array_source_30(Idx)
81338 , p_source_36 => l_array_source_36(Idx)
81339 , p_source_37 => l_array_source_37(Idx)
81340 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81341 , p_source_61 => l_array_source_61(Idx)
81342 , p_source_62 => l_array_source_62(Idx)
81343 , p_source_63 => l_array_source_63(Idx)
81344 , p_source_65 => l_array_source_65(Idx)
81345 , p_source_66 => l_array_source_66(Idx)
81346 , p_source_67 => l_array_source_67(Idx)
81347 , p_source_71 => l_array_source_71(Idx)
81348 , p_source_72 => g_array_event(l_event_id).array_value_char('source_72')
81349 , p_source_74 => l_array_source_74(Idx)
81350 , p_source_75 => l_array_source_75(Idx)
81351 );
81352 If(l_balance_type_code = 'A') THEN
81353 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81354 END IF;
81355
81356 --
81357
81358
81359 --
81360 AcctLineType_111 (
81361 p_application_id => p_application_id
81362 ,p_event_id => l_event_id
81363 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81364 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81365 ,p_actual_flag => l_actual_flag
81366 ,p_balance_type_code => l_balance_type_code
81367 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81368
81369 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
81370 , p_source_21 => l_array_source_21(Idx)
81371 , p_source_22 => l_array_source_22(Idx)
81372 , p_source_24 => l_array_source_24(Idx)
81373 , p_source_25 => l_array_source_25(Idx)
81374 , p_source_28 => l_array_source_28(Idx)
81375 , p_source_29 => l_array_source_29(Idx)
81376 , p_source_30 => l_array_source_30(Idx)
81377 , p_source_36 => l_array_source_36(Idx)
81378 , p_source_37 => l_array_source_37(Idx)
81379 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81380 , p_source_61 => l_array_source_61(Idx)
81381 , p_source_62 => l_array_source_62(Idx)
81382 , p_source_63 => l_array_source_63(Idx)
81383 , p_source_65 => l_array_source_65(Idx)
81384 , p_source_66 => l_array_source_66(Idx)
81385 , p_source_67 => l_array_source_67(Idx)
81386 , p_source_71 => l_array_source_71(Idx)
81387 , p_source_74 => l_array_source_74(Idx)
81388 , p_source_75 => l_array_source_75(Idx)
81389 );
81390 If(l_balance_type_code = 'A') THEN
81391 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81392 END IF;
81393
81394 --
81395
81396
81397 --
81398 AcctLineType_112 (
81399 p_application_id => p_application_id
81400 ,p_event_id => l_event_id
81401 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81402 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81403 ,p_actual_flag => l_actual_flag
81404 ,p_balance_type_code => l_balance_type_code
81405 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81406
81407 , p_source_22 => l_array_source_22(Idx)
81408 , p_source_24 => l_array_source_24(Idx)
81409 , p_source_25 => l_array_source_25(Idx)
81410 , p_source_26 => l_array_source_26(Idx)
81411 , p_source_27 => l_array_source_27(Idx)
81412 , p_source_31 => l_array_source_31(Idx)
81413 , p_source_35 => l_array_source_35(Idx)
81414 , p_source_36 => l_array_source_36(Idx)
81415 , p_source_37 => l_array_source_37(Idx)
81416 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81417 , p_source_61 => l_array_source_61(Idx)
81418 , p_source_62 => l_array_source_62(Idx)
81419 , p_source_67 => l_array_source_67(Idx)
81420 , p_source_71 => l_array_source_71(Idx)
81421 );
81422 If(l_balance_type_code = 'A') THEN
81423 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81424 END IF;
81425
81426 --
81427
81428
81429 --
81430 AcctLineType_113 (
81431 p_application_id => p_application_id
81432 ,p_event_id => l_event_id
81433 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81434 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81435 ,p_actual_flag => l_actual_flag
81436 ,p_balance_type_code => l_balance_type_code
81437 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81438
81439 , p_source_6 => g_array_event(l_event_id).array_value_num('source_6')
81440 , p_source_21 => l_array_source_21(Idx)
81441 , p_source_22 => l_array_source_22(Idx)
81442 , p_source_24 => l_array_source_24(Idx)
81443 , p_source_25 => l_array_source_25(Idx)
81444 , p_source_28 => l_array_source_28(Idx)
81445 , p_source_29 => l_array_source_29(Idx)
81449 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81446 , p_source_30 => l_array_source_30(Idx)
81447 , p_source_36 => l_array_source_36(Idx)
81448 , p_source_37 => l_array_source_37(Idx)
81450 , p_source_61 => l_array_source_61(Idx)
81451 , p_source_62 => l_array_source_62(Idx)
81452 , p_source_63 => l_array_source_63(Idx)
81453 , p_source_65 => l_array_source_65(Idx)
81454 , p_source_66 => l_array_source_66(Idx)
81455 , p_source_67 => l_array_source_67(Idx)
81456 , p_source_71 => l_array_source_71(Idx)
81457 , p_source_74 => l_array_source_74(Idx)
81458 , p_source_75 => l_array_source_75(Idx)
81459 );
81460 If(l_balance_type_code = 'A') THEN
81461 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81462 END IF;
81463
81464 --
81465
81466
81467 --
81468 AcctLineType_114 (
81469 p_application_id => p_application_id
81470 ,p_event_id => l_event_id
81471 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81472 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81473 ,p_actual_flag => l_actual_flag
81474 ,p_balance_type_code => l_balance_type_code
81475 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81476
81477 , p_source_10 => l_array_source_10(Idx)
81478 , p_source_22 => l_array_source_22(Idx)
81479 , p_source_24 => l_array_source_24(Idx)
81480 , p_source_25 => l_array_source_25(Idx)
81481 , p_source_28 => l_array_source_28(Idx)
81482 , p_source_29 => l_array_source_29(Idx)
81483 , p_source_30 => l_array_source_30(Idx)
81484 , p_source_36 => l_array_source_36(Idx)
81485 , p_source_37 => l_array_source_37(Idx)
81486 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81487 , p_source_61 => l_array_source_61(Idx)
81488 , p_source_62 => l_array_source_62(Idx)
81489 , p_source_63 => l_array_source_63(Idx)
81490 , p_source_65 => l_array_source_65(Idx)
81491 , p_source_66 => l_array_source_66(Idx)
81492 , p_source_67 => l_array_source_67(Idx)
81493 , p_source_71 => l_array_source_71(Idx)
81494 , p_source_74 => l_array_source_74(Idx)
81495 , p_source_75 => l_array_source_75(Idx)
81496 );
81497 If(l_balance_type_code = 'A') THEN
81498 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81499 END IF;
81500
81501 --
81502
81503
81504 --
81505 AcctLineType_115 (
81506 p_application_id => p_application_id
81507 ,p_event_id => l_event_id
81508 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81509 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81510 ,p_actual_flag => l_actual_flag
81511 ,p_balance_type_code => l_balance_type_code
81512 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81513
81514 , p_source_10 => l_array_source_10(Idx)
81515 , p_source_22 => l_array_source_22(Idx)
81516 , p_source_24 => l_array_source_24(Idx)
81517 , p_source_25 => l_array_source_25(Idx)
81518 , p_source_28 => l_array_source_28(Idx)
81519 , p_source_29 => l_array_source_29(Idx)
81520 , p_source_30 => l_array_source_30(Idx)
81521 , p_source_36 => l_array_source_36(Idx)
81522 , p_source_37 => l_array_source_37(Idx)
81523 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81524 , p_source_61 => l_array_source_61(Idx)
81525 , p_source_62 => l_array_source_62(Idx)
81526 , p_source_63 => l_array_source_63(Idx)
81527 , p_source_65 => l_array_source_65(Idx)
81528 , p_source_66 => l_array_source_66(Idx)
81529 , p_source_67 => l_array_source_67(Idx)
81530 , p_source_71 => l_array_source_71(Idx)
81531 , p_source_74 => l_array_source_74(Idx)
81532 , p_source_75 => l_array_source_75(Idx)
81533 );
81534 If(l_balance_type_code = 'A') THEN
81535 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81536 END IF;
81537
81538 --
81539
81540
81541 --
81542 AcctLineType_116 (
81543 p_application_id => p_application_id
81544 ,p_event_id => l_event_id
81545 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81546 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81547 ,p_actual_flag => l_actual_flag
81548 ,p_balance_type_code => l_balance_type_code
81549 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81550
81551 , p_source_10 => l_array_source_10(Idx)
81552 , p_source_22 => l_array_source_22(Idx)
81553 , p_source_23 => l_array_source_23(Idx)
81554 , p_source_24 => l_array_source_24(Idx)
81555 , p_source_25 => l_array_source_25(Idx)
81556 , p_source_28 => l_array_source_28(Idx)
81557 , p_source_29 => l_array_source_29(Idx)
81558 , p_source_36 => l_array_source_36(Idx)
81559 , p_source_37 => l_array_source_37(Idx)
81560 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81561 , p_source_61 => l_array_source_61(Idx)
81562 , p_source_62 => l_array_source_62(Idx)
81563 , p_source_63 => l_array_source_63(Idx)
81564 , p_source_65 => l_array_source_65(Idx)
81565 , p_source_66 => l_array_source_66(Idx)
81566 , p_source_67 => l_array_source_67(Idx)
81567 , p_source_71 => l_array_source_71(Idx)
81568 , p_source_74 => l_array_source_74(Idx)
81569 , p_source_75 => l_array_source_75(Idx)
81570 , p_source_76 => l_array_source_76(Idx)
81571 );
81572 If(l_balance_type_code = 'A') THEN
81573 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81574 END IF;
81575
81576 --
81577
81578
81579 --
81580 AcctLineType_117 (
81581 p_application_id => p_application_id
81582 ,p_event_id => l_event_id
81583 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81584 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81585 ,p_actual_flag => l_actual_flag
81586 ,p_balance_type_code => l_balance_type_code
81587 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81588
81589 , p_source_10 => l_array_source_10(Idx)
81590 , p_source_22 => l_array_source_22(Idx)
81591 , p_source_24 => l_array_source_24(Idx)
81592 , p_source_25 => l_array_source_25(Idx)
81593 , p_source_28 => l_array_source_28(Idx)
81597 , p_source_37 => l_array_source_37(Idx)
81594 , p_source_29 => l_array_source_29(Idx)
81595 , p_source_30 => l_array_source_30(Idx)
81596 , p_source_36 => l_array_source_36(Idx)
81598 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81599 , p_source_61 => l_array_source_61(Idx)
81600 , p_source_62 => l_array_source_62(Idx)
81601 , p_source_63 => l_array_source_63(Idx)
81602 , p_source_65 => l_array_source_65(Idx)
81603 , p_source_66 => l_array_source_66(Idx)
81604 , p_source_67 => l_array_source_67(Idx)
81605 , p_source_71 => l_array_source_71(Idx)
81606 , p_source_74 => l_array_source_74(Idx)
81607 , p_source_75 => l_array_source_75(Idx)
81608 );
81609 If(l_balance_type_code = 'A') THEN
81610 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81611 END IF;
81612
81613 --
81614
81615
81616 --
81617 AcctLineType_118 (
81618 p_application_id => p_application_id
81619 ,p_event_id => l_event_id
81620 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81621 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81622 ,p_actual_flag => l_actual_flag
81623 ,p_balance_type_code => l_balance_type_code
81624 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81625
81626 , p_source_10 => l_array_source_10(Idx)
81627 , p_source_22 => l_array_source_22(Idx)
81628 , p_source_24 => l_array_source_24(Idx)
81629 , p_source_25 => l_array_source_25(Idx)
81630 , p_source_28 => l_array_source_28(Idx)
81631 , p_source_29 => l_array_source_29(Idx)
81632 , p_source_30 => l_array_source_30(Idx)
81633 , p_source_36 => l_array_source_36(Idx)
81634 , p_source_37 => l_array_source_37(Idx)
81635 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81636 , p_source_61 => l_array_source_61(Idx)
81637 , p_source_62 => l_array_source_62(Idx)
81638 , p_source_63 => l_array_source_63(Idx)
81639 , p_source_65 => l_array_source_65(Idx)
81640 , p_source_66 => l_array_source_66(Idx)
81641 , p_source_67 => l_array_source_67(Idx)
81642 , p_source_71 => l_array_source_71(Idx)
81643 , p_source_74 => l_array_source_74(Idx)
81644 , p_source_75 => l_array_source_75(Idx)
81645 );
81646 If(l_balance_type_code = 'A') THEN
81647 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81648 END IF;
81649
81650 --
81651
81652
81653 --
81654 AcctLineType_119 (
81655 p_application_id => p_application_id
81656 ,p_event_id => l_event_id
81657 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81658 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81659 ,p_actual_flag => l_actual_flag
81660 ,p_balance_type_code => l_balance_type_code
81661 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81662
81663 , p_source_10 => l_array_source_10(Idx)
81664 , p_source_22 => l_array_source_22(Idx)
81665 , p_source_24 => l_array_source_24(Idx)
81666 , p_source_25 => l_array_source_25(Idx)
81667 , p_source_28 => l_array_source_28(Idx)
81668 , p_source_29 => l_array_source_29(Idx)
81669 , p_source_30 => l_array_source_30(Idx)
81670 , p_source_36 => l_array_source_36(Idx)
81671 , p_source_37 => l_array_source_37(Idx)
81672 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81673 , p_source_61 => l_array_source_61(Idx)
81674 , p_source_62 => l_array_source_62(Idx)
81675 , p_source_63 => l_array_source_63(Idx)
81676 , p_source_65 => l_array_source_65(Idx)
81677 , p_source_66 => l_array_source_66(Idx)
81678 , p_source_67 => l_array_source_67(Idx)
81679 , p_source_71 => l_array_source_71(Idx)
81680 , p_source_74 => l_array_source_74(Idx)
81681 , p_source_75 => l_array_source_75(Idx)
81682 );
81683 If(l_balance_type_code = 'A') THEN
81684 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81685 END IF;
81686
81687 --
81688
81689
81690 --
81691 AcctLineType_120 (
81692 p_application_id => p_application_id
81693 ,p_event_id => l_event_id
81694 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81695 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81696 ,p_actual_flag => l_actual_flag
81697 ,p_balance_type_code => l_balance_type_code
81698 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81699
81700 , p_source_10 => l_array_source_10(Idx)
81701 , p_source_22 => l_array_source_22(Idx)
81702 , p_source_24 => l_array_source_24(Idx)
81703 , p_source_25 => l_array_source_25(Idx)
81704 , p_source_26 => l_array_source_26(Idx)
81705 , p_source_27 => l_array_source_27(Idx)
81706 , p_source_31 => l_array_source_31(Idx)
81707 , p_source_36 => l_array_source_36(Idx)
81708 , p_source_37 => l_array_source_37(Idx)
81709 , p_source_59 => l_array_source_59(Idx)
81710 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81711 , p_source_61 => l_array_source_61(Idx)
81712 , p_source_62 => l_array_source_62(Idx)
81713 , p_source_64 => l_array_source_64(Idx)
81714 , p_source_65 => l_array_source_65(Idx)
81715 , p_source_66 => l_array_source_66(Idx)
81716 , p_source_67 => l_array_source_67(Idx)
81717 , p_source_71 => l_array_source_71(Idx)
81718 , p_source_76 => l_array_source_76(Idx)
81719 );
81720 If(l_balance_type_code = 'A') THEN
81721 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81722 END IF;
81723
81724 --
81725
81726
81727 --
81728 AcctLineType_121 (
81729 p_application_id => p_application_id
81730 ,p_event_id => l_event_id
81731 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81732 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81733 ,p_actual_flag => l_actual_flag
81734 ,p_balance_type_code => l_balance_type_code
81735 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81736
81737 , p_source_4 => g_array_event(l_event_id).array_value_num('source_4')
81738 , p_source_21 => l_array_source_21(Idx)
81739 , p_source_22 => l_array_source_22(Idx)
81740 , p_source_24 => l_array_source_24(Idx)
81741 , p_source_25 => l_array_source_25(Idx)
81745 , p_source_36 => l_array_source_36(Idx)
81742 , p_source_26 => l_array_source_26(Idx)
81743 , p_source_27 => l_array_source_27(Idx)
81744 , p_source_31 => l_array_source_31(Idx)
81746 , p_source_37 => l_array_source_37(Idx)
81747 , p_source_59 => l_array_source_59(Idx)
81748 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81749 , p_source_61 => l_array_source_61(Idx)
81750 , p_source_62 => l_array_source_62(Idx)
81751 , p_source_64 => l_array_source_64(Idx)
81752 , p_source_65 => l_array_source_65(Idx)
81753 , p_source_66 => l_array_source_66(Idx)
81754 , p_source_67 => l_array_source_67(Idx)
81755 , p_source_71 => l_array_source_71(Idx)
81756 , p_source_76 => l_array_source_76(Idx)
81757 );
81758 If(l_balance_type_code = 'A') THEN
81759 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81760 END IF;
81761
81762 --
81763
81764
81765 --
81766 AcctLineType_122 (
81767 p_application_id => p_application_id
81768 ,p_event_id => l_event_id
81769 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81770 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81771 ,p_actual_flag => l_actual_flag
81772 ,p_balance_type_code => l_balance_type_code
81773 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81774
81775 , p_source_10 => l_array_source_10(Idx)
81776 , p_source_22 => l_array_source_22(Idx)
81777 , p_source_24 => l_array_source_24(Idx)
81778 , p_source_25 => l_array_source_25(Idx)
81779 , p_source_26 => l_array_source_26(Idx)
81780 , p_source_28 => l_array_source_28(Idx)
81781 , p_source_29 => l_array_source_29(Idx)
81782 , p_source_30 => l_array_source_30(Idx)
81783 , p_source_31 => l_array_source_31(Idx)
81784 , p_source_36 => l_array_source_36(Idx)
81785 , p_source_37 => l_array_source_37(Idx)
81786 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81787 , p_source_61 => l_array_source_61(Idx)
81788 , p_source_62 => l_array_source_62(Idx)
81789 , p_source_63 => l_array_source_63(Idx)
81790 , p_source_65 => l_array_source_65(Idx)
81791 , p_source_66 => l_array_source_66(Idx)
81792 , p_source_67 => l_array_source_67(Idx)
81793 );
81794 If(l_balance_type_code = 'A') THEN
81795 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81796 END IF;
81797
81798 --
81799
81800
81801 --
81802 AcctLineType_123 (
81803 p_application_id => p_application_id
81804 ,p_event_id => l_event_id
81805 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81806 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81807 ,p_actual_flag => l_actual_flag
81808 ,p_balance_type_code => l_balance_type_code
81809 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81810
81811 , p_source_10 => l_array_source_10(Idx)
81812 , p_source_22 => l_array_source_22(Idx)
81813 , p_source_24 => l_array_source_24(Idx)
81814 , p_source_25 => l_array_source_25(Idx)
81815 , p_source_26 => l_array_source_26(Idx)
81816 , p_source_28 => l_array_source_28(Idx)
81817 , p_source_29 => l_array_source_29(Idx)
81818 , p_source_30 => l_array_source_30(Idx)
81819 , p_source_31 => l_array_source_31(Idx)
81820 , p_source_36 => l_array_source_36(Idx)
81821 , p_source_37 => l_array_source_37(Idx)
81822 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81823 , p_source_61 => l_array_source_61(Idx)
81824 , p_source_62 => l_array_source_62(Idx)
81825 , p_source_63 => l_array_source_63(Idx)
81826 , p_source_65 => l_array_source_65(Idx)
81827 , p_source_66 => l_array_source_66(Idx)
81828 , p_source_67 => l_array_source_67(Idx)
81829 );
81830 If(l_balance_type_code = 'A') THEN
81831 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81832 END IF;
81833
81834 --
81835
81836
81837 --
81838 AcctLineType_124 (
81839 p_application_id => p_application_id
81840 ,p_event_id => l_event_id
81841 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81842 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81843 ,p_actual_flag => l_actual_flag
81844 ,p_balance_type_code => l_balance_type_code
81845 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81846
81847 , p_source_10 => l_array_source_10(Idx)
81848 , p_source_22 => l_array_source_22(Idx)
81849 , p_source_24 => l_array_source_24(Idx)
81850 , p_source_25 => l_array_source_25(Idx)
81851 , p_source_28 => l_array_source_28(Idx)
81852 , p_source_29 => l_array_source_29(Idx)
81853 , p_source_30 => l_array_source_30(Idx)
81854 , p_source_36 => l_array_source_36(Idx)
81855 , p_source_37 => l_array_source_37(Idx)
81856 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81857 , p_source_61 => l_array_source_61(Idx)
81858 , p_source_62 => l_array_source_62(Idx)
81859 , p_source_63 => l_array_source_63(Idx)
81860 , p_source_65 => l_array_source_65(Idx)
81861 , p_source_66 => l_array_source_66(Idx)
81862 , p_source_67 => l_array_source_67(Idx)
81863 , p_source_71 => l_array_source_71(Idx)
81864 , p_source_74 => l_array_source_74(Idx)
81865 , p_source_75 => l_array_source_75(Idx)
81866 , p_source_77 => l_array_source_77(Idx)
81867 );
81868 If(l_balance_type_code = 'A') THEN
81869 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81870 END IF;
81871
81872 --
81873
81874
81875 --
81876 AcctLineType_125 (
81877 p_application_id => p_application_id
81878 ,p_event_id => l_event_id
81879 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81880 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81881 ,p_actual_flag => l_actual_flag
81882 ,p_balance_type_code => l_balance_type_code
81883 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81884
81885 , p_source_10 => l_array_source_10(Idx)
81886 , p_source_22 => l_array_source_22(Idx)
81887 , p_source_24 => l_array_source_24(Idx)
81888 , p_source_25 => l_array_source_25(Idx)
81889 , p_source_28 => l_array_source_28(Idx)
81893 , p_source_37 => l_array_source_37(Idx)
81890 , p_source_29 => l_array_source_29(Idx)
81891 , p_source_30 => l_array_source_30(Idx)
81892 , p_source_36 => l_array_source_36(Idx)
81894 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81895 , p_source_61 => l_array_source_61(Idx)
81896 , p_source_62 => l_array_source_62(Idx)
81897 , p_source_63 => l_array_source_63(Idx)
81898 , p_source_65 => l_array_source_65(Idx)
81899 , p_source_66 => l_array_source_66(Idx)
81900 , p_source_67 => l_array_source_67(Idx)
81901 , p_source_71 => l_array_source_71(Idx)
81902 , p_source_74 => l_array_source_74(Idx)
81903 , p_source_75 => l_array_source_75(Idx)
81904 , p_source_77 => l_array_source_77(Idx)
81905 );
81906 If(l_balance_type_code = 'A') THEN
81907 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81908 END IF;
81909
81910 --
81911
81912
81913 --
81914 AcctLineType_126 (
81915 p_application_id => p_application_id
81916 ,p_event_id => l_event_id
81917 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81918 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81919 ,p_actual_flag => l_actual_flag
81920 ,p_balance_type_code => l_balance_type_code
81921 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81922
81923 , p_source_10 => l_array_source_10(Idx)
81924 , p_source_22 => l_array_source_22(Idx)
81925 , p_source_23 => l_array_source_23(Idx)
81926 , p_source_24 => l_array_source_24(Idx)
81927 , p_source_25 => l_array_source_25(Idx)
81928 , p_source_28 => l_array_source_28(Idx)
81929 , p_source_29 => l_array_source_29(Idx)
81930 , p_source_30 => l_array_source_30(Idx)
81931 , p_source_31 => l_array_source_31(Idx)
81932 , p_source_36 => l_array_source_36(Idx)
81933 , p_source_37 => l_array_source_37(Idx)
81934 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81935 , p_source_61 => l_array_source_61(Idx)
81936 , p_source_62 => l_array_source_62(Idx)
81937 , p_source_63 => l_array_source_63(Idx)
81938 , p_source_65 => l_array_source_65(Idx)
81939 , p_source_66 => l_array_source_66(Idx)
81940 , p_source_67 => l_array_source_67(Idx)
81941 , p_source_71 => l_array_source_71(Idx)
81942 , p_source_74 => l_array_source_74(Idx)
81943 );
81944 If(l_balance_type_code = 'A') THEN
81945 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81946 END IF;
81947
81948 --
81949
81950
81951 --
81952 AcctLineType_127 (
81953 p_application_id => p_application_id
81954 ,p_event_id => l_event_id
81955 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81956 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81957 ,p_actual_flag => l_actual_flag
81958 ,p_balance_type_code => l_balance_type_code
81959 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81960
81961 , p_source_10 => l_array_source_10(Idx)
81962 , p_source_22 => l_array_source_22(Idx)
81963 , p_source_23 => l_array_source_23(Idx)
81964 , p_source_24 => l_array_source_24(Idx)
81965 , p_source_25 => l_array_source_25(Idx)
81966 , p_source_28 => l_array_source_28(Idx)
81967 , p_source_29 => l_array_source_29(Idx)
81968 , p_source_30 => l_array_source_30(Idx)
81969 , p_source_36 => l_array_source_36(Idx)
81970 , p_source_37 => l_array_source_37(Idx)
81971 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
81972 , p_source_61 => l_array_source_61(Idx)
81973 , p_source_62 => l_array_source_62(Idx)
81974 , p_source_63 => l_array_source_63(Idx)
81975 , p_source_65 => l_array_source_65(Idx)
81976 , p_source_66 => l_array_source_66(Idx)
81977 , p_source_67 => l_array_source_67(Idx)
81978 , p_source_71 => l_array_source_71(Idx)
81979 , p_source_74 => l_array_source_74(Idx)
81980 , p_source_75 => l_array_source_75(Idx)
81981 );
81982 If(l_balance_type_code = 'A') THEN
81983 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81984 END IF;
81985
81986 --
81987
81988
81989 --
81990 AcctLineType_128 (
81991 p_application_id => p_application_id
81992 ,p_event_id => l_event_id
81993 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81994 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81995 ,p_actual_flag => l_actual_flag
81996 ,p_balance_type_code => l_balance_type_code
81997 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81998
81999 , p_source_10 => l_array_source_10(Idx)
82000 , p_source_22 => l_array_source_22(Idx)
82001 , p_source_23 => l_array_source_23(Idx)
82002 , p_source_24 => l_array_source_24(Idx)
82003 , p_source_25 => l_array_source_25(Idx)
82004 , p_source_28 => l_array_source_28(Idx)
82005 , p_source_29 => l_array_source_29(Idx)
82006 , p_source_30 => l_array_source_30(Idx)
82007 , p_source_36 => l_array_source_36(Idx)
82008 , p_source_37 => l_array_source_37(Idx)
82009 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
82010 , p_source_61 => l_array_source_61(Idx)
82011 , p_source_62 => l_array_source_62(Idx)
82012 , p_source_63 => l_array_source_63(Idx)
82013 , p_source_65 => l_array_source_65(Idx)
82014 , p_source_66 => l_array_source_66(Idx)
82015 , p_source_67 => l_array_source_67(Idx)
82016 , p_source_71 => l_array_source_71(Idx)
82017 , p_source_74 => l_array_source_74(Idx)
82018 , p_source_75 => l_array_source_75(Idx)
82019 );
82020 If(l_balance_type_code = 'A') THEN
82021 l_actual_gain_loss_ref := l_gain_or_loss_ref;
82022 END IF;
82023
82024 --
82025
82026
82027 --
82028 AcctLineType_129 (
82029 p_application_id => p_application_id
82030 ,p_event_id => l_event_id
82031 ,p_calculate_acctd_flag => l_calculate_acctd_flag
82032 ,p_calculate_g_l_flag => l_calculate_g_l_flag
82033 ,p_actual_flag => l_actual_flag
82034 ,p_balance_type_code => l_balance_type_code
82035 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
82036
82037 , p_source_10 => l_array_source_10(Idx)
82041 , p_source_28 => l_array_source_28(Idx)
82038 , p_source_22 => l_array_source_22(Idx)
82039 , p_source_24 => l_array_source_24(Idx)
82040 , p_source_25 => l_array_source_25(Idx)
82042 , p_source_29 => l_array_source_29(Idx)
82043 , p_source_30 => l_array_source_30(Idx)
82044 , p_source_36 => l_array_source_36(Idx)
82045 , p_source_37 => l_array_source_37(Idx)
82046 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
82047 , p_source_61 => l_array_source_61(Idx)
82048 , p_source_62 => l_array_source_62(Idx)
82049 , p_source_63 => l_array_source_63(Idx)
82050 , p_source_65 => l_array_source_65(Idx)
82051 , p_source_66 => l_array_source_66(Idx)
82052 , p_source_67 => l_array_source_67(Idx)
82053 , p_source_71 => l_array_source_71(Idx)
82054 , p_source_74 => l_array_source_74(Idx)
82055 , p_source_75 => l_array_source_75(Idx)
82056 , p_source_77 => l_array_source_77(Idx)
82057 );
82058 If(l_balance_type_code = 'A') THEN
82059 l_actual_gain_loss_ref := l_gain_or_loss_ref;
82060 END IF;
82061
82062 --
82063
82064
82065 --
82066 AcctLineType_130 (
82067 p_application_id => p_application_id
82068 ,p_event_id => l_event_id
82069 ,p_calculate_acctd_flag => l_calculate_acctd_flag
82070 ,p_calculate_g_l_flag => l_calculate_g_l_flag
82071 ,p_actual_flag => l_actual_flag
82072 ,p_balance_type_code => l_balance_type_code
82073 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
82074
82075 , p_source_10 => l_array_source_10(Idx)
82076 , p_source_22 => l_array_source_22(Idx)
82077 , p_source_24 => l_array_source_24(Idx)
82078 , p_source_25 => l_array_source_25(Idx)
82079 , p_source_28 => l_array_source_28(Idx)
82080 , p_source_29 => l_array_source_29(Idx)
82081 , p_source_30 => l_array_source_30(Idx)
82082 , p_source_36 => l_array_source_36(Idx)
82083 , p_source_37 => l_array_source_37(Idx)
82084 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
82085 , p_source_61 => l_array_source_61(Idx)
82086 , p_source_62 => l_array_source_62(Idx)
82087 , p_source_63 => l_array_source_63(Idx)
82088 , p_source_65 => l_array_source_65(Idx)
82089 , p_source_66 => l_array_source_66(Idx)
82090 , p_source_67 => l_array_source_67(Idx)
82091 , p_source_71 => l_array_source_71(Idx)
82092 , p_source_74 => l_array_source_74(Idx)
82093 , p_source_75 => l_array_source_75(Idx)
82094 , p_source_77 => l_array_source_77(Idx)
82095 );
82096 If(l_balance_type_code = 'A') THEN
82097 l_actual_gain_loss_ref := l_gain_or_loss_ref;
82098 END IF;
82099
82100 --
82101
82102
82103 --
82104 AcctLineType_131 (
82105 p_application_id => p_application_id
82106 ,p_event_id => l_event_id
82107 ,p_calculate_acctd_flag => l_calculate_acctd_flag
82108 ,p_calculate_g_l_flag => l_calculate_g_l_flag
82109 ,p_actual_flag => l_actual_flag
82110 ,p_balance_type_code => l_balance_type_code
82111 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
82112
82113 , p_source_10 => l_array_source_10(Idx)
82114 , p_source_22 => l_array_source_22(Idx)
82115 , p_source_24 => l_array_source_24(Idx)
82116 , p_source_25 => l_array_source_25(Idx)
82117 , p_source_26 => l_array_source_26(Idx)
82118 , p_source_27 => l_array_source_27(Idx)
82119 , p_source_31 => l_array_source_31(Idx)
82120 , p_source_36 => l_array_source_36(Idx)
82121 , p_source_37 => l_array_source_37(Idx)
82122 , p_source_59 => l_array_source_59(Idx)
82123 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
82124 , p_source_61 => l_array_source_61(Idx)
82125 , p_source_62 => l_array_source_62(Idx)
82126 , p_source_64 => l_array_source_64(Idx)
82127 , p_source_65 => l_array_source_65(Idx)
82128 , p_source_66 => l_array_source_66(Idx)
82129 , p_source_67 => l_array_source_67(Idx)
82130 , p_source_71 => l_array_source_71(Idx)
82131 , p_source_76 => l_array_source_76(Idx)
82132 );
82133 If(l_balance_type_code = 'A') THEN
82134 l_actual_gain_loss_ref := l_gain_or_loss_ref;
82135 END IF;
82136
82137 --
82138
82139
82140 --
82141 AcctLineType_132 (
82142 p_application_id => p_application_id
82143 ,p_event_id => l_event_id
82144 ,p_calculate_acctd_flag => l_calculate_acctd_flag
82145 ,p_calculate_g_l_flag => l_calculate_g_l_flag
82146 ,p_actual_flag => l_actual_flag
82147 ,p_balance_type_code => l_balance_type_code
82148 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
82149
82150 , p_source_18 => g_array_event(l_event_id).array_value_num('source_18')
82151 , p_source_22 => l_array_source_22(Idx)
82152 , p_source_23 => l_array_source_23(Idx)
82153 , p_source_24 => l_array_source_24(Idx)
82154 , p_source_25 => l_array_source_25(Idx)
82155 , p_source_28 => l_array_source_28(Idx)
82156 , p_source_29 => l_array_source_29(Idx)
82157 , p_source_30 => l_array_source_30(Idx)
82158 , p_source_36 => l_array_source_36(Idx)
82159 , p_source_37 => l_array_source_37(Idx)
82160 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
82161 , p_source_61 => l_array_source_61(Idx)
82162 , p_source_62 => l_array_source_62(Idx)
82163 , p_source_63 => l_array_source_63(Idx)
82164 , p_source_67 => l_array_source_67(Idx)
82165 , p_source_71 => l_array_source_71(Idx)
82166 , p_source_74 => l_array_source_74(Idx)
82167 , p_source_75 => l_array_source_75(Idx)
82168 , p_source_77 => l_array_source_77(Idx)
82169 , p_source_78 => g_array_event(l_event_id).array_value_num('source_78')
82170 , p_source_79 => g_array_event(l_event_id).array_value_num('source_79')
82171 );
82172 If(l_balance_type_code = 'A') THEN
82173 l_actual_gain_loss_ref := l_gain_or_loss_ref;
82174 END IF;
82175
82176 --
82177
82178
82179 --
82180 AcctLineType_133 (
82181 p_application_id => p_application_id
82182 ,p_event_id => l_event_id
82183 ,p_calculate_acctd_flag => l_calculate_acctd_flag
82187 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
82184 ,p_calculate_g_l_flag => l_calculate_g_l_flag
82185 ,p_actual_flag => l_actual_flag
82186 ,p_balance_type_code => l_balance_type_code
82188
82189 , p_source_18 => g_array_event(l_event_id).array_value_num('source_18')
82190 , p_source_22 => l_array_source_22(Idx)
82191 , p_source_24 => l_array_source_24(Idx)
82192 , p_source_25 => l_array_source_25(Idx)
82193 , p_source_28 => l_array_source_28(Idx)
82194 , p_source_29 => l_array_source_29(Idx)
82195 , p_source_30 => l_array_source_30(Idx)
82196 , p_source_36 => l_array_source_36(Idx)
82197 , p_source_37 => l_array_source_37(Idx)
82198 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
82199 , p_source_61 => l_array_source_61(Idx)
82200 , p_source_62 => l_array_source_62(Idx)
82201 , p_source_63 => l_array_source_63(Idx)
82202 , p_source_67 => l_array_source_67(Idx)
82203 , p_source_71 => l_array_source_71(Idx)
82204 , p_source_74 => l_array_source_74(Idx)
82205 , p_source_75 => l_array_source_75(Idx)
82206 , p_source_77 => l_array_source_77(Idx)
82207 , p_source_78 => g_array_event(l_event_id).array_value_num('source_78')
82208 , p_source_79 => g_array_event(l_event_id).array_value_num('source_79')
82209 , p_source_80 => g_array_event(l_event_id).array_value_char('source_80')
82210 );
82211 If(l_balance_type_code = 'A') THEN
82212 l_actual_gain_loss_ref := l_gain_or_loss_ref;
82213 END IF;
82214
82215 --
82216
82217
82218 --
82219 AcctLineType_134 (
82220 p_application_id => p_application_id
82221 ,p_event_id => l_event_id
82222 ,p_calculate_acctd_flag => l_calculate_acctd_flag
82223 ,p_calculate_g_l_flag => l_calculate_g_l_flag
82224 ,p_actual_flag => l_actual_flag
82225 ,p_balance_type_code => l_balance_type_code
82226 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
82227
82228 , p_source_18 => g_array_event(l_event_id).array_value_num('source_18')
82229 , p_source_22 => l_array_source_22(Idx)
82230 , p_source_24 => l_array_source_24(Idx)
82231 , p_source_25 => l_array_source_25(Idx)
82232 , p_source_28 => l_array_source_28(Idx)
82233 , p_source_29 => l_array_source_29(Idx)
82234 , p_source_30 => l_array_source_30(Idx)
82235 , p_source_36 => l_array_source_36(Idx)
82236 , p_source_37 => l_array_source_37(Idx)
82237 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
82238 , p_source_61 => l_array_source_61(Idx)
82239 , p_source_62 => l_array_source_62(Idx)
82240 , p_source_63 => l_array_source_63(Idx)
82241 , p_source_65 => l_array_source_65(Idx)
82242 , p_source_66 => l_array_source_66(Idx)
82243 , p_source_67 => l_array_source_67(Idx)
82244 , p_source_74 => l_array_source_74(Idx)
82245 , p_source_75 => l_array_source_75(Idx)
82246 );
82247 If(l_balance_type_code = 'A') THEN
82248 l_actual_gain_loss_ref := l_gain_or_loss_ref;
82249 END IF;
82250
82251 --
82252
82253
82254 --
82255 AcctLineType_135 (
82256 p_application_id => p_application_id
82257 ,p_event_id => l_event_id
82258 ,p_calculate_acctd_flag => l_calculate_acctd_flag
82259 ,p_calculate_g_l_flag => l_calculate_g_l_flag
82260 ,p_actual_flag => l_actual_flag
82261 ,p_balance_type_code => l_balance_type_code
82262 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
82263
82264 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
82265 , p_source_21 => l_array_source_21(Idx)
82266 , p_source_22 => l_array_source_22(Idx)
82267 , p_source_24 => l_array_source_24(Idx)
82268 , p_source_25 => l_array_source_25(Idx)
82269 , p_source_26 => l_array_source_26(Idx)
82270 , p_source_27 => l_array_source_27(Idx)
82271 , p_source_31 => l_array_source_31(Idx)
82272 , p_source_36 => l_array_source_36(Idx)
82273 , p_source_37 => l_array_source_37(Idx)
82274 , p_source_59 => l_array_source_59(Idx)
82275 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
82276 , p_source_61 => l_array_source_61(Idx)
82277 , p_source_62 => l_array_source_62(Idx)
82278 , p_source_64 => l_array_source_64(Idx)
82279 , p_source_65 => l_array_source_65(Idx)
82280 , p_source_66 => l_array_source_66(Idx)
82281 , p_source_67 => l_array_source_67(Idx)
82282 , p_source_71 => l_array_source_71(Idx)
82283 , p_source_76 => l_array_source_76(Idx)
82284 );
82285 If(l_balance_type_code = 'A') THEN
82286 l_actual_gain_loss_ref := l_gain_or_loss_ref;
82287 END IF;
82288
82289 --
82290
82291
82292 --
82293 AcctLineType_136 (
82294 p_application_id => p_application_id
82295 ,p_event_id => l_event_id
82296 ,p_calculate_acctd_flag => l_calculate_acctd_flag
82297 ,p_calculate_g_l_flag => l_calculate_g_l_flag
82298 ,p_actual_flag => l_actual_flag
82299 ,p_balance_type_code => l_balance_type_code
82300 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
82301
82302 , p_source_10 => l_array_source_10(Idx)
82303 , p_source_22 => l_array_source_22(Idx)
82304 , p_source_24 => l_array_source_24(Idx)
82305 , p_source_25 => l_array_source_25(Idx)
82306 , p_source_28 => l_array_source_28(Idx)
82307 , p_source_29 => l_array_source_29(Idx)
82308 , p_source_30 => l_array_source_30(Idx)
82309 , p_source_36 => l_array_source_36(Idx)
82310 , p_source_37 => l_array_source_37(Idx)
82311 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
82312 , p_source_61 => l_array_source_61(Idx)
82313 , p_source_62 => l_array_source_62(Idx)
82314 , p_source_63 => l_array_source_63(Idx)
82315 , p_source_65 => l_array_source_65(Idx)
82316 , p_source_66 => l_array_source_66(Idx)
82317 , p_source_67 => l_array_source_67(Idx)
82318 , p_source_71 => l_array_source_71(Idx)
82319 , p_source_74 => l_array_source_74(Idx)
82320 , p_source_75 => l_array_source_75(Idx)
82321 );
82322 If(l_balance_type_code = 'A') THEN
82323 l_actual_gain_loss_ref := l_gain_or_loss_ref;
82324 END IF;
82325
82329 --
82326 --
82327
82328
82330 AcctLineType_137 (
82331 p_application_id => p_application_id
82332 ,p_event_id => l_event_id
82333 ,p_calculate_acctd_flag => l_calculate_acctd_flag
82334 ,p_calculate_g_l_flag => l_calculate_g_l_flag
82335 ,p_actual_flag => l_actual_flag
82336 ,p_balance_type_code => l_balance_type_code
82337 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
82338
82339 , p_source_10 => l_array_source_10(Idx)
82340 , p_source_22 => l_array_source_22(Idx)
82341 , p_source_23 => l_array_source_23(Idx)
82342 , p_source_24 => l_array_source_24(Idx)
82343 , p_source_25 => l_array_source_25(Idx)
82344 , p_source_28 => l_array_source_28(Idx)
82345 , p_source_29 => l_array_source_29(Idx)
82346 , p_source_30 => l_array_source_30(Idx)
82347 , p_source_36 => l_array_source_36(Idx)
82348 , p_source_37 => l_array_source_37(Idx)
82349 , p_source_60 => g_array_event(l_event_id).array_value_num('source_60')
82350 , p_source_61 => l_array_source_61(Idx)
82351 , p_source_62 => l_array_source_62(Idx)
82352 , p_source_63 => l_array_source_63(Idx)
82353 , p_source_65 => l_array_source_65(Idx)
82354 , p_source_66 => l_array_source_66(Idx)
82355 , p_source_67 => l_array_source_67(Idx)
82356 , p_source_71 => l_array_source_71(Idx)
82357 , p_source_74 => l_array_source_74(Idx)
82358 , p_source_75 => l_array_source_75(Idx)
82359 );
82360 If(l_balance_type_code = 'A') THEN
82361 l_actual_gain_loss_ref := l_gain_or_loss_ref;
82362 END IF;
82363
82364 --
82365
82366 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
82367 -- or secondary ledger that has different currency with primary
82368 -- or alc that is calculated by sla
82369 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
82370 (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'))
82371
82372 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
82373 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
82374 AND (l_actual_flag = 'A')) THEN
82375 XLA_AE_LINES_PKG.CreateGainOrLossLines(
82376 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
82377 ,p_application_id => p_application_id
82378 ,p_amb_context_code => 'DEFAULT'
82379 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
82380 ,p_event_class_code => C_EVENT_CLASS_CODE
82381 ,p_event_type_code => C_EVENT_TYPE_CODE
82382
82383 ,p_gain_ccid => TO_NUMBER(g_array_event(l_event_id).array_value_num('source_19'))
82384 ,p_loss_ccid => TO_NUMBER(g_array_event(l_event_id).array_value_num('source_20'))
82385
82386 ,p_actual_flag => l_actual_flag
82387 ,p_enc_flag => null
82388 ,p_actual_g_l_ref => l_actual_gain_loss_ref
82389 ,p_enc_g_l_ref => null
82390 );
82391 END IF;
82392 END IF;
82393 END IF;
82394
82395 ELSE
82396 --
82397 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
82398 --
82399 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82400 trace
82401 (p_msg => 'Trancaction revesal option is Y'
82402 ,p_level => C_LEVEL_STATEMENT
82403 ,p_module => l_log_module);
82404 END IF;
82405 END IF;
82406
82407 END LOOP;
82408 l_result := XLA_AE_LINES_PKG.InsertLines ;
82409 end loop;
82410 close line_cur;
82411
82412
82413 --
82414 -- insert headers into xla_ae_headers_gt table
82415 --
82416 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
82417
82418 -- insert into errors table here.
82419
82420 END LOOP;
82421
82422 --
82423 -- 4865292
82424 --
82425 -- Compare g_hdr_extract_count with event count in
82426 -- CreateHeadersAndLines.
82427 --
82428 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
82429
82430 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82431 trace (p_msg => '# rows extracted from header extract objects '
82432 || ' (running total): '
82433 || g_hdr_extract_count
82434 ,p_level => C_LEVEL_STATEMENT
82435 ,p_module => l_log_module);
82436 END IF;
82437
82438 CLOSE header_cur;
82439 --
82440
82441 --
82442 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
82443 trace
82444 (p_msg => 'END of EventClass_146'
82445 ,p_level => C_LEVEL_PROCEDURE
82446 ,p_module => l_log_module);
82447 END IF;
82448 --
82449 RETURN l_result;
82450 EXCEPTION
82451 WHEN xla_exceptions_pkg.application_exception THEN
82452
82453 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
82454
82455
82456 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
82457
82458 RAISE;
82459
82460 WHEN NO_DATA_FOUND THEN
82461
82462 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
82463 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
82464
82465 FOR header_record IN header_cur
82466 LOOP
82467 l_array_header_events(header_record.event_id) := header_record.event_id;
82468 END LOOP;
82469
82470 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
82471 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
82472
82473 fnd_file.put_line(fnd_file.LOG, ' ');
82474 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
82478 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
82475 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
82476 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
82477
82479 LOOP
82480 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
82481 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
82482 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
82483 END IF;
82484 END LOOP;
82485
82486 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
82487 fnd_file.put_line(fnd_file.LOG, ' ');
82488
82489
82490 xla_exceptions_pkg.raise_message
82491 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_146');
82492
82493
82494 WHEN OTHERS THEN
82495 xla_exceptions_pkg.raise_message
82496 (p_location => 'XLA_00222_AAD_S_000009_PKG.EventClass_146');
82497 END EventClass_146;
82498 --
82499
82500 --
82501 --+============================================+
82502 --| |
82503 --| PRIVATE FUNCTION |
82504 --| |
82505 --+============================================+
82506 --
82507 FUNCTION CreateHeadersAndLines
82508 (p_application_id IN NUMBER
82509 ,p_base_ledger_id IN NUMBER
82510 ,p_target_ledger_id IN NUMBER
82511 ,p_pad_start_date IN DATE
82512 ,p_pad_end_date IN DATE
82513 ,p_primary_ledger_id IN NUMBER)
82514 RETURN BOOLEAN IS
82515 l_created BOOLEAN:=FALSE;
82516 l_event_id NUMBER;
82517 l_event_date DATE;
82518 l_language VARCHAR2(30);
82519 l_currency_code VARCHAR2(30);
82520 l_sla_ledger_id NUMBER;
82521 l_log_module VARCHAR2(240);
82522
82523 BEGIN
82524 --
82525 IF g_log_enabled THEN
82526 l_log_module := C_DEFAULT_MODULE||'.CreateHeadersAndLines';
82527 END IF;
82528 --
82529 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
82530 trace
82531 (p_msg => 'BEGIN of CreateHeadersAndLines'
82532 ,p_level => C_LEVEL_PROCEDURE
82533 ,p_module => l_log_module);
82534 END IF;
82535
82536 l_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
82537 l_currency_code := xla_ae_journal_entry_pkg.g_cache_ledgers_info.currency_code;
82538 l_sla_ledger_id := xla_ae_journal_entry_pkg.g_cache_ledgers_info.sla_ledger_id;
82539
82540 --
82541 -- initialize array of lines with NULL
82542 --
82543 xla_ae_lines_pkg.SetNullLine;
82544
82545 --
82546 -- initialize header extract count -- Bug 4865292
82547 --
82548 g_hdr_extract_count:= 0;
82549
82550
82551 l_created := EventClass_138(
82552 p_application_id => p_application_id
82553 , p_base_ledger_id => p_base_ledger_id
82554 , p_target_ledger_id => p_target_ledger_id
82555 , p_language => l_language
82556 , p_currency_code => l_currency_code
82557 , p_sla_ledger_id => l_sla_ledger_id
82558 , p_pad_start_date => p_pad_start_date
82559 , p_pad_end_date => p_pad_end_date
82560 , p_primary_ledger_id => p_primary_ledger_id
82561 );
82562
82563
82564
82565 IF ( g_diagnostics_mode ='Y' ) THEN
82566
82567 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82568 trace
82569 (p_msg => 'CALL Transaction Objects Diagnostics'
82570 ,p_level => C_LEVEL_STATEMENT
82571 ,p_module => l_log_module);
82572
82573 END IF;
82574
82575 insert_sources_138(
82576 p_target_ledger_id => p_target_ledger_id
82577 , p_language => l_language
82578 , p_sla_ledger_id => l_sla_ledger_id
82579 , p_pad_start_date => p_pad_start_date
82580 , p_pad_end_date => p_pad_end_date
82581 );
82582
82583 END IF;
82584
82585 l_created := EventClass_139(
82586 p_application_id => p_application_id
82587 , p_base_ledger_id => p_base_ledger_id
82588 , p_target_ledger_id => p_target_ledger_id
82589 , p_language => l_language
82590 , p_currency_code => l_currency_code
82591 , p_sla_ledger_id => l_sla_ledger_id
82592 , p_pad_start_date => p_pad_start_date
82593 , p_pad_end_date => p_pad_end_date
82594 , p_primary_ledger_id => p_primary_ledger_id
82595 );
82596
82597
82598
82599 IF ( g_diagnostics_mode ='Y' ) THEN
82600
82601 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82602 trace
82603 (p_msg => 'CALL Transaction Objects Diagnostics'
82604 ,p_level => C_LEVEL_STATEMENT
82605 ,p_module => l_log_module);
82606
82607 END IF;
82608
82609 insert_sources_139(
82610 p_target_ledger_id => p_target_ledger_id
82611 , p_language => l_language
82612 , p_sla_ledger_id => l_sla_ledger_id
82613 , p_pad_start_date => p_pad_start_date
82614 , p_pad_end_date => p_pad_end_date
82615 );
82616
82617 END IF;
82618
82619 l_created := EventClass_140(
82620 p_application_id => p_application_id
82624 , p_currency_code => l_currency_code
82621 , p_base_ledger_id => p_base_ledger_id
82622 , p_target_ledger_id => p_target_ledger_id
82623 , p_language => l_language
82625 , p_sla_ledger_id => l_sla_ledger_id
82626 , p_pad_start_date => p_pad_start_date
82627 , p_pad_end_date => p_pad_end_date
82628 , p_primary_ledger_id => p_primary_ledger_id
82629 );
82630
82631
82632
82633 IF ( g_diagnostics_mode ='Y' ) THEN
82634
82635 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82636 trace
82637 (p_msg => 'CALL Transaction Objects Diagnostics'
82638 ,p_level => C_LEVEL_STATEMENT
82639 ,p_module => l_log_module);
82640
82641 END IF;
82642
82643 insert_sources_140(
82644 p_target_ledger_id => p_target_ledger_id
82645 , p_language => l_language
82646 , p_sla_ledger_id => l_sla_ledger_id
82647 , p_pad_start_date => p_pad_start_date
82648 , p_pad_end_date => p_pad_end_date
82649 );
82650
82651 END IF;
82652
82653 l_created := EventClass_141(
82654 p_application_id => p_application_id
82655 , p_base_ledger_id => p_base_ledger_id
82656 , p_target_ledger_id => p_target_ledger_id
82657 , p_language => l_language
82658 , p_currency_code => l_currency_code
82659 , p_sla_ledger_id => l_sla_ledger_id
82660 , p_pad_start_date => p_pad_start_date
82661 , p_pad_end_date => p_pad_end_date
82662 , p_primary_ledger_id => p_primary_ledger_id
82663 );
82664
82665
82666
82667 IF ( g_diagnostics_mode ='Y' ) THEN
82668
82669 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82670 trace
82671 (p_msg => 'CALL Transaction Objects Diagnostics'
82672 ,p_level => C_LEVEL_STATEMENT
82673 ,p_module => l_log_module);
82674
82675 END IF;
82676
82677 insert_sources_141(
82678 p_target_ledger_id => p_target_ledger_id
82679 , p_language => l_language
82680 , p_sla_ledger_id => l_sla_ledger_id
82681 , p_pad_start_date => p_pad_start_date
82682 , p_pad_end_date => p_pad_end_date
82683 );
82684
82685 END IF;
82686
82687 l_created := EventClass_142(
82688 p_application_id => p_application_id
82689 , p_base_ledger_id => p_base_ledger_id
82690 , p_target_ledger_id => p_target_ledger_id
82691 , p_language => l_language
82692 , p_currency_code => l_currency_code
82693 , p_sla_ledger_id => l_sla_ledger_id
82694 , p_pad_start_date => p_pad_start_date
82695 , p_pad_end_date => p_pad_end_date
82696 , p_primary_ledger_id => p_primary_ledger_id
82697 );
82698
82699
82700
82701 IF ( g_diagnostics_mode ='Y' ) THEN
82702
82703 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82704 trace
82705 (p_msg => 'CALL Transaction Objects Diagnostics'
82706 ,p_level => C_LEVEL_STATEMENT
82707 ,p_module => l_log_module);
82708
82709 END IF;
82710
82711 insert_sources_142(
82712 p_target_ledger_id => p_target_ledger_id
82713 , p_language => l_language
82714 , p_sla_ledger_id => l_sla_ledger_id
82715 , p_pad_start_date => p_pad_start_date
82716 , p_pad_end_date => p_pad_end_date
82717 );
82718
82719 END IF;
82720
82721 l_created := EventClass_143(
82722 p_application_id => p_application_id
82723 , p_base_ledger_id => p_base_ledger_id
82724 , p_target_ledger_id => p_target_ledger_id
82725 , p_language => l_language
82726 , p_currency_code => l_currency_code
82727 , p_sla_ledger_id => l_sla_ledger_id
82728 , p_pad_start_date => p_pad_start_date
82729 , p_pad_end_date => p_pad_end_date
82730 , p_primary_ledger_id => p_primary_ledger_id
82731 );
82732
82733
82734
82735 IF ( g_diagnostics_mode ='Y' ) THEN
82736
82737 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82738 trace
82739 (p_msg => 'CALL Transaction Objects Diagnostics'
82740 ,p_level => C_LEVEL_STATEMENT
82741 ,p_module => l_log_module);
82742
82743 END IF;
82744
82745 insert_sources_143(
82746 p_target_ledger_id => p_target_ledger_id
82747 , p_language => l_language
82748 , p_sla_ledger_id => l_sla_ledger_id
82749 , p_pad_start_date => p_pad_start_date
82750 , p_pad_end_date => p_pad_end_date
82751 );
82752
82753 END IF;
82754
82755 l_created := EventClass_144(
82756 p_application_id => p_application_id
82757 , p_base_ledger_id => p_base_ledger_id
82758 , p_target_ledger_id => p_target_ledger_id
82759 , p_language => l_language
82760 , p_currency_code => l_currency_code
82761 , p_sla_ledger_id => l_sla_ledger_id
82762 , p_pad_start_date => p_pad_start_date
82763 , p_pad_end_date => p_pad_end_date
82764 , p_primary_ledger_id => p_primary_ledger_id
82765 );
82766
82770
82767
82768
82769 IF ( g_diagnostics_mode ='Y' ) THEN
82771 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82772 trace
82773 (p_msg => 'CALL Transaction Objects Diagnostics'
82774 ,p_level => C_LEVEL_STATEMENT
82775 ,p_module => l_log_module);
82776
82777 END IF;
82778
82779 insert_sources_144(
82780 p_target_ledger_id => p_target_ledger_id
82781 , p_language => l_language
82782 , p_sla_ledger_id => l_sla_ledger_id
82783 , p_pad_start_date => p_pad_start_date
82784 , p_pad_end_date => p_pad_end_date
82785 );
82786
82787 END IF;
82788
82789 l_created := EventClass_145(
82790 p_application_id => p_application_id
82791 , p_base_ledger_id => p_base_ledger_id
82792 , p_target_ledger_id => p_target_ledger_id
82793 , p_language => l_language
82794 , p_currency_code => l_currency_code
82795 , p_sla_ledger_id => l_sla_ledger_id
82796 , p_pad_start_date => p_pad_start_date
82797 , p_pad_end_date => p_pad_end_date
82798 , p_primary_ledger_id => p_primary_ledger_id
82799 );
82800
82801
82802
82803 IF ( g_diagnostics_mode ='Y' ) THEN
82804
82805 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82806 trace
82807 (p_msg => 'CALL Transaction Objects Diagnostics'
82808 ,p_level => C_LEVEL_STATEMENT
82809 ,p_module => l_log_module);
82810
82811 END IF;
82812
82813 insert_sources_145(
82814 p_target_ledger_id => p_target_ledger_id
82815 , p_language => l_language
82816 , p_sla_ledger_id => l_sla_ledger_id
82817 , p_pad_start_date => p_pad_start_date
82818 , p_pad_end_date => p_pad_end_date
82819 );
82820
82821 END IF;
82822
82823 l_created := EventClass_146(
82824 p_application_id => p_application_id
82825 , p_base_ledger_id => p_base_ledger_id
82826 , p_target_ledger_id => p_target_ledger_id
82827 , p_language => l_language
82828 , p_currency_code => l_currency_code
82829 , p_sla_ledger_id => l_sla_ledger_id
82830 , p_pad_start_date => p_pad_start_date
82831 , p_pad_end_date => p_pad_end_date
82832 , p_primary_ledger_id => p_primary_ledger_id
82833 );
82834
82835
82836
82837 IF ( g_diagnostics_mode ='Y' ) THEN
82838
82839 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82840 trace
82841 (p_msg => 'CALL Transaction Objects Diagnostics'
82842 ,p_level => C_LEVEL_STATEMENT
82843 ,p_module => l_log_module);
82844
82845 END IF;
82846
82847 insert_sources_146(
82848 p_target_ledger_id => p_target_ledger_id
82849 , p_language => l_language
82850 , p_sla_ledger_id => l_sla_ledger_id
82851 , p_pad_start_date => p_pad_start_date
82852 , p_pad_end_date => p_pad_end_date
82853 );
82854
82855 END IF;
82856
82857
82858 --
82859 -- Bug 4865292
82860 -- When the number of events and that of header extract do not match,
82861 -- set the no header extract flag to indicate there are some issues
82862 -- in header extract.
82863 --
82864 -- Event count context is set in xla_accounting_pkg.unit_processor.
82865 -- Build_Message for this error is called in xla_accounting_pkg.post_accounting
82866 -- to report it as a general error.
82867 --
82868 IF xla_context_pkg.get_event_count_context <> g_hdr_extract_count
82869 AND xla_context_pkg.get_event_nohdr_context <> 'Y' THEN
82870
82871 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82872 trace
82873 (p_msg => '# of extracted headers and events does not match'
82874 ,p_level => C_LEVEL_STATEMENT
82875 ,p_module => l_log_module);
82876
82877 trace
82878 (p_msg => '# of extracted headers: '
82879 ||g_hdr_extract_count
82880 ,p_level => C_LEVEL_STATEMENT
82881 ,p_module => l_log_module);
82882
82883 trace
82884 (p_msg => '# of events in xla_events_gt: '
82885 ||xla_context_pkg.get_event_count_context
82886 ,p_level => C_LEVEL_STATEMENT
82887 ,p_module => l_log_module);
82888
82889 trace
82890 (p_msg => 'Event No Header Extract Context: '
82891 ||xla_context_pkg.get_event_nohdr_context
82892 ,p_level => C_LEVEL_STATEMENT
82893 ,p_module => l_log_module);
82894
82895 END IF;
82896
82897
82898 xla_context_pkg.set_event_nohdr_context
82899 (p_nohdr_extract_flag => 'Y'
82900 ,p_client_id => sys_context('USERENV','CLIENT_IDENTIFIER'));
82901
82902 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82903 trace
82904 (p_msg => 'No Header Extract Flag is set to Y'
82905 ,p_level => C_LEVEL_STATEMENT
82906 ,p_module => l_log_module);
82907 END IF;
82908
82909 END IF;
82910
82911 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
82912 trace
82913 (p_msg => 'END of CreateHeadersAndLines'
82914 ,p_level => C_LEVEL_PROCEDURE
82918 RETURN l_created;
82915 ,p_module => l_log_module);
82916 END IF;
82917
82919 EXCEPTION
82920 WHEN xla_exceptions_pkg.application_exception THEN
82921 RAISE;
82922 WHEN OTHERS THEN
82923 xla_exceptions_pkg.raise_message
82924 (p_location => 'XLA_00222_AAD_S_000009_PKG.CreateHeadersAndLines');
82925 END CreateHeadersAndLines;
82926 --
82927 --
82928
82929 --
82930 --+============================================+
82931 --| |
82932 --| PUBLIC FUNCTION |
82933 --| |
82934 --+============================================+
82935 --
82936 FUNCTION CreateJournalEntries
82937 (p_application_id IN NUMBER
82938 ,p_base_ledger_id IN NUMBER
82939 ,p_pad_start_date IN DATE
82940 ,p_pad_end_date IN DATE
82941 ,p_primary_ledger_id IN NUMBER)
82942 RETURN NUMBER IS
82943 l_log_module VARCHAR2(240);
82944 l_array_ledgers xla_accounting_cache_pkg.t_array_ledger_id;
82945 l_temp_result BOOLEAN;
82946 l_result NUMBER;
82947 BEGIN
82948 --
82949 IF g_log_enabled THEN
82950 l_log_module := C_DEFAULT_MODULE||'.CreateJournalEntries';
82951 END IF;
82952 --
82953 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
82954 trace
82955 (p_msg => 'BEGIN of CreateJournalEntries'||
82956 ' - p_base_ledger_id = '||TO_CHAR(p_base_ledger_id)
82957 ,p_level => C_LEVEL_PROCEDURE
82958 ,p_module => l_log_module);
82959
82960 END IF;
82961
82962 --
82963 g_diagnostics_mode:= xla_accounting_engine_pkg.g_diagnostics_mode;
82964
82965 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
82966 trace
82967 (p_msg => 'g_diagnostics_mode = '||g_diagnostics_mode
82968 ,p_level => C_LEVEL_STATEMENT
82969 ,p_module => l_log_module);
82970 END IF;
82971 --
82972 xla_ae_journal_entry_pkg.SetProductAcctDefinition
82973 (p_product_rule_code => 'MFAR_FED_AR_ACCRUAL_ACCOUNT'
82974 ,p_product_rule_type_code => 'S'
82975 ,p_product_rule_version => ''
82976 ,p_product_rule_name => 'Multi-Fund Federal Receivables Accrual - Account Method'
82977 ,p_amb_context_code => 'DEFAULT'
82978 );
82979
82980 l_array_ledgers :=
82981 xla_ae_journal_entry_pkg.GetAlternateCurrencyLedger
82982 (p_base_ledger_id => p_base_ledger_id);
82983
82984 FOR Idx IN 1 .. l_array_ledgers.COUNT LOOP
82985 l_temp_result :=
82986 XLA_AE_JOURNAL_ENTRY_PKG.GetLedgersInfo
82987 (p_application_id => p_application_id
82988 ,p_base_ledger_id => p_base_ledger_id
82989 ,p_target_ledger_id => l_array_ledgers(Idx)
82990 ,p_primary_ledger_id => p_primary_ledger_id
82991 ,p_pad_start_date => p_pad_start_date
82992 ,p_pad_end_date => p_pad_end_date);
82993
82994 l_temp_result :=
82995 l_temp_result AND
82996 CreateHeadersAndLines
82997 (p_application_id => p_application_id
82998 ,p_base_ledger_id => p_base_ledger_id
82999 ,p_target_ledger_id => l_array_ledgers(Idx)
83000 ,p_pad_start_date => p_pad_start_date
83001 ,p_pad_end_date => p_pad_end_date
83002 ,p_primary_ledger_id => p_primary_ledger_id
83003 );
83004 END LOOP;
83005
83006
83007 IF (g_diagnostics_mode = 'Y' AND
83008 C_LEVEL_UNEXPECTED >= g_log_level AND
83009 xla_environment_pkg.g_Req_Id IS NOT NULL ) THEN
83010
83011 xla_accounting_dump_pkg.acctg_event_extract_log(
83012 p_application_id => p_application_id
83013 ,p_request_id => xla_environment_pkg.g_Req_Id
83014 );
83015
83016 END IF;
83017
83018 CASE l_temp_result
83019 WHEN TRUE THEN l_result := 0;
83020 ELSE l_result := 2;
83021 END CASE;
83022
83023 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
83024 trace
83025 (p_msg => 'return value. = '||TO_CHAR(l_result)
83026 ,p_level => C_LEVEL_PROCEDURE
83027 ,p_module => l_log_module);
83028 trace
83029 (p_msg => 'END of CreateJournalEntries '
83030 ,p_level => C_LEVEL_PROCEDURE
83031 ,p_module => l_log_module);
83032 END IF;
83033
83034 RETURN l_result;
83035 EXCEPTION
83036 WHEN xla_exceptions_pkg.application_exception THEN
83037 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
83038 trace
83039 (p_msg => 'ERROR. = '||sqlerrm
83040 ,p_level => C_LEVEL_PROCEDURE
83041 ,p_module => l_log_module);
83042 END IF;
83043 RAISE;
83044 WHEN OTHERS THEN
83045 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
83046 trace
83047 (p_msg => 'ERROR. = '||sqlerrm
83048 ,p_level => C_LEVEL_PROCEDURE
83049 ,p_module => l_log_module);
83050 END IF;
83051 xla_exceptions_pkg.raise_message
83052 (p_location => 'XLA_00222_AAD_S_000009_PKG.CreateJournalEntries');
83053 END CreateJournalEntries;
83054 --
83055 --=============================================================================
83056 --
83057 --
83058 --
83059 --
83060 --
83061 --
83062 --
83063 --
83064 --
83065 --
83066 --
83067 --
83068 --
83069 --
83070 --
83071 --
83072 --
83073 --
83074 --
83075 --
83076 --
83077 --
83078 --=============================================================================
83079 --=============================================================================
83080 -- *********** Initialization routine **********
83081 --=============================================================================
83082
83083 BEGIN
83084 g_log_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
83085 g_log_enabled := fnd_log.test
83086 (log_level => g_log_level
83087 ,module => C_DEFAULT_MODULE);
83088
83089 IF NOT g_log_enabled THEN
83090 g_log_level := C_LEVEL_LOG_DISABLED;
83091 END IF;
83092 --
83093 END XLA_00222_AAD_S_000009_PKG;
83094 --